summaryrefslogtreecommitdiffstats
path: root/src/gui/text/qtextlayout.cpp
diff options
context:
space:
mode:
authorJiang Jiang <jiang.jiang@nokia.com>2011-09-08 14:31:53 (GMT)
committerJiang Jiang <jiang.jiang@nokia.com>2011-09-08 14:31:53 (GMT)
commit80294c375eca9687d1c34e9ab048294373e7f00c (patch)
tree561fc683ec90c7e4a3747c56fc9337b2a3a5fe08 /src/gui/text/qtextlayout.cpp
parent6326227674efa85c1a5320141041110d211efc75 (diff)
downloadQt-80294c375eca9687d1c34e9ab048294373e7f00c.zip
Qt-80294c375eca9687d1c34e9ab048294373e7f00c.tar.gz
Qt-80294c375eca9687d1c34e9ab048294373e7f00c.tar.bz2
Fix trailing spaces problem by not adding it to QScriptLine.length
It seems to be the only sane way to fix it. Previous attempts to fix it by compensating the trailing space width all failed in some cases, one of the trickiest is when we are having embedded LTR text that has trailing spaces in a RTL paragraph. In this patch we leave line.length not including the trailing space length, but saving it to a separated variable, so that we can always add it back when needed (QTextLine::textLength() for instance). It fixed all the problems in different alignments of both RTL and LTR text. And no regression is found yet. Reviewed-by: Eskil
Diffstat (limited to 'src/gui/text/qtextlayout.cpp')
-rw-r--r--src/gui/text/qtextlayout.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp
index 4fd6ddf..cf361a0 100644
--- a/src/gui/text/qtextlayout.cpp
+++ b/src/gui/text/qtextlayout.cpp
@@ -814,7 +814,7 @@ QTextLine QTextLayout::createLine()
if (l && d->lines.at(l-1).length < 0) {
QTextLine(l-1, d).setNumColumns(INT_MAX);
}
- int from = l > 0 ? d->lines.at(l-1).from + d->lines.at(l-1).length : 0;
+ int from = l > 0 ? d->lines.at(l-1).from + d->lines.at(l-1).length + d->lines.at(l-1).trailingSpaces : 0;
int strlen = d->layoutData->string.length();
if (l && from >= strlen) {
if (!d->lines.at(l-1).length || d->layoutData->string.at(strlen - 1) != QChar::LineSeparator)
@@ -1931,7 +1931,7 @@ found:
if (eng->option.flags() & QTextOption::IncludeTrailingSpaces)
line.textWidth += lbh.spaceData.textWidth;
if (lbh.spaceData.length) {
- line.length += lbh.spaceData.length;
+ line.trailingSpaces = lbh.spaceData.length;
line.hasTrailingSpaces = true;
}
@@ -1995,7 +1995,7 @@ int QTextLine::textLength() const
&& eng->block.isValid() && i == eng->lines.count()-1) {
return eng->lines[i].length - 1;
}
- return eng->lines[i].length;
+ return eng->lines[i].length + eng->lines[i].trailingSpaces;
}
static void drawMenuText(QPainter *p, QFixed x, QFixed y, const QScriptItem &si, QTextItemInt &gf, QTextEngine *eng,