[psaux, cff] Use the new objects.

* include/freetype/internal/psaux.h, src/psaux/psauxmod.c: Fix switching
between new and old engines.

* src/cff/cffgload.c, src/cff/cffparse.c: Update calls.

* src/psaux/psblues.c, src/psaux/psfont.c, src/psaux/psfont.h,
src/psaux/psft.c, src/psaux/psft.h, src/psaux/psintrp.c: Update all
to use new objects.
This commit is contained in:
Ewald Hew 2017-07-20 13:48:19 +08:00
parent 84636c58dc
commit f5b20fa4bf
10 changed files with 163 additions and 152 deletions

View File

@ -1137,18 +1137,22 @@ FT_BEGIN_HEADER
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
FT_Error
(*parse_charstrings_old)( CFF_Decoder* decoder,
FT_Byte* charstring_base,
FT_ULong charstring_len,
FT_Bool in_dict );
#endif
);
FT_Error
(*parse_charstrings)( PS_Decoder* decoder,
FT_Byte* charstring_base,
FT_ULong charstring_len );
} CFF_Decoder_FuncsRec;
/*************************************************************************/
/*************************************************************************/
/***** *****/

View File

@ -169,10 +169,10 @@
{
error = decoder_funcs->prepare( &decoder, size, glyph_index );
if ( !error )
error = decoder_funcs->parse_charstrings( &decoder,
charstring,
charstring_len,
0 );
error = decoder_funcs->parse_charstrings_old( &decoder,
charstring,
charstring_len,
0 );
cff_free_glyph_data( face, &charstring, &charstring_len );
}
@ -198,6 +198,7 @@
{
FT_Error error;
CFF_Decoder decoder;
PS_Decoder psdecoder;
TT_Face face = (TT_Face)glyph->root.face;
FT_Bool hinting, scaled, force_scaling;
CFF_Font cff = (CFF_Font)face->extra.data;
@ -427,14 +428,16 @@
#ifdef CFF_CONFIG_OPTION_OLD_ENGINE
/* choose which CFF renderer to use */
if ( driver->hinting_engine == FT_CFF_HINTING_FREETYPE )
error = decoder_funcs->parse_charstrings( &decoder,
charstring,
charstring_len,
0 );
error = decoder_funcs->parse_charstrings_old( &decoder,
charstring,
charstring_len,
0 );
else
#endif
{
error = decoder_funcs->parse_charstrings( &decoder,
psaux->ps_decoder_init( &decoder, FALSE, &psdecoder );
error = decoder_funcs->parse_charstrings( &psdecoder,
charstring,
charstring_len );
@ -449,7 +452,7 @@
force_scaling = TRUE;
glyph->hint = hinting;
error = decoder_funcs->parse_charstrings( &decoder,
error = decoder_funcs->parse_charstrings( &psdecoder,
charstring,
charstring_len );
}

View File

@ -1299,6 +1299,11 @@
FT_Byte* start,
FT_Byte* limit )
{
#ifdef CFF_CONFIG_OPTION_OLD_ENGINE
PSAux_Service psaux;
#endif
FT_Byte* p = start;
FT_Error error = FT_Err_Ok;
FT_Library library = parser->library;
@ -1397,11 +1402,11 @@
error = FT_THROW( Missing_Module );
goto Exit;
}
error = psaux->cff_decoder_funcs->parse_charstrings( &decoder,
charstring_base,
charstring_len,
1 );
error = psaux->cff_decoder_funcs->parse_charstrings_old( &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

@ -137,10 +137,9 @@
cff_decoder_prepare, /* prepare */
#ifdef CFF_CONFIG_OPTION_OLD_ENGINE
cff_decoder_parse_charstrings /* parse_charstrings */
#else
cf2_decoder_parse_charstrings
cff_decoder_parse_charstrings, /* parse_charstrings_old */
#endif
cf2_decoder_parse_charstrings /* parse_charstrings */
};

View File

@ -67,7 +67,7 @@
CF2_Font font )
{
/* pointer to parsed font object */
CFF_Decoder* decoder = font->decoder;
PS_Decoder* decoder = font->decoder;
CF2_Fixed zoneHeight;
CF2_Fixed maxZoneHeight = 0;

View File

@ -243,7 +243,7 @@
const CF2_Matrix* transform )
{
/* pointer to parsed font object */
CFF_Decoder* decoder = font->decoder;
PS_Decoder* decoder = font->decoder;
FT_Bool needExtraSetup = FALSE;

View File

@ -90,7 +90,7 @@ FT_BEGIN_HEADER
/* FreeType related members */
CF2_OutlineRec outline; /* freetype glyph outline functions */
CFF_Decoder* decoder;
PS_Decoder* decoder;
CFF_SubFont lastSubfont; /* FreeType parsed data; */
/* top font or subfont */

View File

@ -89,7 +89,7 @@
cf2_setGlyphWidth( CF2_Outline outline,
CF2_Fixed width )
{
CFF_Decoder* decoder = outline->decoder;
PS_Decoder* decoder = outline->decoder;
FT_ASSERT( decoder );
@ -128,8 +128,8 @@
const CF2_CallbackParams params )
{
/* downcast the object pointer */
CF2_Outline outline = (CF2_Outline)callbacks;
CFF_Builder* builder;
CF2_Outline outline = (CF2_Outline)callbacks;
PS_Builder* builder;
(void)params; /* only used in debug mode */
@ -140,7 +140,7 @@
builder = &outline->decoder->builder;
/* note: two successive moves simply close the contour twice */
cff_builder_close_contour( builder );
ps_builder_close_contour( builder );
builder->path_begun = 0;
}
@ -152,8 +152,8 @@
FT_Error error;
/* downcast the object pointer */
CF2_Outline outline = (CF2_Outline)callbacks;
CFF_Builder* builder;
CF2_Outline outline = (CF2_Outline)callbacks;
PS_Builder* builder;
FT_ASSERT( outline && outline->decoder );
@ -165,9 +165,9 @@
{
/* record the move before the line; also check points and set */
/* `path_begun' */
error = cff_builder_start_point( builder,
params->pt0.x,
params->pt0.y );
error = ps_builder_start_point( builder,
params->pt0.x,
params->pt0.y );
if ( error )
{
if ( !*callbacks->error )
@ -176,10 +176,10 @@
}
}
/* `cff_builder_add_point1' includes a check_points call for one point */
error = cff_builder_add_point1( builder,
params->pt1.x,
params->pt1.y );
/* `ps_builder_add_point1' includes a check_points call for one point */
error = ps_builder_add_point1( builder,
params->pt1.x,
params->pt1.y );
if ( error )
{
if ( !*callbacks->error )
@ -196,8 +196,8 @@
FT_Error error;
/* downcast the object pointer */
CF2_Outline outline = (CF2_Outline)callbacks;
CFF_Builder* builder;
CF2_Outline outline = (CF2_Outline)callbacks;
PS_Builder* builder;
FT_ASSERT( outline && outline->decoder );
@ -209,9 +209,9 @@
{
/* record the move before the line; also check points and set */
/* `path_begun' */
error = cff_builder_start_point( builder,
params->pt0.x,
params->pt0.y );
error = ps_builder_start_point( builder,
params->pt0.x,
params->pt0.y );
if ( error )
{
if ( !*callbacks->error )
@ -221,7 +221,7 @@
}
/* prepare room for 3 points: 2 off-curve, 1 on-curve */
error = cff_check_points( builder, 3 );
error = ps_builder_check_points( builder, 3 );
if ( error )
{
if ( !*callbacks->error )
@ -229,15 +229,15 @@
return;
}
cff_builder_add_point( builder,
params->pt1.x,
params->pt1.y, 0 );
cff_builder_add_point( builder,
params->pt2.x,
params->pt2.y, 0 );
cff_builder_add_point( builder,
params->pt3.x,
params->pt3.y, 1 );
ps_builder_add_point( builder,
params->pt1.x,
params->pt1.y, 0 );
ps_builder_add_point( builder,
params->pt2.x,
params->pt2.y, 0 );
ps_builder_add_point( builder,
params->pt3.x,
params->pt3.y, 1 );
}
@ -259,11 +259,11 @@
/* get scaling and hint flag from GlyphSlot */
static void
cf2_getScaleAndHintFlag( CFF_Decoder* decoder,
CF2_Fixed* x_scale,
CF2_Fixed* y_scale,
FT_Bool* hinted,
FT_Bool* scaled )
cf2_getScaleAndHintFlag( PS_Decoder* decoder,
CF2_Fixed* x_scale,
CF2_Fixed* y_scale,
FT_Bool* hinted,
FT_Bool* scaled )
{
FT_ASSERT( decoder && decoder->builder.glyph );
@ -290,7 +290,7 @@
/* get units per em from `FT_Face' */
/* TODO: should handle font matrix concatenation? */
static FT_UShort
cf2_getUnitsPerEm( CFF_Decoder* decoder )
cf2_getUnitsPerEm( PS_Decoder* decoder )
{
FT_ASSERT( decoder && decoder->builder.face );
FT_ASSERT( decoder->builder.face->root.units_per_EM );
@ -301,9 +301,9 @@
/* Main entry point: Render one glyph. */
FT_LOCAL_DEF( FT_Error )
cf2_decoder_parse_charstrings( CFF_Decoder* decoder,
FT_Byte* charstring_base,
FT_ULong charstring_len )
cf2_decoder_parse_charstrings( PS_Decoder* decoder,
FT_Byte* charstring_base,
FT_ULong charstring_len )
{
FT_Memory memory;
FT_Error error = FT_Err_Ok;
@ -344,8 +344,8 @@
{
/* build parameters for Adobe engine */
CFF_Builder* builder = &decoder->builder;
CFF_Driver driver = (CFF_Driver)FT_FACE_DRIVER( builder->face );
PS_Builder* builder = &decoder->builder;
CFF_Driver driver = (CFF_Driver)FT_FACE_DRIVER( builder->face );
FT_Bool no_stem_darkening_driver =
driver->no_stem_darkening;
@ -423,7 +423,7 @@
/* get pointer to current FreeType subfont (based on current glyphID) */
FT_LOCAL_DEF( CFF_SubFont )
cf2_getSubfont( CFF_Decoder* decoder )
cf2_getSubfont( PS_Decoder* decoder )
{
FT_ASSERT( decoder && decoder->current_subfont );
@ -433,7 +433,7 @@
/* get pointer to VStore structure */
FT_LOCAL_DEF( CFF_VStore )
cf2_getVStore( CFF_Decoder* decoder )
cf2_getVStore( PS_Decoder* decoder )
{
FT_ASSERT( decoder && decoder->cff );
@ -443,7 +443,7 @@
/* get maxstack value from CFF2 Top DICT */
FT_LOCAL_DEF( FT_UInt )
cf2_getMaxstack( CFF_Decoder* decoder )
cf2_getMaxstack( PS_Decoder* decoder )
{
FT_ASSERT( decoder && decoder->cff );
@ -457,7 +457,7 @@
/* */
/* Note: Uses FT_Fixed not CF2_Fixed for the vector. */
FT_LOCAL_DEF( FT_Error )
cf2_getNormalizedVector( CFF_Decoder* decoder,
cf2_getNormalizedVector( PS_Decoder* decoder,
CF2_UInt *len,
FT_Fixed* *vec )
{
@ -477,7 +477,7 @@
/* get `y_ppem' from `CFF_Size' */
FT_LOCAL_DEF( CF2_Fixed )
cf2_getPpemY( CFF_Decoder* decoder )
cf2_getPpemY( PS_Decoder* decoder )
{
FT_ASSERT( decoder &&
decoder->builder.face &&
@ -501,7 +501,7 @@
/* FreeType stores these as integer font units */
/* (note: variable names seem swapped) */
FT_LOCAL_DEF( CF2_Fixed )
cf2_getStdVW( CFF_Decoder* decoder )
cf2_getStdVW( PS_Decoder* decoder )
{
FT_ASSERT( decoder && decoder->current_subfont );
@ -511,7 +511,7 @@
FT_LOCAL_DEF( CF2_Fixed )
cf2_getStdHW( CFF_Decoder* decoder )
cf2_getStdHW( PS_Decoder* decoder )
{
FT_ASSERT( decoder && decoder->current_subfont );
@ -522,10 +522,10 @@
/* note: FreeType stores 1000 times the actual value for `BlueScale' */
FT_LOCAL_DEF( void )
cf2_getBlueMetrics( CFF_Decoder* decoder,
CF2_Fixed* blueScale,
CF2_Fixed* blueShift,
CF2_Fixed* blueFuzz )
cf2_getBlueMetrics( PS_Decoder* decoder,
CF2_Fixed* blueScale,
CF2_Fixed* blueShift,
CF2_Fixed* blueFuzz )
{
FT_ASSERT( decoder && decoder->current_subfont );
@ -542,9 +542,9 @@
/* get blue values counts and arrays; the FreeType parser has validated */
/* the counts and verified that each is an even number */
FT_LOCAL_DEF( void )
cf2_getBlueValues( CFF_Decoder* decoder,
size_t* count,
FT_Pos* *data )
cf2_getBlueValues( PS_Decoder* decoder,
size_t* count,
FT_Pos* *data )
{
FT_ASSERT( decoder && decoder->current_subfont );
@ -555,9 +555,9 @@
FT_LOCAL_DEF( void )
cf2_getOtherBlues( CFF_Decoder* decoder,
size_t* count,
FT_Pos* *data )
cf2_getOtherBlues( PS_Decoder* decoder,
size_t* count,
FT_Pos* *data )
{
FT_ASSERT( decoder && decoder->current_subfont );
@ -568,9 +568,9 @@
FT_LOCAL_DEF( void )
cf2_getFamilyBlues( CFF_Decoder* decoder,
size_t* count,
FT_Pos* *data )
cf2_getFamilyBlues( PS_Decoder* decoder,
size_t* count,
FT_Pos* *data )
{
FT_ASSERT( decoder && decoder->current_subfont );
@ -581,9 +581,9 @@
FT_LOCAL_DEF( void )
cf2_getFamilyOtherBlues( CFF_Decoder* decoder,
size_t* count,
FT_Pos* *data )
cf2_getFamilyOtherBlues( PS_Decoder* decoder,
size_t* count,
FT_Pos* *data )
{
FT_ASSERT( decoder && decoder->current_subfont );
@ -594,7 +594,7 @@
FT_LOCAL_DEF( CF2_Int )
cf2_getLanguageGroup( CFF_Decoder* decoder )
cf2_getLanguageGroup( PS_Decoder* decoder )
{
FT_ASSERT( decoder && decoder->current_subfont );
@ -605,9 +605,9 @@
/* convert unbiased subroutine index to `CF2_Buffer' and */
/* return 0 on success */
FT_LOCAL_DEF( CF2_Int )
cf2_initGlobalRegionBuffer( CFF_Decoder* decoder,
CF2_Int subrNum,
CF2_Buffer buf )
cf2_initGlobalRegionBuffer( PS_Decoder* decoder,
CF2_Int subrNum,
CF2_Buffer buf )
{
CF2_UInt idx;
@ -633,9 +633,9 @@
/* convert AdobeStandardEncoding code to CF2_Buffer; */
/* used for seac component */
FT_LOCAL_DEF( FT_Error )
cf2_getSeacComponent( CFF_Decoder* decoder,
CF2_Int code,
CF2_Buffer buf )
cf2_getSeacComponent( PS_Decoder* decoder,
CF2_Int code,
CF2_Buffer buf )
{
CF2_Int gid;
FT_Byte* charstring;
@ -680,8 +680,8 @@
FT_LOCAL_DEF( void )
cf2_freeSeacComponent( CFF_Decoder* decoder,
CF2_Buffer buf )
cf2_freeSeacComponent( PS_Decoder* decoder,
CF2_Buffer buf )
{
FT_ASSERT( decoder );
@ -692,9 +692,9 @@
FT_LOCAL_DEF( CF2_Int )
cf2_initLocalRegionBuffer( CFF_Decoder* decoder,
CF2_Int subrNum,
CF2_Buffer buf )
cf2_initLocalRegionBuffer( PS_Decoder* decoder,
CF2_Int subrNum,
CF2_Buffer buf )
{
CF2_UInt idx;
@ -718,7 +718,7 @@
FT_LOCAL_DEF( CF2_Fixed )
cf2_getDefaultWidthX( CFF_Decoder* decoder )
cf2_getDefaultWidthX( PS_Decoder* decoder )
{
FT_ASSERT( decoder && decoder->current_subfont );
@ -728,7 +728,7 @@
FT_LOCAL_DEF( CF2_Fixed )
cf2_getNominalWidthX( CFF_Decoder* decoder )
cf2_getNominalWidthX( PS_Decoder* decoder )
{
FT_ASSERT( decoder && decoder->current_subfont );
@ -740,7 +740,7 @@
FT_LOCAL_DEF( void )
cf2_outline_reset( CF2_Outline outline )
{
CFF_Decoder* decoder = outline->decoder;
PS_Decoder* decoder = outline->decoder;
FT_ASSERT( decoder );
@ -754,12 +754,12 @@
FT_LOCAL_DEF( void )
cf2_outline_close( CF2_Outline outline )
{
CFF_Decoder* decoder = outline->decoder;
PS_Decoder* decoder = outline->decoder;
FT_ASSERT( decoder );
cff_builder_close_contour( &decoder->builder );
ps_builder_close_contour( &decoder->builder );
FT_GlyphLoader_Add( decoder->builder.loader );
}

View File

@ -50,85 +50,85 @@
#include FT_SYSTEM_H
#include "psglue.h"
#include FT_INTERNAL_POSTSCRIPT_AUX_H /* for CFF_Decoder */
#include FT_INTERNAL_POSTSCRIPT_AUX_H /* for PS_Decoder */
FT_BEGIN_HEADER
FT_LOCAL( FT_Error )
cf2_decoder_parse_charstrings( CFF_Decoder* decoder,
FT_Byte* charstring_base,
FT_ULong charstring_len );
cf2_decoder_parse_charstrings( PS_Decoder* decoder,
FT_Byte* charstring_base,
FT_ULong charstring_len );
FT_LOCAL( CFF_SubFont )
cf2_getSubfont( CFF_Decoder* decoder );
cf2_getSubfont( PS_Decoder* decoder );
FT_LOCAL( CFF_VStore )
cf2_getVStore( CFF_Decoder* decoder );
cf2_getVStore( PS_Decoder* decoder );
FT_LOCAL( FT_UInt )
cf2_getMaxstack( CFF_Decoder* decoder );
cf2_getMaxstack( PS_Decoder* decoder );
#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
FT_LOCAL( FT_Error )
cf2_getNormalizedVector( CFF_Decoder* decoder,
CF2_UInt *len,
FT_Fixed* *vec );
cf2_getNormalizedVector( PS_Decoder* decoder,
CF2_UInt *len,
FT_Fixed* *vec );
#endif
FT_LOCAL( CF2_Fixed )
cf2_getPpemY( CFF_Decoder* decoder );
cf2_getPpemY( PS_Decoder* decoder );
FT_LOCAL( CF2_Fixed )
cf2_getStdVW( CFF_Decoder* decoder );
cf2_getStdVW( PS_Decoder* decoder );
FT_LOCAL( CF2_Fixed )
cf2_getStdHW( CFF_Decoder* decoder );
cf2_getStdHW( PS_Decoder* decoder );
FT_LOCAL( void )
cf2_getBlueMetrics( CFF_Decoder* decoder,
CF2_Fixed* blueScale,
CF2_Fixed* blueShift,
CF2_Fixed* blueFuzz );
cf2_getBlueMetrics( PS_Decoder* decoder,
CF2_Fixed* blueScale,
CF2_Fixed* blueShift,
CF2_Fixed* blueFuzz );
FT_LOCAL( void )
cf2_getBlueValues( CFF_Decoder* decoder,
size_t* count,
FT_Pos* *data );
cf2_getBlueValues( PS_Decoder* decoder,
size_t* count,
FT_Pos* *data );
FT_LOCAL( void )
cf2_getOtherBlues( CFF_Decoder* decoder,
size_t* count,
FT_Pos* *data );
cf2_getOtherBlues( PS_Decoder* decoder,
size_t* count,
FT_Pos* *data );
FT_LOCAL( void )
cf2_getFamilyBlues( CFF_Decoder* decoder,
size_t* count,
FT_Pos* *data );
cf2_getFamilyBlues( PS_Decoder* decoder,
size_t* count,
FT_Pos* *data );
FT_LOCAL( void )
cf2_getFamilyOtherBlues( CFF_Decoder* decoder,
size_t* count,
FT_Pos* *data );
cf2_getFamilyOtherBlues( PS_Decoder* decoder,
size_t* count,
FT_Pos* *data );
FT_LOCAL( CF2_Int )
cf2_getLanguageGroup( CFF_Decoder* decoder );
cf2_getLanguageGroup( PS_Decoder* decoder );
FT_LOCAL( CF2_Int )
cf2_initGlobalRegionBuffer( CFF_Decoder* decoder,
CF2_Int subrNum,
CF2_Buffer buf );
cf2_initGlobalRegionBuffer( PS_Decoder* decoder,
CF2_Int subrNum,
CF2_Buffer buf );
FT_LOCAL( FT_Error )
cf2_getSeacComponent( CFF_Decoder* decoder,
CF2_Int code,
CF2_Buffer buf );
cf2_getSeacComponent( PS_Decoder* decoder,
CF2_Int code,
CF2_Buffer buf );
FT_LOCAL( void )
cf2_freeSeacComponent( CFF_Decoder* decoder,
CF2_Buffer buf );
cf2_freeSeacComponent( PS_Decoder* decoder,
CF2_Buffer buf );
FT_LOCAL( CF2_Int )
cf2_initLocalRegionBuffer( CFF_Decoder* decoder,
CF2_Int subrNum,
CF2_Buffer buf );
cf2_initLocalRegionBuffer( PS_Decoder* decoder,
CF2_Int subrNum,
CF2_Buffer buf );
FT_LOCAL( CF2_Fixed )
cf2_getDefaultWidthX( CFF_Decoder* decoder );
cf2_getDefaultWidthX( PS_Decoder* decoder );
FT_LOCAL( CF2_Fixed )
cf2_getNominalWidthX( CFF_Decoder* decoder );
cf2_getNominalWidthX( PS_Decoder* decoder );
/*
@ -139,7 +139,7 @@ FT_BEGIN_HEADER
typedef struct CF2_OutlineRec_
{
CF2_OutlineCallbacksRec root; /* base class must be first */
CFF_Decoder* decoder;
PS_Decoder* decoder;
} CF2_OutlineRec, *CF2_Outline;

View File

@ -476,7 +476,7 @@
FT_Error lastError = FT_Err_Ok;
/* pointer to parsed font object */
CFF_Decoder* decoder = font->decoder;
PS_Decoder* decoder = font->decoder;
FT_Error* error = &font->error;
FT_Memory memory = font->memory;