diff --git a/third_party/skia/src/ports/SkTypeface_mac_ct.cpp b/third_party/skia/src/ports/SkTypeface_mac_ct.cpp index 0000000000..1111111111 100644 --- a/third_party/skia/src/ports/SkTypeface_mac_ct.cpp +++ b/third_party/skia/src/ports/SkTypeface_mac_ct.cpp @@ -383,7 +383,9 @@ static void populate_glyph_to_unicode_slow(CTFontRef ctFont, CFIndex glyphCount, while (glyphCount > 0) { CGGlyph glyph; if (CTFontGetGlyphsForCharacters(ctFont, &unichar, &glyph, 1)) { - if (out[glyph] == 0) { + // CoreText may return a glyph id >= glyphCount for fonts whose + // cmap disagrees with maxp.numGlyphs. Match get_plane_glyph_map. + if (glyph < glyphCount && out[glyph] == 0) { out[glyph] = unichar; --glyphCount; }