summaryrefslogtreecommitdiffstats
path: root/src/gui/text
diff options
context:
space:
mode:
authorJiang Jiang <jiang.jiang@nokia.com>2011-07-04 09:14:42 (GMT)
committerJiang Jiang <jiang.jiang@nokia.com>2011-07-04 10:29:18 (GMT)
commit57993ba7a181c92acfa8a0213ed1260c3b85fbd4 (patch)
tree8db820f29a0d83369ba42c15c00b0fba50312e24 /src/gui/text
parent296f64a839a6af458a98d36da4836cab1d5cbb8e (diff)
downloadQt-57993ba7a181c92acfa8a0213ed1260c3b85fbd4.zip
Qt-57993ba7a181c92acfa8a0213ed1260c3b85fbd4.tar.gz
Qt-57993ba7a181c92acfa8a0213ed1260c3b85fbd4.tar.bz2
Fix horizontal center alignment with trailing space
Text drawn with horizontal center alignment (AlignHCenter) and QTextOption::IncludeTrailingSpaces flag as off should consider the trailing space width (leading space width for RTL lines), because textAdvance here ignores the space. Disregard that space width here in alignLine will make RTL lines aligned a bit to the right. In short, for something like this: |w1|space|text|w2| |<- totalWidth ->| we want to have w1 + spaceWidth = w2 = (totalWidth - textWidth)/2, so that the actual rendered text will appear at the center of the bounding rect. Task-number: QTBUG-18303 Reviewed-by: Eskil
Diffstat (limited to 'src/gui/text')
-rw-r--r--src/gui/text/qtextlayout.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp
index 4b3c9e7..0fbf838 100644
--- a/src/gui/text/qtextlayout.cpp
+++ b/src/gui/text/qtextlayout.cpp
@@ -76,7 +76,7 @@ static QFixed alignLine(QTextEngine *eng, const QScriptLine &line)
if (align & Qt::AlignRight)
x = line.width - (line.textAdvance + eng->leadingSpaceWidth(line));
else if (align & Qt::AlignHCenter)
- x = (line.width - line.textAdvance)/2;
+ x = (line.width - (line.textAdvance))/2 - eng->leadingSpaceWidth(line);
}
return x;
}