[view] Streamline cairo-ft face lifecycle management

This commit is contained in:
Behdad Esfahbod 2022-12-29 18:33:12 -07:00
parent 228a415470
commit ab8b9b4443
2 changed files with 10 additions and 7 deletions

View File

@ -43,6 +43,13 @@ void free_ft_library ()
}
#endif
static void
_release_blob (void *arg)
{
FT_Face ft_face = (FT_Face) arg;
hb_blob_destroy ((hb_blob_t *) ft_face->generic.data);
}
static inline cairo_font_face_t *
helper_cairo_create_ft_font_face (const font_options_t *font_opts)
{
@ -80,6 +87,9 @@ helper_cairo_create_ft_font_face (const font_options_t *font_opts)
}
else
{
ft_face->generic.data = hb_blob_reference (font_opts->blob);
ft_face->generic.finalizer = _release_blob;
#if !defined(HB_NO_VAR) && defined(HAVE_FT_SET_VAR_BLEND_COORDINATES)
unsigned int num_coords;
const float *coords = hb_font_get_var_coords_design (font_opts->font, &num_coords);

View File

@ -134,13 +134,6 @@ helper_cairo_create_scaled_font (const font_options_t *font_opts)
cairo_font_options_destroy (font_options);
cairo_font_face_destroy (cairo_face);
static cairo_user_data_key_t key;
if (cairo_scaled_font_set_user_data (scaled_font,
&key,
(void *) hb_font_reference (font),
(cairo_destroy_func_t) hb_font_destroy))
hb_font_destroy (font);
return scaled_font;
}