From d915ff0eaf43e301c35592376a14778445faa183 Mon Sep 17 00:00:00 2001 From: msizanoen1 Date: Mon, 13 Feb 2023 17:46:02 +0700 Subject: shape: Properly detect COLRv1 color fonts HarfBuzz 7.0.0 introduced 2 new APIs: `hb_ot_color_has_paint` and `hb_ot_color_glyph_has_paint`. Use these APIs to detect the new COLRv1 color font format to ensure compatibility of code relying on the color font detection for rendering with the new font format. --- pango/shape.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/pango/shape.c b/pango/shape.c index e666bb3d..acf4be59 100644 --- a/pango/shape.c +++ b/pango/shape.c @@ -306,6 +306,11 @@ font_has_color (hb_font_t *font) face = hb_font_get_face (font); +#if HB_VERSION_ATLEAST (7, 0, 0) + if (hb_ot_color_has_paint (face)) + return TRUE; +#endif + return hb_ot_color_has_layers (face) || hb_ot_color_has_png (face) || hb_ot_color_has_svg (face); @@ -320,6 +325,11 @@ glyph_has_color (hb_font_t *font, face = hb_font_get_face (font); +#if HB_VERSION_ATLEAST (7, 0, 0) + if (hb_ot_color_glyph_has_paint (face, glyph)) + return TRUE; +#endif + if (hb_ot_color_glyph_get_layers (face, glyph, 0, NULL, NULL) > 0) return TRUE; -- cgit v1.2.1