summaryrefslogtreecommitdiffstats
path: root/tests/auto/qtextlayout
diff options
context:
space:
mode:
authorJiang Jiang <jiang.jiang@nokia.com>2011-03-15 14:54:42 +0100
committerJiang Jiang <jiang.jiang@nokia.com>2011-03-15 15:40:48 +0100
commitfd8183129d0efe99e0d28f524264c59fb9155b80 (patch)
tree5e874568adedc813c2e33bcb0b21415ed00896d7 /tests/auto/qtextlayout
parentc30714122c58a3dc6fd8401427da60c4afc4127b (diff)
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/auto/qtextlayout')
-rw-r--r--tests/auto/qtextlayout/tst_qtextlayout.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/auto/qtextlayout/tst_qtextlayout.cpp b/tests/auto/qtextlayout/tst_qtextlayout.cpp
index 0f1ff66259..2d1556631f 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"