[coretext] Remove old hack now that font layer takes care...
of invalidating font data when font settings change.
This commit is contained in:
parent
c1c78ade71
commit
c90130e625
|
@ -379,37 +379,6 @@ _hb_coretext_shaper_font_data_destroy (hb_coretext_font_data_t *data)
|
||||||
CFRelease ((CTFontRef) data);
|
CFRelease ((CTFontRef) data);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const hb_coretext_font_data_t *
|
|
||||||
hb_coretext_font_data_sync (hb_font_t *font)
|
|
||||||
{
|
|
||||||
retry:
|
|
||||||
const hb_coretext_font_data_t *data = font->data.coretext;
|
|
||||||
if (unlikely (!data)) return nullptr;
|
|
||||||
|
|
||||||
if (fabs (CTFontGetSize ((CTFontRef) data) - (CGFloat) font->ptem) > (CGFloat) .5)
|
|
||||||
{
|
|
||||||
/* XXX-MT-bug
|
|
||||||
* Note that evaluating condition above can be dangerous if another thread
|
|
||||||
* got here first and destructed data. That's, as always, bad use pattern.
|
|
||||||
* If you modify the font (change font size), other threads must not be
|
|
||||||
* using it at the same time. However, since this check is delayed to
|
|
||||||
* when one actually tries to shape something, this is a XXX race condition
|
|
||||||
* (and the only one we have that I know of) right now. Ie. you modify the
|
|
||||||
* font size in one thread, then (supposedly safely) try to use it from two
|
|
||||||
* or more threads and BOOM! I'm not sure how to fix this. We want RCU.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Drop and recreate. */
|
|
||||||
/* If someone dropped it in the mean time, throw it away and don't touch it.
|
|
||||||
* Otherwise, destruct it. */
|
|
||||||
if (likely (font->data.coretext.cmpexch (const_cast<hb_coretext_font_data_t *> (data), nullptr)))
|
|
||||||
_hb_coretext_shaper_font_data_destroy (const_cast<hb_coretext_font_data_t *> (data));
|
|
||||||
else
|
|
||||||
goto retry;
|
|
||||||
}
|
|
||||||
return font->data.coretext;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* hb_coretext_font_create:
|
* hb_coretext_font_create:
|
||||||
* @ct_font: The CTFontRef to work upon
|
* @ct_font: The CTFontRef to work upon
|
||||||
|
@ -455,8 +424,8 @@ hb_coretext_font_create (CTFontRef ct_font)
|
||||||
CTFontRef
|
CTFontRef
|
||||||
hb_coretext_font_get_ct_font (hb_font_t *font)
|
hb_coretext_font_get_ct_font (hb_font_t *font)
|
||||||
{
|
{
|
||||||
const hb_coretext_font_data_t *data = hb_coretext_font_data_sync (font);
|
CTFontRef ct_font = (CTFontRef) (const void *) font->data.coretext;
|
||||||
return data ? (CTFontRef) data : nullptr;
|
return ct_font ? (CTFontRef) ct_font : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -516,7 +485,7 @@ _hb_coretext_shape (hb_shape_plan_t *shape_plan,
|
||||||
{
|
{
|
||||||
hb_face_t *face = font->face;
|
hb_face_t *face = font->face;
|
||||||
CGFontRef cg_font = (CGFontRef) (const void *) face->data.coretext;
|
CGFontRef cg_font = (CGFontRef) (const void *) face->data.coretext;
|
||||||
CTFontRef ct_font = (CTFontRef) hb_coretext_font_data_sync (font);
|
CTFontRef ct_font = (CTFontRef) (const void *) font->data.coretext;
|
||||||
|
|
||||||
CGFloat ct_font_size = CTFontGetSize (ct_font);
|
CGFloat ct_font_size = CTFontGetSize (ct_font);
|
||||||
CGFloat x_mult = (CGFloat) font->x_scale / ct_font_size;
|
CGFloat x_mult = (CGFloat) font->x_scale / ct_font_size;
|
||||||
|
|
Loading…
Reference in New Issue