hb-cairo: Fix handling of foreground color
Use the new cairo_user_scaled_font_get_foreground_color
to obtain the foreground color, since the cr's source
can't be trusted.
Requires https://gitlab.freedesktop.org/cairo/cairo/-/merge_requests/420
diff --git a/src/hb-cairo.cc b/src/hb-cairo.cc
index b0bcb4a..f3d090f 100644
--- a/src/hb-cairo.cc
+++ b/src/hb-cairo.cc
@@ -585,11 +585,9 @@
cairo_font_options_destroy (options);
#endif
- hb_color_t color = HB_COLOR (0, 0, 0, 255);
- cairo_pattern_t *pattern = cairo_get_source (cr);
double r, g, b, a;
- if (cairo_pattern_get_rgba (pattern, &r, &g, &b, &a) == CAIRO_STATUS_SUCCESS)
- color = HB_COLOR (round (b * 255.), round (g * 255.), round (r * 255.), round (a * 255.));
+ cairo_user_scaled_font_get_foreground_color (scaled_font, &r, &g, &b, &a);
+ hb_color_t color = HB_COLOR (round (b * 255.), round (g * 255.), round (r * 255.), round (a * 255.));
hb_position_t x_scale, y_scale;
hb_font_get_scale (font, &x_scale, &y_scale);