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.
This commit is contained in:
parent
f6ccb524af
commit
4e3b2473d8
11
ChangeLog
11
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>
|
2018-07-01 Werner Lemberg <wl@gnu.org>
|
||||||
|
|
||||||
* src/base/ftobjs.c (FT_Get_Color_Glyph_Layer): Guard SFNT function.
|
* src/base/ftobjs.c (FT_Get_Color_Glyph_Layer): Guard SFNT function.
|
||||||
|
|
|
@ -4255,6 +4255,9 @@ FT_BEGIN_HEADER
|
||||||
* same object again.
|
* same object again.
|
||||||
*
|
*
|
||||||
* @output:
|
* @output:
|
||||||
|
* aglyph_index ::
|
||||||
|
* The glyph index of the current layer.
|
||||||
|
*
|
||||||
* acolor_index ::
|
* acolor_index ::
|
||||||
* The color index into the font face's color palette of the current
|
* 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
|
* 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.
|
* The color palette can be retrieved with @FT_Palette_Select.
|
||||||
*
|
*
|
||||||
* @return:
|
* @return:
|
||||||
* The glyph index of the current layer. If there are no more layers
|
* Value~1 if everything is OK. If there are no more layers (or if
|
||||||
* (or if there are no layers at all), value~0 gets returned. In case
|
* there are no layers at all), value~0 gets returned. In case of an
|
||||||
* of an error, value~0 is returned also.
|
* error, value~0 is returned also.
|
||||||
*
|
*
|
||||||
* @note:
|
* @note:
|
||||||
* This function is necessary if you want to handle glyph layers by
|
* This function is necessary if you want to handle glyph layers by
|
||||||
|
@ -4282,6 +4285,7 @@ FT_BEGIN_HEADER
|
||||||
* FT_Color* palette;
|
* FT_Color* palette;
|
||||||
* FT_LayerIterator iterator;
|
* FT_LayerIterator iterator;
|
||||||
*
|
*
|
||||||
|
* FT_Bool have_layers;
|
||||||
* FT_UInt layer_glyph_index;
|
* FT_UInt layer_glyph_index;
|
||||||
* FT_UInt layer_color_index;
|
* FT_UInt layer_color_index;
|
||||||
*
|
*
|
||||||
|
@ -4290,33 +4294,41 @@ FT_BEGIN_HEADER
|
||||||
* if ( error )
|
* if ( error )
|
||||||
* palette = NULL;
|
* palette = NULL;
|
||||||
*
|
*
|
||||||
* iterator.p = NULL;
|
* iterator.p = NULL;
|
||||||
* layer_glyph_index = FT_Get_Color_Glyph_Layer( face,
|
* have_layers = FT_Get_Color_Glyph_Layer( face,
|
||||||
* glyph_index,
|
* glyph_index,
|
||||||
* &layer_color_index,
|
* &layer_glyph_index,
|
||||||
* &iterator );
|
* &layer_color_index,
|
||||||
|
* &iterator );
|
||||||
*
|
*
|
||||||
* if ( palette && layer_glyph_index )
|
* if ( palette && have_layers )
|
||||||
* {
|
* {
|
||||||
* do
|
* do
|
||||||
* {
|
* {
|
||||||
* FT_Color layer_color = palette[layer_color_index];
|
* FT_Color layer_color;
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
|
* if ( layer_color_index == 0xFFFF )
|
||||||
|
* layer_color = text_foreground_color;
|
||||||
|
* else
|
||||||
|
* layer_color = palette[layer_color_index];
|
||||||
|
*
|
||||||
* // Load and render glyph `layer_glyph_index', then
|
* // Load and render glyph `layer_glyph_index', then
|
||||||
* // blend resulting pixmap with previously created pixmaps.
|
* // blend resulting pixmap (using color `layer_color')
|
||||||
|
* // with previously created pixmaps.
|
||||||
*
|
*
|
||||||
* } while ( ( layer_glyph_index =
|
* } while ( FT_Get_Color_Glyph_Layer( face,
|
||||||
* FT_Get_Color_Glyph_Layer( face,
|
* glyph_index,
|
||||||
* glyph_index,
|
* &layer_glyph_index,
|
||||||
* &layer_color_index,
|
* &layer_color_index,
|
||||||
* &iterator ) ) != 0 );
|
* &iterator ) );
|
||||||
* }
|
* }
|
||||||
* }
|
* }
|
||||||
*/
|
*/
|
||||||
FT_EXPORT( FT_UInt )
|
FT_EXPORT( FT_Bool )
|
||||||
FT_Get_Color_Glyph_Layer( FT_Face face,
|
FT_Get_Color_Glyph_Layer( FT_Face face,
|
||||||
FT_UInt base_glyph,
|
FT_UInt base_glyph,
|
||||||
|
FT_UInt *aglyph_index,
|
||||||
FT_UInt *acolor_index,
|
FT_UInt *acolor_index,
|
||||||
FT_LayerIterator* iterator );
|
FT_LayerIterator* iterator );
|
||||||
|
|
||||||
|
|
|
@ -514,6 +514,9 @@ FT_BEGIN_HEADER
|
||||||
* same object again.
|
* same object again.
|
||||||
*
|
*
|
||||||
* @output:
|
* @output:
|
||||||
|
* aglyph_index ::
|
||||||
|
* The glyph index of the current layer.
|
||||||
|
*
|
||||||
* acolor_index ::
|
* acolor_index ::
|
||||||
* The color index into the font face's color palette of the current
|
* 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
|
* 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).
|
* instead (to be set up by the application outside of FreeType).
|
||||||
*
|
*
|
||||||
* @return:
|
* @return:
|
||||||
* The glyph index of the current layer. If there are no more layers
|
* Value~1 if everything is OK. If there are no more layers (or if
|
||||||
* (or if there are no layers at all), value~0 gets returned. In case
|
* there are no layers at all), value~0 gets returned. In case of an
|
||||||
* of an error, value~0 is returned also.
|
* error, value~0 is returned also.
|
||||||
*/
|
*/
|
||||||
typedef FT_UInt
|
typedef FT_Bool
|
||||||
(*TT_Get_Colr_Layer_Func)( TT_Face face,
|
(*TT_Get_Colr_Layer_Func)( TT_Face face,
|
||||||
FT_UInt base_glyph,
|
FT_UInt base_glyph,
|
||||||
|
FT_UInt *aglyph_index,
|
||||||
FT_UInt *acolor_index,
|
FT_UInt *acolor_index,
|
||||||
FT_LayerIterator* iterator );
|
FT_LayerIterator* iterator );
|
||||||
|
|
||||||
|
|
|
@ -4517,17 +4517,19 @@
|
||||||
|
|
||||||
FT_UInt base_glyph = slot->glyph_index;
|
FT_UInt base_glyph = slot->glyph_index;
|
||||||
|
|
||||||
|
FT_Bool have_layers;
|
||||||
FT_UInt glyph_index;
|
FT_UInt glyph_index;
|
||||||
FT_UInt color_index;
|
FT_UInt color_index;
|
||||||
|
|
||||||
|
|
||||||
/* check whether we have colored glyph layers */
|
/* check whether we have colored glyph layers */
|
||||||
iterator.p = NULL;
|
iterator.p = NULL;
|
||||||
glyph_index = FT_Get_Color_Glyph_Layer( face,
|
have_layers = FT_Get_Color_Glyph_Layer( face,
|
||||||
base_glyph,
|
base_glyph,
|
||||||
|
&glyph_index,
|
||||||
&color_index,
|
&color_index,
|
||||||
&iterator );
|
&iterator );
|
||||||
if ( glyph_index )
|
if ( have_layers )
|
||||||
{
|
{
|
||||||
error = FT_New_GlyphSlot( face, NULL );
|
error = FT_New_GlyphSlot( face, NULL );
|
||||||
if ( !error )
|
if ( !error )
|
||||||
|
@ -4546,7 +4548,7 @@
|
||||||
load_flags &= ~FT_LOAD_COLOR;
|
load_flags &= ~FT_LOAD_COLOR;
|
||||||
|
|
||||||
/* render into the new `face->glyph' glyph slot */
|
/* 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 );
|
error = FT_Load_Glyph( face, glyph_index, load_flags );
|
||||||
if ( error )
|
if ( error )
|
||||||
|
@ -4561,11 +4563,11 @@
|
||||||
if ( error )
|
if ( error )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
} while ( ( glyph_index =
|
} while ( FT_Get_Color_Glyph_Layer( face,
|
||||||
FT_Get_Color_Glyph_Layer( face,
|
base_glyph,
|
||||||
base_glyph,
|
&glyph_index,
|
||||||
&color_index,
|
&color_index,
|
||||||
&iterator ) ) != 0 );
|
&iterator ) );
|
||||||
|
|
||||||
if ( !error )
|
if ( !error )
|
||||||
slot->format = FT_GLYPH_FORMAT_BITMAP;
|
slot->format = FT_GLYPH_FORMAT_BITMAP;
|
||||||
|
@ -5471,9 +5473,10 @@
|
||||||
|
|
||||||
/* documentation is in freetype.h */
|
/* documentation is in freetype.h */
|
||||||
|
|
||||||
FT_EXPORT_DEF( FT_UInt )
|
FT_EXPORT_DEF( FT_Bool )
|
||||||
FT_Get_Color_Glyph_Layer( FT_Face face,
|
FT_Get_Color_Glyph_Layer( FT_Face face,
|
||||||
FT_UInt base_glyph,
|
FT_UInt base_glyph,
|
||||||
|
FT_UInt *aglyph_index,
|
||||||
FT_UInt *acolor_index,
|
FT_UInt *acolor_index,
|
||||||
FT_LayerIterator* iterator )
|
FT_LayerIterator* iterator )
|
||||||
{
|
{
|
||||||
|
@ -5482,6 +5485,7 @@
|
||||||
|
|
||||||
|
|
||||||
if ( !face ||
|
if ( !face ||
|
||||||
|
!aglyph_index ||
|
||||||
!acolor_index ||
|
!acolor_index ||
|
||||||
!iterator ||
|
!iterator ||
|
||||||
base_glyph >= (FT_UInt)face->num_glyphs )
|
base_glyph >= (FT_UInt)face->num_glyphs )
|
||||||
|
@ -5496,14 +5500,11 @@
|
||||||
if ( sfnt->get_colr_layer )
|
if ( sfnt->get_colr_layer )
|
||||||
return sfnt->get_colr_layer( ttface,
|
return sfnt->get_colr_layer( ttface,
|
||||||
base_glyph,
|
base_glyph,
|
||||||
|
aglyph_index,
|
||||||
acolor_index,
|
acolor_index,
|
||||||
iterator );
|
iterator );
|
||||||
else
|
else
|
||||||
{
|
|
||||||
*acolor_index = 0;
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -209,15 +209,15 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
FT_LOCAL_DEF( FT_UInt )
|
FT_LOCAL_DEF( FT_Bool )
|
||||||
tt_face_get_colr_layer( TT_Face face,
|
tt_face_get_colr_layer( TT_Face face,
|
||||||
FT_UInt base_glyph,
|
FT_UInt base_glyph,
|
||||||
|
FT_UInt *aglyph_index,
|
||||||
FT_UInt *acolor_index,
|
FT_UInt *acolor_index,
|
||||||
FT_LayerIterator* iterator )
|
FT_LayerIterator* iterator )
|
||||||
{
|
{
|
||||||
Colr* colr = (Colr*)face->colr;
|
Colr* colr = (Colr*)face->colr;
|
||||||
BaseGlyphRecord glyph_record;
|
BaseGlyphRecord glyph_record;
|
||||||
FT_UInt glyph_index;
|
|
||||||
|
|
||||||
|
|
||||||
if ( !colr )
|
if ( !colr )
|
||||||
|
@ -252,17 +252,17 @@
|
||||||
if ( iterator->layer >= iterator->num_layers )
|
if ( iterator->layer >= iterator->num_layers )
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
glyph_index = FT_NEXT_USHORT( iterator->p );
|
*aglyph_index = FT_NEXT_USHORT( iterator->p );
|
||||||
*acolor_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 != 0xFFFF &&
|
||||||
*acolor_index >= face->palette_data.num_palette_entries ) )
|
*acolor_index >= face->palette_data.num_palette_entries ) )
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
iterator->layer++;
|
iterator->layer++;
|
||||||
|
|
||||||
return glyph_index;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -36,9 +36,10 @@ FT_BEGIN_HEADER
|
||||||
FT_LOCAL( void )
|
FT_LOCAL( void )
|
||||||
tt_face_free_colr( TT_Face face );
|
tt_face_free_colr( TT_Face face );
|
||||||
|
|
||||||
FT_LOCAL( FT_UInt )
|
FT_LOCAL( FT_Bool )
|
||||||
tt_face_get_colr_layer( TT_Face face,
|
tt_face_get_colr_layer( TT_Face face,
|
||||||
FT_UInt base_glyph,
|
FT_UInt base_glyph,
|
||||||
|
FT_UInt *aglyph_index,
|
||||||
FT_UInt *acolor_index,
|
FT_UInt *acolor_index,
|
||||||
FT_LayerIterator* iterator );
|
FT_LayerIterator* iterator );
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue