[coretext] Clamp variation settings to min/max

Like our native implementation does; CoreText doesn't itself.

Also fix leak of CFNumber's.
This commit is contained in:
Behdad Esfahbod 2022-10-31 12:20:19 -06:00
parent 1b86753031
commit 4ce0f08897
1 changed files with 7 additions and 4 deletions

View File

@ -347,10 +347,13 @@ _hb_coretext_shaper_font_data_create (hb_font_t *font)
hb_ot_var_axis_info_t info;
unsigned int c = 1;
hb_ot_var_get_axis_infos (font->face, i, &c, &info);
CFDictionarySetValue (variations,
CFNumberCreate (kCFAllocatorDefault, kCFNumberIntType, &info.tag),
CFNumberCreate (kCFAllocatorDefault, kCFNumberFloatType, &font->design_coords[i])
);
float v = hb_clamp (font->design_coords[i], info.min_value, info.max_value);
CFNumberRef tag_number = CFNumberCreate (kCFAllocatorDefault, kCFNumberIntType, &info.tag);
CFNumberRef value_number = CFNumberCreate (kCFAllocatorDefault, kCFNumberFloatType, &v);
CFDictionarySetValue (variations, tag_number, value_number);
CFRelease (tag_number);
CFRelease (value_number);
}
CFDictionaryRef attributes =