| OLD | NEW |
| 1 #if !defined(_FXFT_VERSION_) || _FXFT_VERSION_ == 2501 | |
| 2 /***************************************************************************/ | 1 /***************************************************************************/ |
| 3 /* */ | 2 /* */ |
| 4 /* psmodule.c */ | 3 /* psmodule.c */ |
| 5 /* */ | 4 /* */ |
| 6 /* PSNames module implementation (body). */ | 5 /* PSNames module implementation (body). */ |
| 7 /* */ | 6 /* */ |
| 8 /* Copyright 1996-2003, 2005-2008, 2012, 2013 by */ | 7 /* Copyright 1996-2003, 2005-2008, 2012, 2013 by */ |
| 9 /* David Turner, Robert Wilhelm, and Werner Lemberg. */ | 8 /* David Turner, Robert Wilhelm, and Werner Lemberg. */ |
| 10 /* */ | 9 /* */ |
| 11 /* This file is part of the FreeType project, and may only be used, */ | 10 /* This file is part of the FreeType project, and may only be used, */ |
| 12 /* modified, and distributed under the terms of the FreeType project */ | 11 /* modified, and distributed under the terms of the FreeType project */ |
| 13 /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ | 12 /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ |
| 14 /* this file you indicate that you have read the license and */ | 13 /* this file you indicate that you have read the license and */ |
| 15 /* understand and accept it fully. */ | 14 /* understand and accept it fully. */ |
| 16 /* */ | 15 /* */ |
| 17 /***************************************************************************/ | 16 /***************************************************************************/ |
| 18 | 17 |
| 19 #define FT2_BUILD_LIBRARY | 18 |
| 20 #include "../../include/ft2build.h" | 19 #include <ft2build.h> |
| 21 #include "../../include/freetype/internal/ftdebug.h" | 20 #include FT_INTERNAL_DEBUG_H |
| 22 #include "../../include/freetype/internal/ftobjs.h" | 21 #include FT_INTERNAL_OBJECTS_H |
| 23 #include "../../include/freetype/internal/services/svpscmap.h" | 22 #include FT_SERVICE_POSTSCRIPT_CMAPS_H |
| 24 | 23 |
| 25 #include "psmodule.h" | 24 #include "psmodule.h" |
| 26 #include "pstables.h" | 25 #include "pstables.h" |
| 27 | 26 |
| 28 #include "psnamerr.h" | 27 #include "psnamerr.h" |
| 29 #include "pspic.h" | 28 #include "pspic.h" |
| 30 | 29 |
| 31 | 30 |
| 32 #ifdef FT_CONFIG_OPTION_POSTSCRIPT_NAMES | 31 #ifdef FT_CONFIG_OPTION_POSTSCRIPT_NAMES |
| 33 | 32 |
| 34 | 33 |
| 35 #ifdef FT_CONFIG_OPTION_ADOBE_GLYPH_LIST | 34 #ifdef FT_CONFIG_OPTION_ADOBE_GLYPH_LIST |
| 36 | 35 |
| 37 | 36 |
| 38 #define VARIANT_BIT 0x80000000UL | 37 #define VARIANT_BIT 0x80000000UL |
| 39 #define BASE_GLYPH( code ) ( (FT_UInt32)( (code) & ~VARIANT_BIT ) ) | 38 #define BASE_GLYPH( code ) ( (FT_UInt32)( (code) & ~VARIANT_BIT ) ) |
| 40 | 39 |
| 41 #ifdef __cplusplus | 40 |
| 42 extern "C" { | |
| 43 #endif | |
| 44 /* Return the Unicode value corresponding to a given glyph. Note that */ | 41 /* Return the Unicode value corresponding to a given glyph. Note that */ |
| 45 /* we do deal with glyph variants by detecting a non-initial dot in */ | 42 /* we do deal with glyph variants by detecting a non-initial dot in */ |
| 46 /* the name, as in `A.swash' or `e.final'; in this case, the */ | 43 /* the name, as in `A.swash' or `e.final'; in this case, the */ |
| 47 /* VARIANT_BIT is set in the return value. */ | 44 /* VARIANT_BIT is set in the return value. */ |
| 48 /* */ | 45 /* */ |
| 49 int FXFT_unicode_from_adobe_name( const char* glyph_name ) | 46 static FT_UInt32 |
| 47 ps_unicode_value( const char* glyph_name ) |
| 50 { | 48 { |
| 51 /* If the name begins with `uni', then the glyph name may be a */ | 49 /* If the name begins with `uni', then the glyph name may be a */ |
| 52 /* hard-coded unicode character code. */ | 50 /* hard-coded unicode character code. */ |
| 53 if ( glyph_name[0] == 'u' && | 51 if ( glyph_name[0] == 'u' && |
| 54 glyph_name[1] == 'n' && | 52 glyph_name[1] == 'n' && |
| 55 glyph_name[2] == 'i' ) | 53 glyph_name[2] == 'i' ) |
| 56 { | 54 { |
| 57 /* determine whether the next four characters following are */ | 55 /* determine whether the next four characters following are */ |
| 58 /* hexadecimal. */ | 56 /* hexadecimal. */ |
| 59 | 57 |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 } | 155 } |
| 158 | 156 |
| 159 /* now look up the glyph in the Adobe Glyph List */ | 157 /* now look up the glyph in the Adobe Glyph List */ |
| 160 if ( !dot ) | 158 if ( !dot ) |
| 161 return (FT_UInt32)ft_get_adobe_glyph_index( glyph_name, p ); | 159 return (FT_UInt32)ft_get_adobe_glyph_index( glyph_name, p ); |
| 162 else | 160 else |
| 163 return (FT_UInt32)( ft_get_adobe_glyph_index( glyph_name, dot ) | | 161 return (FT_UInt32)( ft_get_adobe_glyph_index( glyph_name, dot ) | |
| 164 VARIANT_BIT ); | 162 VARIANT_BIT ); |
| 165 } | 163 } |
| 166 } | 164 } |
| 167 #ifdef __cplusplus | |
| 168 } | |
| 169 #endif | |
| 170 | 165 |
| 171 static int xyq_search_node(char* glyph_name, int name_offset, int table_offset,
FT_UInt32 unicode) | |
| 172 { | |
| 173 int i, count; | |
| 174 | |
| 175 // copy letters | |
| 176 while (1) { | |
| 177 glyph_name[name_offset] = ft_adobe_glyph_list[table_offset] & 0x
7f; | |
| 178 name_offset ++; | |
| 179 table_offset ++; | |
| 180 if (!(ft_adobe_glyph_list[table_offset-1] & 0x80)) break; | |
| 181 } | |
| 182 glyph_name[name_offset] = 0; | |
| 183 | |
| 184 // get child count | |
| 185 count = ft_adobe_glyph_list[table_offset] & 0x7f; | |
| 186 | |
| 187 // check if we have value for this node | |
| 188 if (ft_adobe_glyph_list[table_offset] & 0x80) { | |
| 189 unsigned short thiscode = ft_adobe_glyph_list[table_offset+1] *
256 + ft_adobe_glyph_list[table_offset+2]; | |
| 190 if (thiscode == unicode) // found it! | |
| 191 return 1; | |
| 192 table_offset += 3; | |
| 193 } else | |
| 194 table_offset ++; | |
| 195 | |
| 196 // now search in sub-nodes | |
| 197 if (count == 0) return 0; | |
| 198 for (i = 0; i < count; i ++) { | |
| 199 int child_offset = ft_adobe_glyph_list[table_offset+i*2] * 256 +
ft_adobe_glyph_list[table_offset+i*2+1]; | |
| 200 if (xyq_search_node(glyph_name, name_offset, child_offset, unico
de)) | |
| 201 // found in child | |
| 202 return 1; | |
| 203 } | |
| 204 return 0; | |
| 205 } | |
| 206 | |
| 207 // XYQ: function for searching Unicode in the glyph list | |
| 208 void FXFT_adobe_name_from_unicode(char* glyph_name, FT_UInt32 unicode) | |
| 209 { | |
| 210 int i, count; | |
| 211 | |
| 212 // start from top level node | |
| 213 count = ft_adobe_glyph_list[1]; | |
| 214 for (i = 0; i < count; i ++) { | |
| 215 int child_offset = ft_adobe_glyph_list[i*2+2] * 256 + ft_adobe_g
lyph_list[i*2+3]; | |
| 216 if (xyq_search_node(glyph_name, 0, child_offset, unicode)) | |
| 217 return; | |
| 218 } | |
| 219 | |
| 220 // failed, clear the buffer | |
| 221 glyph_name[0] = 0; | |
| 222 } | |
| 223 | 166 |
| 224 /* ft_qsort callback to sort the unicode map */ | 167 /* ft_qsort callback to sort the unicode map */ |
| 225 FT_CALLBACK_DEF( int ) | 168 FT_CALLBACK_DEF( int ) |
| 226 compare_uni_maps( const void* a, | 169 compare_uni_maps( const void* a, |
| 227 const void* b ) | 170 const void* b ) |
| 228 { | 171 { |
| 229 PS_UniMap* map1 = (PS_UniMap*)a; | 172 PS_UniMap* map1 = (PS_UniMap*)a; |
| 230 PS_UniMap* map2 = (PS_UniMap*)b; | 173 PS_UniMap* map2 = (PS_UniMap*)b; |
| 231 FT_UInt32 unicode1 = BASE_GLYPH( map1->unicode ); | 174 FT_UInt32 unicode1 = BASE_GLYPH( map1->unicode ); |
| 232 FT_UInt32 unicode2 = BASE_GLYPH( map2->unicode ); | 175 FT_UInt32 unicode2 = BASE_GLYPH( map2->unicode ); |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 383 | 326 |
| 384 for ( n = 0; n < num_glyphs; n++ ) | 327 for ( n = 0; n < num_glyphs; n++ ) |
| 385 { | 328 { |
| 386 const char* gname = get_glyph_name( glyph_data, n ); | 329 const char* gname = get_glyph_name( glyph_data, n ); |
| 387 | 330 |
| 388 | 331 |
| 389 if ( gname ) | 332 if ( gname ) |
| 390 { | 333 { |
| 391 ps_check_extra_glyph_name( gname, n, | 334 ps_check_extra_glyph_name( gname, n, |
| 392 extra_glyphs, extra_glyph_list_states ); | 335 extra_glyphs, extra_glyph_list_states ); |
| 393 uni_char = FXFT_unicode_from_adobe_name( gname ); | 336 uni_char = ps_unicode_value( gname ); |
| 394 | 337 |
| 395 if ( BASE_GLYPH( uni_char ) != 0 ) | 338 if ( BASE_GLYPH( uni_char ) != 0 ) |
| 396 { | 339 { |
| 397 ps_check_extra_glyph_unicode( uni_char, | 340 ps_check_extra_glyph_unicode( uni_char, |
| 398 extra_glyph_list_states ); | 341 extra_glyph_list_states ); |
| 399 map->unicode = uni_char; | 342 map->unicode = uni_char; |
| 400 map->glyph_index = n; | 343 map->glyph_index = n; |
| 401 map++; | 344 map++; |
| 402 } | 345 } |
| 403 | 346 |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 575 return 0; | 518 return 0; |
| 576 | 519 |
| 577 return ft_standard_glyph_names + ft_sid_names[sid]; | 520 return ft_standard_glyph_names + ft_sid_names[sid]; |
| 578 } | 521 } |
| 579 | 522 |
| 580 | 523 |
| 581 #ifdef FT_CONFIG_OPTION_ADOBE_GLYPH_LIST | 524 #ifdef FT_CONFIG_OPTION_ADOBE_GLYPH_LIST |
| 582 | 525 |
| 583 FT_DEFINE_SERVICE_PSCMAPSREC( | 526 FT_DEFINE_SERVICE_PSCMAPSREC( |
| 584 pscmaps_interface, | 527 pscmaps_interface, |
| 585 (PS_Unicode_ValueFunc) FXFT_unicode_from_adobe_name, | 528 (PS_Unicode_ValueFunc) ps_unicode_value, |
| 586 (PS_Unicodes_InitFunc) ps_unicodes_init, | 529 (PS_Unicodes_InitFunc) ps_unicodes_init, |
| 587 (PS_Unicodes_CharIndexFunc)ps_unicodes_char_index, | 530 (PS_Unicodes_CharIndexFunc)ps_unicodes_char_index, |
| 588 (PS_Unicodes_CharNextFunc) ps_unicodes_char_next, | 531 (PS_Unicodes_CharNextFunc) ps_unicodes_char_next, |
| 589 | 532 |
| 590 (PS_Macintosh_NameFunc) ps_get_macintosh_name, | 533 (PS_Macintosh_NameFunc) ps_get_macintosh_name, |
| 591 (PS_Adobe_Std_StringsFunc) ps_get_standard_strings, | 534 (PS_Adobe_Std_StringsFunc) ps_get_standard_strings, |
| 592 | 535 |
| 593 t1_standard_encoding, | 536 t1_standard_encoding, |
| 594 t1_expert_encoding ) | 537 t1_expert_encoding ) |
| 595 | 538 |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 657 0x20000L, /* driver requires FreeType 2 or above */ | 600 0x20000L, /* driver requires FreeType 2 or above */ |
| 658 | 601 |
| 659 PUT_PS_NAMES_SERVICE( | 602 PUT_PS_NAMES_SERVICE( |
| 660 (void*)&PSCMAPS_INTERFACE_GET ), /* module specific interface */ | 603 (void*)&PSCMAPS_INTERFACE_GET ), /* module specific interface */ |
| 661 (FT_Module_Constructor)NULL, | 604 (FT_Module_Constructor)NULL, |
| 662 (FT_Module_Destructor) NULL, | 605 (FT_Module_Destructor) NULL, |
| 663 (FT_Module_Requester) PUT_PS_NAMES_SERVICE( psnames_get_service ) ) | 606 (FT_Module_Requester) PUT_PS_NAMES_SERVICE( psnames_get_service ) ) |
| 664 | 607 |
| 665 | 608 |
| 666 /* END */ | 609 /* END */ |
| 667 #endif | |
| 668 | |
| OLD | NEW |