提交 7918c261 编写于 作者: B Behdad Esfahbod

[ft] Port ft font funcs to allocated object

上级 da29b437
......@@ -380,23 +380,50 @@ hb_ft_get_glyph_from_name (hb_font_t *font HB_UNUSED,
}
static hb_font_funcs_t *static_ft_funcs = NULL;
#ifdef HB_USE_ATEXIT
static
void free_static_ft_funcs (void)
{
hb_font_funcs_destroy (static_ft_funcs);
}
#endif
static void
_hb_ft_font_set_funcs (hb_font_t *font, FT_Face ft_face, bool unref)
{
static const hb_font_funcs_t ft_ffuncs = {
HB_OBJECT_HEADER_STATIC,
true, /* immutable */
retry:
hb_font_funcs_t *funcs = (hb_font_funcs_t *) hb_atomic_ptr_get (&static_ft_funcs);
{
#define HB_FONT_FUNC_IMPLEMENT(name) hb_ft_get_##name,
HB_FONT_FUNCS_IMPLEMENT_CALLBACKS
#undef HB_FONT_FUNC_IMPLEMENT
if (unlikely (!funcs))
{
funcs = hb_font_funcs_create ();
hb_font_funcs_set_glyph_func (funcs, hb_ft_get_glyph, NULL, NULL);
hb_font_funcs_set_glyph_h_advance_func (funcs, hb_ft_get_glyph_h_advance, NULL, NULL);
hb_font_funcs_set_glyph_v_advance_func (funcs, hb_ft_get_glyph_v_advance, NULL, NULL);
hb_font_funcs_set_glyph_h_origin_func (funcs, hb_ft_get_glyph_h_origin, NULL, NULL);
hb_font_funcs_set_glyph_v_origin_func (funcs, hb_ft_get_glyph_v_origin, NULL, NULL);
hb_font_funcs_set_glyph_h_kerning_func (funcs, hb_ft_get_glyph_h_kerning, NULL, NULL);
hb_font_funcs_set_glyph_v_kerning_func (funcs, hb_ft_get_glyph_v_kerning, NULL, NULL);
hb_font_funcs_set_glyph_extents_func (funcs, hb_ft_get_glyph_extents, NULL, NULL);
hb_font_funcs_set_glyph_contour_point_func (funcs, hb_ft_get_glyph_contour_point, NULL, NULL);
hb_font_funcs_set_glyph_name_func (funcs, hb_ft_get_glyph_name, NULL, NULL);
hb_font_funcs_set_glyph_from_name_func (funcs, hb_ft_get_glyph_from_name, NULL, NULL);
if (!hb_atomic_ptr_cmpexch (&static_ft_funcs, NULL, funcs)) {
hb_font_funcs_destroy (funcs);
goto retry;
}
#ifdef HB_USE_ATEXIT
atexit (free_static_ft_funcs); /* First person registers atexit() callback. */
#endif
};
hb_font_set_funcs (font,
const_cast<hb_font_funcs_t *> (&ft_ffuncs),
funcs,
_hb_ft_font_create (ft_face, unref),
(hb_destroy_func_t) _hb_ft_font_destroy);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册