From 24e84dd21f649a270e03a83a6e7688e1649a7ede Mon Sep 17 00:00:00 2001 From: Jiang Jiang Date: Tue, 3 Jan 2012 15:35:32 +0100 Subject: 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 --- src/gui/text/qtextlayout.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'src/gui/text') 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 QTextLine::glyphRuns(int from, int length) const QFontEngine *mainFontEngine = font.d->engineForScript(si.analysis.script); if (mainFontEngine->type() == QFontEngine::Multi) { QFontEngineMulti *multiFontEngine = static_cast(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 QTextLine::glyphRuns(int from, int length) const subLayout.advances_y[i].toReal()); } - start = end; + if (rtl) + end = start; + else + start = end; which = e; } -- cgit v1.2.3