]> granicus.if.org Git - libass/commitdiff
Fall back to first charmap as last resort
authorGrigori Goronzy <greg@blackbox>
Sun, 1 Aug 2010 21:52:30 +0000 (23:52 +0200)
committerGrigori Goronzy <greg@blackbox>
Sun, 1 Aug 2010 21:58:19 +0000 (23:58 +0200)
If we're already after the font reselection stage and a glyph cannot be
found in a font, try again with the first charmap as a last resort.
This is needed for old "symbol" fonts, for example.

libass/ass_font.c

index ad2863c5786ff6a0156e03d2da60252ec1754dcc..6a1faab457a99b63e40afeb40d5d8c92cfad2b57 100644 (file)
@@ -446,6 +446,14 @@ FT_Glyph ass_font_get_glyph(void *fontconfig_priv, ASS_Font *font,
         if (face_idx >= 0) {
             face = font->faces[face_idx];
             index = FT_Get_Char_Index(face, ch);
+            if (index == 0 && face->num_charmaps > 0) {
+                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);
+            }
             if (index == 0) {
                 ass_msg(font->library, MSGL_ERR,
                         "Glyph 0x%X not found in font for (%s, %d, %d)",