summaryrefslogtreecommitdiffstats
path: root/src/gui/text/qtextengine.cpp
diff options
context:
space:
mode:
authorJiang Jiang <jiang.jiang@nokia.com>2011-04-19 14:40:19 +0200
committerJiang Jiang <jiang.jiang@nokia.com>2011-04-29 11:02:24 +0200
commit044e7602ae72889f363d688dbe0d73cec5f0636a (patch)
treea7f1289e0b4449cea6d61835e50c92b1de958b42 /src/gui/text/qtextengine.cpp
parentd6232575848384f364cecb13f98926989863e852 (diff)
Take leading space width into account for painting and selection
When painting horizontally centered RTL text and selection with trailing spaces, we need to take that space width into account because line.textAdvance doesn't include it. Task-number: QTBUG-18612 Reviewed-by: Eskil (cherry picked from commit 224226727f07e8940e0d3131fe7587b11cc4a6ca)
Diffstat (limited to 'src/gui/text/qtextengine.cpp')
-rw-r--r--src/gui/text/qtextengine.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp
index dab4bb75ec..ce012a818f 100644
--- a/src/gui/text/qtextengine.cpp
+++ b/src/gui/text/qtextengine.cpp
@@ -2777,12 +2777,14 @@ QFixed QTextEngine::alignLine(const QScriptLine &line)
// if width is QFIXED_MAX that means we used setNumColumns() and that implicitly makes this line left aligned.
if (!line.justified && line.width != QFIXED_MAX) {
int align = option.alignment();
+ if (align & Qt::AlignLeft)
+ x -= leadingSpaceWidth(line);
if (align & Qt::AlignJustify && isRightToLeft())
align = Qt::AlignRight;
if (align & Qt::AlignRight)
x = line.width - (line.textAdvance + leadingSpaceWidth(line));
else if (align & Qt::AlignHCenter)
- x = (line.width - line.textAdvance)/2;
+ x = (line.width - (line.textAdvance + leadingSpaceWidth(line)))/2;
}
return x;
}