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/.
This commit is contained in:
Alexei Podtelezhnikov 2018-12-11 23:17:36 -05:00
parent aec5bdb43b
commit 9569a5b2f2
6 changed files with 37 additions and 6 deletions

View File

@ -1,3 +1,18 @@
2018-12-11 Alexei Podtelezhnikov <apodtele@gmail.com>
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 <apodtele@gmail.com>
Color glyph framework and rendering (1/3).

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;