From 5f1d0f61ea182829826d9d76cb85346d3e23305d Mon Sep 17 00:00:00 2001 From: halcanary Date: Tue, 13 Sep 2016 08:08:38 -0700 Subject: SkPDF: SkTypeface_FreeType ToUnicode table improvement. Currently the SkTypeface_FreeType::onGetAdvancedTypefaceMetrics synthesized glyph to Unicode mapping returns the Unicode point of the last character to map to the glyph. In practice it is better to guess the first character to map to the glyph instead. BUG=359065 GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2329953003 Review-Url: https://codereview.chromium.org/2329953003 --- src/ports/SkFontHost_FreeType.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/ports') diff --git a/src/ports/SkFontHost_FreeType.cpp b/src/ports/SkFontHost_FreeType.cpp index 6681c9c1ef..84a74af469 100644 --- a/src/ports/SkFontHost_FreeType.cpp +++ b/src/ports/SkFontHost_FreeType.cpp @@ -447,7 +447,10 @@ static void populate_glyph_to_unicode(FT_Face& face, SkTDArray* glyph SkUnichar charCode = FT_Get_First_Char(face, &glyphIndex); while (glyphIndex) { SkASSERT(glyphIndex < SkToUInt(numGlyphs)); - (*glyphToUnicode)[glyphIndex] = charCode; + // Use the first character that maps to this glyphID. https://crbug.com/359065 + if (0 == (*glyphToUnicode)[glyphIndex]) { + (*glyphToUnicode)[glyphIndex] = charCode; + } charCode = FT_Get_Next_Char(face, charCode, &glyphIndex); } } -- cgit v1.2.3