[colr] Add hb_ot_color_has_paint

This is a counterpart to hb_ot_color_has_layers
for COLRv1 data.
This commit is contained in:
Matthias Clasen 2022-12-18 00:12:32 -05:00 committed by Behdad Esfahbod
parent 63fcb26c9b
commit 021618e91a
3 changed files with 27 additions and 11 deletions

View File

@ -1631,7 +1631,8 @@ struct COLR
{
static constexpr hb_tag_t tableTag = HB_OT_TAG_COLR;
bool has_data () const { return numBaseGlyphs; }
bool has_v0_data () const { return numBaseGlyphs; }
bool has_v1_data () const { return (this+baseGlyphList).len; }
unsigned int get_glyph_layers (hb_codepoint_t glyph,
unsigned int start_offset,

View File

@ -190,15 +190,8 @@ hb_ot_color_palette_get_colors (hb_face_t *face,
* hb_ot_color_has_layers:
* @face: #hb_face_t to work upon
*
* Tests whether a face includes a `COLR` table.
*
* Note that the `COLR` table may contain layers
* or (for v1) more complicated paint graphs, so
* it is not guaranteed that hb_ot_color_get_layers()
* will return information for each color glyph,
* even if this function returns `true`. See
* hb_font_paint_glyph() for an API that will work
* in either case.
* Tests whether a face includes a `COLR` table
* with data according to COLRv0.
*
* Return value: `true` if data found, `false` otherwise
*
@ -207,7 +200,24 @@ hb_ot_color_palette_get_colors (hb_face_t *face,
hb_bool_t
hb_ot_color_has_layers (hb_face_t *face)
{
return face->table.COLR->has_data ();
return face->table.COLR->has_v0_data ();
}
/**
* hb_ot_color_has_paint:
* @face: #hb_face_t to work upon
*
* Tests where a face includes a `COLR` table
* with data according to COLRv1.
*
* Return value: `true` if data found, `false` otherwise
*
* Since: REPLACEME
*/
hb_bool_t
hb_ot_color_has_paint (hb_face_t *face)
{
return face->table.COLR->has_v1_data ();
}
/**

View File

@ -120,6 +120,11 @@ hb_ot_color_glyph_get_layers (hb_face_t *face,
unsigned int *layer_count, /* IN/OUT. May be NULL. */
hb_ot_color_layer_t *layers /* OUT. May be NULL. */);
/* COLRv1 */
HB_EXTERN hb_bool_t
hb_ot_color_has_paint (hb_face_t *face);
/*
* SVG
*/