summaryrefslogtreecommitdiffstats
path: root/src/gui/text/qtextlayout.cpp
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 /src/gui/text/qtextlayout.cpp
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 'src/gui/text/qtextlayout.cpp')
-rw-r--r--src/gui/text/qtextlayout.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp
index 84ad9038d5..ede7426ffc 100644
--- a/src/gui/text/qtextlayout.cpp
+++ b/src/gui/text/qtextlayout.cpp
@@ -1842,8 +1842,17 @@ void QTextLine::layout_helper(int maxGlyphs)
addNextCluster(lbh.currentPosition, end, lbh.tmpData, lbh.glyphCount,
current, lbh.logClusters, lbh.glyphs);
+ // This is a hack to fix a regression caused by the introduction of the
+ // whitespace flag to non-breakable spaces and will cause the non-breakable
+ // spaces to behave as in previous Qt versions in the line breaking algorithm.
+ // The line breaks do not currently follow the Unicode specs, but fixing this would
+ // require refactoring the code and would cause behavioral regressions.
+ bool isBreakableSpace = lbh.currentPosition < eng->layoutData->string.length()
+ && attributes[lbh.currentPosition].whiteSpace
+ && eng->layoutData->string.at(lbh.currentPosition).decompositionTag() != QChar::NoBreak;
+
if (lbh.currentPosition >= eng->layoutData->string.length()
- || attributes[lbh.currentPosition].whiteSpace
+ || isBreakableSpace
|| attributes[lbh.currentPosition].lineBreak) {
sb_or_ws = true;
break;