From 727dee178a392d20eb050d0c446f2fcc29058fa1 Mon Sep 17 00:00:00 2001 From: Victoria Lease Date: Mon, 10 Jun 2013 13:55:54 -0700 Subject: Update freetype to 5e094c6fb2ddd6e8901a5679e2cbb8fa476a38ee Integrated patches from freetype2 git repository, up to hashval 5e094c6fb2ddd6e8901a5679e2cbb8fa476a38ee, which is post-2.4.12. Most recent commit message from freetype git: [truetype] Improve handling of broken sbit advance widths. Noteworthy patches included: [cff] Add a new Type 2 interpreter and hinter. Add support for color embedded bitmaps (eg. color emoji). Change-Id: Ia8b6a67bc18f841b24f44edf80f81f663185b598 --- src/sfnt/sfdriver.c | 318 +++++++++++++++------------------------------------- 1 file changed, 90 insertions(+), 228 deletions(-) (limited to 'src/sfnt/sfdriver.c') diff --git a/src/sfnt/sfdriver.c b/src/sfnt/sfdriver.c index 847d83d..a368b8c 100644 --- a/src/sfnt/sfdriver.c +++ b/src/sfnt/sfdriver.c @@ -4,7 +4,7 @@ /* */ /* High-level SFNT driver interface (body). */ /* */ -/* Copyright 1996-2007, 2009-2011 by */ +/* Copyright 1996-2007, 2009-2013 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -50,6 +50,7 @@ #include FT_SERVICE_SFNT_H #include FT_SERVICE_TT_CMAP_H + /*************************************************************************/ /* */ /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ @@ -60,10 +61,10 @@ #define FT_COMPONENT trace_sfdriver - /* - * SFNT TABLE SERVICE - * - */ + /* + * SFNT TABLE SERVICE + * + */ static void* get_sfnt_table( TT_Face face, @@ -118,37 +119,37 @@ FT_ULong *length ) { if ( !offset || !length ) - return SFNT_Err_Invalid_Argument; + return FT_THROW( Invalid_Argument ); if ( !tag ) *length = face->num_tables; else { if ( idx >= face->num_tables ) - return SFNT_Err_Table_Missing; + return FT_THROW( Table_Missing ); *tag = face->dir_tables[idx].Tag; *offset = face->dir_tables[idx].Offset; *length = face->dir_tables[idx].Length; } - return SFNT_Err_Ok; + return FT_Err_Ok; } - FT_DEFINE_SERVICE_SFNT_TABLEREC(sfnt_service_sfnt_table, + FT_DEFINE_SERVICE_SFNT_TABLEREC( + sfnt_service_sfnt_table, (FT_SFNT_TableLoadFunc)tt_face_load_any, (FT_SFNT_TableGetFunc) get_sfnt_table, - (FT_SFNT_TableInfoFunc)sfnt_table_info - ) + (FT_SFNT_TableInfoFunc)sfnt_table_info ) #ifdef TT_CONFIG_OPTION_POSTSCRIPT_NAMES - /* - * GLYPH DICT SERVICE - * - */ + /* + * GLYPH DICT SERVICE + * + */ static FT_Error sfnt_get_glyph_name( TT_Face face, @@ -172,17 +173,18 @@ sfnt_get_name_index( TT_Face face, FT_String* glyph_name ) { - FT_Face root = &face->root; - FT_UInt i, max_gid = FT_UINT_MAX; + FT_Face root = &face->root; + + FT_UInt i, max_gid = FT_UINT_MAX; if ( root->num_glyphs < 0 ) return 0; - else if ( ( FT_ULong ) root->num_glyphs < FT_UINT_MAX ) - max_gid = ( FT_UInt ) root->num_glyphs; + else if ( (FT_ULong)root->num_glyphs < FT_UINT_MAX ) + max_gid = (FT_UInt)root->num_glyphs; else FT_TRACE0(( "Ignore glyph names for invalid GID 0x%08x - 0x%08x\n", - FT_UINT_MAX, root->num_glyphs )); + FT_UINT_MAX, root->num_glyphs )); for ( i = 0; i < max_gid; i++ ) { @@ -201,18 +203,19 @@ } - FT_DEFINE_SERVICE_GLYPHDICTREC(sfnt_service_glyph_dict, + FT_DEFINE_SERVICE_GLYPHDICTREC( + sfnt_service_glyph_dict, (FT_GlyphDict_GetNameFunc) sfnt_get_glyph_name, - (FT_GlyphDict_NameIndexFunc)sfnt_get_name_index - ) + (FT_GlyphDict_NameIndexFunc)sfnt_get_name_index ) + #endif /* TT_CONFIG_OPTION_POSTSCRIPT_NAMES */ - /* - * POSTSCRIPT NAME SERVICE - * - */ + /* + * POSTSCRIPT NAME SERVICE + * + */ static const char* sfnt_get_ps_name( TT_Face face ) @@ -254,7 +257,7 @@ FT_Memory memory = face->root.memory; TT_NameEntryRec* name = face->name_table.names + found_win; FT_UInt len = name->stringLength / 2; - FT_Error error = SFNT_Err_Ok; + FT_Error error = FT_Err_Ok; FT_UNUSED( error ); @@ -296,7 +299,7 @@ FT_Memory memory = face->root.memory; TT_NameEntryRec* name = face->name_table.names + found_apple; FT_UInt len = name->stringLength; - FT_Error error = SFNT_Err_Ok; + FT_Error error = FT_Err_Ok; FT_UNUSED( error ); @@ -324,17 +327,18 @@ return result; } - FT_DEFINE_SERVICE_PSFONTNAMEREC(sfnt_service_ps_name, - (FT_PsName_GetFunc)sfnt_get_ps_name - ) + + FT_DEFINE_SERVICE_PSFONTNAMEREC( + sfnt_service_ps_name, + (FT_PsName_GetFunc)sfnt_get_ps_name ) /* * TT CMAP INFO */ - FT_DEFINE_SERVICE_TTCMAPSREC(tt_service_get_cmap_info, - (TT_CMap_Info_GetFunc)tt_get_cmap_info - ) + FT_DEFINE_SERVICE_TTCMAPSREC( + tt_service_get_cmap_info, + (TT_CMap_Info_GetFunc)tt_get_cmap_info ) #ifdef TT_CONFIG_OPTION_BDF @@ -367,7 +371,7 @@ *acharset_registry = registry.u.atom; } else - error = SFNT_Err_Invalid_Argument; + error = FT_THROW( Invalid_Argument ); } } @@ -375,10 +379,11 @@ } - FT_DEFINE_SERVICE_BDFRec(sfnt_service_bdf, - (FT_BDF_GetCharsetIdFunc) sfnt_get_charset_id, - (FT_BDF_GetPropertyFunc) tt_face_find_bdf_prop - ) + FT_DEFINE_SERVICE_BDFRec( + sfnt_service_bdf, + (FT_BDF_GetCharsetIdFunc)sfnt_get_charset_id, + (FT_BDF_GetPropertyFunc) tt_face_find_bdf_prop ) + #endif /* TT_CONFIG_OPTION_BDF */ @@ -388,33 +393,33 @@ */ #if defined TT_CONFIG_OPTION_POSTSCRIPT_NAMES && defined TT_CONFIG_OPTION_BDF - FT_DEFINE_SERVICEDESCREC5(sfnt_services, - FT_SERVICE_ID_SFNT_TABLE, &FT_SFNT_SERVICE_SFNT_TABLE_GET, - FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &FT_SFNT_SERVICE_PS_NAME_GET, - FT_SERVICE_ID_GLYPH_DICT, &FT_SFNT_SERVICE_GLYPH_DICT_GET, - FT_SERVICE_ID_BDF, &FT_SFNT_SERVICE_BDF_GET, - FT_SERVICE_ID_TT_CMAP, &FT_TT_SERVICE_GET_CMAP_INFO_GET - ) + FT_DEFINE_SERVICEDESCREC5( + sfnt_services, + FT_SERVICE_ID_SFNT_TABLE, &SFNT_SERVICE_SFNT_TABLE_GET, + FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &SFNT_SERVICE_PS_NAME_GET, + FT_SERVICE_ID_GLYPH_DICT, &SFNT_SERVICE_GLYPH_DICT_GET, + FT_SERVICE_ID_BDF, &SFNT_SERVICE_BDF_GET, + FT_SERVICE_ID_TT_CMAP, &TT_SERVICE_CMAP_INFO_GET ) #elif defined TT_CONFIG_OPTION_POSTSCRIPT_NAMES - FT_DEFINE_SERVICEDESCREC4(sfnt_services, - FT_SERVICE_ID_SFNT_TABLE, &FT_SFNT_SERVICE_SFNT_TABLE_GET, - FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &FT_SFNT_SERVICE_PS_NAME_GET, - FT_SERVICE_ID_GLYPH_DICT, &FT_SFNT_SERVICE_GLYPH_DICT_GET, - FT_SERVICE_ID_TT_CMAP, &FT_TT_SERVICE_GET_CMAP_INFO_GET - ) + FT_DEFINE_SERVICEDESCREC4( + sfnt_services, + FT_SERVICE_ID_SFNT_TABLE, &SFNT_SERVICE_SFNT_TABLE_GET, + FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &SFNT_SERVICE_PS_NAME_GET, + FT_SERVICE_ID_GLYPH_DICT, &SFNT_SERVICE_GLYPH_DICT_GET, + FT_SERVICE_ID_TT_CMAP, &TT_SERVICE_CMAP_INFO_GET ) #elif defined TT_CONFIG_OPTION_BDF - FT_DEFINE_SERVICEDESCREC4(sfnt_services, - FT_SERVICE_ID_SFNT_TABLE, &FT_SFNT_SERVICE_SFNT_TABLE_GET, - FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &FT_SFNT_SERVICE_PS_NAME_GET, - FT_SERVICE_ID_BDF, &FT_SFNT_SERVICE_BDF_GET, - FT_SERVICE_ID_TT_CMAP, &FT_TT_SERVICE_GET_CMAP_INFO_GET - ) + FT_DEFINE_SERVICEDESCREC4( + sfnt_services, + FT_SERVICE_ID_SFNT_TABLE, &SFNT_SERVICE_SFNT_TABLE_GET, + FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &SFNT_SERVICE_PS_NAME_GET, + FT_SERVICE_ID_BDF, &SFNT_SERVICE_BDF_GET, + FT_SERVICE_ID_TT_CMAP, &TT_SERVICE_CMAP_INFO_GET ) #else - FT_DEFINE_SERVICEDESCREC3(sfnt_services, - FT_SERVICE_ID_SFNT_TABLE, &FT_SFNT_SERVICE_SFNT_TABLE_GET, - FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &FT_SFNT_SERVICE_PS_NAME_GET, - FT_SERVICE_ID_TT_CMAP, &FT_TT_SERVICE_GET_CMAP_INFO_GET - ) + FT_DEFINE_SERVICEDESCREC3( + sfnt_services, + FT_SERVICE_ID_SFNT_TABLE, &SFNT_SERVICE_SFNT_TABLE_GET, + FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &SFNT_SERVICE_PS_NAME_GET, + FT_SERVICE_ID_TT_CMAP, &TT_SERVICE_CMAP_INFO_GET ) #endif @@ -422,7 +427,7 @@ sfnt_get_interface( FT_Module module, const char* module_interface ) { - /* FT_SFNT_SERVICES_GET derefers `library' in PIC mode */ + /* SFNT_SERVICES_GET derefers `library' in PIC mode */ #ifdef FT_CONFIG_OPTION_PIC FT_Library library; @@ -435,149 +440,25 @@ #else FT_UNUSED( module ); #endif - return ft_service_list_lookup( FT_SFNT_SERVICES_GET, module_interface ); - } - - -#ifdef FT_CONFIG_OPTION_OLD_INTERNALS - - FT_CALLBACK_DEF( FT_Error ) - tt_face_load_sfnt_header_stub( TT_Face face, - FT_Stream stream, - FT_Long face_index, - SFNT_Header header ) - { - FT_UNUSED( face ); - FT_UNUSED( stream ); - FT_UNUSED( face_index ); - FT_UNUSED( header ); - - return SFNT_Err_Unimplemented_Feature; - } - - - FT_CALLBACK_DEF( FT_Error ) - tt_face_load_directory_stub( TT_Face face, - FT_Stream stream, - SFNT_Header header ) - { - FT_UNUSED( face ); - FT_UNUSED( stream ); - FT_UNUSED( header ); - - return SFNT_Err_Unimplemented_Feature; - } - - - FT_CALLBACK_DEF( FT_Error ) - tt_face_load_hdmx_stub( TT_Face face, - FT_Stream stream ) - { - FT_UNUSED( face ); - FT_UNUSED( stream ); - - return SFNT_Err_Unimplemented_Feature; - } - - - FT_CALLBACK_DEF( void ) - tt_face_free_hdmx_stub( TT_Face face ) - { - FT_UNUSED( face ); - } - - - FT_CALLBACK_DEF( FT_Error ) - tt_face_set_sbit_strike_stub( TT_Face face, - FT_UInt x_ppem, - FT_UInt y_ppem, - FT_ULong* astrike_index ) - { - /* - * We simply forge a FT_Size_Request and call the real function - * that does all the work. - * - * This stub might be called by libXfont in the X.Org Xserver, - * compiled against version 2.1.8 or newer. - */ - - FT_Size_RequestRec req; - - - req.type = FT_SIZE_REQUEST_TYPE_NOMINAL; - req.width = (FT_F26Dot6)x_ppem; - req.height = (FT_F26Dot6)y_ppem; - req.horiResolution = 0; - req.vertResolution = 0; - - *astrike_index = 0x7FFFFFFFUL; - return tt_face_set_sbit_strike( face, &req, astrike_index ); + return ft_service_list_lookup( SFNT_SERVICES_GET, module_interface ); } - FT_CALLBACK_DEF( FT_Error ) - tt_face_load_sbit_stub( TT_Face face, - FT_Stream stream ) - { - FT_UNUSED( face ); - FT_UNUSED( stream ); - - /* - * This function was originally implemented to load the sbit table. - * However, it has been replaced by `tt_face_load_eblc', and this stub - * is only there for some rogue clients which would want to call it - * directly (which doesn't make much sense). - */ - return SFNT_Err_Unimplemented_Feature; - } - - - FT_CALLBACK_DEF( void ) - tt_face_free_sbit_stub( TT_Face face ) - { - /* nothing to do in this stub */ - FT_UNUSED( face ); - } - - - FT_CALLBACK_DEF( FT_Error ) - tt_face_load_charmap_stub( TT_Face face, - void* cmap, - FT_Stream input ) - { - FT_UNUSED( face ); - FT_UNUSED( cmap ); - FT_UNUSED( input ); - - return SFNT_Err_Unimplemented_Feature; - } - - - FT_CALLBACK_DEF( FT_Error ) - tt_face_free_charmap_stub( TT_Face face, - void* cmap ) - { - FT_UNUSED( face ); - FT_UNUSED( cmap ); - - return SFNT_Err_Ok; - } - -#endif /* FT_CONFIG_OPTION_OLD_INTERNALS */ - #ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS -#define PUT_EMBEDDED_BITMAPS(a) a +#define PUT_EMBEDDED_BITMAPS( a ) a #else -#define PUT_EMBEDDED_BITMAPS(a) 0 +#define PUT_EMBEDDED_BITMAPS( a ) NULL #endif + #ifdef TT_CONFIG_OPTION_POSTSCRIPT_NAMES -#define PUT_PS_NAMES(a) a +#define PUT_PS_NAMES( a ) a #else -#define PUT_PS_NAMES(a) 0 +#define PUT_PS_NAMES( a ) NULL #endif - FT_DEFINE_SFNT_INTERFACE(sfnt_interface, + FT_DEFINE_SFNT_INTERFACE( + sfnt_interface, tt_face_goto_table, sfnt_init_face, @@ -587,9 +468,6 @@ tt_face_load_any, - tt_face_load_sfnt_header_stub, /* FT_CONFIG_OPTION_OLD_INTERNALS */ - tt_face_load_directory_stub, /* FT_CONFIG_OPTION_OLD_INTERNALS */ - tt_face_load_head, tt_face_load_hhea, tt_face_load_cmap, @@ -600,54 +478,39 @@ tt_face_load_name, tt_face_free_name, - tt_face_load_hdmx_stub, /* FT_CONFIG_OPTION_OLD_INTERNALS */ - tt_face_free_hdmx_stub, /* FT_CONFIG_OPTION_OLD_INTERNALS */ - tt_face_load_kern, tt_face_load_gasp, tt_face_load_pclt, /* see `ttload.h' */ - PUT_EMBEDDED_BITMAPS(tt_face_load_bhed), - - tt_face_set_sbit_strike_stub, /* FT_CONFIG_OPTION_OLD_INTERNALS */ - tt_face_load_sbit_stub, /* FT_CONFIG_OPTION_OLD_INTERNALS */ - - tt_find_sbit_image, /* FT_CONFIG_OPTION_OLD_INTERNALS */ - tt_load_sbit_metrics, /* FT_CONFIG_OPTION_OLD_INTERNALS */ - - PUT_EMBEDDED_BITMAPS(tt_face_load_sbit_image), + PUT_EMBEDDED_BITMAPS( tt_face_load_bhed ), - tt_face_free_sbit_stub, /* FT_CONFIG_OPTION_OLD_INTERNALS */ + PUT_EMBEDDED_BITMAPS( tt_face_load_sbit_image ), /* see `ttpost.h' */ - PUT_PS_NAMES(tt_face_get_ps_name), - PUT_PS_NAMES(tt_face_free_ps_names), - - tt_face_load_charmap_stub, /* FT_CONFIG_OPTION_OLD_INTERNALS */ - tt_face_free_charmap_stub, /* FT_CONFIG_OPTION_OLD_INTERNALS */ + PUT_PS_NAMES( tt_face_get_ps_name ), + PUT_PS_NAMES( tt_face_free_ps_names ), /* since version 2.1.8 */ - tt_face_get_kerning, /* since version 2.2 */ - tt_face_load_font_dir, tt_face_load_hmtx, /* see `ttsbit.h' and `sfnt.h' */ - PUT_EMBEDDED_BITMAPS(tt_face_load_eblc), - PUT_EMBEDDED_BITMAPS(tt_face_free_eblc), + PUT_EMBEDDED_BITMAPS( tt_face_load_eblc ), + PUT_EMBEDDED_BITMAPS( tt_face_free_eblc ), - PUT_EMBEDDED_BITMAPS(tt_face_set_sbit_strike), - PUT_EMBEDDED_BITMAPS(tt_face_load_strike_metrics), + PUT_EMBEDDED_BITMAPS( tt_face_set_sbit_strike ), + PUT_EMBEDDED_BITMAPS( tt_face_load_strike_metrics ), tt_face_get_metrics ) - FT_DEFINE_MODULE(sfnt_module_class, + FT_DEFINE_MODULE( + sfnt_module_class, 0, /* not a font driver or renderer */ sizeof ( FT_ModuleRec ), @@ -656,12 +519,11 @@ 0x10000L, /* driver version 1.0 */ 0x20000L, /* driver requires FreeType 2.0 or higher */ - (const void*)&FT_SFNT_INTERFACE_GET, /* module specific interface */ + (const void*)&SFNT_INTERFACE_GET, /* module specific interface */ (FT_Module_Constructor)0, (FT_Module_Destructor) 0, - (FT_Module_Requester) sfnt_get_interface - ) + (FT_Module_Requester) sfnt_get_interface ) /* END */ -- cgit v1.2.3