SkFontHost/FreeType/ToUnicode: add an assert

GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1900193002

Review URL: https://codereview.chromium.org/1900193002
This commit is contained in:
halcanary 2016-04-20 08:37:43 -07:00 committed by Commit bot
parent 9d08172828
commit f8c74a1ef9

View File

@ -445,12 +445,14 @@ static bool getWidthAdvance(FT_Face face, int gId, int16_t* data) {
}
static void populate_glyph_to_unicode(FT_Face& face, SkTDArray<SkUnichar>* glyphToUnicode) {
glyphToUnicode->setCount(face->num_glyphs);
sk_bzero(glyphToUnicode->begin(), sizeof((*glyphToUnicode)[0]) * face->num_glyphs);
FT_Long numGlyphs = face->num_glyphs;
glyphToUnicode->setCount(SkToInt(numGlyphs));
sk_bzero(glyphToUnicode->begin(), sizeof((*glyphToUnicode)[0]) * numGlyphs);
FT_UInt glyphIndex;
SkUnichar charCode = FT_Get_First_Char(face, &glyphIndex);
while (glyphIndex) {
SkASSERT(glyphIndex < SkToUInt(numGlyphs));
(*glyphToUnicode)[glyphIndex] = charCode;
charCode = FT_Get_Next_Char(face, charCode, &glyphIndex);
}