[sfnt] Preliminary support of coloured layer outlines

System Internals / FreeType - Shao Yu Zhang [fb.com] - 13 May 2018 01:25 EDT

This commit enables OpenType's COLR/CPAL table handling; a typical application are color emojis that can be scaled to any size.

If the color palette does not exist or is invalid, the rendering step rasterizes the outline instead. The current implementation assumes that the foreground is black.

Enable this by defining option TT_CONFIG_OPTION_COLOR_LAYERS.

There are still some issues with metrics; additionally, an API to fetch color layers is missing.

- devel/ftoption.h, include/freetype/config/ftoption.h (TT_CONFIG_OPTION_COLOR_LAYERS): New macro.

- include/freetype/internal/ftobjs.h (FT_Glyph_LayerRec, FT_Colr_InternalRec): New structures. (FT_Slot_InternalRec): Add `color_layers' field.

- include/freetype/internal/sfnt.h (TT_Load_Colr_Layer_Func, TT_Blend_Colr_Func): New function types. (SFNT_Interface): Add `load_colr', `free_colr', `load_colr_layer', and `colr_blend' fields.

- include/freetype/internal/tttypes.h (TT_FaceRec): Add `colr_and_cpal' field.

- include/freetype/internal/tttags. (TTAG_COLR, TTAG_CPAL): New macros.

- src/sfnt/ttcolr.c, src/sfnt/ttcolr.h: New files.

- src/base/ftobjs.c (ft_glyphslot_done, FT_Render_Glyph_Internal): Handle glyph color layers.

- src/sfnt/Jamfile (_sources), src/sfnt/rules.mk (SFNT_DRV_SRC): Add `ttcolr.c'.

- src/sfnt/sfdriver.c: Include `ttcolr.h'. (PUT_COLOR_LAYERS): New macro. Update call to `FT_DEFINE_SFNT_INTERFACE'.

- src/sfnt/sfnt.c: Include `ttcolr.c'.

- src/sfnt/sfobjs.c (sfnt_load_face): Load `COLR' and `CPAL' tables. (sfnt_done_face): Updated.

- src/truetype/ttgload.c (TT_Load_Glyph): Handle color layers.

f04d81751 [sfnt] Preliminary support of coloured layer outlines.
ChangeLog | 54 ++++
devel/ftoption.h | 9 +
include/freetype/config/ftoption.h | 9 +
include/freetype/internal/ftobjs.h | 21 ++
include/freetype/internal/sfnt.h | 75 +++++
include/freetype/internal/tttypes.h | 5 +
include/freetype/tttags.h | 2 +
src/base/ftobjs.c | 65 +++++
src/sfnt/Jamfile | 1 +
src/sfnt/rules.mk | 1 +
src/sfnt/sfdriver.c | 23 +-
src/sfnt/sfnt.c | 2 +
src/sfnt/sfobjs.c | 13 +-
src/sfnt/ttcolr.c | 546 ++++++++++++++++++++++++++++++++++++
src/sfnt/ttcolr.h | 57 ++++
src/truetype/ttdriver.c | 2 +-
src/truetype/ttgload.c | 31 ++
17 files changed, 912 insertions(+), 4 deletions(-)

Upstream: git.savannah.gnu.org


  • Share