From 5c3da76a439cb00d3cb45eacd51de40959c73cc1 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Sun, 25 Dec 2022 15:04:13 -0700 Subject: [PATCH] [hb-cairo] Change API again We need to work with a hb-font for variations and font-funcs to be fetched properly. --- src/hb-cairo.c | 21 ++++++--------------- src/hb-cairo.h | 6 +++--- util/helper-cairo.hh | 8 +++++--- 3 files changed, 14 insertions(+), 21 deletions(-) diff --git a/src/hb-cairo.c b/src/hb-cairo.c index cfd577c34..185c04dba 100644 --- a/src/hb-cairo.c +++ b/src/hb-cairo.c @@ -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); } diff --git a/src/hb-cairo.h b/src/hb-cairo.h index 53f4b84b7..e55fb3e69 100644 --- a/src/hb-cairo.h +++ b/src/hb-cairo.h @@ -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 diff --git a/util/helper-cairo.hh b/util/helper-cairo.hh index 16cbf0259..a042645d1 100644 --- a/util/helper-cairo.hh +++ b/util/helper-cairo.hh @@ -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);