Fix glyphsEnd range check
authorJiang Jiang <jiang.jiang@nokia.com>
Thu, 19 Jan 2012 15:30:03 +0000 (16:30 +0100)
committerQt by Nokia <qt-info@nokia.com>
Fri, 20 Jan 2012 13:19:59 +0000 (14:19 +0100)
For a character generating more than one glyphs, glyphsRun() needs
to check the next glyph index after the requested range. If that
glyph index is more than one larger than the glyphsEnd we currently
get from logClusters, then glyphsEnd need to be set to the next
glyph index minus one.

Change-Id: I795c595d349418ba755b088d6fe6ff24a6e7dd15
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>
src/gui/text/qtextlayout.cpp

index 1e8cb9e..15ae57d 100644 (file)
@@ -2228,9 +2228,12 @@ QList<QGlyphRun> QTextLine::glyphRuns(int from, int length) const
         int glyphsEnd = (relativeTo == eng->length(&si))
                          ? si.num_glyphs - 1
                          : logClusters[relativeTo];
+        // the glyph index right next to the requested range
+        int nextGlyphIndex = relativeTo < eng->length(&si) - 1 ? logClusters[relativeTo + 1] : si.num_glyphs;
+        if (nextGlyphIndex - 1 > glyphsEnd)
+            glyphsEnd = nextGlyphIndex - 1;
         bool startsInsideLigature = relativeFrom > 0 && logClusters[relativeFrom - 1] == glyphsStart;
-        bool endsInsideLigature = relativeTo < eng->length(&si) - 1
-                               && logClusters[relativeTo + 1] == glyphsEnd;
+        bool endsInsideLigature = nextGlyphIndex == glyphsEnd;
 
         int itemGlyphsStart = logClusters[iterator.itemStart - si.position];
         int itemGlyphsEnd = logClusters[iterator.itemEnd - 1 - si.position];