summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWerner Lemberg <wl@gnu.org>2018-07-02 11:41:44 +0200
committerWerner Lemberg <wl@gnu.org>2018-07-02 11:41:44 +0200
commit4e3b2473d8ca08c9001e4605ba9844168811d2c7 (patch)
tree24103700592948a4bc8838a324ee17f2825e9876
parentf6ccb524af9b7d136f32426362558525b537817c (diff)
downloadfreetype2-4e3b2473d8ca08c9001e4605ba9844168811d2c7.tar.gz
Make `FT_Get_Color_Glyph_Layer' return FT_Bool.
* include/freetype/freetype.h, src/base/ftobjs.c (FT_Get_Color_Glyph_Layer, FT_Render_Glyph_Internal): Updated. * include/freetype/internal/sfnt.h (TT_Get_Colr_Layer_Func), src/sfnt/ttcolr.h, src/sfnt/ttcolr.c (tt_face_get_colr_layer): Updated.
-rw-r--r--ChangeLog11
-rw-r--r--include/freetype/freetype.h48
-rw-r--r--include/freetype/internal/sfnt.h12
-rw-r--r--src/base/ftobjs.c27
-rw-r--r--src/sfnt/ttcolr.c12
-rw-r--r--src/sfnt/ttcolr.h3
6 files changed, 71 insertions, 42 deletions
diff --git a/ChangeLog b/ChangeLog
index dd5738811..2b6c0588a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2018-07-02 Werner Lemberg <wl@gnu.org>
+
+ Make `FT_Get_Color_Glyph_Layer' return FT_Bool.
+
+ * include/freetype/freetype.h, src/base/ftobjs.c
+ (FT_Get_Color_Glyph_Layer, FT_Render_Glyph_Internal): Updated.
+
+ * include/freetype/internal/sfnt.h (TT_Get_Colr_Layer_Func),
+ src/sfnt/ttcolr.h, src/sfnt/ttcolr.c (tt_face_get_colr_layer):
+ Updated.
+
2018-07-01 Werner Lemberg <wl@gnu.org>
* src/base/ftobjs.c (FT_Get_Color_Glyph_Layer): Guard SFNT function.
diff --git a/include/freetype/freetype.h b/include/freetype/freetype.h
index a5896e973..2f58d25b3 100644
--- a/include/freetype/freetype.h
+++ b/include/freetype/freetype.h
@@ -4255,6 +4255,9 @@ FT_BEGIN_HEADER
* same object again.
*
* @output:
+ * aglyph_index ::
+ * The glyph index of the current layer.
+ *
* acolor_index ::
* The color index into the font face's color palette of the current
* layer. The value 0xFFFF is special; it doesn't reference a palette
@@ -4264,9 +4267,9 @@ FT_BEGIN_HEADER
* The color palette can be retrieved with @FT_Palette_Select.
*
* @return:
- * The glyph index of the current layer. If there are no more layers
- * (or if there are no layers at all), value~0 gets returned. In case
- * of an error, value~0 is returned also.
+ * Value~1 if everything is OK. If there are no more layers (or if
+ * there are no layers at all), value~0 gets returned. In case of an
+ * error, value~0 is returned also.
*
* @note:
* This function is necessary if you want to handle glyph layers by
@@ -4282,6 +4285,7 @@ FT_BEGIN_HEADER
* FT_Color* palette;
* FT_LayerIterator iterator;
*
+ * FT_Bool have_layers;
* FT_UInt layer_glyph_index;
* FT_UInt layer_color_index;
*
@@ -4290,33 +4294,41 @@ FT_BEGIN_HEADER
* if ( error )
* palette = NULL;
*
- * iterator.p = NULL;
- * layer_glyph_index = FT_Get_Color_Glyph_Layer( face,
- * glyph_index,
- * &layer_color_index,
- * &iterator );
+ * iterator.p = NULL;
+ * have_layers = FT_Get_Color_Glyph_Layer( face,
+ * glyph_index,
+ * &layer_glyph_index,
+ * &layer_color_index,
+ * &iterator );
*
- * if ( palette && layer_glyph_index )
+ * if ( palette && have_layers )
* {
* do
* {
- * FT_Color layer_color = palette[layer_color_index];
+ * FT_Color layer_color;
*
*
- * // Load and render glyph `layer_glyph_index', then
- * // blend resulting pixmap with previously created pixmaps.
+ * if ( layer_color_index == 0xFFFF )
+ * layer_color = text_foreground_color;
+ * else
+ * layer_color = palette[layer_color_index];
*
- * } while ( ( layer_glyph_index =
- * FT_Get_Color_Glyph_Layer( face,
- * glyph_index,
- * &layer_color_index,
- * &iterator ) ) != 0 );
+ * // Load and render glyph `layer_glyph_index', then
+ * // blend resulting pixmap (using color `layer_color')
+ * // with previously created pixmaps.
+ *
+ * } while ( FT_Get_Color_Glyph_Layer( face,
+ * glyph_index,
+ * &layer_glyph_index,
+ * &layer_color_index,
+ * &iterator ) );
* }
* }
*/
- FT_EXPORT( FT_UInt )
+ FT_EXPORT( FT_Bool )
FT_Get_Color_Glyph_Layer( FT_Face face,
FT_UInt base_glyph,
+ FT_UInt *aglyph_index,
FT_UInt *acolor_index,
FT_LayerIterator* iterator );
diff --git a/include/freetype/internal/sfnt.h b/include/freetype/internal/sfnt.h
index deb1ed4a2..5588f5ddf 100644
--- a/include/freetype/internal/sfnt.h
+++ b/include/freetype/internal/sfnt.h
@@ -514,6 +514,9 @@ FT_BEGIN_HEADER
* same object again.
*
* @output:
+ * aglyph_index ::
+ * The glyph index of the current layer.
+ *
* acolor_index ::
* The color index into the font face's color palette of the current
* layer. The value 0xFFFF is special; it doesn't reference a palette
@@ -521,13 +524,14 @@ FT_BEGIN_HEADER
* instead (to be set up by the application outside of FreeType).
*
* @return:
- * The glyph index of the current layer. If there are no more layers
- * (or if there are no layers at all), value~0 gets returned. In case
- * of an error, value~0 is returned also.
+ * Value~1 if everything is OK. If there are no more layers (or if
+ * there are no layers at all), value~0 gets returned. In case of an
+ * error, value~0 is returned also.
*/
- typedef FT_UInt
+ typedef FT_Bool
(*TT_Get_Colr_Layer_Func)( TT_Face face,
FT_UInt base_glyph,
+ FT_UInt *aglyph_index,
FT_UInt *acolor_index,
FT_LayerIterator* iterator );
diff --git a/src/base/ftobjs.c b/src/base/ftobjs.c
index fa58768e6..4f237e23e 100644
--- a/src/base/ftobjs.c
+++ b/src/base/ftobjs.c
@@ -4517,17 +4517,19 @@
FT_UInt base_glyph = slot->glyph_index;
+ FT_Bool have_layers;
FT_UInt glyph_index;
FT_UInt color_index;
/* check whether we have colored glyph layers */
iterator.p = NULL;
- glyph_index = FT_Get_Color_Glyph_Layer( face,
+ have_layers = FT_Get_Color_Glyph_Layer( face,
base_glyph,
+ &glyph_index,
&color_index,
&iterator );
- if ( glyph_index )
+ if ( have_layers )
{
error = FT_New_GlyphSlot( face, NULL );
if ( !error )
@@ -4546,7 +4548,7 @@
load_flags &= ~FT_LOAD_COLOR;
/* render into the new `face->glyph' glyph slot */
- load_flags |= FT_LOAD_RENDER;
+ load_flags |= FT_LOAD_RENDER;
error = FT_Load_Glyph( face, glyph_index, load_flags );
if ( error )
@@ -4561,11 +4563,11 @@
if ( error )
break;
- } while ( ( glyph_index =
- FT_Get_Color_Glyph_Layer( face,
- base_glyph,
- &color_index,
- &iterator ) ) != 0 );
+ } while ( FT_Get_Color_Glyph_Layer( face,
+ base_glyph,
+ &glyph_index,
+ &color_index,
+ &iterator ) );
if ( !error )
slot->format = FT_GLYPH_FORMAT_BITMAP;
@@ -5471,9 +5473,10 @@
/* documentation is in freetype.h */
- FT_EXPORT_DEF( FT_UInt )
+ FT_EXPORT_DEF( FT_Bool )
FT_Get_Color_Glyph_Layer( FT_Face face,
FT_UInt base_glyph,
+ FT_UInt *aglyph_index,
FT_UInt *acolor_index,
FT_LayerIterator* iterator )
{
@@ -5482,6 +5485,7 @@
if ( !face ||
+ !aglyph_index ||
!acolor_index ||
!iterator ||
base_glyph >= (FT_UInt)face->num_glyphs )
@@ -5496,14 +5500,11 @@
if ( sfnt->get_colr_layer )
return sfnt->get_colr_layer( ttface,
base_glyph,
+ aglyph_index,
acolor_index,
iterator );
else
- {
- *acolor_index = 0;
-
return 0;
- }
}
diff --git a/src/sfnt/ttcolr.c b/src/sfnt/ttcolr.c
index 4dab9724b..9151ab5fa 100644
--- a/src/sfnt/ttcolr.c
+++ b/src/sfnt/ttcolr.c
@@ -209,15 +209,15 @@
}
- FT_LOCAL_DEF( FT_UInt )
+ FT_LOCAL_DEF( FT_Bool )
tt_face_get_colr_layer( TT_Face face,
FT_UInt base_glyph,
+ FT_UInt *aglyph_index,
FT_UInt *acolor_index,
FT_LayerIterator* iterator )
{
- Colr* colr = (Colr*)face->colr;
+ Colr* colr = (Colr*)face->colr;
BaseGlyphRecord glyph_record;
- FT_UInt glyph_index;
if ( !colr )
@@ -252,17 +252,17 @@
if ( iterator->layer >= iterator->num_layers )
return 0;
- glyph_index = FT_NEXT_USHORT( iterator->p );
+ *aglyph_index = FT_NEXT_USHORT( iterator->p );
*acolor_index = FT_NEXT_USHORT( iterator->p );
- if ( glyph_index >= FT_FACE( face )->num_glyphs ||
+ if ( *aglyph_index >= FT_FACE( face )->num_glyphs ||
( *acolor_index != 0xFFFF &&
*acolor_index >= face->palette_data.num_palette_entries ) )
return 0;
iterator->layer++;
- return glyph_index;
+ return 1;
}
diff --git a/src/sfnt/ttcolr.h b/src/sfnt/ttcolr.h
index 983ab831e..46cc0813e 100644
--- a/src/sfnt/ttcolr.h
+++ b/src/sfnt/ttcolr.h
@@ -36,9 +36,10 @@ FT_BEGIN_HEADER
FT_LOCAL( void )
tt_face_free_colr( TT_Face face );
- FT_LOCAL( FT_UInt )
+ FT_LOCAL( FT_Bool )
tt_face_get_colr_layer( TT_Face face,
FT_UInt base_glyph,
+ FT_UInt *aglyph_index,
FT_UInt *acolor_index,
FT_LayerIterator* iterator );