From 2589e5fd94a24cc175fa7690cb3dbf16c7844229 Mon Sep 17 00:00:00 2001 From: Oran Agra Date: Sun, 5 Apr 2009 17:34:40 +0300 Subject: [PATCH] Preparing changes in cff parser later needed for PIC version. * src/cff/cffload.c, src/cff/cffload.h, src/cff/cffobjs.c, src/cff/cffparse.c, src/cff/cffparse.h: Add library pointer to 'CFF_ParserRec' set by `cff_parser_init'. Route library pointer from 'cff_face_init' to 'cff_subfont_load' for `cff_parser_init'. * src/cff/cffparse.c (CFF_Field_Handler): Move it to... * src/cff/cffparse.h: This file, to be used by other C files. --- ChangeLog | 13 +++++++++++++ src/cff/cffload.c | 15 +++++++++------ src/cff/cffload.h | 3 ++- src/cff/cffobjs.c | 7 ++++--- src/cff/cffparse.c | 33 +++------------------------------ src/cff/cffparse.h | 35 ++++++++++++++++++++++++++++++++++- 6 files changed, 65 insertions(+), 41 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1a4237a7b..8344e5703 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2009-04-05 Oran Agra + + Preparing changes in cff parser later needed for PIC version. + + * src/cff/cffload.c, src/cff/cffload.h, src/cff/cffobjs.c, + src/cff/cffparse.c, src/cff/cffparse.h: Add library pointer to + 'CFF_ParserRec' set by `cff_parser_init'. + Route library pointer from 'cff_face_init' to 'cff_subfont_load' + for `cff_parser_init'. + + * src/cff/cffparse.c (CFF_Field_Handler): Move it to... + * src/cff/cffparse.h: This file, to be used by other C files. + 2009-04-05 Oran Agra Minor change in ftstroke.c. diff --git a/src/cff/cffload.c b/src/cff/cffload.c index 24b899d17..a2995115e 100644 --- a/src/cff/cffload.c +++ b/src/cff/cffload.c @@ -1267,7 +1267,8 @@ CFF_Index idx, FT_UInt font_index, FT_Stream stream, - FT_ULong base_offset ) + FT_ULong base_offset, + FT_Library library ) { FT_Error error; CFF_ParserRec parser; @@ -1277,7 +1278,7 @@ CFF_Private priv = &font->private_dict; - cff_parser_init( &parser, CFF_CODE_TOPDICT, &font->font_dict ); + cff_parser_init( &parser, CFF_CODE_TOPDICT, &font->font_dict, library ); /* set defaults */ FT_MEM_ZERO( top, sizeof ( *top ) ); @@ -1328,7 +1329,7 @@ priv->expansion_factor = (FT_Fixed)( 0.06 * 0x10000L ); priv->blue_scale = (FT_Fixed)( 0.039625 * 0x10000L * 1000 ); - cff_parser_init( &parser, CFF_CODE_PRIVATE, priv ); + cff_parser_init( &parser, CFF_CODE_PRIVATE, priv, library ); if ( FT_STREAM_SEEK( base_offset + font->font_dict.private_offset ) || FT_FRAME_ENTER( font->font_dict.private_size ) ) @@ -1381,7 +1382,8 @@ FT_LOCAL_DEF( FT_Error ) - cff_font_load( FT_Stream stream, + cff_font_load( FT_Library library, + FT_Stream stream, FT_Int face_index, CFF_Font font, FT_Bool pure_cff ) @@ -1459,7 +1461,8 @@ &font->font_dict_index, face_index, stream, - base_offset ); + base_offset, + library ); if ( error ) goto Exit; @@ -1507,7 +1510,7 @@ { sub = font->subfonts[idx]; error = cff_subfont_load( sub, &fd_index, idx, - stream, base_offset ); + stream, base_offset, library ); if ( error ) goto Fail_CID; } diff --git a/src/cff/cffload.h b/src/cff/cffload.h index 02498bd5e..2b313acf0 100644 --- a/src/cff/cffload.h +++ b/src/cff/cffload.h @@ -58,7 +58,8 @@ FT_BEGIN_HEADER FT_LOCAL( FT_Error ) - cff_font_load( FT_Stream stream, + cff_font_load( FT_Library library, + FT_Stream stream, FT_Int face_index, CFF_Font font, FT_Bool pure_cff ); diff --git a/src/cff/cffobjs.c b/src/cff/cffobjs.c index 3525ea3b7..e8ac483ad 100644 --- a/src/cff/cffobjs.c +++ b/src/cff/cffobjs.c @@ -408,6 +408,7 @@ PSHinter_Service pshinter; FT_Bool pure_cff = 1; FT_Bool sfnt_format = 0; + FT_Library library = cffface->driver->root.library; #if 0 @@ -419,14 +420,14 @@ goto Bad_Format; #else sfnt = (SFNT_Service)FT_Get_Module_Interface( - cffface->driver->root.library, "sfnt" ); + library, "sfnt" ); if ( !sfnt ) goto Bad_Format; FT_FACE_FIND_GLOBAL_SERVICE( face, psnames, POSTSCRIPT_CMAPS ); pshinter = (PSHinter_Service)FT_Get_Module_Interface( - cffface->driver->root.library, "pshinter" ); + library, "pshinter" ); #endif /* create input stream from resource */ @@ -507,7 +508,7 @@ goto Exit; face->extra.data = cff; - error = cff_font_load( stream, face_index, cff, pure_cff ); + error = cff_font_load( library, stream, face_index, cff, pure_cff ); if ( error ) goto Exit; diff --git a/src/cff/cffparse.c b/src/cff/cffparse.c index 290595f9e..0b316f160 100644 --- a/src/cff/cffparse.c +++ b/src/cff/cffparse.c @@ -34,47 +34,20 @@ #define FT_COMPONENT trace_cffparse - enum - { - cff_kind_none = 0, - cff_kind_num, - cff_kind_fixed, - cff_kind_fixed_thousand, - cff_kind_string, - cff_kind_bool, - cff_kind_delta, - cff_kind_callback, - - cff_kind_max /* do not remove */ - }; - - - /* now generate handlers for the most simple fields */ - typedef FT_Error (*CFF_Field_Reader)( CFF_Parser parser ); - - typedef struct CFF_Field_Handler_ - { - int kind; - int code; - FT_UInt offset; - FT_Byte size; - CFF_Field_Reader reader; - FT_UInt array_max; - FT_UInt count_offset; - - } CFF_Field_Handler; FT_LOCAL_DEF( void ) cff_parser_init( CFF_Parser parser, FT_UInt code, - void* object ) + void* object, + FT_Library library) { FT_MEM_ZERO( parser, sizeof ( *parser ) ); parser->top = parser->stack; parser->object_code = code; parser->object = object; + parser->library = library; } diff --git a/src/cff/cffparse.h b/src/cff/cffparse.h index 8f3fa5885..7e2c00a04 100644 --- a/src/cff/cffparse.h +++ b/src/cff/cffparse.h @@ -36,6 +36,7 @@ FT_BEGIN_HEADER typedef struct CFF_ParserRec_ { + FT_Library library; FT_Byte* start; FT_Byte* limit; FT_Byte* cursor; @@ -52,7 +53,8 @@ FT_BEGIN_HEADER FT_LOCAL( void ) cff_parser_init( CFF_Parser parser, FT_UInt code, - void* object ); + void* object, + FT_Library library); FT_LOCAL( FT_Error ) cff_parser_run( CFF_Parser parser, @@ -60,6 +62,37 @@ FT_BEGIN_HEADER FT_Byte* limit ); + enum + { + cff_kind_none = 0, + cff_kind_num, + cff_kind_fixed, + cff_kind_fixed_thousand, + cff_kind_string, + cff_kind_bool, + cff_kind_delta, + cff_kind_callback, + + cff_kind_max /* do not remove */ + }; + + + /* now generate handlers for the most simple fields */ + typedef FT_Error (*CFF_Field_Reader)( CFF_Parser parser ); + + typedef struct CFF_Field_Handler_ + { + int kind; + int code; + FT_UInt offset; + FT_Byte size; + CFF_Field_Reader reader; + FT_UInt array_max; + FT_UInt count_offset; + + } CFF_Field_Handler; + + FT_END_HEADER