updated "psaux" and "type1z".
The Type 1 driver now completely relies on "psaux". I now need to change the CID driver accordingly, then finally move the Type 2 parsing routines to "psaux" when appropriate..
This commit is contained in:
parent
5ef3c95377
commit
a39acf55f7
10
CHANGES
10
CHANGES
@ -1,5 +1,15 @@
|
||||
LATEST CHANGES
|
||||
|
||||
- updated "docs/docmaker.py", a draft API reference is available at
|
||||
http://www.freetype.org/ft2api.html
|
||||
|
||||
- changed "type1z" to use "psaux"
|
||||
|
||||
- created a new module named "psaux" to hold the Type 1 & Type 2 parsing
|
||||
routines. It should be used by "type1z", "cid" and "cff" in the future
|
||||
|
||||
- fixed an important bug in "FT_Glyph_Get_CBox"
|
||||
|
||||
- fixed some compiler warnings that happened since the TrueType
|
||||
bytecode decoder was deactivated by default..
|
||||
|
||||
|
@ -37,54 +37,7 @@
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Struct> */
|
||||
/* PS_Table */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A PS_Table is a simple object used to store an array of objects in */
|
||||
/* a single memory block. */
|
||||
/* */
|
||||
/* <Fields> */
|
||||
/* block :: The address in memory of the growheap's block. This */
|
||||
/* can change between two object adds, due to */
|
||||
/* reallocation. */
|
||||
/* */
|
||||
/* cursor :: The current top of the grow heap within its block. */
|
||||
/* */
|
||||
/* capacity :: The current size of the heap block. Increments by */
|
||||
/* 1kByte chunks. */
|
||||
/* */
|
||||
/* max_elems :: The maximum number of elements in table. */
|
||||
/* */
|
||||
/* num_elems :: The current number of elements in table. */
|
||||
/* */
|
||||
/* elements :: A table of element addresses within the block. */
|
||||
/* */
|
||||
/* lengths :: A table of element sizes within the block. */
|
||||
/* */
|
||||
/* memory :: The object used for memory operations */
|
||||
/* (alloc/realloc). */
|
||||
/* */
|
||||
typedef struct PS_Table_
|
||||
{
|
||||
FT_Byte* block; /* current memory block */
|
||||
FT_Int cursor; /* current cursor in memory block */
|
||||
FT_Int capacity; /* current size of memory block */
|
||||
FT_Long init;
|
||||
|
||||
FT_Int max_elems;
|
||||
FT_Int num_elems;
|
||||
FT_Byte** elements; /* addresses of table elements */
|
||||
FT_Int* lengths; /* lengths of table elements */
|
||||
|
||||
FT_Memory memory;
|
||||
|
||||
} PS_Table;
|
||||
|
||||
|
||||
typedef struct PS_Table_ PS_Table;
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
@ -118,6 +71,58 @@
|
||||
} PS_Table_Funcs;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Struct> */
|
||||
/* PS_Table */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A PS_Table is a simple object used to store an array of objects in */
|
||||
/* a single memory block. */
|
||||
/* */
|
||||
/* <Fields> */
|
||||
/* block :: The address in memory of the growheap's block. This */
|
||||
/* can change between two object adds, due to */
|
||||
/* reallocation. */
|
||||
/* */
|
||||
/* cursor :: The current top of the grow heap within its block. */
|
||||
/* */
|
||||
/* capacity :: The current size of the heap block. Increments by */
|
||||
/* 1kByte chunks. */
|
||||
/* */
|
||||
/* max_elems :: The maximum number of elements in table. */
|
||||
/* */
|
||||
/* num_elems :: The current number of elements in table. */
|
||||
/* */
|
||||
/* elements :: A table of element addresses within the block. */
|
||||
/* */
|
||||
/* lengths :: A table of element sizes within the block. */
|
||||
/* */
|
||||
/* memory :: The object used for memory operations */
|
||||
/* (alloc/realloc). */
|
||||
/* */
|
||||
/* funcs :: table of method pointers for this object */
|
||||
/* */
|
||||
struct PS_Table_
|
||||
{
|
||||
FT_Byte* block; /* current memory block */
|
||||
FT_Int cursor; /* current cursor in memory block */
|
||||
FT_Int capacity; /* current size of memory block */
|
||||
FT_Long init;
|
||||
|
||||
FT_Int max_elems;
|
||||
FT_Int num_elems;
|
||||
FT_Byte** elements; /* addresses of table elements */
|
||||
FT_Int* lengths; /* lengths of table elements */
|
||||
|
||||
FT_Memory memory;
|
||||
PS_Table_Funcs funcs;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
/***** *****/
|
||||
@ -276,16 +281,10 @@
|
||||
/* */
|
||||
/* error :: The last error returned. */
|
||||
/* */
|
||||
typedef struct T1_Parser_
|
||||
{
|
||||
FT_Byte* cursor;
|
||||
FT_Byte* base;
|
||||
FT_Byte* limit;
|
||||
FT_Error error;
|
||||
FT_Memory memory;
|
||||
|
||||
} T1_Parser;
|
||||
|
||||
/* funcs :: table of functions for the parser */
|
||||
/* */
|
||||
/* */
|
||||
typedef struct T1_Parser_ T1_Parser;
|
||||
|
||||
typedef struct T1_Parser_Funcs_
|
||||
{
|
||||
@ -293,9 +292,9 @@
|
||||
FT_Byte* base,
|
||||
FT_Byte* limit,
|
||||
FT_Memory memory );
|
||||
|
||||
void (*done) ( T1_Parser* parser );
|
||||
|
||||
void (*done) ( T1_Parser* parser );
|
||||
|
||||
void (*skip_spaces) ( T1_Parser* parser );
|
||||
void (*skip_alpha) ( T1_Parser* parser );
|
||||
|
||||
@ -331,6 +330,19 @@
|
||||
|
||||
} T1_Parser_Funcs;
|
||||
|
||||
|
||||
struct T1_Parser_
|
||||
{
|
||||
FT_Byte* cursor;
|
||||
FT_Byte* base;
|
||||
FT_Byte* limit;
|
||||
FT_Error error;
|
||||
FT_Memory memory;
|
||||
|
||||
T1_Parser_Funcs funcs;
|
||||
};
|
||||
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
@ -340,6 +352,48 @@
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
|
||||
typedef struct T1_Builder_ T1_Builder;
|
||||
|
||||
typedef FT_Error (*T1_Builder_Check_Points_Func) ( T1_Builder* builder,
|
||||
FT_Int count );
|
||||
|
||||
typedef void (*T1_Builder_Add_Point_Func) ( T1_Builder* builder,
|
||||
FT_Pos x,
|
||||
FT_Pos y,
|
||||
FT_Byte flag );
|
||||
|
||||
typedef FT_Error (*T1_Builder_Add_Point1_Func) ( T1_Builder* builder,
|
||||
FT_Pos x,
|
||||
FT_Pos y );
|
||||
|
||||
typedef FT_Error (*T1_Builder_Add_Contour_Func) ( T1_Builder* builder );
|
||||
|
||||
typedef FT_Error (*T1_Builder_Start_Point_Func) ( T1_Builder* builder,
|
||||
FT_Pos x,
|
||||
FT_Pos y );
|
||||
|
||||
typedef void (*T1_Builder_Close_Contour_Func)( T1_Builder* builder );
|
||||
|
||||
|
||||
typedef struct T1_Builder_Funcs_
|
||||
{
|
||||
void (*init)( T1_Builder* builder,
|
||||
FT_Face face,
|
||||
FT_Size size,
|
||||
FT_GlyphSlot slot );
|
||||
|
||||
void (*done)( T1_Builder* builder );
|
||||
|
||||
T1_Builder_Check_Points_Func check_points;
|
||||
T1_Builder_Add_Point_Func add_point;
|
||||
T1_Builder_Add_Point1_Func add_point1;
|
||||
T1_Builder_Add_Contour_Func add_contour;
|
||||
T1_Builder_Start_Point_Func start_point;
|
||||
T1_Builder_Close_Contour_Func close_contour;
|
||||
|
||||
} T1_Builder_Funcs;
|
||||
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
@ -395,7 +449,9 @@
|
||||
/* the metrics of a given glyph, not load all of its */
|
||||
/* points. */
|
||||
/* */
|
||||
typedef struct T1_Builder_
|
||||
/* funcs :: array of function pointers for the builder */
|
||||
/* */
|
||||
struct T1_Builder_
|
||||
{
|
||||
FT_Memory memory;
|
||||
FT_Face face;
|
||||
@ -424,47 +480,8 @@
|
||||
FT_Error error; /* only used for memory errors */
|
||||
FT_Bool metrics_only;
|
||||
|
||||
} T1_Builder;
|
||||
|
||||
|
||||
typedef FT_Error (*T1_Builder_Check_Points_Func) ( T1_Builder* builder,
|
||||
FT_Int count );
|
||||
|
||||
typedef void (*T1_Builder_Add_Point_Func) ( T1_Builder* builder,
|
||||
FT_Pos x,
|
||||
FT_Pos y,
|
||||
FT_Byte flag );
|
||||
|
||||
typedef FT_Error (*T1_Builder_Add_Point1_Func) ( T1_Builder* builder,
|
||||
FT_Pos x,
|
||||
FT_Pos y );
|
||||
|
||||
typedef FT_Error (*T1_Builder_Add_Contour_Func) ( T1_Builder* builder );
|
||||
|
||||
typedef FT_Error (*T1_Builder_Start_Point_Func) ( T1_Builder* builder,
|
||||
FT_Pos x,
|
||||
FT_Pos y );
|
||||
|
||||
typedef void (*T1_Builder_Close_Contour_Func)( T1_Builder* builder );
|
||||
|
||||
|
||||
typedef struct T1_Builder_Funcs_
|
||||
{
|
||||
void (*init)( T1_Builder* builder,
|
||||
FT_Face face,
|
||||
FT_Size size,
|
||||
FT_GlyphSlot slot );
|
||||
|
||||
void (*done)( T1_Builder* builder );
|
||||
|
||||
T1_Builder_Check_Points_Func check_points;
|
||||
T1_Builder_Add_Point_Func add_point;
|
||||
T1_Builder_Add_Point1_Func add_point1;
|
||||
T1_Builder_Add_Contour_Func add_contour;
|
||||
T1_Builder_Start_Point_Func start_point;
|
||||
T1_Builder_Close_Contour_Func close_contour;
|
||||
|
||||
} T1_Builder_Funcs;
|
||||
T1_Builder_Funcs funcs;
|
||||
};
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
@ -509,8 +526,27 @@
|
||||
typedef struct T1_Decoder_ T1_Decoder;
|
||||
typedef struct T1_Decoder_Funcs_ T1_Decoder_Funcs;
|
||||
|
||||
typedef FT_Error (*T1_Decoder_Parse_Func)( T1_Decoder* decoder,
|
||||
FT_UInt glyph_index );
|
||||
typedef FT_Error (*T1_Decoder_Callback)( T1_Decoder* decoder,
|
||||
FT_UInt glyph_index );
|
||||
|
||||
struct T1_Decoder_Funcs_
|
||||
{
|
||||
FT_Error (*init) ( T1_Decoder* decoder,
|
||||
FT_Face face,
|
||||
FT_Size size,
|
||||
FT_GlyphSlot slot,
|
||||
FT_Byte** glyph_names,
|
||||
T1_Blend* blend,
|
||||
T1_Decoder_Callback callback );
|
||||
|
||||
void (*done) ( T1_Decoder* decoder );
|
||||
|
||||
FT_Error (*parse_charstrings)( T1_Decoder* decoder,
|
||||
FT_Byte* base,
|
||||
FT_UInt len );
|
||||
};
|
||||
|
||||
|
||||
|
||||
struct T1_Decoder_
|
||||
{
|
||||
@ -539,30 +575,11 @@
|
||||
|
||||
T1_Blend* blend; /* for multiple master support */
|
||||
|
||||
const T1_Decoder_Funcs* funcs;
|
||||
T1_Decoder_Parse_Func parse_glyph;
|
||||
T1_Decoder_Callback parse_callback;
|
||||
T1_Decoder_Funcs funcs;
|
||||
};
|
||||
|
||||
|
||||
struct T1_Decoder_Funcs_
|
||||
{
|
||||
FT_Error (*init) ( T1_Decoder* decoder,
|
||||
FT_Face face,
|
||||
FT_Size size,
|
||||
FT_GlyphSlot slot,
|
||||
FT_Byte** glyph_names,
|
||||
T1_Blend* blend,
|
||||
T1_Decoder_Parse_Func parse );
|
||||
|
||||
void (*done) ( T1_Decoder* decoder );
|
||||
|
||||
FT_Error (*parse_charstrings)( T1_Decoder* decoder,
|
||||
FT_Byte* base,
|
||||
FT_UInt len );
|
||||
|
||||
|
||||
};
|
||||
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
/***** *****/
|
||||
@ -573,7 +590,7 @@
|
||||
|
||||
typedef struct PSAux_Interface_
|
||||
{
|
||||
const PS_Table_Funcs* t1_table_funcs;
|
||||
const PS_Table_Funcs* ps_table_funcs;
|
||||
const T1_Parser_Funcs* t1_parser_funcs;
|
||||
const T1_Builder_Funcs* t1_builder_funcs;
|
||||
const T1_Decoder_Funcs* t1_decoder_funcs;
|
||||
|
@ -1000,6 +1000,7 @@
|
||||
|
||||
|
||||
/* discard a face's autohint globals */
|
||||
LOCAL_FUNC
|
||||
void ah_hinter_done_face_globals( AH_Face_Globals* globals )
|
||||
{
|
||||
FT_Face face = globals->face;
|
||||
|
@ -2,7 +2,7 @@
|
||||
#include <psaux/psobjs.h>
|
||||
#include <psaux/t1decode.h>
|
||||
|
||||
static
|
||||
LOCAL_FUNC
|
||||
const PS_Table_Funcs ps_table_funcs =
|
||||
{
|
||||
PS_Table_New,
|
||||
@ -12,7 +12,7 @@
|
||||
};
|
||||
|
||||
|
||||
static
|
||||
LOCAL_FUNC
|
||||
const T1_Parser_Funcs t1_parser_funcs =
|
||||
{
|
||||
T1_Init_Parser,
|
||||
@ -30,7 +30,7 @@
|
||||
};
|
||||
|
||||
|
||||
static
|
||||
LOCAL_FUNC
|
||||
const T1_Builder_Funcs t1_builder_funcs =
|
||||
{
|
||||
T1_Builder_Init,
|
||||
@ -44,7 +44,7 @@
|
||||
};
|
||||
|
||||
|
||||
static
|
||||
LOCAL_FUNC
|
||||
const T1_Decoder_Funcs t1_decoder_funcs =
|
||||
{
|
||||
T1_Decoder_Init,
|
||||
@ -53,7 +53,7 @@
|
||||
};
|
||||
|
||||
|
||||
static
|
||||
LOCAL_FUNC
|
||||
const PSAux_Interface psaux_interface =
|
||||
{
|
||||
&ps_table_funcs,
|
||||
|
@ -78,6 +78,7 @@
|
||||
table->block = 0;
|
||||
table->capacity = 0;
|
||||
table->cursor = 0;
|
||||
table->funcs = ps_table_funcs;
|
||||
|
||||
Exit:
|
||||
if ( error )
|
||||
@ -1009,6 +1010,7 @@
|
||||
parser->limit = limit;
|
||||
parser->cursor = base;
|
||||
parser->memory = memory;
|
||||
parser->funcs = t1_parser_funcs;
|
||||
}
|
||||
|
||||
|
||||
@ -1082,6 +1084,8 @@
|
||||
builder->left_bearing.y = 0;
|
||||
builder->advance.x = 0;
|
||||
builder->advance.y = 0;
|
||||
|
||||
builder->funcs = t1_builder_funcs;
|
||||
}
|
||||
|
||||
|
||||
|
@ -35,7 +35,15 @@
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
|
||||
LOCAL_DEF
|
||||
const PS_Table_Funcs ps_table_funcs;
|
||||
|
||||
LOCAL_DEF
|
||||
const T1_Parser_Funcs t1_parser_funcs;
|
||||
|
||||
LOCAL_DEF
|
||||
const T1_Builder_Funcs t1_builder_funcs;
|
||||
|
||||
LOCAL_DEF
|
||||
FT_Error PS_Table_New( PS_Table* table,
|
||||
FT_Int count,
|
||||
|
@ -977,18 +977,18 @@
|
||||
FT_Error T1_Decoder_Parse_Glyph( T1_Decoder* decoder,
|
||||
FT_UInt glyph )
|
||||
{
|
||||
return decoder->parse_glyph( decoder, glyph );
|
||||
return decoder->parse_callback( decoder, glyph );
|
||||
}
|
||||
|
||||
|
||||
LOCAL_FUNC
|
||||
FT_Error T1_Decoder_Init( T1_Decoder* decoder,
|
||||
FT_Face face,
|
||||
FT_Size size,
|
||||
FT_GlyphSlot slot,
|
||||
FT_Byte** glyph_names,
|
||||
T1_Blend* blend,
|
||||
T1_Decoder_Parse_Func parse_glyph )
|
||||
FT_Error T1_Decoder_Init( T1_Decoder* decoder,
|
||||
FT_Face face,
|
||||
FT_Size size,
|
||||
FT_GlyphSlot slot,
|
||||
FT_Byte** glyph_names,
|
||||
T1_Blend* blend,
|
||||
T1_Decoder_Callback parse_callback )
|
||||
{
|
||||
MEM_Set( decoder, 0, sizeof(*decoder) );
|
||||
|
||||
@ -1008,12 +1008,12 @@
|
||||
}
|
||||
T1_Builder_Init( &decoder->builder, face, size, slot );
|
||||
|
||||
decoder->num_glyphs = face->num_glyphs;
|
||||
decoder->glyph_names = glyph_names;
|
||||
decoder->blend = blend;
|
||||
decoder->parse_glyph = parse_glyph;
|
||||
decoder->num_glyphs = face->num_glyphs;
|
||||
decoder->glyph_names = glyph_names;
|
||||
decoder->blend = blend;
|
||||
decoder->parse_callback = parse_callback;
|
||||
|
||||
decoder->funcs = &t1_decoder_funcs;
|
||||
decoder->funcs = t1_decoder_funcs;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -18,13 +18,13 @@
|
||||
FT_UInt len );
|
||||
|
||||
LOCAL_DEF
|
||||
FT_Error T1_Decoder_Init( T1_Decoder* decoder,
|
||||
FT_Face face,
|
||||
FT_Size size,
|
||||
FT_GlyphSlot slot,
|
||||
FT_Byte** glyph_names,
|
||||
T1_Blend* blend,
|
||||
T1_Decoder_Parse_Func parse_glyph );
|
||||
FT_Error T1_Decoder_Init( T1_Decoder* decoder,
|
||||
FT_Face face,
|
||||
FT_Size size,
|
||||
FT_GlyphSlot slot,
|
||||
FT_Byte** glyph_names,
|
||||
T1_Blend* blend,
|
||||
T1_Decoder_Callback parse_glyph );
|
||||
|
||||
LOCAL_DEF
|
||||
void T1_Decoder_Done( T1_Decoder* decoder );
|
||||
|
@ -22,7 +22,11 @@
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
#include "ftraster.h"
|
||||
#ifdef FT_FLAT_COMPILE
|
||||
# include "ftraster.h"
|
||||
#else
|
||||
# include <raster1/ftraster.h>
|
||||
#endif
|
||||
#include <freetype/internal/ftcalc.h> /* for FT_MulDiv() only */
|
||||
|
||||
|
||||
|
@ -71,7 +71,7 @@
|
||||
T1_Face face = (T1_Face)decoder->builder.face;
|
||||
T1_Font* type1 = &face->type1;
|
||||
|
||||
return decoder->funcs->parse_charstrings( decoder,
|
||||
return decoder->funcs.parse_charstrings( decoder,
|
||||
type1->charstrings [glyph_index],
|
||||
type1->charstrings_len[glyph_index] );
|
||||
}
|
||||
|
@ -393,7 +393,7 @@
|
||||
void parse_blend_axis_types( T1_Face face,
|
||||
Z1_Loader* loader )
|
||||
{
|
||||
Z1_Token_Rec axis_tokens[ T1_MAX_MM_AXIS ];
|
||||
T1_Token axis_tokens[ T1_MAX_MM_AXIS ];
|
||||
FT_Int n, num_axis;
|
||||
FT_Error error = 0;
|
||||
T1_Blend* blend;
|
||||
@ -422,7 +422,7 @@
|
||||
/* each token is an immediate containing the name of the axis */
|
||||
for ( n = 0; n < num_axis; n++ )
|
||||
{
|
||||
Z1_Token_Rec* token = axis_tokens + n;
|
||||
T1_Token* token = axis_tokens + n;
|
||||
FT_Byte* name;
|
||||
FT_Int len;
|
||||
|
||||
@ -446,7 +446,7 @@
|
||||
}
|
||||
|
||||
Exit:
|
||||
loader->parser.error = error;
|
||||
loader->parser.root.error = error;
|
||||
}
|
||||
|
||||
|
||||
@ -454,7 +454,7 @@
|
||||
void parse_blend_design_positions( T1_Face face,
|
||||
Z1_Loader* loader )
|
||||
{
|
||||
Z1_Token_Rec design_tokens[ T1_MAX_MM_DESIGNS ];
|
||||
T1_Token design_tokens[ T1_MAX_MM_DESIGNS ];
|
||||
FT_Int num_designs;
|
||||
FT_Int num_axis;
|
||||
Z1_Parser* parser = &loader->parser;
|
||||
@ -475,8 +475,8 @@
|
||||
}
|
||||
|
||||
{
|
||||
FT_Byte* old_cursor = parser->cursor;
|
||||
FT_Byte* old_limit = parser->limit;
|
||||
FT_Byte* old_cursor = parser->root.cursor;
|
||||
FT_Byte* old_limit = parser->root.limit;
|
||||
FT_UInt n;
|
||||
|
||||
|
||||
@ -485,15 +485,15 @@
|
||||
|
||||
for ( n = 0; n < (FT_UInt)num_designs; n++ )
|
||||
{
|
||||
Z1_Token_Rec axis_tokens[ T1_MAX_MM_DESIGNS ];
|
||||
Z1_Token_Rec* token;
|
||||
FT_Int axis, n_axis;
|
||||
T1_Token axis_tokens[ T1_MAX_MM_DESIGNS ];
|
||||
T1_Token* token;
|
||||
FT_Int axis, n_axis;
|
||||
|
||||
|
||||
/* read axis/coordinates tokens */
|
||||
token = design_tokens + n;
|
||||
parser->cursor = token->start - 1;
|
||||
parser->limit = token->limit + 1;
|
||||
parser->root.cursor = token->start - 1;
|
||||
parser->root.limit = token->limit + 1;
|
||||
Z1_ToTokenArray( parser, axis_tokens, T1_MAX_MM_AXIS, &n_axis );
|
||||
|
||||
if ( n == 0 )
|
||||
@ -514,21 +514,21 @@
|
||||
/* now, read each axis token into the design position */
|
||||
for ( axis = 0; axis < n_axis; axis++ )
|
||||
{
|
||||
Z1_Token_Rec* token2 = axis_tokens + axis;
|
||||
T1_Token* token2 = axis_tokens + axis;
|
||||
|
||||
|
||||
parser->cursor = token2->start;
|
||||
parser->limit = token2->limit;
|
||||
parser->root.cursor = token2->start;
|
||||
parser->root.limit = token2->limit;
|
||||
blend->design_pos[n][axis] = Z1_ToFixed( parser, 0 );
|
||||
}
|
||||
}
|
||||
|
||||
loader->parser.cursor = old_cursor;
|
||||
loader->parser.limit = old_limit;
|
||||
loader->parser.root.cursor = old_cursor;
|
||||
loader->parser.root.limit = old_limit;
|
||||
}
|
||||
|
||||
Exit:
|
||||
loader->parser.error = error;
|
||||
loader->parser.root.error = error;
|
||||
}
|
||||
|
||||
|
||||
@ -539,7 +539,7 @@
|
||||
FT_Error error = 0;
|
||||
Z1_Parser* parser = &loader->parser;
|
||||
T1_Blend* blend;
|
||||
Z1_Token_Rec axis_tokens[ T1_MAX_MM_AXIS ];
|
||||
T1_Token axis_tokens[ T1_MAX_MM_AXIS ];
|
||||
FT_Int n, num_axis;
|
||||
FT_Byte* old_cursor;
|
||||
FT_Byte* old_limit;
|
||||
@ -554,8 +554,8 @@
|
||||
error = T1_Err_Invalid_File_Format;
|
||||
goto Exit;
|
||||
}
|
||||
old_cursor = parser->cursor;
|
||||
old_limit = parser->limit;
|
||||
old_cursor = parser->root.cursor;
|
||||
old_limit = parser->root.limit;
|
||||
|
||||
error = t1_allocate_blend( face, 0, num_axis );
|
||||
if ( error )
|
||||
@ -566,13 +566,13 @@
|
||||
for ( n = 0; n < num_axis; n++ )
|
||||
{
|
||||
T1_DesignMap* map = blend->design_map + n;
|
||||
Z1_Token_Rec* token;
|
||||
T1_Token* token;
|
||||
FT_Int p, num_points;
|
||||
|
||||
|
||||
token = axis_tokens + n;
|
||||
parser->cursor = token->start;
|
||||
parser->limit = token->limit;
|
||||
parser->root.cursor = token->start;
|
||||
parser->root.limit = token->limit;
|
||||
|
||||
/* count the number of map points */
|
||||
{
|
||||
@ -605,11 +605,11 @@
|
||||
}
|
||||
}
|
||||
|
||||
parser->cursor = old_cursor;
|
||||
parser->limit = old_limit;
|
||||
parser->root.cursor = old_cursor;
|
||||
parser->root.limit = old_limit;
|
||||
|
||||
Exit:
|
||||
parser->error = error;
|
||||
parser->root.error = error;
|
||||
}
|
||||
|
||||
|
||||
@ -620,7 +620,7 @@
|
||||
FT_Error error = 0;
|
||||
Z1_Parser* parser = &loader->parser;
|
||||
T1_Blend* blend = face->blend;
|
||||
Z1_Token_Rec master;
|
||||
T1_Token master;
|
||||
FT_UInt n;
|
||||
FT_Byte* old_cursor;
|
||||
FT_Byte* old_limit;
|
||||
@ -634,18 +634,18 @@
|
||||
}
|
||||
|
||||
Z1_ToToken( parser, &master );
|
||||
if ( master.type != z1_token_array )
|
||||
if ( master.type != t1_token_array )
|
||||
{
|
||||
FT_ERROR(( "parse_weight_vector: incorrect format!\n" ));
|
||||
error = T1_Err_Invalid_File_Format;
|
||||
goto Exit;
|
||||
}
|
||||
|
||||
old_cursor = parser->cursor;
|
||||
old_limit = parser->limit;
|
||||
old_cursor = parser->root.cursor;
|
||||
old_limit = parser->root.limit;
|
||||
|
||||
parser->cursor = master.start;
|
||||
parser->limit = master.limit;
|
||||
parser->root.cursor = master.start;
|
||||
parser->root.limit = master.limit;
|
||||
|
||||
for ( n = 0; n < blend->num_designs; n++ )
|
||||
{
|
||||
@ -653,11 +653,11 @@
|
||||
blend->weight_vector[n] = Z1_ToFixed( parser, 0 );
|
||||
}
|
||||
|
||||
parser->cursor = old_cursor;
|
||||
parser->limit = old_limit;
|
||||
parser->root.cursor = old_cursor;
|
||||
parser->root.limit = old_limit;
|
||||
|
||||
Exit:
|
||||
parser->error = error;
|
||||
parser->root.error = error;
|
||||
}
|
||||
|
||||
|
||||
@ -674,8 +674,8 @@
|
||||
FT_UNUSED( face );
|
||||
|
||||
|
||||
parser->cursor = parser->limit;
|
||||
parser->error = 0;
|
||||
parser->root.cursor = parser->root.limit;
|
||||
parser->root.error = 0;
|
||||
}
|
||||
|
||||
#endif /* Z1_CONFIG_OPTION_NO_MM_SUPPORT */
|
||||
@ -693,49 +693,49 @@
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* First of all, define the token field static variables. This is a set */
|
||||
/* of Z1_Field_Rec variables used later. */
|
||||
/* of T1_Field variables used later. */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
|
||||
#define Z1_NEW_STRING( _name, _field ) \
|
||||
static \
|
||||
const Z1_Field_Rec z1_field_ ## _field = \
|
||||
Z1_FIELD_STRING( _field );
|
||||
const T1_Field z1_field_ ## _field = \
|
||||
T1_FIELD_STRING( _field );
|
||||
|
||||
#define Z1_NEW_BOOL( _name, _field ) \
|
||||
static \
|
||||
const Z1_Field_Rec z1_field_ ## _field = \
|
||||
Z1_FIELD_BOOL( _field );
|
||||
const T1_Field z1_field_ ## _field = \
|
||||
T1_FIELD_BOOL( _field );
|
||||
|
||||
#define Z1_NEW_NUM( _name, _field ) \
|
||||
static \
|
||||
const Z1_Field_Rec z1_field_ ## _field = \
|
||||
Z1_FIELD_NUM( _field );
|
||||
const T1_Field z1_field_ ## _field = \
|
||||
T1_FIELD_NUM( _field );
|
||||
|
||||
#define Z1_NEW_FIXED( _name, _field ) \
|
||||
static \
|
||||
const Z1_Field_Rec z1_field_ ## _field = \
|
||||
Z1_FIELD_FIXED( _field, _power );
|
||||
const T1_Field z1_field_ ## _field = \
|
||||
T1_FIELD_FIXED( _field, _power );
|
||||
|
||||
#define Z1_NEW_NUM_TABLE( _name, _field, _max, _count ) \
|
||||
static \
|
||||
const Z1_Field_Rec z1_field_ ## _field = \
|
||||
Z1_FIELD_NUM_ARRAY( _field, _count, _max );
|
||||
const T1_Field z1_field_ ## _field = \
|
||||
T1_FIELD_NUM_ARRAY( _field, _count, _max );
|
||||
|
||||
#define Z1_NEW_FIXED_TABLE( _name, _field, _max, _count ) \
|
||||
static \
|
||||
const Z1_Field_Rec z1_field_ ## _field = \
|
||||
Z1_FIELD_FIXED_ARRAY( _field, _count, _max );
|
||||
const T1_Field z1_field_ ## _field = \
|
||||
T1_FIELD_FIXED_ARRAY( _field, _count, _max );
|
||||
|
||||
#define Z1_NEW_NUM_TABLE2( _name, _field, _max ) \
|
||||
static \
|
||||
const Z1_Field_Rec z1_field_ ## _field = \
|
||||
Z1_FIELD_NUM_ARRAY2( _field, _max );
|
||||
const T1_Field z1_field_ ## _field = \
|
||||
T1_FIELD_NUM_ARRAY2( _field, _max );
|
||||
|
||||
#define Z1_NEW_FIXED_TABLE2( _name, _field, _max ) \
|
||||
static \
|
||||
const Z1_Field_Rec z1_field_ ## _field = \
|
||||
Z1_FIELD_FIXED_ARRAY2( _field, _max );
|
||||
const T1_Field z1_field_ ## _field = \
|
||||
T1_FIELD_FIXED_ARRAY2( _field, _max );
|
||||
|
||||
|
||||
#define Z1_FONTINFO_STRING( n, f ) Z1_NEW_STRING( n, f )
|
||||
@ -796,7 +796,7 @@
|
||||
Z1_KeyWord_Type type;
|
||||
Z1_KeyWord_Location location;
|
||||
Z1_Parse_Func parsing;
|
||||
const Z1_Field_Rec* field;
|
||||
const T1_Field* field;
|
||||
|
||||
} Z1_KeyWord;
|
||||
|
||||
@ -871,7 +871,7 @@
|
||||
if ( keyword->type == t1_keyword_callback )
|
||||
{
|
||||
keyword->parsing( face, loader );
|
||||
error = loader->parser.error;
|
||||
error = loader->parser.root.error;
|
||||
goto Exit;
|
||||
}
|
||||
|
||||
@ -922,45 +922,19 @@
|
||||
|
||||
|
||||
static
|
||||
int is_space( char c )
|
||||
int is_space( FT_Byte c )
|
||||
{
|
||||
return ( c == ' ' || c == '\t' || c == '\r' || c == '\n' );
|
||||
return (c == ' ' || c == '\t' || c == '\r' || c == '\n' );
|
||||
}
|
||||
|
||||
|
||||
static
|
||||
int is_alpha( char c )
|
||||
int is_alpha( FT_Byte c )
|
||||
{
|
||||
return ( isalnum( (int)c ) ||
|
||||
( c == '.' ) ||
|
||||
( c == '_' ) );
|
||||
return (isalnum(c) || c == '.' || c == '_' );
|
||||
}
|
||||
|
||||
|
||||
static
|
||||
void skip_whitespace( Z1_Parser* parser )
|
||||
{
|
||||
FT_Byte* cur = parser->cursor;
|
||||
|
||||
|
||||
while ( cur < parser->limit && is_space( *cur ) )
|
||||
cur++;
|
||||
|
||||
parser->cursor = cur;
|
||||
}
|
||||
|
||||
|
||||
static
|
||||
void skip_blackspace( Z1_Parser* parser )
|
||||
{
|
||||
FT_Byte* cur = parser->cursor;
|
||||
|
||||
while ( cur < parser->limit && !is_space( *cur ) )
|
||||
cur++;
|
||||
|
||||
parser->cursor = cur;
|
||||
}
|
||||
|
||||
|
||||
static
|
||||
int read_binary_data( Z1_Parser* parser,
|
||||
@ -968,7 +942,7 @@
|
||||
FT_Byte** base )
|
||||
{
|
||||
FT_Byte* cur;
|
||||
FT_Byte* limit = parser->limit;
|
||||
FT_Byte* limit = parser->root.limit;
|
||||
|
||||
|
||||
/* the binary data has the following format */
|
||||
@ -976,26 +950,26 @@
|
||||
/* `size' [white*] RD white ....... ND */
|
||||
/* */
|
||||
|
||||
skip_whitespace( parser );
|
||||
cur = parser->cursor;
|
||||
Z1_Skip_Spaces( parser );
|
||||
cur = parser->root.cursor;
|
||||
|
||||
if ( cur < limit && (FT_Byte)( *cur - '0' ) < 10 )
|
||||
{
|
||||
*size = Z1_ToInt( parser );
|
||||
|
||||
skip_whitespace( parser );
|
||||
skip_blackspace( parser ); /* `RD' or `-|' or something else */
|
||||
Z1_Skip_Spaces( parser );
|
||||
Z1_Skip_Alpha ( parser ); /* `RD' or `-|' or something else */
|
||||
|
||||
/* there is only one whitespace char after the */
|
||||
/* `RD' or `-|' token */
|
||||
*base = parser->cursor + 1;
|
||||
*base = parser->root.cursor + 1;
|
||||
|
||||
parser->cursor += *size+1;
|
||||
parser->root.cursor += *size+1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
FT_ERROR(( "read_binary_data: invalid size field\n" ));
|
||||
parser->error = T1_Err_Invalid_File_Format;
|
||||
parser->root.error = T1_Err_Invalid_File_Format;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1010,17 +984,17 @@
|
||||
{
|
||||
Z1_Parser* parser = &loader->parser;
|
||||
FT_Error error;
|
||||
FT_Memory memory = parser->memory;
|
||||
FT_Memory memory = parser->root.memory;
|
||||
FT_Int len;
|
||||
FT_Byte* cur;
|
||||
FT_Byte* cur2;
|
||||
FT_Byte* limit;
|
||||
|
||||
|
||||
skip_whitespace( parser );
|
||||
Z1_Skip_Spaces( parser );
|
||||
|
||||
cur = parser->cursor;
|
||||
limit = parser->limit;
|
||||
cur = parser->root.cursor;
|
||||
limit = parser->root.limit;
|
||||
|
||||
if ( cur >= limit - 1 || *cur != '/' )
|
||||
return;
|
||||
@ -1035,14 +1009,14 @@
|
||||
{
|
||||
if ( ALLOC( face->type1.font_name, len + 1 ) )
|
||||
{
|
||||
parser->error = error;
|
||||
parser->root.error = error;
|
||||
return;
|
||||
}
|
||||
|
||||
MEM_Copy( face->type1.font_name, cur, len );
|
||||
face->type1.font_name[len] = '\0';
|
||||
}
|
||||
parser->cursor = cur2;
|
||||
parser->root.cursor = cur2;
|
||||
}
|
||||
|
||||
|
||||
@ -1104,8 +1078,10 @@
|
||||
Z1_Loader* loader )
|
||||
{
|
||||
Z1_Parser* parser = &loader->parser;
|
||||
FT_Byte* cur = parser->cursor;
|
||||
FT_Byte* limit = parser->limit;
|
||||
FT_Byte* cur = parser->root.cursor;
|
||||
FT_Byte* limit = parser->root.limit;
|
||||
|
||||
PSAux_Interface* psaux = (PSAux_Interface*)face->psaux;
|
||||
|
||||
|
||||
/* skip whitespace */
|
||||
@ -1115,7 +1091,7 @@
|
||||
if ( cur >= limit )
|
||||
{
|
||||
FT_ERROR(( "parse_encoding: out of bounds!\n" ));
|
||||
parser->error = T1_Err_Invalid_File_Format;
|
||||
parser->root.error = T1_Err_Invalid_File_Format;
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -1126,23 +1102,23 @@
|
||||
{
|
||||
T1_Encoding* encode = &face->type1.encoding;
|
||||
FT_Int count, n;
|
||||
Z1_Table* char_table = &loader->encoding_table;
|
||||
FT_Memory memory = parser->memory;
|
||||
PS_Table* char_table = &loader->encoding_table;
|
||||
FT_Memory memory = parser->root.memory;
|
||||
FT_Error error;
|
||||
|
||||
|
||||
/* read the number of entries in the encoding, should be 256 */
|
||||
count = Z1_ToInt( parser );
|
||||
if ( parser->error )
|
||||
if ( parser->root.error )
|
||||
return;
|
||||
|
||||
/* we use a Z1_Table to store our charnames */
|
||||
encode->num_chars = count;
|
||||
if ( ALLOC_ARRAY( encode->char_index, count, FT_Short ) ||
|
||||
ALLOC_ARRAY( encode->char_name, count, FT_String* ) ||
|
||||
( error = Z1_New_Table( char_table, count, memory ) ) != 0 )
|
||||
( error = psaux->ps_table_funcs->init( char_table, count, memory ) ) != 0 )
|
||||
{
|
||||
parser->error = error;
|
||||
parser->root.error = error;
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1159,8 +1135,8 @@
|
||||
/* */
|
||||
/* We stop when we encounter a `def'. */
|
||||
|
||||
cur = parser->cursor;
|
||||
limit = parser->limit;
|
||||
cur = parser->root.cursor;
|
||||
limit = parser->root.limit;
|
||||
n = 0;
|
||||
|
||||
for ( ; cur < limit; )
|
||||
@ -1189,9 +1165,9 @@
|
||||
FT_Int charcode;
|
||||
|
||||
|
||||
parser->cursor = cur;
|
||||
parser->root.cursor = cur;
|
||||
charcode = Z1_ToInt( parser );
|
||||
cur = parser->cursor;
|
||||
cur = parser->root.cursor;
|
||||
|
||||
/* skip whitespace */
|
||||
while ( cur < limit && is_space( *cur ) )
|
||||
@ -1210,10 +1186,10 @@
|
||||
|
||||
len = cur2 - cur - 1;
|
||||
|
||||
parser->error = Z1_Add_Table( char_table, charcode,
|
||||
parser->root.error = Z1_Add_Table( char_table, charcode,
|
||||
cur + 1, len + 1 );
|
||||
char_table->elements[charcode][len] = '\0';
|
||||
if ( parser->error )
|
||||
if ( parser->root.error )
|
||||
return;
|
||||
|
||||
cur = cur2;
|
||||
@ -1224,7 +1200,7 @@
|
||||
}
|
||||
|
||||
face->type1.encoding_type = t1_encoding_array;
|
||||
parser->cursor = cur;
|
||||
parser->root.cursor = cur;
|
||||
}
|
||||
/* Otherwise, we should have either `StandardEncoding' or */
|
||||
/* `ExpertEncoding' */
|
||||
@ -1241,7 +1217,7 @@
|
||||
else
|
||||
{
|
||||
FT_ERROR(( "parse_encoding: invalid token!\n" ));
|
||||
parser->error = T1_Err_Invalid_File_Format;
|
||||
parser->root.error = T1_Err_Invalid_File_Format;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1252,23 +1228,24 @@
|
||||
Z1_Loader* loader )
|
||||
{
|
||||
Z1_Parser* parser = &loader->parser;
|
||||
Z1_Table* table = &loader->subrs;
|
||||
FT_Memory memory = parser->memory;
|
||||
PS_Table* table = &loader->subrs;
|
||||
FT_Memory memory = parser->root.memory;
|
||||
FT_Error error;
|
||||
FT_Int n;
|
||||
|
||||
|
||||
PSAux_Interface* psaux = (PSAux_Interface*)face->psaux;
|
||||
|
||||
loader->num_subrs = Z1_ToInt( parser );
|
||||
if ( parser->error )
|
||||
if ( parser->root.error )
|
||||
return;
|
||||
|
||||
/* position the parser right before the `dup' of the first subr */
|
||||
skip_whitespace( parser );
|
||||
skip_blackspace( parser ); /* `array' */
|
||||
skip_whitespace( parser );
|
||||
Z1_Skip_Spaces( parser );
|
||||
Z1_Skip_Alpha( parser ); /* `array' */
|
||||
Z1_Skip_Spaces( parser );
|
||||
|
||||
/* initialize subrs array */
|
||||
error = Z1_New_Table( table, loader->num_subrs, memory );
|
||||
error = psaux->ps_table_funcs->init( table, loader->num_subrs, memory );
|
||||
if ( error )
|
||||
goto Fail;
|
||||
|
||||
@ -1285,7 +1262,7 @@
|
||||
|
||||
/* If the next token isn't `dup', we are also done. This */
|
||||
/* happens when there are `holes' in the Subrs array. */
|
||||
if ( strncmp( (char*)parser->cursor, "dup", 3 ) != 0 )
|
||||
if ( strncmp( (char*)parser->root.cursor, "dup", 3 ) != 0 )
|
||||
break;
|
||||
|
||||
index = Z1_ToInt( parser );
|
||||
@ -1297,14 +1274,14 @@
|
||||
/* (bound to `noaccess put') or by two separate tokens: */
|
||||
/* `noaccess' & `put'. We position the parser right */
|
||||
/* before the next `dup', if any. */
|
||||
skip_whitespace( parser );
|
||||
skip_blackspace( parser ); /* `NP' or `I' or `noaccess' */
|
||||
skip_whitespace( parser );
|
||||
Z1_Skip_Spaces( parser );
|
||||
Z1_Skip_Alpha( parser ); /* `NP' or `I' or `noaccess' */
|
||||
Z1_Skip_Spaces( parser );
|
||||
|
||||
if ( strncmp( (char*)parser->cursor, "put", 3 ) == 0 )
|
||||
if ( strncmp( (char*)parser->root.cursor, "put", 3 ) == 0 )
|
||||
{
|
||||
skip_blackspace( parser ); /* skip `put' */
|
||||
skip_whitespace( parser );
|
||||
Z1_Skip_Alpha( parser ); /* skip `put' */
|
||||
Z1_Skip_Spaces( parser );
|
||||
}
|
||||
|
||||
/* some fonts use a value of -1 for lenIV to indicate that */
|
||||
@ -1326,7 +1303,7 @@
|
||||
return;
|
||||
|
||||
Fail:
|
||||
parser->error = error;
|
||||
parser->root.error = error;
|
||||
}
|
||||
|
||||
|
||||
@ -1335,13 +1312,15 @@
|
||||
Z1_Loader* loader )
|
||||
{
|
||||
Z1_Parser* parser = &loader->parser;
|
||||
Z1_Table* code_table = &loader->charstrings;
|
||||
Z1_Table* name_table = &loader->glyph_names;
|
||||
FT_Memory memory = parser->memory;
|
||||
PS_Table* code_table = &loader->charstrings;
|
||||
PS_Table* name_table = &loader->glyph_names;
|
||||
FT_Memory memory = parser->root.memory;
|
||||
FT_Error error;
|
||||
|
||||
PSAux_Interface* psaux = (PSAux_Interface*)face->psaux;
|
||||
|
||||
FT_Byte* cur;
|
||||
FT_Byte* limit = parser->limit;
|
||||
FT_Byte* limit = parser->root.limit;
|
||||
FT_Int n;
|
||||
|
||||
|
||||
@ -1350,12 +1329,15 @@
|
||||
return;
|
||||
|
||||
loader->num_glyphs = Z1_ToInt( parser );
|
||||
if ( parser->error )
|
||||
if ( parser->root.error )
|
||||
return;
|
||||
|
||||
/* initialize tables */
|
||||
error = Z1_New_Table( code_table, loader->num_glyphs, memory ) ||
|
||||
Z1_New_Table( name_table, loader->num_glyphs, memory );
|
||||
error = psaux->ps_table_funcs->init( code_table, loader->num_glyphs, memory );
|
||||
if (error)
|
||||
goto Fail;
|
||||
|
||||
error = psaux->ps_table_funcs->init( name_table, loader->num_glyphs, memory );
|
||||
if ( error )
|
||||
goto Fail;
|
||||
|
||||
@ -1371,9 +1353,9 @@
|
||||
/* */
|
||||
/* note that we stop when we find a `def' */
|
||||
/* */
|
||||
skip_whitespace( parser );
|
||||
Z1_Skip_Spaces( parser );
|
||||
|
||||
cur = parser->cursor;
|
||||
cur = parser->root.cursor;
|
||||
if ( cur >= limit )
|
||||
break;
|
||||
|
||||
@ -1391,7 +1373,7 @@
|
||||
break;
|
||||
|
||||
if ( *cur != '/' )
|
||||
skip_blackspace( parser );
|
||||
Z1_Skip_Alpha( parser );
|
||||
else
|
||||
{
|
||||
FT_Byte* cur2 = cur + 1;
|
||||
@ -1409,7 +1391,7 @@
|
||||
/* add a trailing zero to the name table */
|
||||
name_table->elements[n][len] = '\0';
|
||||
|
||||
parser->cursor = cur2;
|
||||
parser->root.cursor = cur2;
|
||||
if ( !read_binary_data( parser, &size, &base ) )
|
||||
return;
|
||||
|
||||
@ -1433,7 +1415,7 @@
|
||||
return;
|
||||
|
||||
Fail:
|
||||
parser->error = error;
|
||||
parser->root.error = error;
|
||||
}
|
||||
|
||||
|
||||
@ -1480,9 +1462,9 @@
|
||||
Z1_Parser* parser = &loader->parser;
|
||||
|
||||
|
||||
parser->cursor = base;
|
||||
parser->limit = base + size;
|
||||
parser->error = 0;
|
||||
parser->root.cursor = base;
|
||||
parser->root.limit = base + size;
|
||||
parser->root.error = 0;
|
||||
|
||||
{
|
||||
FT_Byte* cur = base;
|
||||
@ -1509,17 +1491,17 @@
|
||||
|
||||
if ( cur < limit )
|
||||
{
|
||||
Z1_Token_Rec token;
|
||||
T1_Token token;
|
||||
|
||||
|
||||
/* skip the `known' keyword and the token following it */
|
||||
cur += 5;
|
||||
loader->parser.cursor = cur;
|
||||
loader->parser.root.cursor = cur;
|
||||
Z1_ToToken( &loader->parser, &token );
|
||||
|
||||
/* if the last token was an array, skip it! */
|
||||
if ( token.type == z1_token_array )
|
||||
cur2 = parser->cursor;
|
||||
if ( token.type == t1_token_array )
|
||||
cur2 = parser->root.cursor;
|
||||
}
|
||||
cur = cur2;
|
||||
}
|
||||
@ -1571,13 +1553,13 @@
|
||||
if ( n >= len )
|
||||
{
|
||||
/* we found it -- run the parsing callback! */
|
||||
parser->cursor = cur2;
|
||||
skip_whitespace( parser );
|
||||
parser->error = t1_load_keyword( face, loader, keyword );
|
||||
if ( parser->error )
|
||||
return parser->error;
|
||||
parser->root.cursor = cur2;
|
||||
Z1_Skip_Spaces( parser );
|
||||
parser->root.error = t1_load_keyword( face, loader, keyword );
|
||||
if ( parser->root.error )
|
||||
return parser->root.error;
|
||||
|
||||
cur = parser->cursor;
|
||||
cur = parser->root.cursor;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -1588,7 +1570,7 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
return parser->error;
|
||||
return parser->root.error;
|
||||
}
|
||||
|
||||
|
||||
@ -1635,7 +1617,8 @@
|
||||
Z1_Parser* parser;
|
||||
T1_Font* type1 = &face->type1;
|
||||
FT_Error error;
|
||||
|
||||
|
||||
PSAux_Interface* psaux = (PSAux_Interface*)face->psaux;
|
||||
|
||||
t1_init_loader( &loader, face );
|
||||
|
||||
@ -1643,7 +1626,7 @@
|
||||
type1->private_dict.lenIV = 4;
|
||||
|
||||
parser = &loader.parser;
|
||||
error = Z1_New_Parser( parser, face->root.stream, face->root.memory );
|
||||
error = Z1_New_Parser( parser, face->root.stream, face->root.memory, psaux );
|
||||
if ( error )
|
||||
goto Exit;
|
||||
|
||||
|
@ -44,15 +44,15 @@
|
||||
Z1_Parser parser; /* parser used to read the stream */
|
||||
|
||||
FT_Int num_chars; /* number of characters in encoding */
|
||||
Z1_Table encoding_table; /* Z1_Table used to store the */
|
||||
PS_Table encoding_table; /* PS_Table used to store the */
|
||||
/* encoding character names */
|
||||
|
||||
FT_Int num_glyphs;
|
||||
Z1_Table glyph_names;
|
||||
Z1_Table charstrings;
|
||||
PS_Table glyph_names;
|
||||
PS_Table charstrings;
|
||||
|
||||
FT_Int num_subrs;
|
||||
Z1_Table subrs;
|
||||
PS_Table subrs;
|
||||
FT_Bool fontdata;
|
||||
|
||||
} Z1_Loader;
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -27,181 +27,6 @@
|
||||
#endif
|
||||
|
||||
|
||||
/* simple enumeration type used to identify token types */
|
||||
typedef enum Z1_Token_Type_
|
||||
{
|
||||
z1_token_none = 0,
|
||||
z1_token_any,
|
||||
z1_token_string,
|
||||
z1_token_array,
|
||||
|
||||
/* do not remove */
|
||||
z1_token_max
|
||||
|
||||
} Z1_Token_Type;
|
||||
|
||||
|
||||
/* a simple structure used to identify tokens */
|
||||
typedef struct Z1_Token_Rec_
|
||||
{
|
||||
FT_Byte* start; /* first character of token in input stream */
|
||||
FT_Byte* limit; /* first character after the token */
|
||||
Z1_Token_Type type; /* type of token.. */
|
||||
|
||||
} Z1_Token_Rec;
|
||||
|
||||
|
||||
/* enumeration type used to identify object fields */
|
||||
typedef enum Z1_Field_Type_
|
||||
{
|
||||
z1_field_none = 0,
|
||||
z1_field_bool,
|
||||
z1_field_integer,
|
||||
z1_field_fixed,
|
||||
z1_field_string,
|
||||
z1_field_integer_array,
|
||||
z1_field_fixed_array,
|
||||
|
||||
/* do not remove */
|
||||
z1_field_max
|
||||
|
||||
} Z1_Field_Type;
|
||||
|
||||
|
||||
/* structure type used to model object fields */
|
||||
typedef struct Z1_Field_Rec_
|
||||
{
|
||||
Z1_Field_Type type; /* type of field */
|
||||
FT_UInt offset; /* offset of field in object */
|
||||
FT_Byte size; /* size of field in bytes */
|
||||
FT_UInt array_max; /* maximum number of elements for array */
|
||||
FT_UInt count_offset; /* offset of element count for arrays */
|
||||
FT_Int flag_bit; /* bit number for field flag */
|
||||
|
||||
} Z1_Field_Rec;
|
||||
|
||||
|
||||
#define Z1_FIELD_BOOL( _fname ) \
|
||||
{ \
|
||||
z1_field_bool, \
|
||||
FT_FIELD_OFFSET( _fname ), \
|
||||
FT_FIELD_SIZE( _fname ), \
|
||||
0, 0, 0 \
|
||||
}
|
||||
|
||||
#define Z1_FIELD_NUM( _fname ) \
|
||||
{ \
|
||||
z1_field_integer, \
|
||||
FT_FIELD_OFFSET( _fname ), \
|
||||
FT_FIELD_SIZE( _fname ), \
|
||||
0, 0, 0 \
|
||||
}
|
||||
|
||||
#define Z1_FIELD_FIXED( _fname, _power ) \
|
||||
{ \
|
||||
z1_field_fixed, \
|
||||
FT_FIELD_OFFSET( _fname ), \
|
||||
FT_FIELD_SIZE( _fname ), \
|
||||
0, 0, 0 \
|
||||
}
|
||||
|
||||
#define Z1_FIELD_STRING( _fname ) \
|
||||
{ \
|
||||
z1_field_string, \
|
||||
FT_FIELD_OFFSET( _fname ), \
|
||||
FT_FIELD_SIZE( _fname ), \
|
||||
0, 0, 0 \
|
||||
}
|
||||
|
||||
#define Z1_FIELD_NUM_ARRAY( _fname, _fcount, _fmax ) \
|
||||
{ \
|
||||
z1_field_integer, \
|
||||
FT_FIELD_OFFSET( _fname ), \
|
||||
FT_FIELD_SIZE_DELTA( _fname ), \
|
||||
_fmax, \
|
||||
FT_FIELD_OFFSET( _fcount ), \
|
||||
0 \
|
||||
}
|
||||
|
||||
#define Z1_FIELD_FIXED_ARRAY( _fname, _fcount, _fmax ) \
|
||||
{ \
|
||||
z1_field_fixed, \
|
||||
FT_FIELD_OFFSET( _fname ), \
|
||||
FT_FIELD_SIZE_DELTA( _fname ), \
|
||||
_fmax, \
|
||||
FT_FIELD_OFFSET( _fcount ), \
|
||||
0 \
|
||||
}
|
||||
|
||||
#define Z1_FIELD_NUM_ARRAY2( _fname, _fmax ) \
|
||||
{ \
|
||||
z1_field_integer, \
|
||||
FT_FIELD_OFFSET( _fname ), \
|
||||
FT_FIELD_SIZE_DELTA( _fname ), \
|
||||
_fmax, \
|
||||
0, 0 \
|
||||
}
|
||||
|
||||
#define Z1_FIELD_FIXED_ARRAY2( _fname, _fmax ) \
|
||||
{ \
|
||||
z1_field_fixed, \
|
||||
FT_FIELD_OFFSTE( _fname ), \
|
||||
FT_FIELD_SIZE_DELTA( _fname ), \
|
||||
_fmax, \
|
||||
0, 0 \
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Struct> */
|
||||
/* Z1_Table */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A Z1_Table is a simple object used to store an array of objects in */
|
||||
/* a single memory block. */
|
||||
/* */
|
||||
/* <Fields> */
|
||||
/* block :: The address in memory of the growheap's block. This */
|
||||
/* can change between two object adds, due to the use of */
|
||||
/* reallocation. */
|
||||
/* */
|
||||
/* cursor :: The current top of the grow heap within its block. */
|
||||
/* */
|
||||
/* capacity :: The current size of the heap block. Increments in */
|
||||
/* 1kByte blocks. */
|
||||
/* */
|
||||
/* init :: A boolean. Set when the table has been initialized */
|
||||
/* (the table user should set this field). */
|
||||
/* */
|
||||
/* max_elems :: The maximum number of elements in the table. */
|
||||
/* */
|
||||
/* num_elems :: The current number of elements in the table. */
|
||||
/* */
|
||||
/* elements :: A table of element addresses within the block. */
|
||||
/* */
|
||||
/* lengths :: A table of element sizes within the block. */
|
||||
/* */
|
||||
/* memory :: The memory object used for memory operations */
|
||||
/* (allocation/reallocation). */
|
||||
/* */
|
||||
typedef struct Z1_Table_
|
||||
{
|
||||
FT_Byte* block; /* current memory block */
|
||||
FT_Int cursor; /* current cursor in memory block */
|
||||
FT_Int capacity; /* current size of memory block */
|
||||
FT_Long init;
|
||||
|
||||
FT_Int max_elems;
|
||||
FT_Int num_elems;
|
||||
FT_Byte** elements; /* addresses of table elements */
|
||||
FT_Int* lengths; /* lengths of table elements */
|
||||
|
||||
FT_Memory memory;
|
||||
|
||||
} Z1_Table;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Struct> */
|
||||
@ -241,8 +66,8 @@
|
||||
/* */
|
||||
typedef struct Z1_Parser_
|
||||
{
|
||||
T1_Parser root;
|
||||
FT_Stream stream;
|
||||
FT_Memory memory;
|
||||
|
||||
FT_Byte* base_dict;
|
||||
FT_Int base_len;
|
||||
@ -254,92 +79,33 @@
|
||||
FT_Byte in_memory;
|
||||
FT_Byte single_block;
|
||||
|
||||
FT_Byte* cursor;
|
||||
FT_Byte* limit;
|
||||
FT_Error error;
|
||||
|
||||
} Z1_Parser;
|
||||
|
||||
|
||||
LOCAL_DEF
|
||||
FT_Error Z1_New_Table( Z1_Table* table,
|
||||
FT_Int count,
|
||||
FT_Memory memory );
|
||||
#define Z1_Add_Table(p,i,o,l) (p)->funcs.add( (p), i, o, l )
|
||||
#define Z1_Done_Table(p) do { if ((p)->funcs.done) (p)->funcs.done( p ); } while (0)
|
||||
#define Z1_Release_Table(p) do { if ((p)->funcs.release) (p)->funcs.release( p ); } while (0)
|
||||
|
||||
|
||||
#define Z1_Skip_Spaces(p) (p)->root.funcs.skip_spaces( &(p)->root )
|
||||
#define Z1_Skip_Alpha(p) (p)->root.funcs.skip_alpha ( &(p)->root )
|
||||
|
||||
#define Z1_ToInt(p) (p)->root.funcs.to_int( &(p)->root )
|
||||
#define Z1_ToFixed(p,t) (p)->root.funcs.to_fixed( &(p)->root, t )
|
||||
|
||||
#define Z1_ToCoordArray(p,m,c) (p)->root.funcs.to_coord_array( &(p)->root, m, c )
|
||||
#define Z1_ToFixedArray(p,m,f,t) (p)->root.funcs.to_fixed_array( &(p)->root, m, f, t )
|
||||
#define Z1_ToToken(p,t) (p)->root.funcs.to_token( &(p)->root, t )
|
||||
#define Z1_ToTokenArray(p,t,m,c) (p)->root.funcs.to_token_array( &(p)->root, t, m, c )
|
||||
|
||||
#define Z1_Load_Field(p,f,o,m,pf) (p)->root.funcs.load_field( &(p)->root, f, o, m, pf )
|
||||
#define Z1_Load_Field_Table(p,f,o,m,pf) (p)->root.funcs.load_field_table( &(p)->root, f, o, m, pf )
|
||||
|
||||
LOCAL_DEF
|
||||
FT_Error Z1_Add_Table( Z1_Table* table,
|
||||
FT_Int index,
|
||||
void* object,
|
||||
FT_Int length );
|
||||
|
||||
#if 0
|
||||
LOCAL_DEF
|
||||
void Z1_Done_Table( Z1_Table* table );
|
||||
#endif
|
||||
|
||||
LOCAL_DEF
|
||||
void Z1_Release_Table( Z1_Table* table );
|
||||
|
||||
LOCAL_DEF
|
||||
FT_Long Z1_ToInt( Z1_Parser* parser );
|
||||
|
||||
LOCAL_DEF
|
||||
FT_Long Z1_ToFixed( Z1_Parser* parser,
|
||||
FT_Int power_ten );
|
||||
|
||||
LOCAL_DEF
|
||||
FT_Int Z1_ToCoordArray( Z1_Parser* parser,
|
||||
FT_Int max_coords,
|
||||
FT_Short* coords );
|
||||
|
||||
LOCAL_DEF
|
||||
FT_Int Z1_ToFixedArray( Z1_Parser* parser,
|
||||
FT_Int max_values,
|
||||
FT_Fixed* values,
|
||||
FT_Int power_ten );
|
||||
|
||||
#if 0
|
||||
LOCAL_DEF
|
||||
FT_String* Z1_ToString( Z1_Parser* parser );
|
||||
|
||||
LOCAL_DEF
|
||||
FT_Bool Z1_ToBool( Z1_Parser* parser );
|
||||
#endif
|
||||
|
||||
|
||||
LOCAL_DEF
|
||||
void Z1_Skip_Spaces( Z1_Parser* parser );
|
||||
|
||||
LOCAL_DEF
|
||||
void Z1_ToToken( Z1_Parser* parser,
|
||||
Z1_Token_Rec* token );
|
||||
|
||||
LOCAL_FUNC
|
||||
void Z1_ToTokenArray( Z1_Parser* parser,
|
||||
Z1_Token_Rec* tokens,
|
||||
FT_UInt max_tokens,
|
||||
FT_Int* pnum_tokens );
|
||||
|
||||
LOCAL_DEF
|
||||
FT_Error Z1_Load_Field( Z1_Parser* parser,
|
||||
const Z1_Field_Rec* field,
|
||||
void** objects,
|
||||
FT_UInt max_objects,
|
||||
FT_ULong* pflags );
|
||||
|
||||
LOCAL_DEF
|
||||
FT_Error Z1_Load_Field_Table( Z1_Parser* parser,
|
||||
const Z1_Field_Rec* field,
|
||||
void** objects,
|
||||
FT_UInt max_objects,
|
||||
FT_ULong* pflags );
|
||||
|
||||
|
||||
LOCAL_DEF
|
||||
FT_Error Z1_New_Parser( Z1_Parser* parser,
|
||||
FT_Stream stream,
|
||||
FT_Memory memory );
|
||||
FT_Error Z1_New_Parser( Z1_Parser* parser,
|
||||
FT_Stream stream,
|
||||
FT_Memory memory,
|
||||
PSAux_Interface* psaux );
|
||||
|
||||
LOCAL_DEF
|
||||
FT_Error Z1_Get_Private_Dict( Z1_Parser* parser );
|
||||
|
Loading…
Reference in New Issue
Block a user