diff options
author | Oleg Oshmyan <chortos@inbox.lv> | 2020-10-23 01:41:21 +0300 |
---|---|---|
committer | Oleg Oshmyan <chortos@inbox.lv> | 2020-10-23 01:41:21 +0300 |
commit | 152d0484e98f118d01987138695cf40579c9e297 (patch) | |
tree | f29ea5efe765248cc2533567f3a264d26600c508 | |
parent | 6a956a5a234b0508c0ec23540c5217910d97dd08 (diff) | |
download | libass-152d0484e98f118d01987138695cf40579c9e297.tar.bz2 libass-152d0484e98f118d01987138695cf40579c9e297.tar.xz |
coretext: return full/PostScript name on fallback
CoreText's "family name" can use TT_NAME_ID_TYPOGRAPHIC_FAMILY names,
which we ignore for compatibility with VSFilter. As a result, fallback
returns a family name that we then fail to find, and fallback fails.
Return a fuller name (fullname or postscriptname as appropriate)
instead, which should be more reliable.
-rw-r--r-- | libass/ass_coretext.c | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/libass/ass_coretext.c b/libass/ass_coretext.c index 0de54ed..13f30d0 100644 --- a/libass/ass_coretext.c +++ b/libass/ass_coretext.c @@ -60,19 +60,23 @@ static void destroy_font(void *priv) SAFE_CFRelease(fontd); } -static bool check_postscript(void *priv) +static bool is_postscript_font_format(CFNumberRef cfformat) { bool ret = false; - CTFontDescriptorRef fontd = priv; - CFNumberRef cfformat = - CTFontDescriptorCopyAttribute(fontd, kCTFontFormatAttribute); int format; - if (CFNumberGetValue(cfformat, kCFNumberIntType, &format)) { ret = format == kCTFontFormatOpenTypePostScript || format == kCTFontFormatPostScript; } + return ret; +} +static bool check_postscript(void *priv) +{ + CTFontDescriptorRef fontd = priv; + CFNumberRef cfformat = + CTFontDescriptorCopyAttribute(fontd, kCTFontFormatAttribute); + bool ret = is_postscript_font_format(cfformat); SAFE_CFRelease(cfformat); return ret; } @@ -224,16 +228,19 @@ static char *get_fallback(void *priv, const char *family, uint32_t codepoint) 0, (UInt8*)&codepointle, sizeof(codepointle), kCFStringEncodingUTF32LE, false); CTFontRef fb = CTFontCreateForString(font, r, CFRangeMake(0, 1)); - CFStringRef cffamily = CTFontCopyFamilyName(fb); - char *res_family = cfstr2buf(cffamily); + CFNumberRef cfformat = CTFontCopyAttribute(fb, kCTFontFormatAttribute); + CFStringRef cfname = is_postscript_font_format(cfformat) ? + CTFontCopyPostScriptName(fb) : CTFontCopyFullName(fb); + char *res_name = cfstr2buf(cfname); SAFE_CFRelease(name); SAFE_CFRelease(font); SAFE_CFRelease(r); SAFE_CFRelease(fb); - SAFE_CFRelease(cffamily); + SAFE_CFRelease(cfformat); + SAFE_CFRelease(cfname); - return res_family; + return res_name; } static void get_substitutions(void *priv, const char *name, |