From 27a4f9c4ac45ff65f941964f7351b64b1e6a9f35 Mon Sep 17 00:00:00 2001 From: scuri Date: Tue, 20 Oct 2009 17:20:18 +0000 Subject: *** empty log message *** --- src/freetype2/psnames/psmodule.c | 220 +++++++++++++++++++++++++++++++-------- src/freetype2/psnames/psmodule.h | 2 +- src/freetype2/psnames/psnames.c | 1 + src/freetype2/psnames/pspic.c | 77 ++++++++++++++ src/freetype2/psnames/pspic.h | 54 ++++++++++ src/freetype2/psnames/pstables.h | 9 +- 6 files changed, 319 insertions(+), 44 deletions(-) create mode 100644 src/freetype2/psnames/pspic.c create mode 100644 src/freetype2/psnames/pspic.h (limited to 'src/freetype2/psnames') diff --git a/src/freetype2/psnames/psmodule.c b/src/freetype2/psnames/psmodule.c index 8d8c476..3518850 100644 --- a/src/freetype2/psnames/psmodule.c +++ b/src/freetype2/psnames/psmodule.c @@ -4,7 +4,7 @@ /* */ /* PSNames module implementation (body). */ /* */ -/* Copyright 1996-2001, 2002, 2003, 2005, 2006, 2007 by */ +/* Copyright 1996-2001, 2002, 2003, 2005, 2006, 2007, 2008 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -24,16 +24,17 @@ #include "pstables.h" #include "psnamerr.h" +#include "pspic.h" -#ifndef FT_CONFIG_OPTION_NO_POSTSCRIPT_NAMES +#ifdef FT_CONFIG_OPTION_POSTSCRIPT_NAMES #ifdef FT_CONFIG_OPTION_ADOBE_GLYPH_LIST #define VARIANT_BIT 0x80000000UL -#define BASE_GLYPH( code ) ( (code) & ~VARIANT_BIT ) +#define BASE_GLYPH( code ) ( (FT_UInt32)( (code) & ~VARIANT_BIT ) ) /* Return the Unicode value corresponding to a given glyph. Note that */ @@ -57,7 +58,7 @@ /* `uniXXXXYYYYZZZZ'... */ FT_Int count; - FT_ULong value = 0; + FT_UInt32 value = 0; const char* p = glyph_name + 3; @@ -92,7 +93,7 @@ if ( *p == '\0' ) return value; if ( *p == '.' ) - return value | VARIANT_BIT; + return (FT_UInt32)( value | VARIANT_BIT ); } } @@ -101,7 +102,7 @@ if ( glyph_name[0] == 'u' ) { FT_Int count; - FT_ULong value = 0; + FT_UInt32 value = 0; const char* p = glyph_name + 1; @@ -132,7 +133,7 @@ if ( *p == '\0' ) return value; if ( *p == '.' ) - return value | VARIANT_BIT; + return (FT_UInt32)( value | VARIANT_BIT ); } } @@ -154,9 +155,10 @@ /* now look up the glyph in the Adobe Glyph List */ if ( !dot ) - return ft_get_adobe_glyph_index( glyph_name, p ); + return (FT_UInt32)ft_get_adobe_glyph_index( glyph_name, p ); else - return ft_get_adobe_glyph_index( glyph_name, dot ) | VARIANT_BIT; + return (FT_UInt32)( ft_get_adobe_glyph_index( glyph_name, dot ) | + VARIANT_BIT ); } } @@ -174,9 +176,121 @@ /* sort base glyphs before glyph variants */ if ( unicode1 == unicode2 ) - return map1->unicode - map2->unicode; + { + if ( map1->unicode > map2->unicode ) + return 1; + else if ( map1->unicode < map2->unicode ) + return -1; + else + return 0; + } else - return unicode1 - unicode2; + { + if ( unicode1 > unicode2 ) + return 1; + else if ( unicode1 < unicode2 ) + return -1; + else + return 0; + } + } + + + /* support for extra glyphs not handled (well) in AGL; */ + /* we add extra mappings for them if necessary */ + +#define EXTRA_GLYPH_LIST_SIZE 10 + + static const FT_UInt32 ft_extra_glyph_unicodes[EXTRA_GLYPH_LIST_SIZE] = + { + /* WGL 4 */ + 0x0394, + 0x03A9, + 0x2215, + 0x00AD, + 0x02C9, + 0x03BC, + 0x2219, + 0x00A0, + /* Romanian */ + 0x021A, + 0x021B + }; + + static const char ft_extra_glyph_names[] = + { + 'D','e','l','t','a',0, + 'O','m','e','g','a',0, + 'f','r','a','c','t','i','o','n',0, + 'h','y','p','h','e','n',0, + 'm','a','c','r','o','n',0, + 'm','u',0, + 'p','e','r','i','o','d','c','e','n','t','e','r','e','d',0, + 's','p','a','c','e',0, + 'T','c','o','m','m','a','a','c','c','e','n','t',0, + 't','c','o','m','m','a','a','c','c','e','n','t',0 + }; + + static const FT_Int + ft_extra_glyph_name_offsets[EXTRA_GLYPH_LIST_SIZE] = + { + 0, + 6, + 12, + 21, + 28, + 35, + 38, + 53, + 59, + 72 + }; + + + static void + ps_check_extra_glyph_name( const char* gname, + FT_UInt glyph, + FT_UInt* extra_glyphs, + FT_UInt *states ) + { + FT_UInt n; + + + for ( n = 0; n < EXTRA_GLYPH_LIST_SIZE; n++ ) + { + if ( ft_strcmp( ft_extra_glyph_names + + ft_extra_glyph_name_offsets[n], gname ) == 0 ) + { + if ( states[n] == 0 ) + { + /* mark this extra glyph as a candidate for the cmap */ + states[n] = 1; + extra_glyphs[n] = glyph; + } + + return; + } + } + } + + + static void + ps_check_extra_glyph_unicode( FT_UInt32 uni_char, + FT_UInt *states ) + { + FT_UInt n; + + + for ( n = 0; n < EXTRA_GLYPH_LIST_SIZE; n++ ) + { + if ( uni_char == ft_extra_glyph_unicodes[n] ) + { + /* disable this extra glyph from being added to the cmap */ + states[n] = 2; + + return; + } + } } @@ -191,12 +305,15 @@ { FT_Error error; + FT_UInt extra_glyph_list_states[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + FT_UInt extra_glyphs[EXTRA_GLYPH_LIST_SIZE]; + /* we first allocate the table */ table->num_maps = 0; table->maps = 0; - if ( !FT_NEW_ARRAY( table->maps, num_glyphs ) ) + if ( !FT_NEW_ARRAY( table->maps, num_glyphs + EXTRA_GLYPH_LIST_SIZE ) ) { FT_UInt n; FT_UInt count; @@ -213,10 +330,14 @@ if ( gname ) { + ps_check_extra_glyph_name( gname, n, + extra_glyphs, extra_glyph_list_states ); uni_char = ps_unicode_value( gname ); if ( BASE_GLYPH( uni_char ) != 0 ) { + ps_check_extra_glyph_unicode( uni_char, + extra_glyph_list_states ); map->unicode = uni_char; map->glyph_index = n; map++; @@ -227,6 +348,19 @@ } } + for ( n = 0; n < EXTRA_GLYPH_LIST_SIZE; n++ ) + { + if ( extra_glyph_list_states[n] == 1 ) + { + /* This glyph name has an additional representation. */ + /* Add it to the cmap. */ + + map->unicode = ft_extra_glyph_unicodes[n]; + map->glyph_index = extra_glyphs[n]; + map++; + } + } + /* now compress the table a bit */ count = (FT_UInt)( map - table->maps ); @@ -303,7 +437,7 @@ } - static FT_ULong + static FT_UInt32 ps_unicodes_char_next( PS_Unicodes table, FT_UInt32 *unicode ) { @@ -384,56 +518,66 @@ } - static - const FT_Service_PsCMapsRec pscmaps_interface = - { #ifdef FT_CONFIG_OPTION_ADOBE_GLYPH_LIST - + FT_DEFINE_SERVICE_PSCMAPSREC(pscmaps_interface, (PS_Unicode_ValueFunc) ps_unicode_value, (PS_Unicodes_InitFunc) ps_unicodes_init, (PS_Unicodes_CharIndexFunc)ps_unicodes_char_index, (PS_Unicodes_CharNextFunc) ps_unicodes_char_next, + (PS_Macintosh_NameFunc) ps_get_macintosh_name, + (PS_Adobe_Std_StringsFunc) ps_get_standard_strings, + + t1_standard_encoding, + t1_expert_encoding + ) + #else + FT_DEFINE_SERVICE_PSCMAPSREC(pscmaps_interface, 0, 0, 0, 0, -#endif /* FT_CONFIG_OPTION_ADOBE_GLYPH_LIST */ - (PS_Macintosh_NameFunc) ps_get_macintosh_name, (PS_Adobe_Std_StringsFunc) ps_get_standard_strings, t1_standard_encoding, t1_expert_encoding - }; + ) + +#endif /* FT_CONFIG_OPTION_ADOBE_GLYPH_LIST */ + + + FT_DEFINE_SERVICEDESCREC1(pscmaps_services, + FT_SERVICE_ID_POSTSCRIPT_CMAPS, &FT_PSCMAPS_INTERFACE_GET + ) - static const FT_ServiceDescRec pscmaps_services[] = - { - { FT_SERVICE_ID_POSTSCRIPT_CMAPS, &pscmaps_interface }, - { NULL, NULL } - }; static FT_Pointer psnames_get_service( FT_Module module, const char* service_id ) { - FT_UNUSED( module ); + FT_Library library = module->library; + FT_UNUSED(library); - return ft_service_list_lookup( pscmaps_services, service_id ); + return ft_service_list_lookup( FT_PSCMAPS_SERVICES_GET, service_id ); } -#endif /* !FT_CONFIG_OPTION_NO_POSTSCRIPT_NAMES */ +#endif /* FT_CONFIG_OPTION_POSTSCRIPT_NAMES */ +#ifndef FT_CONFIG_OPTION_POSTSCRIPT_NAMES +#define PUT_PS_NAMES_SERVICE(a) 0 +#else +#define PUT_PS_NAMES_SERVICE(a) a +#endif - FT_CALLBACK_TABLE_DEF - const FT_Module_Class psnames_module_class = - { + FT_DEFINE_MODULE(psnames_module_class, + 0, /* this is not a font driver, nor a renderer */ sizeof ( FT_ModuleRec ), @@ -441,18 +585,12 @@ 0x10000L, /* driver version */ 0x20000L, /* driver requires FreeType 2 or above */ -#ifdef FT_CONFIG_OPTION_NO_POSTSCRIPT_NAMES - 0, + PUT_PS_NAMES_SERVICE((void*)&FT_PSCMAPS_INTERFACE_GET), /* module specific interface */ (FT_Module_Constructor)0, (FT_Module_Destructor) 0, - (FT_Module_Requester) 0 -#else - (void*)&pscmaps_interface, /* module specific interface */ - (FT_Module_Constructor)0, - (FT_Module_Destructor) 0, - (FT_Module_Requester) psnames_get_service -#endif - }; + (FT_Module_Requester) PUT_PS_NAMES_SERVICE(psnames_get_service) + ) + /* END */ diff --git a/src/freetype2/psnames/psmodule.h b/src/freetype2/psnames/psmodule.h index 232fdfb..28fa148 100644 --- a/src/freetype2/psnames/psmodule.h +++ b/src/freetype2/psnames/psmodule.h @@ -27,7 +27,7 @@ FT_BEGIN_HEADER - FT_EXPORT_VAR( const FT_Module_Class ) psnames_module_class; + FT_DECLARE_MODULE( psnames_module_class ) FT_END_HEADER diff --git a/src/freetype2/psnames/psnames.c b/src/freetype2/psnames/psnames.c index d6ed998..1ede225 100644 --- a/src/freetype2/psnames/psnames.c +++ b/src/freetype2/psnames/psnames.c @@ -19,6 +19,7 @@ #define FT_MAKE_OPTION_SINGLE_OBJECT #include +#include "pspic.c" #include "psmodule.c" diff --git a/src/freetype2/psnames/pspic.c b/src/freetype2/psnames/pspic.c new file mode 100644 index 0000000..ed7dadd --- /dev/null +++ b/src/freetype2/psnames/pspic.c @@ -0,0 +1,77 @@ +/***************************************************************************/ +/* */ +/* pspic.c */ +/* */ +/* The FreeType position independent code services for psnames module. */ +/* */ +/* Copyright 2009 by */ +/* Oran Agra and Mickey Gabel. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + +#include +#include FT_FREETYPE_H +#include FT_INTERNAL_OBJECTS_H +#include "pspic.h" + +#ifdef FT_CONFIG_OPTION_PIC + + /* forward declaration of PIC init functions from psmodule.c */ + FT_Error FT_Create_Class_pscmaps_services( FT_Library, FT_ServiceDescRec**); + void FT_Destroy_Class_pscmaps_services( FT_Library, FT_ServiceDescRec*); + void FT_Init_Class_pscmaps_interface( FT_Library, FT_Service_PsCMapsRec*); + + void + psnames_module_class_pic_free( FT_Library library ) + { + FT_PIC_Container* pic_container = &library->pic_container; + FT_Memory memory = library->memory; + if ( pic_container->psnames ) + { + PSModulePIC* container = (PSModulePIC*)pic_container->psnames; + if(container->pscmaps_services) + FT_Destroy_Class_pscmaps_services(library, container->pscmaps_services); + container->pscmaps_services = NULL; + FT_FREE( container ); + pic_container->psnames = NULL; + } + } + + FT_Error + psnames_module_class_pic_init( FT_Library library ) + { + FT_PIC_Container* pic_container = &library->pic_container; + FT_Error error = FT_Err_Ok; + PSModulePIC* container; + FT_Memory memory = library->memory; + + /* allocate pointer, clear and set global container pointer */ + if ( FT_ALLOC ( container, sizeof ( *container ) ) ) + return error; + FT_MEM_SET( container, 0, sizeof(*container) ); + pic_container->psnames = container; + + /* initialize pointer table - this is how the module usually expects this data */ + error = FT_Create_Class_pscmaps_services(library, &container->pscmaps_services); + if(error) + goto Exit; + FT_Init_Class_pscmaps_interface(library, &container->pscmaps_interface); + +Exit: + if(error) + psnames_module_class_pic_free(library); + return error; + } + + +#endif /* FT_CONFIG_OPTION_PIC */ + + +/* END */ diff --git a/src/freetype2/psnames/pspic.h b/src/freetype2/psnames/pspic.h new file mode 100644 index 0000000..75a14fd --- /dev/null +++ b/src/freetype2/psnames/pspic.h @@ -0,0 +1,54 @@ +/***************************************************************************/ +/* */ +/* pspic.h */ +/* */ +/* The FreeType position independent code services for psnames module. */ +/* */ +/* Copyright 2009 by */ +/* Oran Agra and Mickey Gabel. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + +#ifndef __PSPIC_H__ +#define __PSPIC_H__ + + +FT_BEGIN_HEADER + +#include FT_INTERNAL_PIC_H + +#ifndef FT_CONFIG_OPTION_PIC +#define FT_PSCMAPS_SERVICES_GET pscmaps_services +#define FT_PSCMAPS_INTERFACE_GET pscmaps_interface + +#else /* FT_CONFIG_OPTION_PIC */ + +#include FT_SERVICE_POSTSCRIPT_CMAPS_H + + typedef struct PSModulePIC_ + { + FT_ServiceDescRec* pscmaps_services; + FT_Service_PsCMapsRec pscmaps_interface; + } PSModulePIC; + +#define GET_PIC(lib) ((PSModulePIC*)((lib)->pic_container.psnames)) +#define FT_PSCMAPS_SERVICES_GET (GET_PIC(library)->pscmaps_services) +#define FT_PSCMAPS_INTERFACE_GET (GET_PIC(library)->pscmaps_interface) + +#endif /* FT_CONFIG_OPTION_PIC */ + + /* */ + +FT_END_HEADER + +#endif /* __PSPIC_H__ */ + + +/* END */ diff --git a/src/freetype2/psnames/pstables.h b/src/freetype2/psnames/pstables.h index cc40ef7..1521e9c 100644 --- a/src/freetype2/psnames/pstables.h +++ b/src/freetype2/psnames/pstables.h @@ -4,7 +4,7 @@ /* */ /* PostScript glyph names. */ /* */ -/* Copyright 2005 by */ +/* Copyright 2005, 2008 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -561,7 +561,10 @@ * The lookup function to get the Unicode value for a given string * is defined below the table. */ - static const unsigned char ft_adobe_glyph_list[54791] = + +#ifdef FT_CONFIG_OPTION_ADOBE_GLYPH_LIST + + static const unsigned char ft_adobe_glyph_list[54791L] = { 0, 52, 0,106, 2,167, 3, 63, 4,220, 6,125, 9,143, 10, 23, 11,137, 12,199, 14,246, 15, 87, 16,233, 17,219, 18,104, 19, 88, @@ -4086,5 +4089,7 @@ return 0; } +#endif /* FT_CONFIG_OPTION_ADOBE_GLYPH_LIST */ + /* END */ -- cgit v1.2.3