From 30d0d9c56c5f481b93141ca2742f6c992443ac46 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Tue, 24 Jan 2023 15:43:17 -0500 Subject: [PATCH] Adapt to cairo changes Adapt to the api in the cairo MR that will be used, and make the code build with older cairo. --- meson.build | 1 + src/hb-cairo-utils.cc | 4 +++- src/hb-cairo.cc | 4 +++- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/meson.build b/meson.build index 07ed493fb..9819d80c4 100644 --- a/meson.build +++ b/meson.build @@ -211,6 +211,7 @@ if cairo_dep.found() else check_funcs += [['cairo_user_font_face_set_render_color_glyph_func', {'deps': cairo_dep}]] check_funcs += [['cairo_font_options_get_custom_palette_color', {'deps': cairo_dep}]] + check_funcs += [['cairo_user_scaled_font_get_foreground_source', {'deps': cairo_dep}]] endif endif diff --git a/src/hb-cairo-utils.cc b/src/hb-cairo-utils.cc index 1eeee7a40..0d6a7e4b6 100644 --- a/src/hb-cairo-utils.cc +++ b/src/hb-cairo-utils.cc @@ -287,12 +287,14 @@ _hb_cairo_get_color_stops (hb_cairo_context_t *c, for (unsigned i = 0; i < len; i++) if ((*stops)[i].is_foreground) { +#ifdef HAVE_CAIRO_USER_SCALED_FONT_GET_FOREGROUND_SOURCE double r, g, b, a; - cairo_pattern_t *foreground = cairo_user_scaled_font_get_foreground_source (c->scaled_font); + cairo_pattern_t *foreground = cairo_user_scaled_font_get_foreground_source (c->scaled_font, true); if (cairo_pattern_get_rgba (foreground, &r, &g, &b, &a) == CAIRO_STATUS_SUCCESS) (*stops)[i].color = HB_COLOR (round (b * 255.), round (g * 255.), round (r * 255.), round (a * hb_color_get_alpha ((*stops)[i].color))); else +#endif (*stops)[i].color = HB_COLOR (0, 0, 0, hb_color_get_alpha ((*stops)[i].color)); } diff --git a/src/hb-cairo.cc b/src/hb-cairo.cc index 0033ea5be..64bcc63c6 100644 --- a/src/hb-cairo.cc +++ b/src/hb-cairo.cc @@ -253,11 +253,13 @@ hb_cairo_paint_color (hb_paint_funcs_t *pfuncs HB_UNUSED, if (use_foreground) { +#ifdef HAVE_CAIRO_USER_SCALED_FONT_GET_FOREGROUND_SOURCE double r, g, b, a; - cairo_pattern_t *foreground = cairo_user_scaled_font_get_foreground_source (c->scaled_font); + cairo_pattern_t *foreground = cairo_user_scaled_font_get_foreground_source (c->scaled_font, true); if (cairo_pattern_get_rgba (foreground, &r, &g, &b, &a) == CAIRO_STATUS_SUCCESS) cairo_set_source_rgba (cr, r, g, b, a * hb_color_get_alpha (color) / 255.); else +#endif cairo_set_source_rgba (cr, 0, 0, 0, hb_color_get_alpha (color) / 255.); } else