summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRodger Combs <rodger.combs@gmail.com>2018-10-11 02:32:50 -0500
committerOleg Oshmyan <chortos@inbox.lv>2019-09-26 16:48:42 +0300
commite52fd88b3b52e3da2dba167f3fbadb8342c6da56 (patch)
tree095f00f6f1aa437a7b328a4fc4d262767d41f32e
parent2ed1760c88f348a72199aefd58ab3ff5ce06a35d (diff)
downloadlibass-e52fd88b3b52e3da2dba167f3fbadb8342c6da56.tar.bz2
libass-e52fd88b3b52e3da2dba167f3fbadb8342c6da56.tar.xz
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.
-rw-r--r--libass/ass_coretext.c8
1 files 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);