[hb-cairo] Change API again

We need to work with a hb-font for variations and font-funcs
to be fetched properly.
This commit is contained in:
Behdad Esfahbod 2022-12-25 15:04:13 -07:00
parent 9f7538c260
commit 5c3da76a43
3 changed files with 14 additions and 21 deletions

View File

@ -387,24 +387,15 @@ user_font_face_create (hb_font_t *font)
}
cairo_font_face_t *
hb_cairo_font_face_create (hb_face_t *face)
hb_cairo_font_face_create (hb_font_t *font)
{
cairo_font_face_t *cairo_face;
hb_font_make_immutable (font);
hb_font_t *font = hb_font_create (face);
cairo_face = user_font_face_create (font);
hb_font_destroy (font);
return cairo_face;
return user_font_face_create (font);
}
hb_face_t *
hb_cairo_font_face_get_face (cairo_font_face_t *font_face)
hb_font_t *
hb_cairo_font_face_get_font (cairo_font_face_t *font_face)
{
hb_font_t *font = cairo_font_face_get_user_data (font_face, &hb_cairo_font_user_data_key);
if (!font)
return NULL;
return hb_font_get_face (font);
return cairo_font_face_get_user_data (font_face, &hb_cairo_font_user_data_key);
}

View File

@ -33,10 +33,10 @@
HB_BEGIN_DECLS
HB_EXTERN cairo_font_face_t *
hb_cairo_font_face_create (hb_face_t *face);
hb_cairo_font_face_create (hb_font_t *font);
HB_EXTERN hb_face_t *
hb_cairo_font_face_get_face (cairo_font_face_t *font_face);
HB_EXTERN hb_font_t *
hb_cairo_font_face_get_font (cairo_font_face_t *font_face);
HB_END_DECLS

View File

@ -100,7 +100,7 @@ helper_cairo_create_scaled_font (const font_options_t *font_opts)
cairo_font_face_t *cairo_face;
if (use_hb_draw)
cairo_face = hb_cairo_font_face_create (hb_font_get_face (font));
cairo_face = hb_cairo_font_face_create (font);
#ifdef HAVE_CAIRO_FT
else
cairo_face = helper_cairo_create_ft_font_face (font_opts);
@ -143,13 +143,15 @@ helper_cairo_create_scaled_font (const font_options_t *font_opts)
static inline bool
helper_cairo_scaled_font_has_color (cairo_scaled_font_t *scaled_font)
{
hb_face_t *face = hb_cairo_font_face_get_face (cairo_scaled_font_get_font_face (scaled_font));
hb_font_t *font = hb_cairo_font_face_get_font (cairo_scaled_font_get_font_face (scaled_font));
#ifdef HAVE_CAIRO_FT
if (!face)
if (!font)
return helper_cairo_ft_scaled_font_has_color (scaled_font);
#endif
hb_face_t *face = hb_font_get_face (font);
return hb_ot_color_has_png (face) ||
hb_ot_color_has_layers (face) ||
hb_ot_color_has_paint (face);