Fix the UCS-2 surrogates handling in Q*FontEndine*::stringToCmap()
authorKonstantin Ritt <ritt.ks@gmail.com>
Mon, 9 Jul 2012 14:08:54 +0000 (17:08 +0300)
committerQt by Nokia <qt-info@nokia.com>
Tue, 10 Jul 2012 01:23:46 +0000 (03:23 +0200)
by making sure QGlyphLayout's numGlyphs member is properly initialized
if the string-to-glyphs lookup was successful
(tip: a surrogate pair produces a single glyph index).

Change-Id: I01953f3b6281d79e1a214bfab0424e796d94769a
Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm
src/plugins/platforms/windows/qwindowsfontengine.cpp
src/plugins/platforms/windows/qwindowsfontenginedirectwrite.cpp

index b07d59d..92eaebb 100644 (file)
@@ -211,6 +211,8 @@ bool QCoreTextFontEngine::stringToCMap(const QChar *str, int len, QGlyphLayout *
     }
 
     *nglyphs = glyph_pos;
+    glyphs->numGlyphs = glyph_pos;
+
     if (flags & GlyphIndicesOnly)
         return true;
 
index b3bba55..d7f48e5 100644 (file)
@@ -363,6 +363,7 @@ bool QWindowsFontEngine::stringToCMap(const QChar *str, int len, QGlyphLayout *g
         return false;
     }
 
+    glyphs->numGlyphs = *nglyphs;
     *nglyphs = getGlyphIndexes(str, len, glyphs, flags & RightToLeft);
 
     if (!(flags & GlyphIndicesOnly))
index 1f7c4f4..3490ebf 100644 (file)
@@ -330,6 +330,7 @@ bool QWindowsFontEngineDirectWrite::stringToCMap(const QChar *str, int len, QGly
                 glyphs->glyphs[i] = glyphIndices[i];
 
             *nglyphs = len;
+            glyphs->numGlyphs = len;
 
             if (!(flags & GlyphIndicesOnly))
                 recalcAdvances(glyphs, 0);