diff options
-rw-r--r-- | src/gui/text/qtextlayout.cpp | 3 | ||||
-rw-r--r-- | tests/auto/qtextlayout/tst_qtextlayout.cpp | 13 |
2 files changed, 15 insertions, 1 deletions
diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp index a1a17af..3f67408 100644 --- a/src/gui/text/qtextlayout.cpp +++ b/src/gui/text/qtextlayout.cpp @@ -858,7 +858,8 @@ QRectF QTextLayout::boundingRect() const const QScriptLine &si = d->lines[i]; xmin = qMin(xmin, si.x); ymin = qMin(ymin, si.y); - xmax = qMax(xmax, si.x+si.textWidth); + QFixed lineWidth = si.width < QFIXED_MAX ? qMax(si.width, si.textWidth) : si.textWidth; + xmax = qMax(xmax, si.x+lineWidth); // ### shouldn't the ascent be used in ymin??? ymax = qMax(ymax, si.y+si.height()); } diff --git a/tests/auto/qtextlayout/tst_qtextlayout.cpp b/tests/auto/qtextlayout/tst_qtextlayout.cpp index b67dc30..1a5f493 100644 --- a/tests/auto/qtextlayout/tst_qtextlayout.cpp +++ b/tests/auto/qtextlayout/tst_qtextlayout.cpp @@ -111,6 +111,7 @@ private slots: void widthOfTabs(); void columnWrapWithTabs(); void boundingRectForUnsetLineWidth(); + void boundingRectForSetLineWidth(); // QTextLine stuff void setNumColumnsWrapAtWordBoundaryOrAnywhere(); @@ -1319,6 +1320,18 @@ void tst_QTextLayout::boundingRectForUnsetLineWidth() QCOMPARE(layout.boundingRect().width(), line.naturalTextWidth()); } +void tst_QTextLayout::boundingRectForSetLineWidth() +{ + QTextLayout layout("FOOBAR"); + + layout.beginLayout(); + QTextLine line = layout.createLine(); + line.setLineWidth(QFIXED_MAX - 1); + layout.endLayout(); + + QCOMPARE(layout.boundingRect().width(), qreal(QFIXED_MAX - 1)); +} + void tst_QTextLayout::lineWidthFromBOM() { const QString string(QChar(0xfeff)); // BYTE ORDER MARK |