diff options
author | Jiang Jiang <jiang.jiang@nokia.com> | 2011-03-15 13:54:42 (GMT) |
---|---|---|
committer | Jiang Jiang <jiang.jiang@nokia.com> | 2011-03-15 14:40:48 (GMT) |
commit | fd8183129d0efe99e0d28f524264c59fb9155b80 (patch) | |
tree | 5e874568adedc813c2e33bcb0b21415ed00896d7 /tests | |
parent | c30714122c58a3dc6fd8401427da60c4afc4127b (diff) | |
download | Qt-fd8183129d0efe99e0d28f524264c59fb9155b80.zip Qt-fd8183129d0efe99e0d28f524264c59fb9155b80.tar.gz Qt-fd8183129d0efe99e0d28f524264c59fb9155b80.tar.bz2 |
Adjust right bearing when breaking with line separators
If we found a forced line break with line separator (e.g. '\n'),
take the right bearing of previous glyph into account, otherwise
the resulting text width will be slightly smaller than the one
without a line separator.
Task-number: QTBUG-17020
Reviewed-by: Eskil
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/qtextlayout/tst_qtextlayout.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/auto/qtextlayout/tst_qtextlayout.cpp b/tests/auto/qtextlayout/tst_qtextlayout.cpp index 0f1ff66..2d15566 100644 --- a/tests/auto/qtextlayout/tst_qtextlayout.cpp +++ b/tests/auto/qtextlayout/tst_qtextlayout.cpp @@ -124,6 +124,7 @@ private slots: void lineWidthFromBOM(); void textWidthVsWIdth(); void textWidthWithStackedTextEngine(); + void textWidthWithLineSeparator(); private: QFont testFont; @@ -1399,5 +1400,21 @@ void tst_QTextLayout::textWidthWithStackedTextEngine() QCOMPARE(line.naturalTextWidth(), fm.width(text)); } +void tst_QTextLayout::textWidthWithLineSeparator() +{ + QString s1("Save Project"), s2("Save Project\ntest"); + s2.replace('\n', QChar::LineSeparator); + + QTextLayout layout1(s1), layout2(s2); + layout1.beginLayout(); + layout2.beginLayout(); + + QTextLine line1 = layout1.createLine(); + QTextLine line2 = layout2.createLine(); + line1.setLineWidth(0x1000); + line2.setLineWidth(0x1000); + QCOMPARE(line1.naturalTextWidth(), line2.naturalTextWidth()); +} + QTEST_MAIN(tst_QTextLayout) #include "tst_qtextlayout.moc" |