[psaux] Objects for new interpreter (part 2)

Make the new objects copy over values. They are essentially wrapper types
for the different decoders/builders.

* include/freetype/internal/psaux.h: Update declarations.
Add is_t1 flag to PS_Builder.
* src/psaux/psdecode.h, src/psaux/psobjs.h: Update declarations.

* src/psaux/psdecode.c, src/psaux/psobjs.c: Implement copy with two modes.

* src/psaux/psauxmod.c: Add builder and decoder functions to PSAux service.
This commit is contained in:
Ewald Hew 2017-07-20 13:47:04 +08:00
parent d6983de532
commit 0d8c52714d
6 changed files with 165 additions and 70 deletions

View File

@ -457,14 +457,12 @@ FT_BEGIN_HEADER
typedef struct PS_Builder_FuncsRec_ typedef struct PS_Builder_FuncsRec_
{ {
void void
(*init)( PS_Builder builder, (*init)( void* builder,
FT_Face face, FT_Bool is_t1,
FT_Size size, PS_Builder* ps_builder );
FT_GlyphSlot slot,
FT_Bool hinting );
void void
(*done)( PS_Builder builder ); (*done)( PS_Builder* builder );
} PS_Builder_FuncsRec; } PS_Builder_FuncsRec;
@ -521,13 +519,13 @@ FT_BEGIN_HEADER
FT_Outline* base; FT_Outline* base;
FT_Outline* current; FT_Outline* current;
FT_Pos pos_x; FT_Pos* pos_x;
FT_Pos pos_y; FT_Pos* pos_y;
FT_Vector left_bearing; FT_Vector* left_bearing;
FT_Vector advance; FT_Vector* advance;
FT_BBox bbox; /* bounding box */ FT_BBox* bbox; /* bounding box */
FT_Bool path_begun; FT_Bool path_begun;
FT_Bool load_points; FT_Bool load_points;
FT_Bool no_recurse; FT_Bool no_recurse;
@ -537,6 +535,8 @@ FT_BEGIN_HEADER
void* hints_funcs; /* hinter-specific */ void* hints_funcs; /* hinter-specific */
void* hints_globals; /* hinter-specific */ void* hints_globals; /* hinter-specific */
FT_Bool is_t1;
PS_Builder_FuncsRec funcs; PS_Builder_FuncsRec funcs;
}; };
@ -570,15 +570,16 @@ FT_BEGIN_HEADER
typedef FT_Error typedef FT_Error
(*PS_Decoder_Get_Glyph_Callback)( TT_Face face, (*CFF_Decoder_Get_Glyph_Callback)( TT_Face face,
FT_UInt glyph_index, FT_UInt glyph_index,
FT_Byte** pointer, FT_Byte** pointer,
FT_ULong* length ); FT_ULong* length );
typedef void typedef void
(*PS_Decoder_Free_Glyph_Callback)( TT_Face face, (*CFF_Decoder_Free_Glyph_Callback)( TT_Face face,
FT_Byte** pointer, FT_Byte** pointer,
FT_ULong length ); FT_ULong length );
typedef struct PS_Decoder_ typedef struct PS_Decoder_
{ {
@ -620,8 +621,8 @@ FT_BEGIN_HEADER
FT_Bool seac; FT_Bool seac;
PS_Decoder_Get_Glyph_Callback get_glyph_callback; CFF_Decoder_Get_Glyph_Callback get_glyph_callback;
PS_Decoder_Free_Glyph_Callback free_glyph_callback; CFF_Decoder_Free_Glyph_Callback free_glyph_callback;
/* Type 1 stuff */ /* Type 1 stuff */
FT_Service_PsCMaps psnames; /* for seac */ FT_Service_PsCMaps psnames; /* for seac */
@ -638,6 +639,8 @@ FT_BEGIN_HEADER
FT_Long* buildchar; FT_Long* buildchar;
FT_UInt len_buildchar; FT_UInt len_buildchar;
void* t1_parse_callback;
} PS_Decoder; } PS_Decoder;
@ -1069,18 +1072,6 @@ FT_BEGIN_HEADER
} CFF_Decoder_Zone; } 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_ typedef struct CFF_Decoder_
{ {
CFF_Builder builder; CFF_Builder builder;
@ -1268,6 +1259,11 @@ FT_BEGIN_HEADER
FT_UInt32 FT_UInt32
(*cff_random)( FT_UInt32 r ); (*cff_random)( FT_UInt32 r );
void
(*ps_decoder_init)( void* decoder,
FT_Bool is_t1,
PS_Decoder* ps_decoder );
T1_CMap_Classes t1_cmap_classes; T1_CMap_Classes t1_cmap_classes;

View File

@ -23,6 +23,7 @@
#include "t1cmap.h" #include "t1cmap.h"
#include "psft.h" #include "psft.h"
#include "cffdecode.h" #include "cffdecode.h"
#include "psdecode.h"
#ifndef T1_CONFIG_OPTION_NO_AFM #ifndef T1_CONFIG_OPTION_NO_AFM
#include "afmparse.h" #include "afmparse.h"
@ -61,6 +62,14 @@
}; };
FT_CALLBACK_TABLE_DEF
const PS_Builder_FuncsRec ps_builder_funcs =
{
ps_builder_init, /* init */
ps_builder_done /* done */
};
FT_CALLBACK_TABLE_DEF FT_CALLBACK_TABLE_DEF
const T1_Builder_FuncsRec t1_builder_funcs = const T1_Builder_FuncsRec t1_builder_funcs =
{ {
@ -144,6 +153,7 @@
&t1_decoder_funcs, &t1_decoder_funcs,
t1_decrypt, t1_decrypt,
cff_random, cff_random,
ps_decoder_init,
(const T1_CMap_ClassesRec*) &t1_cmap_classes, (const T1_CMap_ClassesRec*) &t1_cmap_classes,

View File

@ -2,7 +2,6 @@
#include <ft2build.h> #include <ft2build.h>
#include FT_INTERNAL_SERVICE_H #include FT_INTERNAL_SERVICE_H
#include FT_SERVICE_CFF_TABLE_LOAD_H
#include "psdecode.h" #include "psdecode.h"
#include "psobjs.h" #include "psobjs.h"
@ -16,42 +15,76 @@
/* ps_decoder_init */ /* ps_decoder_init */
/* */ /* */
/* <Description> */ /* <Description> */
/* Initializes a given glyph decoder. */ /* Creates a decoder for the combined Type 1 / CFF interpreter. */
/* */ /* */
/* <InOut> */ /* <InOut> */
/* decoder :: A pointer to the glyph builder to initialize. */ /* decoder :: A pointer to the glyph builder to initialize. */
/* */ /* */
/* <Input> */ /* <Input> */
/* face :: The current face object. */
/* */ /* */
/* size :: The current size object. */
/* */ /* */
/* slot :: The current glyph object. */
/* */ /* */
/* hinting :: Whether hinting is active. */
/* */ /* */
/* hint_mode :: The hinting mode. */
/* */ /* */
FT_LOCAL_DEF( void ) FT_LOCAL_DEF( void )
ps_decoder_init( PS_Decoder* decoder, ps_decoder_init( void* decoder,
TT_Face face, FT_Bool is_t1,
FT_Size size, PS_Decoder* ps_decoder )
CFF_GlyphSlot slot,
FT_Byte** glyph_names,
PS_Blend blend,
FT_Bool hinting,
FT_Render_Mode hint_mode,
PS_Decoder_Get_Glyph_Callback get_callback,
PS_Decoder_Free_Glyph_Callback free_callback )
{ {
FT_ZERO( ps_decoder );
if ( is_t1 )
{
T1_Decoder t1_decoder = (T1_Decoder)decoder;
ps_builder_init( &t1_decoder->builder,
is_t1,
&ps_decoder->builder );
ps_decoder->psnames = t1_decoder->psnames;
ps_decoder->num_glyphs = t1_decoder->num_glyphs;
ps_decoder->glyph_names = t1_decoder->glyph_names;
ps_decoder->hint_mode = t1_decoder->hint_mode;
ps_decoder->blend = t1_decoder->blend;
/* ps_decoder->t1_parse_callback = t1_decoder->parse_callback; */
ps_decoder->num_locals = t1_decoder->num_subrs;
ps_decoder->locals = t1_decoder->subrs;
ps_decoder->locals_len = t1_decoder->subrs_len;
ps_decoder->locals_hash = t1_decoder->subrs_hash;
ps_decoder->buildchar = t1_decoder->buildchar;
ps_decoder->len_buildchar = t1_decoder->len_buildchar;
ps_decoder->lenIV = t1_decoder->lenIV;
}
else
{
CFF_Decoder* cff_decoder = (CFF_Decoder*)decoder;
ps_builder_init( &cff_decoder->builder,
is_t1,
&ps_decoder->builder );
ps_decoder->cff = cff_decoder->cff;
ps_decoder->current_subfont = cff_decoder->current_subfont;
ps_decoder->num_globals = cff_decoder->num_globals;
ps_decoder->globals = cff_decoder->globals;
ps_decoder->globals_bias = cff_decoder->globals_bias;
ps_decoder->num_locals = cff_decoder->num_locals;
ps_decoder->locals = cff_decoder->locals;
ps_decoder->locals_bias = cff_decoder->locals_bias;
ps_decoder->glyph_width = cff_decoder->glyph_width;
ps_decoder->nominal_width = cff_decoder->nominal_width;
ps_decoder->width_only = cff_decoder->width_only;
ps_decoder->hint_mode = cff_decoder->hint_mode;
ps_decoder->get_glyph_callback = cff_decoder->get_glyph_callback;
ps_decoder->free_glyph_callback = cff_decoder->free_glyph_callback;
}
} }
/* this function is used to select the subfont */
/* and the locals subrs array */
FT_LOCAL_DEF( FT_Error )
ps_decoder_prepare( PS_Decoder* decoder,
FT_Size size,
FT_UInt glyph_index )
{
}

View File

@ -5,9 +5,16 @@
#include <ft2build.h> #include <ft2build.h>
#include FT_INTERNAL_POSTSCRIPT_AUX_H #include FT_INTERNAL_POSTSCRIPT_AUX_H
#include "cffdecode.h"
#include "t1decode.h" FT_BEGIN_HEADER
FT_LOCAL( void )
ps_decoder_init( void* decoder,
FT_Bool is_t1,
PS_Decoder* ps_decoder );
FT_END_HEADER
#endif #endif

View File

@ -2052,12 +2052,63 @@
/* hinting :: Whether hinting should be applied. */ /* hinting :: Whether hinting should be applied. */
/* */ /* */
FT_LOCAL_DEF( void ) FT_LOCAL_DEF( void )
ps_builder_init( PS_Builder* builder, ps_builder_init( void* builder,
TT_Face face, FT_Bool is_t1,
FT_Size size, PS_Builder* ps_builder )
CFF_GlyphSlot glyph,
FT_Bool hinting )
{ {
FT_ZERO( ps_builder );
if ( is_t1 )
{
T1_Builder t1builder = (T1_Builder)builder;
ps_builder->face = (TT_Face)t1builder->face;
ps_builder->glyph = t1builder->glyph;
ps_builder->memory = t1builder->memory;
ps_builder->loader = t1builder->loader;
ps_builder->base = t1builder->base;
ps_builder->current = t1builder->current;
ps_builder->pos_x = &t1builder->pos_x;
ps_builder->pos_y = &t1builder->pos_y;
ps_builder->left_bearing = &t1builder->left_bearing;
ps_builder->advance = &t1builder->advance;
ps_builder->bbox = &t1builder->bbox;
ps_builder->path_begun = 0;
ps_builder->load_points = t1builder->load_points;
ps_builder->no_recurse = t1builder->no_recurse;
ps_builder->metrics_only = t1builder->metrics_only;
}
else
{
CFF_Builder* cffbuilder = (CFF_Builder*)builder;
ps_builder->face = cffbuilder->face;
ps_builder->memory = cffbuilder->memory;
ps_builder->glyph = cffbuilder->glyph;
ps_builder->loader = cffbuilder->loader;
ps_builder->base = cffbuilder->base;
ps_builder->current = cffbuilder->current;
ps_builder->pos_x = &cffbuilder->pos_x;
ps_builder->pos_y = &cffbuilder->pos_y;
ps_builder->left_bearing = &cffbuilder->left_bearing;
ps_builder->advance = &cffbuilder->advance;
ps_builder->bbox = &cffbuilder->bbox;
ps_builder->path_begun = cffbuilder->path_begun;
ps_builder->load_points = cffbuilder->load_points;
ps_builder->no_recurse = cffbuilder->no_recurse;
ps_builder->metrics_only = cffbuilder->metrics_only;
}
ps_builder->is_t1 = is_t1;
ps_builder->funcs = ps_builder_funcs;
} }

View File

@ -242,11 +242,9 @@ FT_BEGIN_HEADER
/*************************************************************************/ /*************************************************************************/
FT_LOCAL( void ) FT_LOCAL( void )
ps_builder_init( PS_Builder* builder, ps_builder_init( void* builder,
TT_Face face, FT_Bool is_t1,
FT_Size size, PS_Builder* ps_builder );
CFF_GlyphSlot glyph,
FT_Bool hinting );
FT_LOCAL( void ) FT_LOCAL( void )
ps_builder_done( PS_Builder* builder ); ps_builder_done( PS_Builder* builder );