diff options
author | Jiang Jiang <jiang.jiang@nokia.com> | 2011-03-24 12:33:31 (GMT) |
---|---|---|
committer | Jiang Jiang <jiang.jiang@nokia.com> | 2011-03-24 12:43:34 (GMT) |
commit | c6646102288ccb3619895405f3ec42c5803a13b7 (patch) | |
tree | bcabd4fb36494c29bfe0a5e80f14a86cc17d64ea /src/gui/painting | |
parent | 7659d865ebb1e52f452ed041270e09e5024825a1 (diff) | |
download | Qt-c6646102288ccb3619895405f3ec42c5803a13b7.zip Qt-c6646102288ccb3619895405f3ec42c5803a13b7.tar.gz Qt-c6646102288ccb3619895405f3ec42c5803a13b7.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.
Task-number: QTBUG-18303
Reviewed-by: Eskil
Diffstat (limited to 'src/gui/painting')
-rw-r--r-- | src/gui/painting/qpainter.cpp | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp index 2c25e70..b1f5f4c 100644 --- a/src/gui/painting/qpainter.cpp +++ b/src/gui/painting/qpainter.cpp @@ -8149,6 +8149,10 @@ start_lengthVariant: engine.option.setTextDirection(layout_direction); if (tf & Qt::AlignJustify) engine.option.setAlignment(Qt::AlignJustify); + else if (tf & Qt::AlignRight) + engine.option.setAlignment(Qt::AlignRight); + else if (tf & Qt::AlignHCenter) + engine.option.setAlignment(Qt::AlignHCenter); else engine.option.setAlignment(Qt::AlignLeft); // do not do alignment twice @@ -8244,14 +8248,7 @@ start_lengthVariant: for (int i = 0; i < textLayout.lineCount(); i++) { QTextLine line = textLayout.lineAt(i); - - qreal advance = line.horizontalAdvance(); - if (tf & Qt::AlignRight) - xoff = r.width() - advance; - else if (tf & Qt::AlignHCenter) - xoff = (r.width() - advance)/2; - - line.draw(painter, QPointF(r.x() + xoff + line.x(), r.y() + yoff)); + line.draw(painter, QPointF(r.x(), r.y() + yoff)); } if (restore) { |