/**************************************************************************** * * psmodule.c * * psnames module implementation (body). * * Copyright (C) 1996-2023 by * David Turner, Robert Wilhelm, and Werner Lemberg. * * 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 <freetype/internal/ftdebug.h> #include <freetype/internal/ftobjs.h> #include <freetype/internal/services/svpscmap.h> #include "psmodule.h" /* * The file `pstables.h' with its arrays and its function * `ft_get_adobe_glyph_index' is useful for other projects also (for * example, `pdfium' is using it). However, if used as a C++ header, * including it in two different source files makes it necessary to use * `extern const' for the declaration of its arrays, otherwise the data * would be duplicated as mandated by the C++ standard. * * For this reason, we use `DEFINE_PS_TABLES' to guard the function * definitions, and `DEFINE_PS_TABLES_DATA' to provide both proper array * declarations and definitions. */ #include "pstables.h" #define DEFINE_PS_TABLES #define DEFINE_PS_TABLES_DATA #include "pstables.h" #include "psnamerr.h" #ifdef FT_CONFIG_OPTION_POSTSCRIPT_NAMES #ifdef FT_CONFIG_OPTION_ADOBE_GLYPH_LIST #define VARIANT_BIT … #define BASE_GLYPH( code ) … /* Return the Unicode value corresponding to a given glyph. Note that */ /* we do deal with glyph variants by detecting a non-initial dot in */ /* the name, as in `A.swash' or `e.final'; in this case, the */ /* VARIANT_BIT is set in the return value. */ /* */ FT_CALLBACK_DEF( FT_UInt32 ) ps_unicode_value( const char* glyph_name ) { … } /* ft_qsort callback to sort the unicode map */ FT_COMPARE_DEF( int ) compare_uni_maps( const void* a, const void* b ) { … } /* support for extra glyphs not handled (well) in AGL; */ /* we add extra mappings for them if necessary */ #define EXTRA_GLYPH_LIST_SIZE … static const FT_UInt32 ft_extra_glyph_unicodes[EXTRA_GLYPH_LIST_SIZE] = …; static const char ft_extra_glyph_names[] = …; static const FT_Int ft_extra_glyph_name_offsets[EXTRA_GLYPH_LIST_SIZE] = …; static void ps_check_extra_glyph_name( const char* gname, FT_UInt glyph, FT_UInt* extra_glyphs, FT_UInt *states ) { … } static void ps_check_extra_glyph_unicode( FT_UInt32 uni_char, FT_UInt *states ) { … } /* Build a table that maps Unicode values to glyph indices. */ FT_CALLBACK_DEF( FT_Error ) ps_unicodes_init( FT_Memory memory, PS_Unicodes table, FT_UInt num_glyphs, PS_GetGlyphNameFunc get_glyph_name, PS_FreeGlyphNameFunc free_glyph_name, FT_Pointer glyph_data ) { … } FT_CALLBACK_DEF( FT_UInt ) ps_unicodes_char_index( PS_Unicodes table, FT_UInt32 unicode ) { … } FT_CALLBACK_DEF( FT_UInt ) ps_unicodes_char_next( PS_Unicodes table, FT_UInt32 *unicode ) { … } #endif /* FT_CONFIG_OPTION_ADOBE_GLYPH_LIST */ FT_CALLBACK_DEF( const char* ) ps_get_macintosh_name( FT_UInt name_index ) { … } FT_CALLBACK_DEF( const char* ) ps_get_standard_strings( FT_UInt sid ) { … } #ifdef FT_CONFIG_OPTION_ADOBE_GLYPH_LIST FT_DEFINE_SERVICE_PSCMAPSREC( pscmaps_interface, ps_unicode_value, /* PS_Unicode_ValueFunc unicode_value */ ps_unicodes_init, /* PS_Unicodes_InitFunc unicodes_init */ ps_unicodes_char_index, /* PS_Unicodes_CharIndexFunc unicodes_char_index */ ps_unicodes_char_next, /* PS_Unicodes_CharNextFunc unicodes_char_next */ ps_get_macintosh_name, /* PS_Macintosh_NameFunc macintosh_name */ ps_get_standard_strings, /* PS_Adobe_Std_StringsFunc adobe_std_strings */ t1_standard_encoding, /* adobe_std_encoding */ t1_expert_encoding /* adobe_expert_encoding */ ) #else FT_DEFINE_SERVICE_PSCMAPSREC( pscmaps_interface, NULL, /* PS_Unicode_ValueFunc unicode_value */ NULL, /* PS_Unicodes_InitFunc unicodes_init */ NULL, /* PS_Unicodes_CharIndexFunc unicodes_char_index */ NULL, /* PS_Unicodes_CharNextFunc unicodes_char_next */ ps_get_macintosh_name, /* PS_Macintosh_NameFunc macintosh_name */ ps_get_standard_strings, /* PS_Adobe_Std_StringsFunc adobe_std_strings */ t1_standard_encoding, /* adobe_std_encoding */ t1_expert_encoding /* adobe_expert_encoding */ ) #endif /* FT_CONFIG_OPTION_ADOBE_GLYPH_LIST */ FT_DEFINE_SERVICEDESCREC1( pscmaps_services, FT_SERVICE_ID_POSTSCRIPT_CMAPS, &pscmaps_interface ) static FT_Pointer psnames_get_service( FT_Module module, const char* service_id ) { … } #endif /* FT_CONFIG_OPTION_POSTSCRIPT_NAMES */ #ifndef FT_CONFIG_OPTION_POSTSCRIPT_NAMES #define PUT_PS_NAMES_SERVICE … #else #define PUT_PS_NAMES_SERVICE( a ) … #endif FT_DEFINE_MODULE( psnames_module_class, 0, /* this is not a font driver, nor a renderer */ sizeof ( FT_ModuleRec ), "psnames", /* driver name */ 0x10000L, /* driver version */ 0x20000L, /* driver requires FreeType 2 or above */ PUT_PS_NAMES_SERVICE( (void*)&pscmaps_interface ), /* module specific interface */ NULL, /* FT_Module_Constructor module_init */ NULL, /* FT_Module_Destructor module_done */ PUT_PS_NAMES_SERVICE( psnames_get_service ) /* FT_Module_Requester get_interface */ ) /* END */