[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[freetype2] color 9569a5b 2/3: Color glyph framework and rendering (2/3)
From: |
Alexei Podtelezhnikov |
Subject: |
[freetype2] color 9569a5b 2/3: Color glyph framework and rendering (2/3). |
Date: |
Tue, 11 Dec 2018 23:29:18 -0500 (EST) |
branch: color
commit 9569a5b2f21696c0535b3ecea2e391811a8995d2
Author: Alexei Podtelezhnikov <address@hidden>
Commit: Alexei Podtelezhnikov <address@hidden>
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/.
---
ChangeLog | 15 +++++++++++++++
include/freetype/freetype.h | 10 ++++++----
include/freetype/ftglyph.h | 5 +++++
src/base/ftglyph.c | 9 +++++++++
src/base/ftobjs.c | 2 +-
src/type42/t42objs.c | 2 +-
6 files changed, 37 insertions(+), 6 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index fabcd15..4242a21 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,20 @@
2018-12-11 Alexei Podtelezhnikov <address@hidden>
+ 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 <address@hidden>
+
Color glyph framework and rendering (1/3).
* include/freetype/fttypes.h (FT_Color): Move here...
diff --git a/include/freetype/freetype.h b/include/freetype/freetype.h
index 1b3e603..9398f39 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 2577ccc..1f05c3e 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 27402ec..ed6f16e 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 e248b7b..9022d25 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 991f604..98c9a49 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;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [freetype2] color 9569a5b 2/3: Color glyph framework and rendering (2/3).,
Alexei Podtelezhnikov <=