summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEwald Hew <ewaldhew@gmail.com>2017-06-08 18:29:29 +0800
committerEwald Hew <ewaldhew@gmail.com>2017-08-21 14:17:42 +0800
commit2955c65535f055b0ee8552e9daa382404673eb16 (patch)
tree8e45ef172706ce7527d9651f8dc58225a19cb261
parente2ca0a446f619b2c6113c15f132984d34572c7f2 (diff)
downloadfreetype2-2955c65535f055b0ee8552e9daa382404673eb16.tar.gz
[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.
-rw-r--r--include/freetype/internal/psaux.h19
-rw-r--r--src/cff/cffgload.c6
-rw-r--r--src/psaux/cf2ft.c14
-rw-r--r--src/psaux/cffdecode.c19
-rw-r--r--src/psaux/cffdecode.h4
5 files changed, 44 insertions, 18 deletions
diff --git a/include/freetype/internal/psaux.h b/include/freetype/internal/psaux.h
index e29d45246..bcc84e38d 100644
--- a/include/freetype/internal/psaux.h
+++ b/include/freetype/internal/psaux.h
@@ -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,
diff --git a/src/cff/cffgload.c b/src/cff/cffgload.c
index a5fde87b5..18dbf6542 100644
--- a/src/cff/cffgload.c
+++ b/src/cff/cffgload.c
@@ -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 )
diff --git a/src/psaux/cf2ft.c b/src/psaux/cf2ft.c
index c6c00d162..169e1160b 100644
--- a/src/psaux/cf2ft.c
+++ b/src/psaux/cf2ft.c
@@ -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 ) );
}
diff --git a/src/psaux/cffdecode.c b/src/psaux/cffdecode.c
index e1af544f0..baa318bbe 100644
--- a/src/psaux/cffdecode.c
+++ b/src/psaux/cffdecode.c
@@ -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;
}
diff --git a/src/psaux/cffdecode.h b/src/psaux/cffdecode.h
index a890a505c..1b021b720 100644
--- a/src/psaux/cffdecode.h
+++ b/src/psaux/cffdecode.h
@@ -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,