diff --git a/docs/harfbuzz-sections.txt b/docs/harfbuzz-sections.txt index e4f89d264..5dedc07d9 100644 --- a/docs/harfbuzz-sections.txt +++ b/docs/harfbuzz-sections.txt @@ -544,6 +544,7 @@ hb_ot_color_glyph_reference_png hb_ot_color_glyph_reference_svg hb_ot_color_has_layers hb_ot_color_has_paint +hb_ot_color_glyph_has_paint hb_ot_color_has_palettes hb_ot_color_has_png hb_ot_color_has_svg diff --git a/src/hb-ot-color-colr-table.hh b/src/hb-ot-color-colr-table.hh index 96e9430e9..a5ebc8e7e 100644 --- a/src/hb-ot-color-colr-table.hh +++ b/src/hb-ot-color-colr-table.hh @@ -2011,6 +2011,19 @@ struct COLR return true; } + bool + has_paint_for_glyph (hb_codepoint_t glyph) const + { + if (version == 1) + { + const Paint *paint = get_base_glyph_paint (glyph); + + return paint != nullptr; + } + + return false; + } + bool paint_glyph (hb_font_t *font, hb_codepoint_t glyph, hb_paint_funcs_t *funcs, void *data, unsigned int palette, hb_color_t foreground, bool clip = true) const { diff --git a/src/hb-ot-color.cc b/src/hb-ot-color.cc index 4a2707e5a..1716a149c 100644 --- a/src/hb-ot-color.cc +++ b/src/hb-ot-color.cc @@ -224,6 +224,25 @@ hb_ot_color_has_paint (hb_face_t *face) return face->table.COLR->has_v1_data (); } +/** + * hb_ot_color_glyph_has_paint: + * @face: #hb_face_t to work upon + * @glyph: The glyph index to query + * + * Tests where a face includes COLRv1 paint + * data for @glyph. + * + * Return value: `true` if data found, `false` otherwise + * + * Since: REPLACEME + */ +hb_bool_t +hb_ot_color_glyph_has_paint (hb_face_t *face, + hb_codepoint_t glyph) +{ + return face->table.COLR->has_paint_for_glyph (glyph); +} + /** * hb_ot_color_glyph_get_layers: * @face: #hb_face_t to work upon diff --git a/src/hb-ot-color.h b/src/hb-ot-color.h index f29d7cf5f..22ee497e3 100644 --- a/src/hb-ot-color.h +++ b/src/hb-ot-color.h @@ -125,6 +125,10 @@ hb_ot_color_glyph_get_layers (hb_face_t *face, HB_EXTERN hb_bool_t hb_ot_color_has_paint (hb_face_t *face); +HB_EXTERN hb_bool_t +hb_ot_color_glyph_has_paint (hb_face_t *face, + hb_codepoint_t glyph); + /* * SVG */