[psaux, cff] Add callbacks for inter-module calls.

NOTE: Does not compile!

* include/freetype/internal/psaux.h: Add function pointer declarations.

* src/psaux/cffdecode.c (cff_decoder_init): Updated to take in callbacks.
* src/psaux/cffdecode.h: Ditto.

* src/cff/cffgload.c (cff_compute_max_advance, cff_slot_load): Update calls to pass in callbacks.
* src/psaux/cf2ft.c, src/psaux/cffdecode.c: Use them.
This commit is contained in:
Ewald Hew 2017-06-08 18:29:29 +08:00
parent f174295aeb
commit 0f1a34023f
5 changed files with 44 additions and 18 deletions

View File

@ -868,6 +868,18 @@ FT_BEGIN_HEADER
} CFF_Decoder_Zone;
typedef FT_Error
(*CFF_Decoder_Get_Glyph_Callback)( TT_Face face,
FT_UInt glyph_index,
FT_Byte** pointer,
FT_ULong* length );
typedef void
(*CFF_Decoder_Free_Glyph_Callback)( TT_Face face,
FT_Byte** pointer,
FT_ULong length );
typedef struct CFF_Decoder_
{
CFF_Builder builder;
@ -909,6 +921,9 @@ FT_BEGIN_HEADER
CFF_SubFont current_subfont; /* for current glyph_index */
CFF_Decoder_Get_Glyph_Callback get_glyph_callback;
CFF_Decoder_Free_Glyph_Callback free_glyph_callback;
} CFF_Decoder;
typedef const struct CFF_Decoder_FuncsRec_* CFF_Decoder_Funcs;
@ -921,7 +936,9 @@ FT_BEGIN_HEADER
CFF_Size size,
CFF_GlyphSlot slot,
FT_Bool hinting,
FT_Render_Mode hint_mode );
FT_Render_Mode hint_mode,
CFF_Decoder_Get_Glyph_Callback get_callback,
CFF_Decoder_Free_Glyph_Callback free_callback );
FT_Error
(*prepare)( CFF_Decoder* decoder,

View File

@ -149,7 +149,7 @@
*max_advance = 0;
/* Initialize load decoder */
decoder_funcs->init( &decoder, face, 0, 0, 0, 0 );
decoder_funcs->init( &decoder, face, 0, 0, 0, 0, 0, 0 );
decoder.builder.metrics_only = 1;
decoder.builder.load_points = 0;
@ -404,7 +404,9 @@
decoder_funcs->init( &decoder, face, size, glyph, hinting,
FT_LOAD_TARGET_MODE( load_flags ) );
FT_LOAD_TARGET_MODE( load_flags ),
cff_get_glyph_data,
cff_free_glyph_data );
/* this is for pure CFFs */
if ( load_flags & FT_LOAD_ADVANCE_ONLY )

View File

@ -647,10 +647,10 @@
return FT_THROW( Invalid_Glyph_Format );
}
error = cff_get_glyph_data( decoder->builder.face,
(CF2_UInt)gid,
&charstring,
&len );
error = decoder->get_glyph_callback( decoder->builder.face,
(CF2_UInt)gid,
&charstring,
&len );
/* TODO: for now, just pass the FreeType error through */
if ( error )
return error;
@ -672,9 +672,9 @@
{
FT_ASSERT( decoder );
cff_free_glyph_data( decoder->builder.face,
(FT_Byte**)&buf->start,
(FT_ULong)( buf->end - buf->start ) );
decoder->free_glyph_callback( decoder->builder.face,
(FT_Byte**)&buf->start,
(FT_ULong)( buf->end - buf->start ) );
}

View File

@ -272,8 +272,8 @@
FT_GlyphLoader_Prepare( builder->loader );
/* First load `bchar' in builder */
error = cff_get_glyph_data( face, (FT_UInt)bchar_index,
&charstring, &charstring_len );
error = decoder->get_glyph_callback( face, (FT_UInt)bchar_index,
&charstring, &charstring_len );
if ( !error )
{
/* the seac operator must not be nested */
@ -282,7 +282,7 @@
charstring_len, 0 );
decoder->seac = FALSE;
cff_free_glyph_data( face, &charstring, charstring_len );
decoder->free_glyph_callback( face, &charstring, charstring_len );
if ( error )
goto Exit;
@ -302,8 +302,8 @@
builder->pos_y = ady;
/* Now load `achar' on top of the base outline. */
error = cff_get_glyph_data( face, (FT_UInt)achar_index,
&charstring, &charstring_len );
error = decoder->get_glyph_callback( face, (FT_UInt)achar_index,
&charstring, &charstring_len );
if ( !error )
{
/* the seac operator must not be nested */
@ -312,7 +312,7 @@
charstring_len, 0 );
decoder->seac = FALSE;
cff_free_glyph_data( face, &charstring, charstring_len );
decoder->free_glyph_callback( face, &charstring, charstring_len );
if ( error )
goto Exit;
@ -2231,7 +2231,9 @@
CFF_Size size,
CFF_GlyphSlot slot,
FT_Bool hinting,
FT_Render_Mode hint_mode )
FT_Render_Mode hint_mode,
CFF_Decoder_Get_Glyph_Callback get_callback,
CFF_Decoder_Free_Glyph_Callback free_callback )
{
CFF_Font cff = (CFF_Font)face->extra.data;
@ -2251,6 +2253,9 @@
decoder->num_globals );
decoder->hint_mode = hint_mode;
decoder->get_glyph_callback = get_callback;
decoder->free_glyph_callback = free_callback;
}

View File

@ -14,7 +14,9 @@ FT_BEGIN_HEADER
CFF_Size size,
CFF_GlyphSlot slot,
FT_Bool hinting,
FT_Render_Mode hint_mode);
FT_Render_Mode hint_mode,
CFF_Decoder_Get_Glyph_Callback get_callback,
CFF_Decoder_Free_Glyph_Callback free_callback);
FT_LOCAL( FT_Error )
cff_decoder_prepare( CFF_Decoder* decoder,