From 52fb8b819182379ec34b880f89aa39563546db96 Mon Sep 17 00:00:00 2001 From: Grigori Goronzy Date: Sun, 18 Apr 2010 01:28:25 +0200 Subject: Use first Windows charmap as fallback MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Extend the charmap selection heuristics to select the first Windows charmap if no Unicode charmap is found. Fixes one particular font, FGP楷書体NT-M, and possibly others. --- libass/ass_font.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/libass/ass_font.c b/libass/ass_font.c index 5ac2a31..3d81202 100644 --- a/libass/ass_font.c +++ b/libass/ass_font.c @@ -39,12 +39,15 @@ #define VERTICAL_LOWER_BOUND 0x02f1 /** - * Select Microfost Unicode CharMap, if the font has one. + * Select a good charmap, prefer Microsoft Unicode charmaps. * Otherwise, let FreeType decide. */ static void charmap_magic(ASS_Library *library, FT_Face face) { int i; + int ms_cmap = -1; + + // Search for a Microsoft Unicode cmap for (i = 0; i < face->num_charmaps; ++i) { FT_CharMap cmap = face->charmaps[i]; unsigned pid = cmap->platform_id; @@ -54,7 +57,15 @@ static void charmap_magic(ASS_Library *library, FT_Face face) || eid == 10 /*full unicode */ )) { FT_Set_Charmap(face, cmap); return; - } + } else if (pid == 3 && ms_cmap < 0) + ms_cmap = i; + } + + // Try the first Microsoft cmap if no Microsoft Unicode cmap was found + if (ms_cmap >= 0) { + FT_CharMap cmap = face->charmaps[ms_cmap]; + FT_Set_Charmap(face, cmap); + return; } if (!face->charmap) { -- cgit v1.2.3