summaryrefslogtreecommitdiffstats
path: root/src/gui/text/qtextlayout.cpp
diff options
context:
space:
mode:
authorJiang Jiang <jiang.jiang@nokia.com>2011-03-24 12:33:31 (GMT)
committerJiang Jiang <jiang.jiang@nokia.com>2011-04-19 08:55:55 (GMT)
commit8c68e8ffa32ca26d0fd87f1349d6783e4242a9d1 (patch)
tree6ae0a7269151fefc17423d3d2d3a15436d15d851 /src/gui/text/qtextlayout.cpp
parent1d28996fd635eed07eff61502ab67f7158ba43cd (diff)
downloadQt-8c68e8ffa32ca26d0fd87f1349d6783e4242a9d1.zip
Qt-8c68e8ffa32ca26d0fd87f1349d6783e4242a9d1.tar.gz
Qt-8c68e8ffa32ca26d0fd87f1349d6783e4242a9d1.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. Backported from master. Task-number: QTBUG-18303 Reviewed-by: Eskil
Diffstat (limited to 'src/gui/text/qtextlayout.cpp')
-rw-r--r--src/gui/text/qtextlayout.cpp19
1 files changed, 1 insertions, 18 deletions
diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp
index 905f81b..692620f 100644
--- a/src/gui/text/qtextlayout.cpp
+++ b/src/gui/text/qtextlayout.cpp
@@ -64,23 +64,6 @@ QT_BEGIN_NAMESPACE
#define SuppressText 0x5012
#define SuppressBackground 0x513
-static inline QFixed leadingSpaceWidth(QTextEngine *eng, const QScriptLine &line)
-{
- if (!line.hasTrailingSpaces
- || (eng->option.flags() & QTextOption::IncludeTrailingSpaces)
- || !(eng->option.alignment() & Qt::AlignRight)
- || !eng->isRightToLeft())
- return QFixed();
-
- int pos = line.length;
- const HB_CharAttributes *attributes = eng->attributes();
- if (!attributes)
- return QFixed();
- while (pos > 0 && attributes[line.from + pos - 1].whiteSpace)
- --pos;
- return eng->width(line.from + pos, line.length - pos);
-}
-
static QFixed alignLine(QTextEngine *eng, const QScriptLine &line)
{
QFixed x = 0;
@@ -91,7 +74,7 @@ static QFixed alignLine(QTextEngine *eng, const QScriptLine &line)
if (align & Qt::AlignJustify && eng->isRightToLeft())
align = Qt::AlignRight;
if (align & Qt::AlignRight)
- x = line.width - (line.textAdvance + leadingSpaceWidth(eng, line));
+ x = line.width - (line.textAdvance + eng->leadingSpaceWidth(line));
else if (align & Qt::AlignHCenter)
x = (line.width - line.textAdvance)/2;
}