Create new `PSAux' service interface entries.

NOTE: Does not compile!

* include/freetype/internal/psaux.h: Include
FT_INTERNAL_TRUETYPE_TYPES_H.
(CFF_Builder_FuncsRec, CFF_Decocer_FuncsRec): New function tables.
(CFF_Builder): Updated.
Fix for forward declaration.
(PSAux_ServiceRec): New field `cff_decoder_funcs'.

* src/psaux/psauxmod.c (cff_builder_funcs, cff_decoder_funcs): New
function tables.
(PSAux_Interface): Updated.

* include/freetype/internal/tttypes.h (TT_FaceRec): Add `psaux'
service interface.

* src/cff/cffgload.c, src/cff/cffobjs.c, src/cff/cffparse.c: Update
function calls to use psaux service.
This commit is contained in:
Ewald Hew 2017-09-24 21:56:54 +02:00 committed by Werner Lemberg
parent 816c9c1f83
commit 1487be586e
7 changed files with 210 additions and 29 deletions

View File

@ -1,3 +1,26 @@
2017-09-24 Ewald Hew <ewaldhew@gmail.com>
[psaux, cff] Create new `PSAux' service interface entries.
NOTE: Does not compile!
* include/freetype/internal/psaux.h: Include
FT_INTERNAL_TRUETYPE_TYPES_H.
(CFF_Builder_FuncsRec, CFF_Decocer_FuncsRec): New function tables.
(CFF_Builder): Updated.
Fix for forward declaration.
(PSAux_ServiceRec): New field `cff_decoder_funcs'.
* src/psaux/psauxmod.c (cff_builder_funcs, cff_decoder_funcs): New
function tables.
(PSAux_Interface): Updated.
* include/freetype/internal/tttypes.h (TT_FaceRec): Add `psaux'
service interface.
* src/cff/cffgload.c, src/cff/cffobjs.c, src/cff/cffparse.c: Update
function calls to use psaux service.
2017-09-24 Ewald Hew <ewaldhew@gmail.com>
[psaux, cff] Move CFF builder components into `psaux' module.

View File

@ -25,6 +25,7 @@
#include FT_INTERNAL_OBJECTS_H
#include FT_INTERNAL_TYPE1_TYPES_H
#include FT_INTERNAL_HASH_H
#include FT_INTERNAL_TRUETYPE_TYPES_H
#include FT_SERVICE_POSTSCRIPT_CMAPS_H
@ -703,6 +704,67 @@ FT_BEGIN_HEADER
} T1_DecoderRec;
/*************************************************************************/
/*************************************************************************/
/***** *****/
/***** CFF BUILDER *****/
/***** *****/
/*************************************************************************/
/*************************************************************************/
typedef struct CFF_Builder_ CFF_Builder;
typedef FT_Error
(*CFF_Builder_Check_Points_Func)( CFF_Builder* builder,
FT_Int count );
typedef void
(*CFF_Builder_Add_Point_Func)( CFF_Builder* builder,
FT_Pos x,
FT_Pos y,
FT_Byte flag );
typedef FT_Error
(*CFF_Builder_Add_Point1_Func)( CFF_Builder* builder,
FT_Pos x,
FT_Pos y );
typedef FT_Error
(*CFF_Builder_Start_Point_Func)( CFF_Builder* builder,
FT_Pos x,
FT_Pos y );
typedef void
(*CFF_Builder_Close_Contour_Func)( CFF_Builder* builder );
/* static */
typedef FT_Error
(*CFF_Builder_Add_Contour_Func)( CFF_Builder* builder );
typedef const struct CFF_Builder_FuncsRec_* CFF_Builder_Funcs;
typedef struct CFF_Builder_FuncsRec_
{
/* static */
void
(*init)( CFF_Builder* builder,
TT_Face face,
CFF_Size size,
CFF_GlyphSlot glyph,
FT_Bool hinting );
/* static */
void
(*done)( CFF_Builder* builder );
CFF_Builder_Check_Points_Func check_points;
CFF_Builder_Add_Point_Func add_point;
CFF_Builder_Add_Point1_Func add_point1;
CFF_Builder_Add_Contour_Func add_contour;
CFF_Builder_Start_Point_Func start_point;
CFF_Builder_Close_Contour_Func close_contour;
} CFF_Builder_FuncsRec;
/*************************************************************************/
/* */
/* <Structure> */
@ -748,7 +810,7 @@ FT_BEGIN_HEADER
/* */
/* hints_globals :: Auxiliary pointer for hinting. */
/* */
typedef struct CFF_Builder_
struct CFF_Builder_
{
FT_Memory memory;
TT_Face face;
@ -772,7 +834,10 @@ FT_BEGIN_HEADER
void* hints_funcs; /* hinter-specific */
void* hints_globals; /* hinter-specific */
} CFF_Builder;
CFF_Builder_FuncsRec funcs;
};
/*************************************************************************/
@ -846,6 +911,34 @@ FT_BEGIN_HEADER
} CFF_Decoder;
typedef const struct CFF_Decoder_FuncsRec_* CFF_Decoder_Funcs;
typedef struct CFF_Decoder_FuncsRec_
{
void
(*init)( CFF_Decoder* decoder,
TT_Face face,
CFF_Size size,
CFF_GlyphSlot slot,
FT_Bool hinting,
FT_Render_Mode hint_mode );
FT_Error
(*prepare)( CFF_Decoder* decoder,
CFF_Size size,
FT_UInt glyph_index );
FT_Error
(*parse_charstrings)( CFF_Decoder* decoder,
FT_Byte* charstring_base,
FT_ULong charstring_len
#ifdef CFF_CONFIG_OPTION_OLD_ENGINE
/*TODO(ewaldhew): seems hacky, is there a better way to do this?*/
,FT_Bool in_dict
#endif
);
} CFF_Decoder_FuncsRec;
/*************************************************************************/
/*************************************************************************/
@ -959,6 +1052,8 @@ FT_BEGIN_HEADER
/* fields after this comment line were added after version 2.1.10 */
const AFM_Parser_FuncsRec* afm_parser_funcs;
const CFF_Decoder_FuncsRec* cff_decoder_funcs;
} PSAux_ServiceRec, *PSAux_Service;
/* backward compatible type definition */

View File

@ -1445,6 +1445,9 @@ FT_BEGIN_HEADER
void* var;
#endif
/* a typeless pointer to the PostScript Aux service */
void* psaux;
/***********************************************************************/
/* */

View File

@ -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,8 +42,6 @@
#define FT_COMPONENT trace_cffgload
FT_LOCAL_DEF( FT_Error )
cff_get_glyph_data( TT_Face face,
FT_UInt glyph_index,
@ -144,11 +143,13 @@
FT_Int glyph_index;
CFF_Font cff = (CFF_Font)face->other;
PSAux_Service psaux = (PSAux_Service)face->psaux;
const CFF_Decoder_Funcs decoder_funcs = psaux->cff_decoder_funcs;
*max_advance = 0;
/* Initialize load decoder */
cff_decoder_init( &decoder, face, 0, 0, 0, 0 );
decoder_funcs->init( &decoder, face, 0, 0, 0, 0 );
decoder.builder.metrics_only = 1;
decoder.builder.load_points = 0;
@ -167,12 +168,12 @@
&charstring, &charstring_len );
if ( !error )
{
error = cff_decoder_prepare( &decoder, size, glyph_index );
error = decoder_funcs->prepare( &decoder, size, glyph_index );
if ( !error )
error = cff_decoder_parse_charstrings( &decoder,
charstring,
charstring_len,
0 );
error = decoder_funcs->parse_charstrings( &decoder,
charstring,
charstring_len,
0 );
cff_free_glyph_data( face, &charstring, &charstring_len );
}
@ -202,6 +203,9 @@
FT_Bool hinting, scaled, force_scaling;
CFF_Font cff = (CFF_Font)face->extra.data;
PSAux_Service psaux = (PSAux_Service)face->psaux;
const CFF_Decoder_Funcs decoder_funcs = psaux->cff_decoder_funcs;
FT_Matrix font_matrix;
FT_Vector font_offset;
@ -399,8 +403,8 @@
FT_ULong charstring_len;
cff_decoder_init( &decoder, face, size, glyph, hinting,
FT_LOAD_TARGET_MODE( load_flags ) );
decoder_funcs->init( &decoder, face, size, glyph, hinting,
FT_LOAD_TARGET_MODE( load_flags ) );
/* this is for pure CFFs */
if ( load_flags & FT_LOAD_ADVANCE_ONLY )
@ -415,23 +419,23 @@
if ( error )
goto Glyph_Build_Finished;
error = cff_decoder_prepare( &decoder, size, glyph_index );
error = decoder_funcs->prepare( &decoder, size, glyph_index );
if ( error )
goto Glyph_Build_Finished;
#ifdef CFF_CONFIG_OPTION_OLD_ENGINE
/* choose which CFF renderer to use */
if ( driver->hinting_engine == FT_CFF_HINTING_FREETYPE )
error = cff_decoder_parse_charstrings( &decoder,
charstring,
charstring_len,
0 );
error = decoder_funcs->parse_charstrings( &decoder,
charstring,
charstring_len,
0 );
else
#endif
{
error = cf2_decoder_parse_charstrings( &decoder,
charstring,
charstring_len );
error = decoder_funcs->parse_charstrings( &decoder,
charstring,
charstring_len );
/* Adobe's engine uses 16.16 numbers everywhere; */
/* as a consequence, glyphs larger than 2000ppem get rejected */
@ -444,9 +448,9 @@
force_scaling = TRUE;
glyph->hint = hinting;
error = cf2_decoder_parse_charstrings( &decoder,
charstring,
charstring_len );
error = decoder_funcs->parse_charstrings( &decoder,
charstring,
charstring_len );
}
}
@ -484,7 +488,7 @@
Glyph_Build_Finished:
/* save new glyph tables, if no error */
if ( !error )
cff_builder_done( &decoder.builder );
decoder.builder.funcs.done( &decoder.builder );
/* XXX: anything to do for broken glyph entry? */
}

View File

@ -39,6 +39,8 @@
#include "cfferrs.h"
#include FT_INTERNAL_POSTSCRIPT_AUX_H
/*************************************************************************/
/* */
@ -493,6 +495,7 @@
SFNT_Service sfnt;
FT_Service_PsCMaps psnames;
PSHinter_Service pshinter;
PSAux_Service psaux;
FT_Bool pure_cff = 1;
FT_Bool cff2 = 0;
FT_Bool sfnt_format = 0;
@ -513,6 +516,16 @@
pshinter = (PSHinter_Service)FT_Get_Module_Interface(
library, "pshinter" );
psaux = (PSAux_Service)FT_Get_Module_Interface(
library, "psaux" );
if ( !psaux )
{
FT_ERROR(( "cff_face_init: cannot access `psaux' module\n" ));
error = FT_THROW( Missing_Module );
goto Exit;
}
face->psaux = psaux;
FT_TRACE2(( "CFF driver\n" ));
/* create input stream from resource */

