diff --git a/ChangeLog b/ChangeLog index fabcd1518..4242a2179 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +2018-12-11 Alexei Podtelezhnikov + + Color glyph framework and rendering (2/3). + + * include/freetype/freetype.h (FT_GlyphSlotRec): Rename reserved + pointer `other' into `color'. + * include/freetype/ftglyph.h (FT_OutlineGlyphRec): Add new field + `color'. Technically this breaks binary compatibility but this is + highly unlikely. + * src/base/ftglyph.c (ft_outline_glyph_{init,done,copy,prepare}): + Handle color and copy it between FT_Glyph and FT_GlyphSlot. + + * src/base/ftobjs.c (ft_glyphslot_clear): s/other/color/. + * src/type42/t42objs.c (t42_glyphslot_clear): s/other/color/. + 2018-12-11 Alexei Podtelezhnikov Color glyph framework and rendering (1/3). diff --git a/include/freetype/freetype.h b/include/freetype/freetype.h index 1b3e60365..9398f39ee 100644 --- a/include/freetype/freetype.h +++ b/include/freetype/freetype.h @@ -1785,9 +1785,6 @@ FT_BEGIN_HEADER * This is the length in bytes of the control data. Currently internal * to FreeType. * - * other :: - * Reserved. - * * lsb_delta :: * The difference between hinted and unhinted left side bearing while * auto-hinting is active. Zero otherwise. @@ -1796,6 +1793,11 @@ FT_BEGIN_HEADER * The difference between hinted and unhinted right side bearing while * auto-hinting is active. Zero otherwise. * + * color :: + * Supplemental pointer to the color array with elements corresponding + * to each outline contour. It is used with @FT_RENDER_MODE_RGBA, + * when consecutive contours of the same color are rendered as layers. + * * @note: * If @FT_Load_Glyph is called with default flags (see @FT_LOAD_DEFAULT) * the glyph image is loaded in the glyph slot in its native format @@ -1904,7 +1906,7 @@ FT_BEGIN_HEADER FT_Pos lsb_delta; FT_Pos rsb_delta; - void* other; + FT_Color* color; FT_Slot_Internal internal; diff --git a/include/freetype/ftglyph.h b/include/freetype/ftglyph.h index 2577ccc2e..1f05c3e64 100644 --- a/include/freetype/ftglyph.h +++ b/include/freetype/ftglyph.h @@ -203,6 +203,10 @@ FT_BEGIN_HEADER * outline :: * A descriptor for the outline. * + * color :: + * Supplemental pointer to the color array with elements corresponding + * to each outline contour. + * * @note: * You can typecast an @FT_Glyph to @FT_OutlineGlyph if you have * `glyph->format == FT_GLYPH_FORMAT_OUTLINE`. This lets you access the @@ -219,6 +223,7 @@ FT_BEGIN_HEADER { FT_GlyphRec root; FT_Outline outline; + FT_Color* color; } FT_OutlineGlyphRec; diff --git a/src/base/ftglyph.c b/src/base/ftglyph.c index 27402ecf8..ed6f16e60 100644 --- a/src/base/ftglyph.c +++ b/src/base/ftglyph.c @@ -182,6 +182,7 @@ goto Exit; FT_Outline_Copy( source, target ); + glyph->color = slot->color; Exit: return error; @@ -192,9 +193,13 @@ ft_outline_glyph_done( FT_Glyph outline_glyph ) { FT_OutlineGlyph glyph = (FT_OutlineGlyph)outline_glyph; + FT_Memory memory = FT_GLYPH( glyph )->library->memory; FT_Outline_Done( FT_GLYPH( glyph )->library, &glyph->outline ); + + if ( glyph->outline.flags & FT_OUTLINE_OWNER ) + FT_FREE( glyph->color ); } @@ -213,7 +218,10 @@ source->outline.n_contours, &target->outline ); if ( !error ) + { FT_Outline_Copy( &source->outline, &target->outline ); + target->color = source->color; + } return error; } @@ -255,6 +263,7 @@ slot->format = FT_GLYPH_FORMAT_OUTLINE; slot->outline = glyph->outline; + slot->color = glyph->color; slot->outline.flags &= ~FT_OUTLINE_OWNER; return FT_Err_Ok; diff --git a/src/base/ftobjs.c b/src/base/ftobjs.c index e248b7b70..9022d2536 100644 --- a/src/base/ftobjs.c +++ b/src/base/ftobjs.c @@ -551,7 +551,7 @@ slot->subglyphs = NULL; slot->control_data = NULL; slot->control_len = 0; - slot->other = NULL; + slot->color = NULL; slot->format = FT_GLYPH_FORMAT_NONE; slot->linearHoriAdvance = 0; diff --git a/src/type42/t42objs.c b/src/type42/t42objs.c index 991f6041c..98c9a49c8 100644 --- a/src/type42/t42objs.c +++ b/src/type42/t42objs.c @@ -628,7 +628,7 @@ slot->subglyphs = NULL; slot->control_data = NULL; slot->control_len = 0; - slot->other = NULL; + slot->color = NULL; slot->format = FT_GLYPH_FORMAT_NONE; slot->linearHoriAdvance = 0;