summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorQt Continuous Integration System <qt-info@nokia.com>2010-05-27 13:43:18 (GMT)
committerQt Continuous Integration System <qt-info@nokia.com>2010-05-27 13:43:18 (GMT)
commitfeb23c057b81210c1a46eee114c5c55a96197205 (patch)
tree35e419ac314b627ded2f1c0c0a4aca6e108677b7 /src
parent8f011df08139bea59c12ae0804969334a9374dc8 (diff)
parent3f74a095086f49be23f526a5adc7e65687a19c31 (diff)
downloadQt-feb23c057b81210c1a46eee114c5c55a96197205.zip
Qt-feb23c057b81210c1a46eee114c5c55a96197205.tar.gz
Qt-feb23c057b81210c1a46eee114c5c55a96197205.tar.bz2
Merge branch '4.6' of scm.dev.nokia.troll.no:qt/oslo-staging-2 into 4.6-integration
* '4.6' of scm.dev.nokia.troll.no:qt/oslo-staging-2: Fix regression with Qt::AlignRight on monospaced text in QTextLayout Back port change d85b149a5c7f3532f8e1a593a79298c9ae38a95f
Diffstat (limited to 'src')
-rw-r--r--src/gui/painting/qpainter.cpp5
-rw-r--r--src/gui/text/qtextengine_p.h1
-rw-r--r--src/gui/text/qtextlayout.cpp5
3 files changed, 7 insertions, 4 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));
}
diff --git a/src/gui/text/qtextengine_p.h b/src/gui/text/qtextengine_p.h
index f36cbd2..5054b66 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 3c0e85e..c5dd854 100644
--- a/src/gui/text/qtextlayout.cpp
+++ b/src/gui/text/qtextlayout.cpp
@@ -89,9 +89,9 @@ static QFixed alignLine(QTextEngine *eng, const QScriptLine &line)
if (align & Qt::AlignJustify && eng->option.textDirection() == Qt::RightToLeft)
align = Qt::AlignRight;
if (align & Qt::AlignRight)
- x = line.width - (line.textWidth + leadingSpaceWidth(eng, line));
+ x = line.width - (line.textAdvance + leadingSpaceWidth(eng, line));
else if (align & Qt::AlignHCenter)
- x = (line.width - line.textWidth)/2;
+ x = (line.width - line.textAdvance)/2;
}
return x;
}
@@ -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) {