[coretext] Move code around

This commit is contained in:
Behdad Esfahbod 2016-02-22 15:42:53 +09:00
parent ca539e37a4
commit 90194efb84
1 changed files with 26 additions and 20 deletions

View File

@ -77,17 +77,8 @@ HB_SHAPER_DATA_ENSURE_DECLARE(coretext, font)
* shaper face data
*/
static CTFontRef
create_ct_font (CGFontRef cg_font, CGFloat font_size)
{
CTFontRef ct_font = CTFontCreateWithGraphicsFont (cg_font, font_size, NULL, NULL);
if (unlikely (!ct_font)) {
DEBUG_MSG (CORETEXT, cg_font, "Font CTFontCreateWithGraphicsFont() failed");
return NULL;
}
/* Create font copy with cascade list that has LastResort first; this speeds up CoreText
* font fallback which we don't need anyway. */
static CTFontDescriptorRef
get_last_resort_font_desc (void)
{
// TODO Handle allocation failures?
CTFontDescriptorRef last_resort = CTFontDescriptorCreateWithNameAndSize (CFSTR("LastResort"), 0);
@ -104,11 +95,26 @@ create_ct_font (CGFontRef cg_font, CGFloat font_size)
&kCFTypeDictionaryValueCallBacks);
CFRelease (cascade_list);
CTFontDescriptorRef new_font_desc = CTFontDescriptorCreateWithAttributes (attributes);
CTFontDescriptorRef font_desc = CTFontDescriptorCreateWithAttributes (attributes);
CFRelease (attributes);
return font_desc;
}
CTFontRef new_ct_font = CTFontCreateCopyWithAttributes (ct_font, 0.0, NULL, new_font_desc);
CFRelease (new_font_desc);
static CTFontRef
create_ct_font (CGFontRef cg_font, CGFloat font_size)
{
CTFontRef ct_font = CTFontCreateWithGraphicsFont (cg_font, font_size, NULL, NULL);
if (unlikely (!ct_font)) {
DEBUG_MSG (CORETEXT, cg_font, "Font CTFontCreateWithGraphicsFont() failed");
return NULL;
}
/* Create font copy with cascade list that has LastResort first; this speeds up CoreText
* font fallback which we don't need anyway. */
{
CTFontDescriptorRef last_resort_font_desc = get_last_resort_font_desc ();
CTFontRef new_ct_font = CTFontCreateCopyWithAttributes (ct_font, 0.0, NULL, last_resort_font_desc);
CFRelease (last_resort_font_desc);
if (new_ct_font)
{
CFRelease (ct_font);