summaryrefslogtreecommitdiffstats
path: root/src/gui/painting/qpainter.cpp
diff options
context:
space:
mode:
authorEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>2010-05-27 10:04:19 (GMT)
committerEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>2010-05-27 11:12:04 (GMT)
commit4085d3eef59763b91ae63818b5885e1027eef3c1 (patch)
treeeb3cc20529cde5b93a002862de603e42e7bb2c22 /src/gui/painting/qpainter.cpp
parent9dcc2de14862da0bba6b74c51ac6e7a5193d4f08 (diff)
downloadQt-4085d3eef59763b91ae63818b5885e1027eef3c1.zip
Qt-4085d3eef59763b91ae63818b5885e1027eef3c1.tar.gz
Qt-4085d3eef59763b91ae63818b5885e1027eef3c1.tar.bz2
Back port change d85b149a5c7f3532f8e1a593a79298c9ae38a95f
Fixes right alignment of monospaced text, which was a regression in Qt 4.6.0. Initially it was fixed in Qt 4.7 only, but the regression was later deemed severe enough to fix in 4.6.x as well. Task-number: QTBUG-8864 Reviewed-by: thorbjorn
Diffstat (limited to 'src/gui/painting/qpainter.cpp')
-rw-r--r--src/gui/painting/qpainter.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp
index 96981af..6055a04 100644
--- a/src/gui/painting/qpainter.cpp
+++ b/src/gui/painting/qpainter.cpp
@@ -7806,10 +7806,11 @@ start_lengthVariant:
for (int i = 0; i < textLayout.lineCount(); i++) {
QTextLine line = textLayout.lineAt(i);
+ qreal advance = textLayout.engine()->lines[i].textAdvance.toReal();
if (tf & Qt::AlignRight)
- xoff = r.width() - line.naturalTextWidth();
+ xoff = r.width() - advance;
else if (tf & Qt::AlignHCenter)
- xoff = (r.width() - line.naturalTextWidth())/2;
+ xoff = (r.width() - advance)/2;
line.draw(painter, QPointF(r.x() + xoff + line.x(), r.y() + yoff));
}