View File

@ -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"
@ -1305,6 +1305,7 @@
FT_UNUSED( library );
parser->top = parser->stack;
parser->start = start;
parser->limit = limit;
@ -1388,10 +1389,19 @@
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 );
psaux = (PSAux_Service)FT_Get_Module_Interface(
library, "psaux" );
if ( !psaux )
{
FT_ERROR(( "cff_parser_run: cannot access `psaux' module\n" ));
error = FT_THROW( Missing_Module );
goto Exit;
}
error = psaux->cff_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 */

View File

@ -21,6 +21,8 @@
#include "psobjs.h"
#include "t1decode.h"
#include "t1cmap.h"
#include "cf2ft.h"
#include "cffdecode.h"
#ifndef T1_CONFIG_OPTION_NO_AFM
#include "afmparse.h"
@ -104,6 +106,35 @@
};
FT_CALLBACK_TABLE_DEF
const CFF_Builder_FuncsRec cff_builder_funcs =
{
cff_builder_init, /* init */
cff_builder_done, /* done */
cff_check_points, /* check_points */
cff_builder_add_point, /* add_point */
cff_builder_add_point1, /* add_point1 */
cff_builder_add_contour, /* add_contour */
cff_builder_start_point, /* start_point */
cff_builder_close_contour /* close_contour */
};
FT_CALLBACK_TABLE_DEF
const CFF_Decoder_FuncsRec cff_decoder_funcs =
{
cff_decoder_init, /* init */
cff_decoder_prepare, /* prepare */
#ifdef CFF_CONFIG_OPTION_OLD_ENGINE
cff_decoder_parse_charstrings /* parse_charstrings */
#else
cf2_decoder_parse_charstrings
#endif
};
static
const PSAux_Interface psaux_interface =
{
@ -120,6 +151,8 @@
#else
0,
#endif
&cff_decoder_funcs,
};