summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEwald Hew <ewaldhew@gmail.com>2017-05-20 17:58:28 +0800
committerEwald Hew <ewaldhew@gmail.com>2017-06-05 14:39:32 +0800
commit16fc42e1c39d7e9bea3962f3b6b2cd1b00d70802 (patch)
treeb96d1c74ab0d8074b961a92a637c3b47561eb00a
parentb6baf12391beaf7c4eab7000d1c0e1e4d222dfb8 (diff)
downloadfreetype2-16fc42e1c39d7e9bea3962f3b6b2cd1b00d70802.tar.gz
Added func ptrs for cff get/free glyph_data (callback)
-rw-r--r--include/freetype/internal/psaux.h24
-rw-r--r--src/cff/cffgload.c9
-rw-r--r--src/cff/cffgload.h1
-rw-r--r--src/cff/cffparse.c15
-rw-r--r--src/psaux/cf2ft.c15
-rw-r--r--src/psaux/cffdecode.c19
-rw-r--r--src/psaux/psauxmod.c2
-rw-r--r--src/psaux/psobjs.c3
8 files changed, 58 insertions, 30 deletions
diff --git a/include/freetype/internal/psaux.h b/include/freetype/internal/psaux.h
index e0b7694a3..7118bf359 100644
--- a/include/freetype/internal/psaux.h
+++ b/include/freetype/internal/psaux.h
@@ -712,7 +712,8 @@ FT_BEGIN_HEADER
/*************************************************************************/
-#if 0
+#if 1
+ //TODO(ewaldhew): use these in cf2_interp
typedef FT_Error
(*CFF_Builder_Check_Points_Func)( CFF_Builder* builder,
FT_Int count );
@@ -833,7 +834,7 @@ FT_BEGIN_HEADER
void* hints_funcs; /* hinter-specific */
void* hints_globals; /* hinter-specific */
- //CFF_Builder_FuncsRec funcs;
+ CFF_Builder_FuncsRec funcs;
} CFF_Builder;
@@ -866,6 +867,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;
@@ -907,6 +920,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;
@@ -919,7 +935,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 0e3916c14..4047391c6 100644
--- a/src/cff/cffgload.c
+++ b/src/cff/cffgload.c
@@ -21,6 +21,7 @@
#include FT_INTERNAL_STREAM_H
#include FT_INTERNAL_SFNT_H
#include FT_INTERNAL_CALC_H
+#include FT_INTERNAL_POSTSCRIPT_AUX_H
#include FT_OUTLINE_H
#include FT_CFF_DRIVER_H
@@ -41,7 +42,7 @@
#define FT_COMPONENT trace_cffgload
-FT_LOCAL_DEF( FT_Error )
+ FT_LOCAL_DEF( FT_Error )
cff_get_glyph_data( TT_Face face,
FT_UInt glyph_index,
FT_Byte** pointer,
@@ -148,7 +149,7 @@ FT_LOCAL_DEF( FT_Error )
*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;
@@ -403,7 +404,9 @@ FT_LOCAL_DEF( FT_Error )
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/cff/cffgload.h b/src/cff/cffgload.h
index 61ab6a42d..b2e945d03 100644
--- a/src/cff/cffgload.h
+++ b/src/cff/cffgload.h
@@ -27,7 +27,6 @@
FT_BEGIN_HEADER
-//TODO(ewaldhew): these need to be func ptr too
FT_LOCAL( FT_Error )
cff_get_glyph_data( TT_Face face,
FT_UInt glyph_index,
diff --git a/src/cff/cffparse.c b/src/cff/cffparse.c
index 6d617e26e..acf824a20 100644
--- a/src/cff/cffparse.c
+++ b/src/cff/cffparse.c
@@ -21,10 +21,10 @@
#include FT_INTERNAL_STREAM_H
#include FT_INTERNAL_DEBUG_H
#include FT_INTERNAL_CALC_H
+#include FT_INTERNAL_POSTSCRIPT_AUX_H
#include "cfferrs.h"
#include "cffpic.h"
-#include "cffgload.h"
#include "cffload.h"
@@ -1304,6 +1304,7 @@
FT_Library library = parser->library;
FT_UNUSED( library );
+
parser->top = parser->stack;
parser->start = start;
@@ -1388,10 +1389,14 @@
cff_rec.top_font.font_dict.num_axes = parser->num_axes;
decoder.cff = &cff_rec;
- error = cff_decoder_parse_charstrings( &decoder,
- charstring_base,
- charstring_len,
- 1 );
+ /* TODO(ewaldhew): link this
+ PSAux_Service psaux = cff->psaux;
+ const CFF_Decoder_Funcs decoder_funcs = psaux->cff_decoder_funcs;
+ */
+ error = decoder_funcs->parse_charstrings( &decoder,
+ charstring_base,
+ charstring_len,
+ 1 );
/* Now copy the stack data in the temporary decoder object, */
/* converting it back to charstring number representations */
diff --git a/src/psaux/cf2ft.c b/src/psaux/cf2ft.c
index 7cc046480..7b7f72b66 100644
--- a/src/psaux/cf2ft.c
+++ b/src/psaux/cf2ft.c
@@ -649,10 +649,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;
@@ -674,10 +674,9 @@
{
FT_ASSERT( decoder );
- //TODO(ewaldhew): needs to use func ptr too
- 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 025f46233..c28279e6b 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;
@@ -2227,7 +2227,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;
@@ -2247,6 +2249,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/psauxmod.c b/src/psaux/psauxmod.c
index 17f78880b..a37ac746b 100644
--- a/src/psaux/psauxmod.c
+++ b/src/psaux/psauxmod.c
@@ -105,7 +105,7 @@
&t1_cmap_unicode_class_rec
};
-#if 0
+#if 1
FT_CALLBACK_TABLE_DEF
const CFF_Builder_FuncsRec cff_builder_funcs =
{
diff --git a/src/psaux/psobjs.c b/src/psaux/psobjs.c
index 5e3e3751b..37ea6fe52 100644
--- a/src/psaux/psobjs.c
+++ b/src/psaux/psobjs.c
@@ -1836,8 +1836,7 @@
builder->advance.x = 0;
builder->advance.y = 0;
- //TODO(ewaldhew): what is this even used for? (ref t1_builder_funcs)
- //builder->funcs = cff_builder_funcs;
+ builder->funcs = cff_builder_funcs;
}