diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp index 733bb57928..52d2ba0d54 100644 --- a/src/gui/text/qtextlayout.cpp +++ b/src/gui/text/qtextlayout.cpp @@ -1776,6 +1776,11 @@ void QTextLine::layout_helper(int maxGlyphs) QFixed x = line.x + line.textWidth + lbh.tmpData.textWidth + lbh.spaceData.textWidth; QFixed tabWidth = eng->calculateTabWidth(item, x); + attributes = eng->attributes(); + if (!attributes) + return; + lbh.logClusters = eng->layoutData->logClustersPtr; + lbh.glyphs = eng->shapedGlyphs(¤t); lbh.spaceData.textWidth += tabWidth; lbh.spaceData.length++; diff --git a/tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp b/tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp index a9a358711b..4b2970cd17 100644 --- a/tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp +++ b/tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp @@ -116,6 +116,7 @@ private slots: void boundingRectForSetLineWidth(); void glyphLessItems(); void justifyTrailingSpaces(); + void layoutWithCustomTabStops(); // QTextLine stuff void setNumColumnsWrapAtWordBoundaryOrAnywhere(); @@ -2050,5 +2051,38 @@ void tst_QTextLayout::nbsp() layout.endLayout(); } +void tst_QTextLayout::layoutWithCustomTabStops() +{ + QScopedPointer textLayout(new QTextLayout); + QList tabStops; + + const int tabWidth = 18; + const int maxTabPos = 2500; + for (int tabPos = tabWidth; tabPos < maxTabPos; tabPos += tabWidth) + tabStops << QTextOption::Tab(tabPos, QTextOption::LeftTab); + + QTextOption textOption; + textOption.setTabs(tabStops); + textLayout->setTextOption(textOption); + + textLayout->setText(QStringLiteral("\ta aa aa aa aa aa aa")); + + textLayout->beginLayout(); + textLayout->createLine(); + textLayout->endLayout(); + + qreal shortWidth = textLayout->maximumWidth(); + + textLayout->setText(QStringLiteral("\ta aa aa aa aa aa aa aa aa aa aa aa aa a")); + + textLayout->beginLayout(); + textLayout->createLine(); + textLayout->endLayout(); + + qreal longWidth = textLayout->maximumWidth(); + + QVERIFY(longWidth > shortWidth); +} + QTEST_MAIN(tst_QTextLayout) #include "tst_qtextlayout.moc"