summaryrefslogtreecommitdiffstats
path: root/libass/ass_font.c
diff options
context:
space:
mode:
authorGrigori Goronzy <greg@blackbox>2011-04-09 21:48:08 +0200
committerGrigori Goronzy <greg@blackbox>2011-04-09 21:48:08 +0200
commit1e246a4a242afd2ddc4e9dea698ce8ec02e3538a (patch)
tree40907d4ec1af6ae345b2a131e8e24bc84a759cea /libass/ass_font.c
parent08033ad0caa6c2ff54944064157ed0b72a858042 (diff)
downloadlibass-1e246a4a242afd2ddc4e9dea698ce8ec02e3538a.tar.bz2
libass-1e246a4a242afd2ddc4e9dea698ce8ec02e3538a.tar.xz
Improved "last resort" charmap matching
After font reselection, loop through all charmaps if no glyph can't be found until we hopefully find one that works. If we get here at all, the font is seriously broken, so this is unlikely to harm anything. This improves the last resort charmap fallback introduced in 96057d.
Diffstat (limited to 'libass/ass_font.c')
-rw-r--r--libass/ass_font.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/libass/ass_font.c b/libass/ass_font.c
index 74467df..d732dfe 100644
--- a/libass/ass_font.c
+++ b/libass/ass_font.c
@@ -446,12 +446,13 @@ FT_Glyph ass_font_get_glyph(void *fontconfig_priv, ASS_Font *font,
face = font->faces[face_idx];
index = FT_Get_Char_Index(face, ch);
if (index == 0 && face->num_charmaps > 0) {
+ int i;
ass_msg(font->library, MSGL_WARN,
- "Glyph 0x%X not found, falling back to first charmap", ch);
- FT_CharMap cur = face->charmap;
- FT_Set_Charmap(face, face->charmaps[0]);
- index = FT_Get_Char_Index(face, ch);
- FT_Set_Charmap(face, cur);
+ "Glyph 0x%X not found, broken font? Trying all charmaps", ch);
+ for (i = 0; i < face->num_charmaps; i++) {
+ FT_Set_Charmap(face, face->charmaps[i]);
+ if ((index = FT_Get_Char_Index(face, ch)) != 0) break;
+ }
}
if (index == 0) {
ass_msg(font->library, MSGL_ERR,