From e52fd88b3b52e3da2dba167f3fbadb8342c6da56 Mon Sep 17 00:00:00 2001 From: Rodger Combs Date: Thu, 11 Oct 2018 02:32:50 -0500 Subject: coretext: fix reading weights of some fonts Some fonts have weights that can be expressed more precisely as doubles than as floats. In these cases, when writing to a float, CFNumberGetValue will set the value to the closest approximation, but return false (so we'd just clobber whatever it set with 0). Easy fix: just store to a double instead. --- libass/ass_coretext.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libass/ass_coretext.c b/libass/ass_coretext.c index 661b95c..ebcf61f 100644 --- a/libass/ass_coretext.c +++ b/libass/ass_coretext.c @@ -116,17 +116,17 @@ static void get_name(CTFontDescriptorRef fontd, CFStringRef attr, } static void get_trait(CFDictionaryRef traits, CFStringRef attribute, - float *trait) + double *trait) { CFNumberRef cftrait = CFDictionaryGetValue(traits, attribute); - if (!CFNumberGetValue(cftrait, kCFNumberFloatType, trait)) - *trait = 0.0; + *trait = 0.0; + CFNumberGetValue(cftrait, kCFNumberDoubleType, trait); } static void get_font_traits(CTFontDescriptorRef fontd, ASS_FontProviderMetaData *meta) { - float weight, slant, width; + double weight, slant, width; CFDictionaryRef traits = CTFontDescriptorCopyAttribute(fontd, kCTFontTraitsAttribute); -- cgit v1.2.3