Skip to content

Add API for retrieving 'COLR' v1 ClipBox

Dominik Röttsches requested to merge drott/freetype:clipList into master

Add API for retrieving 'COLR' v1 ClipBox

Add a new API FT_Get_Color_Glyph_ClipBox for retrieving an optional 'COLR' v1 glyph-specific clip box, which helps upstream graphics libraries allocate a sufficiently large bitmap for a glyph, without having to traverse glyph graph for that. See [1] for background on the introduction of this spec change.

[1] https://github.com/googlefonts/colr-gradients-spec/issues/251

  • include/freetype/ftcolor.h (FT_Get_Color_Glyph_ClipBox): Add API to retrieve clip box, a newer addition to the 'COLR' v1 spec.
  • include/freetype/internal/sfnt.h (TT_Get_Coor_Glyph_ClipBox_Func): Add function type and prepare pointer in SFNT interface.
  • src/base/ftobjs.c (FT_Get_Color_Glyph_ClipBox): Link API with SFNT implementation.
  • src/sfnt/sfdriver.c (PUT_COLOR_LAYERS_V1): Fill SFNT interface pointer with implementation in ttcolr.c.
  • src/sfnt/ttcolr.c (tt_face_load_colr): Parse global clip list offset. (tt_face_get_color_glyph_clipbox): Implement finding the clip box for a glyph id from the clip list array. Scale, transform, translate clipbox according to what is configured on FT_Face before returning.
  • src/sfnt/ttcolr.h (tt_face_load_colr): Add declaration.
Edited by Dominik Röttsches

Merge request reports