From 3f74a095086f49be23f526a5adc7e65687a19c31 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Thu, 27 May 2010 13:14:20 +0200 Subject: Fix regression with Qt::AlignRight on monospaced text in QTextLayout For monospaced fonts, using the width (including the bearing) of the text to align it to the right hand side, will break alignment of columns of characters. To fix the problem, we go back to the old procedure, by using the advance of the text as basis of alignment instead. Done-by: thorbjorn Reviewed-by: Eskil --- src/gui/text/qtextlayout.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp index d4cb230..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; } -- cgit v0.12