Add invalid glyph index protection
This commit is contained in:
parent
175dd62a90
commit
1ca796b3a3
@ -48,7 +48,7 @@ int fontGlyphIndexFromCodePoint(CFNT_s* font, u32 codePoint)
|
||||
font = g_sharedFont;
|
||||
if (!font)
|
||||
return -1;
|
||||
int ret = font->finf.alterCharIndex;
|
||||
int ret = 0xFFFF;
|
||||
if (codePoint < 0x10000)
|
||||
{
|
||||
for (CMAP_s* cmap = font->finf.cmap; cmap; cmap = cmap->next)
|
||||
@ -79,6 +79,13 @@ int fontGlyphIndexFromCodePoint(CFNT_s* font, u32 codePoint)
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ret == 0xFFFF) // Bogus CMAP entry. Probably exist to save space by using TABLE mappings?
|
||||
{
|
||||
if (font->finf.alterCharIndex == 0xFFFF)
|
||||
return -1;
|
||||
else
|
||||
return font->finf.alterCharIndex;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user