Commit aa919383 authored by David Turner's avatar David Turner
Browse files

yet another logical transformation of the internals to make them

more consistent and understandable..

mainly, changing things like PS_Table  => PS_TableRec + *PS_Table
parent 77e54f36
......@@ -137,18 +137,24 @@ FT_BEGIN_HEADER
} FT_ValidatorRec;
FT_BASE( void )
ft_validator_init( FT_Validator valid,
FT_Byte* base,
FT_Byte* limit,
FT_ValidationLevel level );
/* sets the error field in a validator, then calls 'longjmp' to return */
/* to high-level caller. Using 'setjmp/longjmp' avoids many stupid */
/* error checks within the validation routines.. */
/* */
FT_BASE( void )
ft_validate_error( FT_Valid valid,
FT_Error error );
ft_validator_error( FT_Validator valid,
FT_Error error );
/* calls ft_validate_error. Assumes that the 'valid' local variable holds */
/* a pointer to the current validator object.. */
/* */
#define FT_INVALID(_error) ft_validate_error( valid, _error )
#define FT_INVALID(_error) ft_validator_error( valid, _error )
/* called when a broken table is detected */
#define FT_INVALID_TOO_SHORT FT_INVALID( FT_Err_Invalid_Format )
......@@ -206,9 +212,6 @@ FT_BEGIN_HEADER
typedef void (*FT_CMap_DoneFunc)( FT_CMap cmap );
typedef FT_Error (*FT_CMap_ValidateFunc)( FT_Pointer cmap_data,
FT_Validator valid );
typedef FT_UInt (*FT_CMap_CharIndexFunc)( FT_Pointer cmap_data,
FT_ULong char_code );
......@@ -220,13 +223,24 @@ FT_BEGIN_HEADER
FT_UInt size;
FT_CMap_InitFunc init;
FT_CMap_DoneFunc done;
FT_CMap_ValidateFunc validate;
FT_CMap_CharIndexFunc char_index;
FT_CMap_CharNextFunc char_next;
} FT_CMap_ClassRec;
/* create a new charmap and add it to charmap->face */
FT_BASE( FT_Error )
FT_CMap_New( FT_CMap_Class clazz,
FT_Pointer data,
FT_CharMap charmap,
FT_CMap *acmap );
/* destroy a charmap (don't remove it from face's list though) */
FT_BASE( void )
FT_CMap_Done( FT_CMap cmap );
/*************************************************************************/
/* */
/* <Struct> */
......
......@@ -38,13 +38,14 @@ FT_BEGIN_HEADER
/*************************************************************************/
typedef struct PS_Table_ PS_Table;
typedef struct PS_TableRec_* PS_Table;
typedef const struct PS_Table_FuncsRec_* PS_Table_Funcs;
/*************************************************************************/
/* */
/* <Struct> */
/* PS_Table_Funcs */
/* PS_Table_FuncsRec */
/* */
/* <Description> */
/* A set of function pointers to manage PS_Table objects. */
......@@ -58,32 +59,32 @@ FT_BEGIN_HEADER
/* */
/* table_release :: Releases table data, then finalizes it. */
/* */
typedef struct PS_Table_Funcs_
typedef struct PS_Table_FuncsRec_
{
FT_Error
(*init)( PS_Table* table,
(*init)( PS_Table table,
FT_Int count,
FT_Memory memory );
void
(*done)( PS_Table* table );
(*done)( PS_Table table );
FT_Error
(*add)( PS_Table* table,
(*add)( PS_Table table,
FT_Int index,
void* object,
FT_Int length );
void
(*release)( PS_Table* table );
(*release)( PS_Table table );
} PS_Table_Funcs;
} PS_Table_FuncsRec;
/*************************************************************************/
/* */
/* <Struct> */
/* PS_Table */
/* PS_TableRec */
/* */
/* <Description> */
/* A PS_Table is a simple object used to store an array of objects in */
......@@ -112,7 +113,7 @@ FT_BEGIN_HEADER
/* */
/* funcs :: A table of method pointers for this object. */
/* */
struct PS_Table_
typedef struct PS_TableRec_
{
FT_Byte* block; /* current memory block */
FT_Offset cursor; /* current cursor in memory block */
......@@ -124,10 +125,10 @@ FT_BEGIN_HEADER
FT_Byte** elements; /* addresses of table elements */
FT_Int* lengths; /* lengths of table elements */
FT_Memory memory;
PS_Table_Funcs funcs;
FT_Memory memory;
PS_Table_FuncsRec funcs;
};
} PS_TableRec;
/*************************************************************************/
......@@ -138,46 +139,51 @@ FT_BEGIN_HEADER
/*************************************************************************/
/*************************************************************************/
typedef struct T1_Parser_ T1_Parser;
typedef struct PS_ParserRec_* PS_Parser;
typedef struct T1_TokenRec_* T1_Token;
typedef struct T1_FieldRec_* T1_Field;
/* simple enumeration type used to identify token types */
typedef enum T1_Token_Type_
{
t1_token_none = 0,
t1_token_any,
t1_token_string,
t1_token_array,
T1_TOKEN_TYPE_NONE = 0,
T1_TOKEN_TYPE_ANY,
T1_TOKEN_TYPE_STRING,
T1_TOKEN_TYPE_ARRAY,
/* do not remove */
t1_token_max
T1_TOKEN_TYPE_MAX
} T1_Token_Type;
/* a simple structure used to identify tokens */
typedef struct T1_Token_
typedef struct T1_TokenRec_
{
FT_Byte* start; /* first character of token in input stream */
FT_Byte* limit; /* first character after the token */
T1_Token_Type type; /* type of token */
} T1_Token;
} T1_TokenRec;
/* enumeration type used to identify object fields */
typedef enum T1_Field_Type_
{
t1_field_none = 0,
t1_field_bool,
t1_field_integer,
t1_field_fixed,
t1_field_string,
t1_field_integer_array,
t1_field_fixed_array,
t1_field_callback,
T1_FIELD_TYPE_NONE = 0,
T1_FIELD_TYPE_BOOL,
T1_FIELD_TYPE_INTEGER,
T1_FIELD_TYPE_FIXED,
T1_FIELD_TYPE_STRING,
T1_FIELD_TYPE_INTEGER_ARRAY,
T1_FIELD_TYPE_FIXED_ARRAY,
T1_FIELD_TYPE_CALLBACK,
/* do not remove */
t1_field_max
T1_FIELD_TYPE_MAX
} T1_Field_Type;
......@@ -200,7 +206,7 @@ FT_BEGIN_HEADER
/* structure type used to model object fields */
typedef struct T1_Field_
typedef struct T1_FieldRec_
{
const char* ident; /* field identifier */
T1_Field_Location location;
......@@ -212,7 +218,7 @@ FT_BEGIN_HEADER
/* array */
FT_UInt count_offset; /* offset of element count for */
/* arrays */
} T1_Field;
} T1_FieldRec;
#define T1_NEW_SIMPLE_FIELD( _ident, _type, _fname ) \
......@@ -226,7 +232,7 @@ FT_BEGIN_HEADER
#define T1_NEW_CALLBACK_FIELD( _ident, _reader ) \
{ \
_ident, T1CODE, t1_field_callback, \
_ident, T1CODE, T1_FIELD_TYPE_CALLBACK, \
(T1_Field_Parser)_reader, \
0, 0, \
0, 0 \
......@@ -252,32 +258,32 @@ FT_BEGIN_HEADER
},
#define T1_FIELD_BOOL( _ident, _fname ) \
T1_NEW_SIMPLE_FIELD( _ident, t1_field_bool, _fname )
#define T1_FIELD_TYPE_BOOL( _ident, _fname ) \
T1_NEW_SIMPLE_FIELD( _ident, T1_FIELD_TYPE_BOOL, _fname )
#define T1_FIELD_NUM( _ident, _fname ) \
T1_NEW_SIMPLE_FIELD( _ident, t1_field_integer, _fname )
T1_NEW_SIMPLE_FIELD( _ident, T1_FIELD_TYPE_INTEGER, _fname )
#define T1_FIELD_FIXED( _ident, _fname ) \
T1_NEW_SIMPLE_FIELD( _ident, t1_field_fixed, _fname )
T1_NEW_SIMPLE_FIELD( _ident, T1_FIELD_TYPE_FIXED, _fname )
#define T1_FIELD_STRING( _ident, _fname ) \
T1_NEW_SIMPLE_FIELD( _ident, t1_field_string, _fname )
T1_NEW_SIMPLE_FIELD( _ident, T1_FIELD_TYPE_STRING, _fname )
#define T1_FIELD_NUM_TABLE( _ident, _fname, _fmax ) \
T1_NEW_TABLE_FIELD( _ident, t1_field_integer_array, \
T1_NEW_TABLE_FIELD( _ident, T1_FIELD_TYPE_INTEGER_ARRAY, \
_fname, _fmax )
#define T1_FIELD_FIXED_TABLE( _ident, _fname, _fmax ) \
T1_NEW_TABLE_FIELD( _ident, t1_field_fixed_array, \
T1_NEW_TABLE_FIELD( _ident, T1_FIELD_TYPE_FIXED_ARRAY, \
_fname, _fmax )
#define T1_FIELD_NUM_TABLE2( _ident, _fname, _fmax ) \
T1_NEW_TABLE_FIELD2( _ident, t1_field_integer_array, \
T1_NEW_TABLE_FIELD2( _ident, T1_FIELD_TYPE_INTEGER_ARRAY, \
_fname, _fmax )
#define T1_FIELD_FIXED_TABLE2( _ident, _fname, _fmax ) \
T1_NEW_TABLE_FIELD2( _ident, t1_field_fixed_array, \
T1_NEW_TABLE_FIELD2( _ident, T1_FIELD_TYPE_FIXED_ARRAY, \
_fname, _fmax )
#define T1_FIELD_CALLBACK( _ident, _name ) \
......@@ -294,70 +300,72 @@ FT_BEGIN_HEADER
/*************************************************************************/
/*************************************************************************/
typedef struct T1_Parser_Funcs_
typedef const struct PS_Parser_FuncsRec_* PS_Parser_Funcs;
typedef struct PS_Parser_FuncsRec_
{
void
(*init)( T1_Parser* parser,
(*init)( PS_Parser parser,
FT_Byte* base,
FT_Byte* limit,
FT_Memory memory );
void
(*done)( T1_Parser* parser );
(*done)( PS_Parser parser );
void
(*skip_spaces)( T1_Parser* parser );
(*skip_spaces)( PS_Parser parser );
void
(*skip_alpha)( T1_Parser* parser );
(*skip_alpha)( PS_Parser parser );
FT_Long
(*to_int)( T1_Parser* parser );
(*to_int)( PS_Parser parser );
FT_Fixed
(*to_fixed)( T1_Parser* parser,
(*to_fixed)( PS_Parser parser,
FT_Int power_ten );
FT_Int
(*to_coord_array)( T1_Parser* parser,
(*to_coord_array)( PS_Parser parser,
FT_Int max_coords,
FT_Short* coords );
FT_Int
(*to_fixed_array)( T1_Parser* parser,
(*to_fixed_array)( PS_Parser parser,
FT_Int max_values,
FT_Fixed* values,
FT_Int power_ten );
void
(*to_token)( T1_Parser* parser,
T1_Token* token );
(*to_token)( PS_Parser parser,
T1_Token token );
void
(*to_token_array)( T1_Parser* parser,
T1_Token* tokens,
(*to_token_array)( PS_Parser parser,
T1_Token tokens,
FT_UInt max_tokens,
FT_Int* pnum_tokens );
FT_Error
(*load_field)( T1_Parser* parser,
const T1_Field* field,
(*load_field)( PS_Parser parser,
const T1_Field field,
void** objects,
FT_UInt max_objects,
FT_ULong* pflags );
FT_Error
(*load_field_table)( T1_Parser* parser,
const T1_Field* field,
(*load_field_table)( PS_Parser parser,
const T1_Field field,
void** objects,
FT_UInt max_objects,
FT_ULong* pflags );
} T1_Parser_Funcs;
} PS_Parser_FuncsRec;
/*************************************************************************/
/* */
/* <Struct> */
/* T1_Parser */
/* PS_ParserRec */
/* */
/* <Description> */
/* A T1_Parser is an object used to parse a Type 1 font very quickly. */
/* A PS_Parser is an object used to parse a Type 1 font very quickly. */
/* */
/* <Fields> */
/* cursor :: The current position in the text. */
......@@ -372,16 +380,17 @@ FT_BEGIN_HEADER
/* */
/* funcs :: A table of functions for the parser. */
/* */
struct T1_Parser_
typedef struct PS_ParserRec_
{
FT_Byte* cursor;
FT_Byte* base;
FT_Byte* limit;
FT_Error error;
FT_Memory memory;
FT_Byte* cursor;
FT_Byte* base;
FT_Byte* limit;
FT_Error error;
FT_Memory memory;
T1_Parser_Funcs funcs;
};
PS_Parser_FuncsRec funcs;
} PS_ParserRec;
......@@ -567,28 +576,28 @@ FT_BEGIN_HEADER
#endif /* 0 */
typedef struct T1_Decoder_Zone_
typedef struct T1_Decoder_ZoneRec_
{
FT_Byte* cursor;
FT_Byte* base;
FT_Byte* limit;
} T1_Decoder_Zone;
} T1_Decoder_ZoneRec, *T1_Decoder_Zone;
typedef struct T1_Decoder_ T1_Decoder;
typedef struct T1_Decoder_Funcs_ T1_Decoder_Funcs;
typedef struct T1_DecoderRec_* T1_Decoder;
typedef const struct T1_Decoder_FuncsRec_* T1_Decoder_Funcs;
typedef FT_Error
(*T1_Decoder_Callback)( T1_Decoder* decoder,
FT_UInt glyph_index );
(*T1_Decoder_Callback)( T1_Decoder decoder,
FT_UInt glyph_index );
struct T1_Decoder_Funcs_
typedef struct T1_Decoder_FuncsRec_
{
FT_Error
(*init) ( T1_Decoder* decoder,
(*init) ( T1_Decoder decoder,
FT_Face face,
FT_Size size,
FT_GlyphSlot slot,
......@@ -598,26 +607,27 @@ FT_BEGIN_HEADER
T1_Decoder_Callback callback );
void
(*done) ( T1_Decoder* decoder );
(*done) ( T1_Decoder decoder );
FT_Error
(*parse_charstrings)( T1_Decoder* decoder,
(*parse_charstrings)( T1_Decoder decoder,
FT_Byte* base,
FT_UInt len );
};
} T1_Decoder_FuncsRec;
struct T1_Decoder_
typedef struct T1_DecoderRec_
{
T1_Builder builder;
FT_Long stack[T1_MAX_CHARSTRINGS_OPERANDS];
FT_Long* top;
T1_Decoder_Zone zones[T1_MAX_SUBRS_CALLS + 1];
T1_Decoder_Zone* zone;
T1_Decoder_ZoneRec zones[T1_MAX_SUBRS_CALLS + 1];
T1_Decoder_Zone zone;
PSNames_Interface* psnames; /* for seac */
PSNames_Service psnames; /* for seac */
FT_UInt num_glyphs;
FT_Byte** glyph_names;
......@@ -636,8 +646,9 @@ FT_BEGIN_HEADER
T1_Blend* blend; /* for multiple master support */
T1_Decoder_Callback parse_callback;
T1_Decoder_Funcs funcs;
};
T1_Decoder_FuncsRec funcs;
} T1_DecoderRec;
/*************************************************************************/
......@@ -650,10 +661,10 @@ FT_BEGIN_HEADER
typedef struct PSAux_Interface_
{
const PS_Table_Funcs* ps_table_funcs;
const T1_Parser_Funcs* t1_parser_funcs;
const PS_Table_Funcs ps_table_funcs;
const PS_Parser_Funcs ps_parser_funcs;
const T1_Builder_Funcs* t1_builder_funcs;
const T1_Decoder_Funcs* t1_decoder_funcs;
const T1_Decoder_Funcs t1_decoder_funcs;
void
(*t1_decrypt)( FT_Byte* buffer,
......@@ -662,6 +673,7 @@ FT_BEGIN_HEADER
} PSAux_Interface;
typedef PSAux_Interface* PSAux_Service;
FT_END_HEADER
......
......@@ -607,8 +607,9 @@ FT_BEGIN_HEADER
T1_Hints_Funcs (*get_t1_funcs) ( FT_Module module );
T2_Hints_Funcs (*get_t2_funcs) ( FT_Module module );
} PSHinter_Interface, *PSHinter_InterfacePtr;
} PSHinter_Interface;
typedef PSHinter_Interface* PSHinter_Service;
FT_END_HEADER
......
......@@ -226,9 +226,12 @@ FT_BEGIN_HEADER
const unsigned short* adobe_expert_encoding;
PS_Next_Unicode_Func next_unicode;
} PSNames_Interface;
typedef PSNames_Interface* PSNames_Service;
FT_END_HEADER
#endif /* __PSNAMES_H__ */
......
......@@ -522,6 +522,9 @@ FT_BEGIN_HEADER
} SFNT_Interface;
/* transitional */
typedef SFNT_Interface* SFNT_Service;
FT_END_HEADER
#endif /* __SFNT_H__ */
......
......@@ -1101,6 +1101,20 @@ FT_BEGIN_HEADER
} TT_CharMapRec;
typedef const struct TT_CMap_ClassRec_* TT_CMap_Class;
typedef FT_Error (*TT_CMap_ValidateFunc)( FT_Byte* data,
FT_Validator valid );
typedef struct TT_CMap_ClassRec_
{
FT_CMap_ClassRec clazz;
TT_CMap_ValidateFunc validate;
} TT_CMap_ClassRec;
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
......
......@@ -1374,6 +1374,76 @@
}
FT_BASE_DEF( void )
FT_CMap_Done( FT_CMap cmap )
{
if ( cmap )
{
FT_CMap_Class clazz = cmap->clazz;
FT_Face face = cmap->charmap.face;
FT_Memory memory = FT_FACE_MEMORY(face);
if ( clazz->done )
clazz->done( cmap->data );
FREE( cmap );
}
}
FT_BASE_DEF( FT_Error )
FT_CMap_New( FT_CMap_Class clazz,
FT_Pointer data,
FT_CharMap charmap,
FT_CMap *acmap )
{
FT_Error error = 0;
FT_Face face;
FT_Memory memory;
FT_CMap cmap;
if ( clazz == NULL || charmap == NULL || charmap->face == NULL )
return FT_Err_Invalid_Argument;
face = charmap->face;
memory = FT_FACE_MEMORY(face);
if ( !ALLOC( cmap, clazz->size ) )
{
cmap->charmap = *charmap;
cmap->clazz = clazz;
cmap->data = data;
if ( clazz->init )
{
error = clazz->init( cmap, data );
if (error)
goto Fail;
}
/* add it to our list of charmaps */
if ( REALLOC_ARRAY( face->charmaps,
face->num_charmaps,
face->num_charmaps+1,
FT_CharMap* ) )
goto Fail;
face->charmaps[ face->num_charmaps++ ] = (FT_CharMap) cmap;
}
Exit:
if ( acmap )
*acmap = cmap;
return error;
Fail: