summaryrefslogtreecommitdiffstats
path: root/src/gui/painting
diff options
context:
space:
mode:
authorJiang Jiang <jiang.jiang@nokia.com>2011-03-24 12:33:31 (GMT)
committerJiang Jiang <jiang.jiang@nokia.com>2011-04-19 08:55:55 (GMT)
commit8c68e8ffa32ca26d0fd87f1349d6783e4242a9d1 (patch)
tree6ae0a7269151fefc17423d3d2d3a15436d15d851 /src/gui/painting
parent1d28996fd635eed07eff61502ab67f7158ba43cd (diff)
downloadQt-8c68e8ffa32ca26d0fd87f1349d6783e4242a9d1.zip
Qt-8c68e8ffa32ca26d0fd87f1349d6783e4242a9d1.tar.gz
Qt-8c68e8ffa32ca26d0fd87f1349d6783e4242a9d1.tar.bz2
Let QTextLine decide its own x position in QPainter
So that it can take trailing space width into account when doing right aligned text drawing. Backported from master. Task-number: QTBUG-18303 Reviewed-by: Eskil
Diffstat (limited to 'src/gui/painting')
-rw-r--r--src/gui/painting/qpainter.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp
index 0e279c9..3735e7c 100644
--- a/src/gui/painting/qpainter.cpp
+++ b/src/gui/painting/qpainter.cpp
@@ -8097,12 +8097,16 @@ start_lengthVariant:
QTextLine line = textLayout.lineAt(i);
qreal advance = line.horizontalAdvance();
- if (tf & Qt::AlignRight)
- xoff = r.width() - advance;
+ xoff = 0;
+ if (tf & Qt::AlignRight) {
+ QTextEngine *eng = textLayout.engine();
+ xoff = r.width() - advance -
+ eng->leadingSpaceWidth(eng->lines[line.lineNumber()]).toReal();
+ }
else if (tf & Qt::AlignHCenter)
- xoff = (r.width() - advance)/2;
+ xoff = (r.width() - advance) / 2;
- line.draw(painter, QPointF(r.x() + xoff + line.x(), r.y() + yoff));
+ line.draw(painter, QPointF(r.x() + xoff, r.y() + yoff));
}
if (restore) {