* src/psaux/t1cmap.h, src/psaux/t1cmap.c, src/type1/t1cmap.h, src/type1/t1cmap.c: updating and moving the Type 1 FT_CMap support from "src/type1" to "src/psaux" since it's going to be shared by the Type 1 and CID font drivers.. * src/psaux/Jamfile, src/psaux/psaux.c, src/psaux/psauxmod.c, src/psaux/rules.mk, include/freetype/internal/psaux.h: added support for Type 1 FT_CMaps.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169
diff --git a/ChangeLog b/ChangeLog
index 7ad82b7..d7f105d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2002-03-21 David Turner <david@freetype.org>
+
+ * src/base/ftobjs.c, src/pcf/pcfdriver.c, src/pcf/pcfread.c: updated
+ to new FT_CMap definitions
+
+ * src/psaux/t1cmap.h, src/psaux/t1cmap.c, src/type1/t1cmap.h,
+ src/type1/t1cmap.c: updating and moving the Type 1 FT_CMap support
+ from "src/type1" to "src/psaux" since it's going to be shared
+ by the Type 1 and CID font drivers..
+
+ * src/psaux/Jamfile, src/psaux/psaux.c, src/psaux/psauxmod.c,
+ src/psaux/rules.mk, include/freetype/internal/psaux.h: added support
+ for Type 1 FT_CMaps.
+
2002-03-20 David Turner <david@freetype.org>
* src/base/ftgloadr.c (FT_GlyphLoader_CheckSubGlyphs): fixed a memory
diff --git a/include/freetype/internal/psaux.h b/include/freetype/internal/psaux.h
index d5e9bc5..eb3bb31 100644
--- a/include/freetype/internal/psaux.h
+++ b/include/freetype/internal/psaux.h
@@ -651,6 +651,25 @@ FT_BEGIN_HEADER
} T1_DecoderRec;
+ /*************************************************************************/
+ /*************************************************************************/
+ /***** *****/
+ /***** TYPE1 CHARMAPS *****/
+ /***** *****/
+ /*************************************************************************/
+ /*************************************************************************/
+
+ typedef const struct T1_CMap_ClassesRec_* T1_CMap_Classes;
+
+ typedef struct T1_CMap_ClassesRec_
+ {
+ FT_CMap_Class standard;
+ FT_CMap_Class expert;
+ FT_CMap_Class custom;
+ FT_CMap_Class unicode;
+
+ } T1_CMap_ClassesRec;
+
/*************************************************************************/
/*************************************************************************/
@@ -660,7 +679,7 @@ FT_BEGIN_HEADER
/*************************************************************************/
/*************************************************************************/
- typedef struct PSAux_Interface_
+ typedef struct PSAux_ServiceRec_
{
const PS_Table_Funcs ps_table_funcs;
const PS_Parser_Funcs ps_parser_funcs;
@@ -672,9 +691,12 @@ FT_BEGIN_HEADER
FT_Offset length,
FT_UShort seed );
- } PSAux_Interface;
+ T1_CMap_Classes t1_cmap_classes;
+
+ } PSAux_ServiceRec, *PSAux_Service;
- typedef PSAux_Interface* PSAux_Service;
+ /* backwards-compatible type definition */
+ typedef PSAux_ServiceRec PSAux_Interface;
FT_END_HEADER
diff --git a/src/pcf/pcfdriver.c b/src/pcf/pcfdriver.c
index 1e866a3..571af40 100644
--- a/src/pcf/pcfdriver.c
+++ b/src/pcf/pcfdriver.c
@@ -37,6 +37,198 @@ THE SOFTWARE.
#include "pcferror.h"
+#undef FT_COMPONENT
+#define FT_COMPONENT trace_pcfread
+
+#ifdef FT_CONFIG_OPTION_USE_CMAPS
+
+ typedef struct PCF_CMapRec_
+ {
+ FT_CMapRec cmap;
+ FT_UInt num_encodings;
+ PCF_Encoding encodings;
+
+ } PCF_CMapRec, *PCF_CMap;
+
+
+ FT_CALLBACK_DEF( FT_Error )
+ pcf_cmap_init( PCF_CMap cmap )
+ {
+ PCF_Face face = (PCF_Face) FT_CMAP_FACE(cmap);
+
+ cmap->num_encodings = (FT_UInt) face->nencodings;
+ cmap->encodings = face->encodings;
+
+ return FT_Err_Ok;
+ }
+
+
+ FT_CALLBACK_DEF( void )
+ pcf_cmap_done( PCF_CMap cmap )
+ {
+ cmap->encodings = NULL;
+ cmap->num_encodings = 0;
+ }
+
+
+ FT_CALLBACK_DEF( FT_UInt )
+ pcf_cmap_char_index( FT_CMap cmap,
+ FT_UInt32 charcode )
+ {
+ PCF_Encoding encoding = cmap->encodings;
+ FT_UInt min, max, mid;
+ FT_UInt result = 0;
+
+ min = 0;
+ max = cmap->num_encodings;
+
+ while ( min < max )
+ {
+ FT_UInt32 code;
+
+ mid = ( min + max ) >> 1;
+ code = encodings[mid].enc;
+
+ if ( charcode == code )
+ {
+ result = encodings[mid].glyph;
+ break;
+ }
+
+ if ( charcode < code )
+ max = mid;
+ else
+ min = mid+1;
+ }
+
+ return result;
+ }
+
+
+ FT_CALLBACK_DEF( FT_UInt )
+ pcf_cmap_char_next( PCF_CMap cmap,
+ FT_UInt32 *acharcode )
+ {
+ PCF_Encoding encodings = cmap->encodings;
+ FT_UInt min, max, mid;
+ FT_UInt32 charcode = *acharcode + 1;
+ FT_UInt result = 0;
+
+ min = 0;
+ max = cmap->num_encodings;
+
+ while ( min < max )
+ {
+ FT_UInt32 code;
+
+ mid = ( min + max ) >> 1;
+ code = encodings[mid].enc;
+
+ if ( charcode == code )
+ {
+ result = encodings[mid].glyph;
+ goto Exit;
+ }
+
+ if ( charcode < code )
+ max = mid;
+ else
+ min = mid+1;
+ }
+
+ charcode = 0;
+ if ( ++min < cmap->num_encodings )
+ {
+ charcode = encodings[min].enc;
+ glyph = encodings[min].glyph;
+ }
+
+ Exit:
+ *acharcode = charcode;
+ return result;
+ }
+
+
+ FT_CALLBACK_TABLE const FT_CMap_ClassRec pcf_cmap_class =
+ {
+ sizeof( PCF_CMapRec ),
+ (FT_CMap_InitFunc) pcf_cmap_init,
+ (FT_CMap_DoneFunc) pcf_cmap_done,
+ (FT_CMap_CharIndexFunc) pcf_cmap_char_index,
+ (FT_CMap_CharNextFunc) pcf_cmap_char_next
+ };
+
+#else /* !FT_CONFIG_OPTION_USE_CMAPS */
+
+ static FT_UInt
+ PCF_Char_Get_Index( FT_CharMap charmap,
+ FT_Long char_code )
+ {
+ PCF_Face face = (PCF_Face)charmap->face;
+ PCF_Encoding en_table = face->encodings;
+ int low, high, mid;
+
+
+ FT_TRACE4(( "get_char_index %ld\n", char_code ));
+
+ low = 0;
+ high = face->nencodings - 1;
+ while ( low <= high )
+ {
+ mid = ( low + high ) / 2;
+ if ( char_code < en_table[mid].enc )
+ high = mid - 1;
+ else if ( char_code > en_table[mid].enc )
+ low = mid + 1;
+ else
+ return en_table[mid].glyph;
+ }
+
+ return 0;
+ }
+
+
+ static FT_Long
+ PCF_Char_Get_Next( FT_CharMap charmap,
+ FT_Long char_code )
+ {
+ PCF_Face face = (PCF_Face)charmap->face;
+ PCF_Encoding en_table = face->encodings;
+ int low, high, mid;
+
+
+ FT_TRACE4(( "get_next_char %ld\n", char_code ));
+
+ char_code++;
+ low = 0;
+ high = face->nencodings - 1;
+
+ while ( low <= high )
+ {
+ mid = ( low + high ) / 2;
+ if ( char_code < en_table[mid].enc )
+ high = mid - 1;
+ else if ( char_code > en_table[mid].enc )
+ low = mid + 1;
+ else
+ return char_code;
+ }
+
+ if ( high < 0 )
+ high = 0;
+
+ while ( high < face->nencodings )
+ {
+ if ( en_table[high].enc >= char_code )
+ return en_table[high].enc;
+ high++;
+ }
+
+ return 0;
+ }
+
+#endif /* !FT_CONFIG_OPTION_USE_CMAPS */
+
/*************************************************************************/
/* */
@@ -48,7 +240,7 @@ THE SOFTWARE.
#define FT_COMPONENT trace_pcfdriver
- static FT_Error
+ FT_CALLBACK_DEF( FT_Error )
PCF_Face_Done( PCF_Face face )
{
FT_Memory memory = FT_FACE_MEMORY( face );
@@ -86,7 +278,7 @@ THE SOFTWARE.
}
- static FT_Error
+ FT_CALLBACK_DEF( FT_Error )
PCF_Face_Init( FT_Stream stream,
PCF_Face face,
FT_Int face_index,
@@ -104,13 +296,75 @@ THE SOFTWARE.
if ( error )
goto Fail;
- return PCF_Err_Ok;
+ /* set-up charmap */
+ {
+ FT_String *charset_registry, *charset_encoding;
+ FT_Face root = FT_FACE(face);
+ FT_Bool unicode_charmap = 0;
+
+
+ charset_registry = face->charset_registry;
+ charset_encoding = face->charset_encoding;
+
+ if ( ( charset_registry != NULL ) &&
+ ( charset_encoding != NULL ) )
+ {
+ if ( !strcmp( face->charset_registry, "ISO10646" ) ||
+ ( !strcmp( face->charset_registry, "ISO8859" ) &&
+ !strcmp( face->charset_encoding, "1" ) ) )
+ unicode_charmap = 1;
+ }
+
+#ifdef FT_CONFIG_OPTION_USE_CMAPS
+ {
+ FT_CharMapRec charmap;
+
+ charmap.face = FT_FACE(face);
+ charmap.encoding = ft_encoding_none;
+ charmap.platform_id = 0;
+ charmap.encoding_id = 0;
+
+ if ( unicode_charmap )
+ {
+ charmap.encoding = ft_encoding_unicode;
+ charmap.platform_id = 3;
+ charmap.encoding_id = 1;
+ }
+
+ error = FT_CMap_New( &pcf_cmap_class, NULL, &charmap, NULL );
+ }
+#else /* !FT_CONFIG_OPTION_USE_CMAPS */
+
+ /* XXX: charmaps. For now, report unicode for Unicode and Latin 1 */
+ root->charmaps = &face->charmap_handle;
+ root->num_charmaps = 1;
+
+ face->charmap.encoding = ft_encoding_none;
+ face->charmap.platform_id = 0;
+ face->charmap.encoding_id = 0;
+
+ if ( unicode_charmap )
+ {
+ face->charmap.encoding = ft_encoding_unicode;
+ face->charmap.platform_id = 3;
+ face->charmap.encoding_id = 1;
+ }
+
+ face->charmap.face = root;
+ face->charmap_handle = &face->charmap;
+ root->charmap = face->charmap_handle;
+
+#endif /* !FT_CONFIG_OPTION_USE_CMAPS */
+
+ }
+
+ Exit:
+ return error;
Fail:
FT_TRACE2(( "[not a valid PCF file]\n" ));
- PCF_Face_Done( face );
-
- return PCF_Err_Unknown_File_Format; /* error */
+ error = PCF_Err_Unknown_File_Format; /* error */
+ goto Exit;
}
@@ -256,74 +510,6 @@ THE SOFTWARE.
}
- static FT_UInt
- PCF_Char_Get_Index( FT_CharMap charmap,
- FT_Long char_code )
- {
- PCF_Face face = (PCF_Face)charmap->face;
- PCF_Encoding en_table = face->encodings;
- int low, high, mid;
-
-
- FT_TRACE4(( "get_char_index %ld\n", char_code ));
-
- low = 0;
- high = face->nencodings - 1;
- while ( low <= high )
- {
- mid = ( low + high ) / 2;
- if ( char_code < en_table[mid].enc )
- high = mid - 1;
- else if ( char_code > en_table[mid].enc )
- low = mid + 1;
- else
- return en_table[mid].glyph;
- }
-
- return 0;
- }
-
-
- static FT_Long
- PCF_Char_Get_Next( FT_CharMap charmap,
- FT_Long char_code )
- {
- PCF_Face face = (PCF_Face)charmap->face;
- PCF_Encoding en_table = face->encodings;
- int low, high, mid;
-
-
- FT_TRACE4(( "get_next_char %ld\n", char_code ));
-
- char_code++;
- low = 0;
- high = face->nencodings - 1;
-
- while ( low <= high )
- {
- mid = ( low + high ) / 2;
- if ( char_code < en_table[mid].enc )
- high = mid - 1;
- else if ( char_code > en_table[mid].enc )
- low = mid + 1;
- else
- return char_code;
- }
-
- if ( high < 0 )
- high = 0;
-
- while ( high < face->nencodings )
- {
- if ( en_table[high].enc >= char_code )
- return en_table[high].enc;
- high++;
- }
-
- return 0;
- }
-
-
FT_CALLBACK_TABLE_DEF
const FT_Driver_ClassRec pcf_driver_class =
{
@@ -353,17 +539,26 @@ THE SOFTWARE.
(FT_Slot_InitFunc)0,
(FT_Slot_DoneFunc)0,
- (FT_Size_ResetPointsFunc) PCF_Set_Pixel_Size,
- (FT_Size_ResetPixelsFunc)PCF_Set_Pixel_Size,
+ (FT_Size_ResetPointsFunc) PCF_Set_Pixel_Size,
+ (FT_Size_ResetPixelsFunc) PCF_Set_Pixel_Size,
+
+ (FT_Slot_LoadFunc) PCF_Glyph_Load,
- (FT_Slot_LoadFunc) PCF_Glyph_Load,
+#ifndef FT_CONFIG_OPTION_USE_CMAPS
(FT_CharMap_CharIndexFunc) PCF_Char_Get_Index,
+#else
+ (FT_CharMap_CharNextFunc) 0,
+#endif
(FT_Face_GetKerningFunc) 0,
- (FT_Face_AttachFunc) 0,
+ (FT_Face_AttachFunc) 0,
(FT_Face_GetAdvancesFunc) 0,
+#ifndef FT_CONFIG_OPTION_USE_CMAPS
(FT_CharMap_CharNextFunc) PCF_Char_Get_Next,
+#else
+ (FT_CharMap_CharNextFunc) 0
+#endif
};
diff --git a/src/pcf/pcfread.c b/src/pcf/pcfread.c
index 52899c8..582b1a5 100644
--- a/src/pcf/pcfread.c
+++ b/src/pcf/pcfread.c
@@ -866,11 +866,11 @@ THE SOFTWARE.
error = pcf_read_TOC( stream, face );
if ( error )
- return error;
+ goto Exit;
error = pcf_get_properties( stream, face );
if ( error )
- return error;;
+ goto Exit;
/* Use the old accelerators if no BDF accelerators are in the file. */
hasBDFAccelerators = pcf_has_table_type( face->toc.tables,
@@ -880,30 +880,30 @@ THE SOFTWARE.
{
error = pcf_get_accel( stream, face, PCF_ACCELERATORS );
if ( error )
- goto Bail;
+ goto Exit;
}
/* metrics */
error = pcf_get_metrics( stream, face );
if ( error )
- goto Bail;
+ goto Exit;
/* bitmaps */
error = pcf_get_bitmaps( stream, face );
if ( error )
- goto Bail;
+ goto Exit;
/* encodings */
error = pcf_get_encodings( stream, face );
if ( error )
- goto Bail;
+ goto Exit;
/* BDF style accelerators (i.e. bounds based on encoded glyphs) */
if ( hasBDFAccelerators )
{
error = pcf_get_accel( stream, face, PCF_BDF_ACCELERATORS );
if ( error )
- goto Bail;
+ goto Exit;
}
/* XXX: TO DO: inkmetrics and glyph_names are missing */
@@ -958,7 +958,7 @@ THE SOFTWARE.
if ( ALLOC( root->family_name, l * sizeof ( char ) ) )
- goto Bail;
+ goto Exit;
strcpy( root->family_name, prop->value.atom );
}
}
@@ -969,7 +969,7 @@ THE SOFTWARE.
root->num_fixed_sizes = 1;
if ( ALLOC_ARRAY( root->available_sizes, 1, FT_Bitmap_Size ) )
- goto Bail;
+ goto Exit;
prop = pcf_find_property( face, "PIXEL_SIZE" );
if ( prop != NULL )
@@ -977,12 +977,6 @@ THE SOFTWARE.
root->available_sizes->height =
root->available_sizes->width = (FT_Short)( prop->value.integer );
-#if 0 /* average width property support removed until maturation */
- prop = pcf_find_property( face, "AVERAGE_WIDTH" );
- if ( prop != NULL )
- root->available_sizes->width = (FT_Short)( prop->value.integer / 10 );
-#endif
-
size_set = 1;
}
else
@@ -1003,12 +997,6 @@ THE SOFTWARE.
(FT_Short)( prop->value.integer *
yres->value.integer / 720 );
-#if 0 /* average width property support removed until maturation */
- if ( avgw != NULL )
- root->available_sizes->width =
- (FT_Short)( avgw->value.integer / 10 );
- else
-#endif
root->available_sizes->width =
(FT_Short)( prop->value.integer *
xres->value.integer / 720 );
@@ -1020,28 +1008,19 @@ THE SOFTWARE.
if (size_set == 0 )
{
-#if 0
- printf( "PCF Warning: Pixel Size undefined, assuming 12\n");
-#endif
root->available_sizes->width = 12;
root->available_sizes->height = 12;
}
- /* XXX: charmaps. For now, report unicode for Unicode and Latin 1 */
- root->charmaps = &face->charmap_handle;
- root->num_charmaps = 1;
-
- face->charmap.encoding = ft_encoding_none;
- face->charmap.platform_id = 0;
- face->charmap.encoding_id = 0;
-
+ /* set-up charset */
{
PCF_Property charset_registry = 0, charset_encoding = 0;
-
-
+ FT_Bool unicode_charmap = 0;
+
+
charset_registry = pcf_find_property( face, "CHARSET_REGISTRY" );
charset_encoding = pcf_find_property( face, "CHARSET_ENCODING" );
-
+
if ( ( charset_registry != NULL ) &&
( charset_encoding != NULL ) )
{
@@ -1051,34 +1030,29 @@ THE SOFTWARE.
if ( ALLOC( face->charset_encoding,
( strlen( charset_encoding->value.atom ) + 1 ) *
sizeof ( char ) ) )
- goto Bail;
+ goto Exit;
+
if ( ALLOC( face->charset_registry,
( strlen( charset_registry->value.atom ) + 1 ) *
sizeof ( char ) ) )
- goto Bail;
+ goto Exit;
+
strcpy( face->charset_registry, charset_registry->value.atom );
strcpy( face->charset_encoding, charset_encoding->value.atom );
-
- if ( !strcmp( face->charset_registry, "ISO10646" ) ||
- ( !strcmp( face->charset_registry, "ISO8859" ) &&
- !strcmp( face->charset_encoding, "1" ) ) )
- {
- face->charmap.encoding = ft_encoding_unicode;
- face->charmap.platform_id = 3;
- face->charmap.encoding_id = 1;
- }
}
}
}
-
- face->charmap.face = root;
- face->charmap_handle = &face->charmap;
- root->charmap = face->charmap_handle;
}
- return PCF_Err_Ok;
-
- Bail:
- return PCF_Err_Invalid_File_Format;
+
+ Exit:
+ if (error)
+ {
+ /* this is done to respect the behaviour of the original */
+ /* PCF font driver.. */
+ error = PCF_Err_Invalid_File_Format;
+ }
+
+ return error;
}
diff --git a/src/psaux/Jamfile b/src/psaux/Jamfile
index 4f63dac..9481ac3 100644
--- a/src/psaux/Jamfile
+++ b/src/psaux/Jamfile
@@ -10,7 +10,7 @@ SubDirHdrs [ FT2_SubDir src psaux ] ;
if $(FT2_MULTI)
{
- _sources = psauxmod psobjs t1decode ;
+ _sources = psauxmod psobjs t1decode t1cmap ;
}
else
{
diff --git a/src/psaux/psaux.c b/src/psaux/psaux.c
index 54d85e5..875744f 100644
--- a/src/psaux/psaux.c
+++ b/src/psaux/psaux.c
@@ -22,6 +22,7 @@
#include "psobjs.c"
#include "psauxmod.c"
#include "t1decode.c"
+#include "t1cmap.c"
/* END */
diff --git a/src/psaux/psauxmod.c b/src/psaux/psauxmod.c
index 6d99aff..1171f0e 100644
--- a/src/psaux/psauxmod.c
+++ b/src/psaux/psauxmod.c
@@ -20,6 +20,7 @@
#include "psauxmod.h"
#include "psobjs.h"
#include "t1decode.h"
+#include "t1cmap.h"
FT_CALLBACK_TABLE_DEF
@@ -73,6 +74,16 @@
};
+ FT_CALLBACK_TABLE_DEF
+ const T1_CMap_ClassesRec t1_cmap_classes =
+ {
+ &t1_cmap_standard_class_rec,
+ &t1_cmap_expert_class_rec,
+ &t1_cmap_custom_class_rec,
+ &t1_cmap_unicode_class_rec
+ };
+
+
static
const PSAux_Interface psaux_interface =
{
@@ -81,7 +92,9 @@
&t1_builder_funcs,
&t1_decoder_funcs,
- T1_Decrypt
+ T1_Decrypt,
+
+ (const T1_CMap_ClassesRec*) &t1_cmap_classes,
};
diff --git a/src/psaux/rules.mk b/src/psaux/rules.mk
index 671b14d..87556d5 100644
--- a/src/psaux/rules.mk
+++ b/src/psaux/rules.mk
@@ -28,6 +28,7 @@ PSAUX_COMPILE := $(FT_COMPILE) $I$(PSAUX_DIR)
#
PSAUX_DRV_SRC := $(PSAUX_DIR_)psobjs.c \
$(PSAUX_DIR_)t1decode.c \
+ $(PSAUX_DIR_)t1cmap.c \
$(PSAUX_DIR_)psauxmod.c
# PSAUX driver headers
diff --git a/src/psaux/t1cmap.c b/src/psaux/t1cmap.c
index d33b84c..2588f69 100644
--- a/src/psaux/t1cmap.c
+++ b/src/psaux/t1cmap.c
@@ -1,4 +1,7 @@
#include "t1cmap.h"
+#include <stdlib.h>
+
+#include FT_INTERNAL_DEBUG_H
/***************************************************************************/
/***************************************************************************/
@@ -8,18 +11,18 @@
/***************************************************************************/
/***************************************************************************/
- static( void )
+ static void
t1_cmap_std_init( T1_CMapStd cmap,
FT_Int is_expert )
{
T1_Face face = (T1_Face) FT_CMAP_FACE(cmap);
PSNames_Service psnames = face->psnames;
- cmap->num_glyphs = face->type1.num_glyphs;
- cmap->glyph_names = face->type1.glyph_names;
- cmap->sid_strings = sid_strings;
- cmap->code_to_sid = is_expert ? psnames->adobe_expert_encoding
- : psnames->adobe_std_encoding;
+ cmap->num_glyphs = face->type1.num_glyphs;
+ cmap->glyph_names = face->type1.glyph_names;
+ cmap->sid_to_string = psnames->adobe_std_strings;
+ cmap->code_to_sid = is_expert ? psnames->adobe_expert_encoding
+ : psnames->adobe_std_encoding;
FT_ASSERT( cmap->code_to_sid != NULL );
}
@@ -28,10 +31,10 @@
FT_CALLBACK_DEF( void )
t1_cmap_std_done( T1_CMapStd cmap )
{
- cmap->num_glyphs = 0;
- cmap->glyph_names = NULL;
- cmap->sid_strings = NULL;
- cmap->code_to_sid = NULL;
+ cmap->num_glyphs = 0;
+ cmap->glyph_names = NULL;
+ cmap->sid_to_string = NULL;
+ cmap->code_to_sid = NULL;
}
@@ -43,13 +46,12 @@
if ( char_code < 256 )
{
- FT_UInt code;
+ FT_UInt code, n;
const char* glyph_name;
- FT_Int n;
/* conver character code to Adobe SID string */
code = cmap->code_to_sid[ char_code ];
- glyph_name = cmap->adobe_sid_strings[ code ];
+ glyph_name = cmap->sid_to_string( code );
/* look for the corresponding glyph name */
for ( n = 0; n < cmap->num_glyphs; n++ )
@@ -77,7 +79,7 @@
while ( char_code < 256 )
{
- result = t1_cmap_standard_char_index( cmap, char_code );
+ result = t1_cmap_std_char_index( cmap, char_code );
if ( result != 0 )
goto Exit;
@@ -99,46 +101,39 @@
}
- FT_CALLBACK_TABLE const T1_CMap_ClassRec
+ FT_LOCAL_DEF( const FT_CMap_ClassRec )
t1_cmap_standard_class_rec =
{
sizeof( T1_CMapStdRec ),
- t1_cmap_standard_init,
- t1_cmap_std_done,
- t1_cmap_std_char_index,
- t1_cmap_std_char_next
+ (FT_CMap_InitFunc) t1_cmap_standard_init,
+ (FT_CMap_DoneFunc) t1_cmap_std_done,
+ (FT_CMap_CharIndexFunc) t1_cmap_std_char_index,
+ (FT_CMap_CharNextFunc) t1_cmap_std_char_next
};
- FT_LOCAL_DEF( T1_CMap_Class )
- t1_cmap_standard_class = &t1_cmap_standard_class_rec;
-
-
-
- FT_CALLBACK_DEF( void )
+ FT_CALLBACK_DEF( FT_Error )
t1_cmap_expert_init( T1_CMapStd cmap )
{
t1_cmap_std_init( cmap, 1 );
return 0;
}
- FT_CALLBACK_TABLE const FT_CMap_ClassRec
+ FT_LOCAL_DEF( const FT_CMap_ClassRec )
t1_cmap_expert_class_rec =
{
sizeof( T1_CMapStdRec ),
- t1_cmap_expert_init,
- t1_cmap_std_done,
- t1_cmap_std_char_index,
- t1_cmap_std_char_next
+ (FT_CMap_InitFunc) t1_cmap_expert_init,
+ (FT_CMap_DoneFunc) t1_cmap_std_done,
+ (FT_CMap_CharIndexFunc) t1_cmap_std_char_index,
+ (FT_CMap_CharNextFunc) t1_cmap_std_char_next
};
- FT_LOCAL_DEF( FT_CMap_Class )
- t1_cmap_expert_class = &t1_cmap_expert_class_rec;
/***************************************************************************/
@@ -153,8 +148,8 @@
FT_CALLBACK_DEF( FT_Error )
t1_cmap_custom_init( T1_CMapCustom cmap )
{
- T1_Face face = (T1_Face) FT_CMAP_FACE(cmap);
- T1_Encoding encoding = face->type1.encoding;
+ T1_Face face = (T1_Face) FT_CMAP_FACE(cmap);
+ T1_Encoding encoding = &face->type1.encoding;
cmap->first = encoding->code_first;
cmap->count = (FT_UInt)(encoding->code_last - cmap->first + 1);
@@ -192,8 +187,8 @@
FT_CALLBACK_DEF( FT_UInt )
- t1_cmap_custom_char_next( T1_CMapCustion cmap,
- FT_UInt32 *pchar_code )
+ t1_cmap_custom_char_next( T1_CMapCustom cmap,
+ FT_UInt32 *pchar_code )
{
FT_UInt result = 0;
FT_UInt32 char_code = *pchar_code;
@@ -205,7 +200,7 @@
char_code = cmap->first;
index = (FT_UInt32)( char_code - cmap->first );
- while ( index < cmap->count; index++, char_code++ )
+ for ( ; index < cmap->count; index++, char_code++ )
{
result = cmap->indices[index];
if ( result != 0 )
@@ -220,19 +215,17 @@
}
- FT_CALLBACK_TABLE const FT_CMap_ClassRec
+ FT_LOCAL_DEF( const FT_CMap_ClassRec )
t1_cmap_custom_class_rec =
{
sizeof( T1_CMapCustomRec ),
- t1_cmap_custom_init,
- t1_cmap_custom_done,
- t1_cmap_custom_char_index,
- t1_cmap_custom_char_next
+ (FT_CMap_InitFunc) t1_cmap_custom_init,
+ (FT_CMap_DoneFunc) t1_cmap_custom_done,
+ (FT_CMap_CharIndexFunc) t1_cmap_custom_char_index,
+ (FT_CMap_CharNextFunc) t1_cmap_custom_char_next
};
- FT_LOCAL_DEF( FT_CMap_Class )
- t1_cmap_custom_class = &t1_cmap_custom_class_rec;
/***************************************************************************/
@@ -243,14 +236,32 @@
/***************************************************************************/
/***************************************************************************/
+ FT_CALLBACK_DEF( FT_Int )
+ t1_cmap_uni_pair_compare( const void* pair1,
+ const void* pair2 )
+ {
+ FT_UInt32 u1 = ((T1_CMapUniPair)pair1)->unicode;
+ FT_UInt32 u2 = ((T1_CMapUniPair)pair2)->unicode;
+
+ if ( u1 < u2 )
+ return -1;
+
+ if ( u1 > u2 )
+ return +1;
+
+ return 0;
+ }
+
+
FT_CALLBACK_DEF( FT_Error )
t1_cmap_unicode_init( T1_CMapUnicode cmap )
{
- FT_Error error;
- FT_UInt count;
- T1_Face face = (T1_Face) FT_CMAP_FACE(cmap);
- FT_Memory memory = FT_FACE_MEMORY(face);
+ FT_Error error;
+ FT_UInt count;
+ T1_Face face = (T1_Face) FT_CMAP_FACE(cmap);
+ FT_Memory memory = FT_FACE_MEMORY(face);
+ PSNames_Service psnames = face->psnames;
cmap->num_pairs = 0;
cmap->pairs = NULL;
@@ -272,7 +283,7 @@
/* build unsorted pair table by matching glyph names */
if ( gname )
{
- uni_code = PS_Unicode_Value( gname );
+ uni_code = psnames->unicode_value( gname );
if ( uni_code != 0 )
{
@@ -281,28 +292,32 @@
pair++;
}
}
-
- if ( new_count == 0 )
- {
- /* there are no unicode characters in here !! */
- FREE( cmap->pairs );
- error = FT_Err_Invalid_Argument;
- }
- else
+ }
+
+ new_count = (FT_UInt)( pair - cmap->pairs );
+ if ( new_count == 0 )
+ {
+ /* there are no unicode characters in here !! */
+ FREE( cmap->pairs );
+ error = FT_Err_Invalid_Argument;
+ }
+ else
+ {
+ /* re-allocate if the new array is much smaller than the original */
+ /* one.. */
+ if ( new_count != count && new_count < count/2 )
{
- /* re-allocate if the new array is much smaller than the original */
- /* one.. */
- if ( new_count != count && new_count < count/2 )
- REALLOC_ARRAY( cmap->pairs, count, new_count, T1_CMapUniPairRec )
-
- /* sort the pairs table to allow efficient binary searches */
- qsort( cmap->pairs,
- new_count,
- sizeof(T1_CMapUniPairRec),
- t1_cmap_uni_pair_compare );
-
- cmap->num_pairs = new_count;
+ (void)REALLOC_ARRAY( cmap->pairs, count, new_count, T1_CMapUniPairRec );
+ error = 0;
}
+
+ /* sort the pairs table to allow efficient binary searches */
+ qsort( cmap->pairs,
+ new_count,
+ sizeof(T1_CMapUniPairRec),
+ t1_cmap_uni_pair_compare );
+
+ cmap->num_pairs = new_count;
}
}
@@ -313,7 +328,7 @@
FT_CALLBACK_DEF( void )
t1_cmap_unicode_done( T1_CMapUnicode cmap )
{
- FT_Face face = FT_CMAP_FACE(cmap);
+ FT_Face face = FT_CMAP_FACE(cmap);
FT_Memory memory = FT_FACE_MEMORY(face);
FREE( cmap->pairs );
@@ -321,6 +336,7 @@
}
+
FT_CALLBACK_DEF( FT_UInt )
t1_cmap_unicode_char_index( T1_CMapUnicode cmap,
FT_UInt32 char_code )
@@ -351,7 +367,8 @@
t1_cmap_unicode_char_next( T1_CMapUnicode cmap,
FT_UInt32 *pchar_code )
{
- FT_UInt32 char_code = *pchar_code + 1;
+ FT_UInt result = 0;
+ FT_UInt32 char_code = *pchar_code + 1;
Restart:
{
@@ -362,7 +379,7 @@
while ( min < max )
{
- mid = min + (max - min)/2;
+ mid = min + ((max - min) >> 1);
pair = cmap->pairs + mid;
if ( pair->unicode == char_code )
@@ -386,7 +403,7 @@
if ( min < cmap->num_pairs )
{
- pair = cmap->num_pairs + min;
+ pair = cmap->pairs + min;
result = pair->gindex;
if ( result != 0 )
char_code = pair->unicode;
@@ -403,8 +420,14 @@
t1_cmap_unicode_class_rec =
{
sizeof( T1_CMapUnicodeRec ),
- t1_cmap_unicode_init,
- t1_cmap_unicode_done,
- t1_cmap_unicode_char_index,
- t1_cmap_unicode_char_next
+ (FT_CMap_InitFunc) t1_cmap_unicode_init,
+ (FT_CMap_DoneFunc) t1_cmap_unicode_done,
+ (FT_CMap_CharIndexFunc) t1_cmap_unicode_char_index,
+ (FT_CMap_CharNextFunc) t1_cmap_unicode_char_next
};
+
+
+
+ FT_LOCAL_DEF( const FT_CMap_Class )
+ t1_cmap_unicode_class = &t1_cmap_unicode_class_rec;
+
diff --git a/src/psaux/t1cmap.h b/src/psaux/t1cmap.h
index bc0290c..55ce2c1 100644
--- a/src/psaux/t1cmap.h
+++ b/src/psaux/t1cmap.h
@@ -1,6 +1,11 @@
#ifndef __FT_TYPE1_CMAP_H__
#define __FT_TYPE1_CMAP_H__
+#include <ft2build.h>
+#include FT_INTERNAL_OBJECTS_H
+#include FT_INTERNAL_TYPE1_TYPES_H
+#include FT_INTERNAL_POSTSCRIPT_NAMES_H
+
FT_BEGIN_HEADER
/***************************************************************************/
@@ -16,22 +21,21 @@ FT_BEGIN_HEADER
typedef struct T1_CMapStdRec_
{
- FT_CMapRec cmap;
+ FT_CMapRec cmap;
- const FT_UShort* charcode_to_sid;
- const char* const* adobe_sid_strings;
+ const FT_UShort* code_to_sid;
+ PS_Adobe_Std_Strings_Func sid_to_string;
- FT_UInt num_glyphs;
- const char** glyph_names;
-
+ FT_UInt num_glyphs;
+ const char* const* glyph_names;
} T1_CMapStdRec;
- FT_LOCAL( FT_CMap_Class ) t1_cmap_standard_class;
-
- FT_LOCAL( FT_CMap_Class ) t1_cmap_expert_class;
-
+ FT_LOCAL( const FT_CMap_ClassRec ) t1_cmap_standard_class_rec;
+
+ FT_LOCAL( const FT_CMap_ClassRec ) t1_cmap_expert_class_rec;
+
/***************************************************************************/
/***************************************************************************/
/***** *****/
@@ -47,13 +51,12 @@ FT_BEGIN_HEADER
FT_CMapRec cmap;
FT_UInt first;
FT_UInt count;
- FT_UInt* indices;
+ FT_UShort* indices;
} T1_CMapCustomRec;
-
- FT_LOCAL( FT_CMap_Class ) t1_cmap_custom_class;
-
+ FT_LOCAL( const FT_CMap_ClassRec ) t1_cmap_custom_class_rec;
+
/***************************************************************************/
/***************************************************************************/
/***** *****/
@@ -82,7 +85,7 @@ FT_BEGIN_HEADER
} T1_CMapUnicodeRec;
- FT_LOCAL( FT_CMap_Class ) t1_cmap_unicode_class;
+ FT_LOCAL( const FT_CMap_ClassRec ) t1_cmap_unicode_class_rec;
/* */