[coretext] Fix formatting

This commit is contained in:
Behdad Esfahbod 2021-08-04 10:24:14 -06:00
parent db6fbe29e4
commit e80c86ffa6
1 changed files with 34 additions and 29 deletions

View File

@ -332,38 +332,43 @@ _hb_coretext_shaper_font_data_create (hb_font_t *font)
return nullptr; return nullptr;
} }
if (font->coords) { if (font->coords)
hb_ot_var_axis_info_t info; {
unsigned int c = 1; CFMutableDictionaryRef variations =
CFMutableDictionaryRef variations = CFDictionaryCreateMutable (kCFAllocatorDefault, CFDictionaryCreateMutable (kCFAllocatorDefault,
font->num_coords, font->num_coords,
&kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryKeyCallBacks,
&kCFTypeDictionaryValueCallBacks); &kCFTypeDictionaryValueCallBacks);
for (unsigned int i=0; i < font->num_coords; i++) for (unsigned i = 0; i < font->num_coords; i++)
{ {
if (font->coords[i] == 0) continue; if (font->coords[i] == 0.) continue;
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])
);
}
CFDictionaryRef attributes = CFDictionaryCreate (kCFAllocatorDefault, hb_ot_var_axis_info_t info;
(const void **) &kCTFontVariationAttribute, unsigned int c = 1;
(const void **) &variations, hb_ot_var_get_axis_infos (font->face, i, &c, &info);
1, CFDictionarySetValue (variations,
&kCFTypeDictionaryKeyCallBacks, CFNumberCreate (kCFAllocatorDefault, kCFNumberIntType, &info.tag),
&kCFTypeDictionaryValueCallBacks); CFNumberCreate (kCFAllocatorDefault, kCFNumberFloatType, &font->design_coords[i])
);
}
CTFontDescriptorRef varDesc = CTFontDescriptorCreateWithAttributes(attributes); CFDictionaryRef attributes =
CTFontRef new_ct_font = CTFontCreateCopyWithAttributes(ct_font, 0, nullptr, varDesc); CFDictionaryCreate (kCFAllocatorDefault,
CFRelease (ct_font); (const void **) &kCTFontVariationAttribute,
CFRelease (attributes); (const void **) &variations,
CFRelease (variations); 1,
ct_font = new_ct_font; &kCFTypeDictionaryKeyCallBacks,
} &kCFTypeDictionaryValueCallBacks);
CTFontDescriptorRef varDesc = CTFontDescriptorCreateWithAttributes (attributes);
CTFontRef new_ct_font = CTFontCreateCopyWithAttributes (ct_font, 0, nullptr, varDesc);
CFRelease (ct_font);
CFRelease (attributes);
CFRelease (variations);
ct_font = new_ct_font;
}
return (hb_coretext_font_data_t *) ct_font; return (hb_coretext_font_data_t *) ct_font;
} }