summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGrigori Goronzy <greg@blackbox>2010-04-18 01:28:25 +0200
committerGrigori Goronzy <greg@blackbox>2010-04-18 01:29:18 +0200
commit52fb8b819182379ec34b880f89aa39563546db96 (patch)
tree521d5aaf430207b0649dcbc349d7210628a2955f
parentccb40a479f51fda8fe2e63686eab004d7e1cdbdb (diff)
downloadlibass-52fb8b819182379ec34b880f89aa39563546db96.tar.bz2
libass-52fb8b819182379ec34b880f89aa39563546db96.tar.xz
Use first Windows charmap as fallback
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.
-rw-r--r--libass/ass_font.c15
1 files 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) {