summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJiang Jiang <jiang.jiang@nokia.com>2012-01-03 15:35:32 +0100
committerQt by Nokia <qt-info@nokia.com>2012-01-05 02:17:04 +0100
commit24e84dd21f649a270e03a83a6e7688e1649a7ede (patch)
tree4d5054723e0752bfda3b6b0f76afb629f839f1f8 /src
parent07edbd23ed774c4f0331bb92d35add77fe91769c (diff)
Support RTL text with merge font engines
Text like Urdu use mixed RTL scripts from Persian, Arabic and so on. In RTL, sub glyph runs for individual font engines must be added from end to start, so that the positions can still be calculated in a left to right manner. Task-number: QTBUG-23404 Change-Id: I7e55e4b7b858b3abbe94e352c93d36de6226ff58 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>
Diffstat (limited to 'src')
-rw-r--r--src/gui/text/qtextlayout.cpp16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp
index f2622a7b20..6cf24d130b 100644
--- a/src/gui/text/qtextlayout.cpp
+++ b/src/gui/text/qtextlayout.cpp
@@ -2264,11 +2264,12 @@ QList<QGlyphRun> QTextLine::glyphRuns(int from, int length) const
QFontEngine *mainFontEngine = font.d->engineForScript(si.analysis.script);
if (mainFontEngine->type() == QFontEngine::Multi) {
QFontEngineMulti *multiFontEngine = static_cast<QFontEngineMulti *>(mainFontEngine);
- int start = 0;
- int end;
- int which = glyphLayout.glyphs[0] >> 24;
- for (end = 0; end < glyphLayout.numGlyphs; ++end) {
- const int e = glyphLayout.glyphs[end] >> 24;
+ int end = rtl ? glyphLayout.numGlyphs : 0;
+ int start = rtl ? end : 0;
+ int which = glyphLayout.glyphs[rtl ? start - 1 : end] >> 24;
+ for (; (rtl && start > 0) || (!rtl && end < glyphLayout.numGlyphs);
+ rtl ? --start : ++end) {
+ const int e = glyphLayout.glyphs[rtl ? start - 1 : end] >> 24;
if (e == which)
continue;
@@ -2286,7 +2287,10 @@ QList<QGlyphRun> QTextLine::glyphRuns(int from, int length) const
subLayout.advances_y[i].toReal());
}
- start = end;
+ if (rtl)
+ end = start;
+ else
+ start = end;
which = e;
}