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): Update 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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207
diff --git a/ChangeLog b/ChangeLog
index 02e0611..0114f48 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,22 @@
2017-09-24 Ewald Hew <ewaldhew@gmail.com>
+ [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): Update 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.
+
+2017-09-24 Ewald Hew <ewaldhew@gmail.com>
+
[psaux, cff] Create new `PSAux' service interface entries.
NOTE: Does not compile!
diff --git a/include/freetype/internal/psaux.h b/include/freetype/internal/psaux.h
index e29d452..bcc84e3 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 a5fde87..18dbf65 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 c6c00d1..169e116 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 e1af544..baa318b 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 a890a50..1b021b7 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,