Adapt to cairo changes

Adapt to the api in the cairo MR that will be used,
and make the code build with older cairo.
This commit is contained in:
Matthias Clasen 2023-01-24 15:43:17 -05:00
parent 034d4d26f2
commit 30d0d9c56c
3 changed files with 7 additions and 2 deletions

View File

@ -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

View File

@ -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));
}

View File

@ -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