summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com>2014-06-24 12:40:03 +0200
committerEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com>2014-07-08 08:35:02 +0200
commitb56a42be1476d7b3330968d81329a5e29b5fb819 (patch)
tree298869329d61ad7a6740accb870b8156317bc5dd /tests
parent1c08a41cb9b4a080b2465b1df70941e9c508bf1f (diff)
REG: Fix nbsp in QTextLayout
At some point since Qt 4.8, the nbsp character has acquired the whitespace attribute, causing it to be treated exactly like an ordinary space. To account for this, we add an extra check in the layout code to avoid breaking on non-breaking spaces even if they have the whiteSpace flag set. This is a temporary fix for the regression. The line breaking algorithm needs to be refactored and support Unicode tr14 properly, which it currently doesn't. [ChangeLog][Text] Fixed lines breaking on non-breaking spaces. Task-number: QTBUG-39832 Change-Id: Ibd7e1a11ce4b82c611ecda1542c8638a67bf3cae Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp b/tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp
index 26eaec0470..ec698e5db4 100644
--- a/tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp
+++ b/tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp
@@ -139,6 +139,7 @@ private slots:
void cursorInLigatureWithMultipleLines();
void xToCursorForLigatures();
void cursorInNonStopChars();
+ void nbsp();
private:
QFont testFont;
@@ -2011,5 +2012,28 @@ void tst_QTextLayout::justifyTrailingSpaces()
QVERIFY(qFuzzyIsNull(layout.lineAt(0).cursorToX(0)));
}
+void tst_QTextLayout::nbsp()
+{
+ QString s = QString() + QChar(' ') + QChar('a') + QString(10, QChar::Nbsp) + QChar('a') + QChar(' ') + QChar('A');
+ QString text = s + s + s + s + s + s + s + s + s + s + s + s + s + s;
+ QTextLayout layout(text);
+ layout.setCacheEnabled(true);
+ layout.beginLayout();
+ layout.createLine();
+ layout.endLayout();
+
+ int naturalWidth = qCeil(layout.lineAt(0).naturalTextWidth());
+ int lineWidth = naturalWidth;
+
+ layout.beginLayout();
+ QTextLine line = layout.createLine();
+ while (lineWidth-- > naturalWidth / 2) {
+ line.setLineWidth(lineWidth);
+ QVERIFY(text.at(line.textLength()-1).unicode() != QChar::Nbsp);
+ }
+
+ layout.endLayout();
+}
+
QTEST_MAIN(tst_QTextLayout)
#include "tst_qtextlayout.moc"