diff options
author | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com> | 2011-07-06 11:44:57 +0200 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2011-07-06 13:29:44 +0200 |
commit | febb4b8df382352596ac814e9d69a4548c56208f (patch) | |
tree | f7335edf570a8a0af4a88a06e1fe8a126b889604 /src | |
parent | 3422bc3b186a32ae985d3130090b71305380bbd6 (diff) |
Fix bidi reordering when part of text is rendered by fallback font
If the fallback font is used for part of a RTL text, we need to
position the different text items accordingly, subtracting the advance
instead of adding it.
Task-number: QTBUG-17117
Done-with: Lars
(cherry picked from commit e5e1ff0d6f4e6a8457da61b5b215730de6f960bd)
Change-Id: I73b501d36e5c9e12112cc1997c1d360f3a4a6083
Reviewed-on: http://codereview.qt.nokia.com/1228
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/painting/qpainter.cpp | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp index 6a4c7db7f0..8752cb86a7 100644 --- a/src/gui/painting/qpainter.cpp +++ b/src/gui/painting/qpainter.cpp @@ -6629,6 +6629,10 @@ void QPainter::drawTextItem(const QPointF &p, const QTextItem &_ti) qreal x = p.x(); qreal y = p.y(); + bool rtl = ti.flags & QTextItem::RightToLeft; + if (rtl) + x += ti.width.toReal(); + int start = 0; int end, i; for (end = 0; end < ti.glyphs.numGlyphs; ++end) { @@ -6645,14 +6649,19 @@ void QPainter::drawTextItem(const QPointF &p, const QTextItem &_ti) ti2.width += ti.glyphs.effectiveAdvance(i); } + if (rtl) + x -= ti2.width.toReal(); + d->engine->drawTextItem(QPointF(x, y), ti2); + if (!rtl) + x += ti2.width.toReal(); + // reset the high byte for all glyphs and advance to the next sub-string const int hi = which << 24; for (i = start; i < end; ++i) { glyphs.glyphs[i] = hi | glyphs.glyphs[i]; } - x += ti2.width.toReal(); // change engine start = end; @@ -6667,6 +6676,9 @@ void QPainter::drawTextItem(const QPointF &p, const QTextItem &_ti) ti2.width += ti.glyphs.effectiveAdvance(i); } + if (rtl) + x -= ti2.width.toReal(); + if (d->extended) d->extended->drawTextItem(QPointF(x, y), ti2); else |