# HG changeset patch # User eugeni # Date 1162595460 0 # Node ID 092cb80a8ba45b03523592bafb92f90c7af38d39 # Parent 325db3f2aba30a8f665433f050bd18e341f75646 Prefer microsoft-specific charmaps to all other. There are some fonts with both 'Unicode' and 'Microsoft/Unicode' charmaps, and the second always seems to be the right choice. diff -r 325db3f2aba3 -r 092cb80a8ba4 libass/ass_cache.c --- a/libass/ass_cache.c Fri Nov 03 22:53:24 2006 +0000 +++ b/libass/ass_cache.c Fri Nov 03 23:11:00 2006 +0000 @@ -57,6 +57,24 @@ } /** + * Select Microfost Unicode CharMap, if the font has one. + * Otherwise, let FreeType decide. + */ +static void charmap_magic(FT_Face face) +{ + int i; + for (i = 0; i < face->num_charmaps; ++i) { + FT_CharMap cmap = face->charmaps[i]; + unsigned pid = cmap->platform_id; + unsigned eid = cmap->encoding_id; + if (pid == 3 /*microsoft*/ && (eid == 1 /*unicode bmp*/ || eid == 10 /*full unicode*/)) { + FT_Set_Charmap(face, cmap); + break; + } + } +} + +/** * \brief Get a face object, either from cache or created through FreeType+FontConfig. * \param library FreeType library object * \param fontconfig_priv fontconfig private data @@ -91,6 +109,8 @@ no_more_font_messages = 1; return 1; } + + charmap_magic(*face); item = face_cache + face_cache_size; item->path = strdup(path);