diff options
author | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com> | 2010-05-27 12:04:19 +0200 |
---|---|---|
committer | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com> | 2010-05-27 13:12:04 +0200 |
commit | 4085d3eef59763b91ae63818b5885e1027eef3c1 (patch) | |
tree | eb3cc20529cde5b93a002862de603e42e7bb2c22 | |
parent | 9dcc2de14862da0bba6b74c51ac6e7a5193d4f08 (diff) |
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
-rw-r--r-- | src/gui/painting/qpainter.cpp | 5 | ||||
-rw-r--r-- | src/gui/text/qtextengine_p.h | 1 | ||||
-rw-r--r-- | src/gui/text/qtextlayout.cpp | 1 |
3 files changed, 5 insertions, 2 deletions
diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp index 96981af266..6055a04cc1 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)); } diff --git a/src/gui/text/qtextengine_p.h b/src/gui/text/qtextengine_p.h index f36cbd2619..5054b66941 100644 --- a/src/gui/text/qtextengine_p.h +++ b/src/gui/text/qtextengine_p.h @@ -382,6 +382,7 @@ struct Q_AUTOTEST_EXPORT QScriptLine QFixed y; QFixed width; QFixed textWidth; + QFixed textAdvance; int from; signed int length : 29; mutable uint justified : 1; diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp index 3c0e85ec91..d4cb23037c 100644 --- a/src/gui/text/qtextlayout.cpp +++ b/src/gui/text/qtextlayout.cpp @@ -1928,6 +1928,7 @@ void QTextLine::layout_helper(int maxGlyphs) found: if (lbh.rightBearing > 0) // If right bearing has not yet been adjusted lbh.adjustRightBearing(); + line.textAdvance = line.textWidth; line.textWidth -= qMin(QFixed(), lbh.rightBearing); if (line.length == 0) { |