* src/base/ftmac.c (p2c_str): Removed. (file_spec_from_path) [TARGET_API_MAC_CARBON]: Added support for OS X. (is_dfont) [TARGET_API_MAC_CARBON]: Define only for OS X. Handle `nameLen' <= 6 also. (parse_fond): Remove unused variable `name_table'. Use functionality of old p2c_str directly. Add safety checks. (read_lwfn): Initialize `size_p'. Check for size_p == NULL. (new_memory_stream, open_face_from_buffer): Updated to FreeType 2.1. (FT_New_Face_From_LWFN): Remove unused variable `memory'. Remove some dead code. (FT_New_Face_From_SFNT): Remove unused variable `stream'. (FT_New_Face_From_dfont) [TARGET_API_MAC_CARBON]: Define only for OS X. (FT_New_Face_From_FOND): Remove unused variable `error'. (ResourceForkSize): New function. (FT_New_Face): Use it. Handle empty resource forks. Conditionalize some code for OS X. Add code to call normal loader as a fallback. Some more variable renames to avoid troubles on the Mac. * src/raster/ftraster.c: s/Unknown|Ascending|Descending|Flat/\1_State/. * src/smooth/ftgrays.c: s/TScan/TCoord/. Other changes for the Mac. * include/freetype/config/ftconfig.h: Define FT_MACINTOSH for Mac platforms. * src/base/ftobjs.c: s/macintosh/FT_MACINTOSH/. * src/raster/ftrend1.c (ft_raster1_render): Make `pitch' always an even number.
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
diff --git a/ChangeLog b/ChangeLog
index 5ac26f0..5e4e8c6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,28 @@
+2002-04-30 Wenlin Institute (Tom Bishop) <wenlin@wenlin.com>
+
+ * src/base/ftmac.c (p2c_str): Removed.
+ (file_spec_from_path) [TARGET_API_MAC_CARBON]: Added support for
+ OS X.
+ (is_dfont) [TARGET_API_MAC_CARBON]: Define only for OS X.
+ Handle `nameLen' <= 6 also.
+ (parse_fond): Remove unused variable `name_table'.
+ Use functionality of old p2c_str directly.
+ Add safety checks.
+ (read_lwfn): Initialize `size_p'.
+ Check for size_p == NULL.
+ (new_memory_stream, open_face_from_buffer): Updated to FreeType 2.1.
+ (FT_New_Face_From_LWFN): Remove unused variable `memory'.
+ Remove some dead code.
+ (FT_New_Face_From_SFNT): Remove unused variable `stream'.
+ (FT_New_Face_From_dfont) [TARGET_API_MAC_CARBON]: Define only for
+ OS X.
+ (FT_New_Face_From_FOND): Remove unused variable `error'.
+ (ResourceForkSize): New function.
+ (FT_New_Face): Use it.
+ Handle empty resource forks.
+ Conditionalize some code for OS X.
+ Add code to call normal loader as a fallback.
+
2002-04-30 Werner Lemberg <wl@gnu.org>
`interface' is reserved on the Mac.
@@ -15,6 +40,21 @@
* src/truetype/ttdriver.c: s/interface/tt_interface/.
* src/type1/t1driver.c: s/interface/t1_interface/.
+ Some more variable renames to avoid troubles on the Mac.
+
+ * src/raster/ftraster.c:
+ s/Unknown|Ascending|Descending|Flat/\1_State/.
+ * src/smooth/ftgrays.c: s/TScan/TCoord/.
+
+ Other changes for the Mac.
+
+ * include/freetype/config/ftconfig.h: Define FT_MACINTOSH for
+ Mac platforms.
+ * src/base/ftobjs.c: s/macintosh/FT_MACINTOSH/.
+
+ * src/raster/ftrend1.c (ft_raster1_render): Make `pitch' always
+ an even number.
+
2002-04-29 Jouk Jansen <joukj@hrem.stm.tudelft.nl>
* descrip.mms (all): Add pfr driver.
diff --git a/include/freetype/config/ftconfig.h b/include/freetype/config/ftconfig.h
index 3e76bc9..72bee0c 100644
--- a/include/freetype/config/ftconfig.h
+++ b/include/freetype/config/ftconfig.h
@@ -103,6 +103,18 @@ FT_BEGIN_HEADER
/*************************************************************************/
/* */
+ /* Mac support */
+ /* */
+ /* This is the only necessary change, so it is defined here instead */
+ /* providing a new configuration file. */
+ /* */
+#if defined( __APPLE__ ) || ( defined( __MWERKS__ ) && defined( macintosh ) )
+#define FT_MACINTOSH 1
+#endif
+
+
+ /*************************************************************************/
+ /* */
/* IntN types */
/* */
/* Used to guarantee the size of some specific integers. */
diff --git a/src/base/ftmac.c b/src/base/ftmac.c
index 462220d..d433992 100644
--- a/src/base/ftmac.c
+++ b/src/base/ftmac.c
@@ -19,36 +19,38 @@
/*
Notes
- Mac suitcase files can (and often do!) contain multiple fonts. To
+ Mac suitcase files can (and often do!) contain multiple fonts. To
support this I use the face_index argument of FT_(Open|New)_Face()
functions, and pretend the suitcase file is a collection.
- Warning: although the FOND driver sets face->num_faces field to the
+
+ Warning: Although the FOND driver sets face->num_faces field to the
number of available fonts, but the Type 1 driver sets it to 1 anyway.
So this field is currently not reliable, and I don't see a clean way
- to resolve that. The face_index argument translates to
+ to resolve that. The face_index argument translates to
+
Get1IndResource( 'FOND', face_index + 1 );
+
so clients should figure out the resource index of the FOND.
(I'll try to provide some example code for this at some point.)
-
The Mac FOND support works roughly like this:
- Check whether the offered stream points to a Mac suitcase file.
This is done by checking the file type: it has to be 'FFIL' or 'tfil'.
The stream that gets passed to our init_face() routine is a stdio
stream, which isn't usable for us, since the FOND resources live
- in the resource fork. So we just grab the stream->pathname field.
+ in the resource fork. So we just grab the stream->pathname field.
- Read the FOND resource into memory, then check whether there is
- a TrueType font and/or (!) a Type 1 font available.
+ a TrueType font and/or(!) a Type 1 font available.
- If there is a Type 1 font available (as a separate 'LWFN' file),
read its data into memory, massage it slightly so it becomes
PFB data, wrap it into a memory stream, load the Type 1 driver
and delegate the rest of the work to it by calling FT_Open_Face().
(XXX TODO: after this has been done, the kerning data from the FOND
- resource should be appended to the face: on the Mac there are usually
- no AFM files available. However, this is tricky since we need to map
+ resource should be appended to the face: On the Mac there are usually
+ no AFM files available. However, this is tricky since we need to map
Mac char codes to ps glyph names to glyph ID's...)
- If there is a TrueType font (an 'sfnt' resource), read it into
@@ -80,26 +82,25 @@
#define PREFER_LWFN 1
#endif
-
- /* Quick'n'dirty Pascal string to C string converter.
- Warning: this call is not thread safe! Use with caution. */
- static char*
- p2c_str( unsigned char* pstr )
- {
- static char cstr[256];
-
-
- ft_strncpy( cstr, (char*)pstr + 1, pstr[0] );
- cstr[pstr[0]] = '\0';
- return cstr;
- }
-
-
/* Given a pathname, fill in a file spec. */
static int
file_spec_from_path( const char* pathname,
FSSpec* spec )
{
+#if TARGET_API_MAC_CARBON
+
+ OSErr e;
+ FSRef ref;
+
+
+ e = FSPathMakeRef( (UInt8 *)pathname, &ref, false /* not a directory */ );
+ if ( e == noErr )
+ e = FSGetCatalogInfo( &ref, kFSCatInfoNone, NULL, NULL, spec, NULL );
+
+ return ( e == noErr ) ? 0 : (-1);
+
+#else
+
Str255 p_path;
FT_ULong path_len;
@@ -115,6 +116,8 @@
return -1;
else
return 0;
+
+#endif
}
@@ -132,24 +135,21 @@
}
+#if TARGET_API_MAC_CARBON
+
/* is this a Mac OS X .dfont file */
static Boolean
is_dfont( FSSpec* spec )
{
- int nameLen = spec->name[0];
+ int nameLen = spec->name[0];
- if ( spec->name[nameLen - 5] == '.' &&
- spec->name[nameLen - 4] == 'd' &&
- spec->name[nameLen - 3] == 'f' &&
- spec->name[nameLen - 2] == 'o' &&
- spec->name[nameLen - 1] == 'n' &&
- spec->name[nameLen ] == 't' )
- return true;
- else
- return false;
+ return nameLen >= 6 &&
+ !memcmp( spec->name + nameLen - 5, ".dfont", 6 );
}
+#endif
+
/* Given a PostScript font name, create the Macintosh LWFN file name. */
static void
@@ -193,12 +193,12 @@
FCBPBRec pb;
OSErr error;
+
pb.ioNamePtr = file_name;
pb.ioVRefNum = 0;
pb.ioRefNum = ref_num;
pb.ioFCBIndx = 0;
-
error = PBGetFCBInfoSync( &pb );
if ( error == noErr )
{
@@ -280,7 +280,6 @@
unsigned char* p = (unsigned char*)fond_data;
StyleTable* style;
unsigned short string_count;
- unsigned char* name_table = 0;
char ps_name[256];
unsigned char* names[64];
int i;
@@ -298,16 +297,43 @@
p += names[i][0];
p++;
}
- ft_strcpy( ps_name, p2c_str( names[0] ) ); /* Family name */
- if ( style->indexes[0] > 1 )
{
- unsigned char* suffixes = names[style->indexes[0] - 1];
+ size_t ps_name_len = (size_t)names[0][0];
+
+
+ if ( ps_name_len != 0 )
+ {
+ memcpy(ps_name, names[0] + 1, ps_name_len);
+ ps_name[ps_name_len] = 0;
+ }
+ if ( style->indexes[0] > 1 )
+ {
+ unsigned char* suffixes = names[style->indexes[0] - 1];
+
+
+ for ( i = 1; i < suffixes[0]; i++ )
+ {
+ unsigned char* s;
+ size_t j = suffixes[i] - 1;
+
+
+ if ( j < string_count && ( s = names[j] ) != NULL )
+ {
+ size_t s_len = (size_t)s[0];
- for ( i = 1; i <= suffixes[0]; i++ )
- strcat( ps_name, p2c_str( names[suffixes[i] - 1] ) );
+ if ( s_len != 0 && ps_name_len + s_len < sizeof ( ps_name ) )
+ {
+ memcpy( ps_name + ps_name_len, s + 1, s_len );
+ ps_name_len += s_len;
+ ps_name[ps_name_len] = 0;
+ }
+ }
+ }
+ }
}
+
create_lwfn_name( ps_name, lwfn_file_name );
}
}
@@ -326,7 +352,7 @@
{
FT_Error error = FT_Err_Ok;
short res_ref, res_id;
- unsigned char *buffer, *p, *size_p;
+ unsigned char *buffer, *p, *size_p = NULL;
FT_ULong total_size = 0;
FT_ULong post_size, pfb_chunk_size;
Handle post_data;
@@ -340,7 +366,7 @@
/* First pass: load all POST resources, and determine the size of
the output buffer. */
- res_id = 501;
+ res_id = 501;
last_code = -1;
for (;;)
@@ -368,9 +394,9 @@
/* Second pass: append all POST data to the buffer, add PFB fields.
Glue all consecutive chunks of the same type together. */
- p = buffer;
- res_id = 501;
- last_code = -1;
+ p = buffer;
+ res_id = 501;
+ last_code = -1;
pfb_chunk_size = 0;
for (;;)
@@ -387,10 +413,13 @@
if ( last_code != -1 )
{
/* we're done adding a chunk, fill in the size field */
- *size_p++ = (FT_Byte)( pfb_chunk_size & 0xFF );
- *size_p++ = (FT_Byte)( ( pfb_chunk_size >> 8 ) & 0xFF );
- *size_p++ = (FT_Byte)( ( pfb_chunk_size >> 16 ) & 0xFF );
- *size_p++ = (FT_Byte)( ( pfb_chunk_size >> 24 ) & 0xFF );
+ if ( size_p != NULL )
+ {
+ *size_p++ = (FT_Byte)( pfb_chunk_size & 0xFF );
+ *size_p++ = (FT_Byte)( ( pfb_chunk_size >> 8 ) & 0xFF );
+ *size_p++ = (FT_Byte)( ( pfb_chunk_size >> 16 ) & 0xFF );
+ *size_p++ = (FT_Byte)( ( pfb_chunk_size >> 24 ) & 0xFF );
+ }
pfb_chunk_size = 0;
}
@@ -442,39 +471,36 @@
/* Create a new memory stream from a buffer and a size. */
static FT_Error
- new_memory_stream( FT_Library library,
- FT_Byte* base,
- FT_ULong size,
- FT_Stream_Close close,
- FT_Stream* astream )
+ new_memory_stream( FT_Library library,
+ FT_Byte* base,
+ FT_ULong size,
+ FT_Stream_CloseFunc close,
+ FT_Stream *astream )
{
- FT_Error error;
- FT_Memory memory;
- FT_Stream stream;
+ FT_Error error;
+ FT_Memory memory;
+ FT_Stream stream;
- if ( !library )
- return FT_Err_Invalid_Library_Handle;
+ if ( !library )
+ return FT_Err_Invalid_Library_Handle;
- if ( !base )
- return FT_Err_Invalid_Argument;
+ if ( !base )
+ return FT_Err_Invalid_Argument;
- *astream = 0;
- memory = library->memory;
- if ( FT_NEW( stream ) )
- goto Exit;
+ *astream = 0;
+ memory = library->memory;
+ if ( FT_NEW( stream ) )
+ goto Exit;
- FT_Stream_OpenMemory( library,
- base,
- size,
- stream );
+ FT_Stream_OpenMemory( stream, base, size );
- stream->close = close;
+ stream->close = close;
- *astream = stream;
+ *astream = stream;
- Exit:
- return error;
+ Exit:
+ return error;
}
@@ -485,7 +511,7 @@
FT_ULong size,
FT_Long face_index,
char* driver_name,
- FT_Face* aface )
+ FT_Face *aface )
{
FT_Open_Args args;
FT_Error error;
@@ -517,9 +543,10 @@
(*aface)->face_flags &= ~FT_FACE_FLAG_EXTERNAL_STREAM;
else
{
- FT_Stream_Close( stream );
+ FT_Stream_CloseFunc( stream );
FT_FREE( stream );
}
+
return error;
}
@@ -529,35 +556,17 @@
FT_New_Face_From_LWFN( FT_Library library,
FSSpec* spec,
FT_Long face_index,
- FT_Face* aface )
+ FT_Face *aface )
{
- FT_Byte* pfb_data;
- FT_ULong pfb_size;
- FT_Error error;
- FT_Memory memory = library->memory;
+ FT_Byte* pfb_data;
+ FT_ULong pfb_size;
+ FT_Error error;
error = read_lwfn( library->memory, spec, &pfb_data, &pfb_size );
if ( error )
return error;
-#if 0
- {
- FILE* f;
- char* path;
-
-
- path = p2c_str( spec->name );
- strcat( path, ".PFB" );
- f = fopen( path, "wb" );
- if ( f )
- {
- fwrite( pfb_data, 1, pfb_size, f );
- fclose( f );
- }
- }
-#endif
-
return open_face_from_buffer( library,
pfb_data,
pfb_size,
@@ -572,12 +581,11 @@
FT_New_Face_From_SFNT( FT_Library library,
short sfnt_id,
FT_Long face_index,
- FT_Face* aface )
+ FT_Face *aface )
{
Handle sfnt = NULL;
FT_Byte* sfnt_data;
size_t sfnt_size;
- FT_Stream stream = NULL;
FT_Error error = 0;
FT_Memory memory = library->memory;
@@ -612,7 +620,7 @@
FT_New_Face_From_Suitcase( FT_Library library,
FSSpec* spec,
FT_Long face_index,
- FT_Face* aface )
+ FT_Face *aface )
{
FT_Error error = FT_Err_Ok;
short res_ref, res_index;
@@ -648,6 +656,8 @@
}
+#if TARGET_API_MAC_CARBON
+
/* Create a new FT_Face from a file spec to a suitcase file. */
static FT_Error
FT_New_Face_From_dfont( FT_Library library,
@@ -694,8 +704,10 @@
return error;
}
+#endif
+
- /* documentation in ftmac.h */
+ /* documentation is in ftmac.h */
FT_EXPORT_DEF( FT_Error )
FT_New_Face_From_FOND( FT_Library library,
@@ -703,13 +715,12 @@
FT_Long face_index,
FT_Face *aface )
{
- short sfnt_id, have_sfnt, have_lwfn = 0;
- Str255 lwfn_file_name;
- short fond_id;
- OSType fond_type;
- Str255 fond_name;
- FSSpec lwfn_spec;
- FT_Error error = FT_Err_Unknown_File_Format;
+ short sfnt_id, have_sfnt, have_lwfn = 0;
+ Str255 lwfn_file_name;
+ short fond_id;
+ OSType fond_type;
+ Str255 fond_name;
+ FSSpec lwfn_spec;
GetResInfo( fond, &fond_id, &fond_type, fond_name );
@@ -743,7 +754,7 @@
}
- /* documentation in ftmac.h */
+ /* documentation is in ftmac.h */
FT_EXPORT_DEF( FT_Error )
FT_GetFile_From_Mac_Name( char* fontName,
@@ -792,7 +803,7 @@
&style, &size );
if ( stat2 == 0 && size == 0 )
{
- char fullName[256];
+ char fullName[256];
/* build up a complete face name */
@@ -829,6 +840,25 @@
}
+ static long
+ ResourceForkSize(FSSpec* spec)
+ {
+ long len;
+ short refNum;
+ OSErr e;
+
+
+ e = FSpOpenRF( spec, fsRdPerm, &refNum ); /* I.M. Files 2-155 */
+ if ( e == noErr )
+ {
+ e = GetEOF( refNum, &len );
+ FSClose( refNum );
+ }
+
+ return ( e == noErr ) ? len : 0;
+ }
+
+
/*************************************************************************/
/* */
/* <Function> */
@@ -858,20 +888,31 @@
if ( file_spec_from_path( pathname, &spec ) )
return FT_Err_Invalid_Argument;
- file_type = get_file_type( &spec );
- if ( file_type == 'FFIL' || file_type == 'tfil' )
- return FT_New_Face_From_Suitcase( library, &spec, face_index, aface );
- else if ( file_type == 'LWFN' )
- return FT_New_Face_From_LWFN( library, &spec, face_index, aface );
- else if ( is_dfont( &spec ) )
- return FT_New_Face_From_dfont( library, &spec, face_index, aface );
- else /* let it fall through to normal loader (.ttf, .otf, etc.) */
+ /* Regardless of type, don't try to use the resource fork if it is */
+ /* empty. Some TTF fonts have type `FFIL', for example, but they */
+ /* only have data forks. */
+
+ if ( ResourceForkSize( &spec ) != 0 )
{
- args.flags = ft_open_pathname;
- args.pathname = (char*)pathname;
+ file_type = get_file_type( &spec );
+ if ( file_type == 'FFIL' || file_type == 'tfil' )
+ return FT_New_Face_From_Suitcase( library, &spec, face_index, aface );
- return FT_Open_Face( library, &args, face_index, aface );
+ if ( file_type == 'LWFN' )
+ return FT_New_Face_From_LWFN( library, &spec, face_index, aface );
}
+
+#if TARGET_API_MAC_CARBON
+
+ if ( is_dfont( &spec ) )
+ return FT_New_Face_From_dfont( library, &spec, face_index, aface );
+
+#endif
+
+ /* let it fall through to normal loader (.ttf, .otf, etc.) */
+ args.flags = ft_open_pathname;
+ args.pathname = (char*)pathname;
+ return FT_Open_Face( library, &args, face_index, aface );
}
diff --git a/src/base/ftobjs.c b/src/base/ftobjs.c
index 18e25c4..116826e 100644
--- a/src/base/ftobjs.c
+++ b/src/base/ftobjs.c
@@ -738,7 +738,7 @@
/* there's a Mac-specific extended implementation of FT_New_Face() */
/* in src/mac/ftmac.c */
-#ifndef macintosh
+#ifndef FT_MACINTOSH
/* documentation is in freetype.h */
@@ -761,7 +761,7 @@
return FT_Open_Face( library, &args, face_index, aface );
}
-#endif /* !macintosh */
+#endif /* !FT_MACINTOSH */
/* documentation is in freetype.h */
diff --git a/src/raster/ftraster.c b/src/raster/ftraster.c
index b3da35d..d756563 100644
--- a/src/raster/ftraster.c
+++ b/src/raster/ftraster.c
@@ -271,10 +271,10 @@
/* States of each line, arc, and profile */
typedef enum TStates_
{
- Unknown,
- Ascending,
- Descending,
- Flat
+ Unknown_State,
+ Ascending_State,
+ Descending_State,
+ Flat_State
} TStates;
@@ -579,12 +579,12 @@
switch ( aState )
{
- case Ascending:
+ case Ascending_State:
ras.cProfile->flow = Flow_Up;
FT_TRACE6(( "New ascending profile = %lx\n", (long)ras.cProfile ));
break;
- case Descending:
+ case Descending_State:
ras.cProfile->flow = Flow_Down;
FT_TRACE6(( "New descending profile = %lx\n", (long)ras.cProfile ));
break;
@@ -1265,34 +1265,34 @@
switch ( ras.state )
{
- case Unknown:
+ case Unknown_State:
if ( y > ras.lastY )
{
- if ( New_Profile( RAS_VARS Ascending ) )
+ if ( New_Profile( RAS_VARS Ascending_State ) )
return FAILURE;
}
else
{
if ( y < ras.lastY )
- if ( New_Profile( RAS_VARS Descending ) )
+ if ( New_Profile( RAS_VARS Descending_State ) )
return FAILURE;
}
break;
- case Ascending:
+ case Ascending_State:
if ( y < ras.lastY )
{
- if ( End_Profile( RAS_VAR ) ||
- New_Profile( RAS_VARS Descending ) )
+ if ( End_Profile( RAS_VAR ) ||
+ New_Profile( RAS_VARS Descending_State ) )
return FAILURE;
}
break;
- case Descending:
+ case Descending_State:
if ( y > ras.lastY )
{
- if ( End_Profile( RAS_VAR ) ||
- New_Profile( RAS_VARS Ascending ) )
+ if ( End_Profile( RAS_VAR ) ||
+ New_Profile( RAS_VARS Ascending_State ) )
return FAILURE;
}
break;
@@ -1305,13 +1305,13 @@
switch ( ras.state )
{
- case Ascending:
+ case Ascending_State:
if ( Line_Up( RAS_VARS ras.lastX, ras.lastY,
x, y, ras.minY, ras.maxY ) )
return FAILURE;
break;
- case Descending:
+ case Descending_State:
if ( Line_Down( RAS_VARS ras.lastX, ras.lastY,
x, y, ras.minY, ras.maxY ) )
return FAILURE;
@@ -1402,11 +1402,11 @@
{
/* the arc is y-monotonous, either ascending or descending */
/* detect a change of direction */
- state_bez = y1 < y3 ? Ascending : Descending;
+ state_bez = y1 < y3 ? Ascending_State : Descending_State;
if ( ras.state != state_bez )
{
/* finalize current profile if any */
- if ( ras.state != Unknown &&
+ if ( ras.state != Unknown_State &&
End_Profile( RAS_VAR ) )
goto Fail;
@@ -1416,7 +1416,7 @@
}
/* now call the appropriate routine */
- if ( state_bez == Ascending )
+ if ( state_bez == Ascending_State )
{
if ( Bezier_Up( RAS_VARS 2, Split_Conic, ras.minY, ras.maxY ) )
goto Fail;
@@ -1529,12 +1529,12 @@
}
else
{
- state_bez = ( y1 <= y4 ) ? Ascending : Descending;
+ state_bez = ( y1 <= y4 ) ? Ascending_State : Descending_State;
/* detect a change of direction */
if ( ras.state != state_bez )
{
- if ( ras.state != Unknown &&
+ if ( ras.state != Unknown_State &&
End_Profile( RAS_VAR ) )
goto Fail;
@@ -1543,7 +1543,7 @@
}
/* compute intersections */
- if ( state_bez == Ascending )
+ if ( state_bez == Ascending_State )
{
if ( Bezier_Up( RAS_VARS 3, Split_Cubic, ras.minY, ras.maxY ) )
goto Fail;
@@ -1838,7 +1838,7 @@
for ( i = 0; i < ras.outline.n_contours; i++ )
{
- ras.state = Unknown;
+ ras.state = Unknown_State;
ras.gProfile = NULL;
if ( Decompose_Curve( RAS_VARS (unsigned short)start,
diff --git a/src/raster/ftrend1.c b/src/raster/ftrend1.c
index 05211e6..0b67bbc 100644
--- a/src/raster/ftrend1.c
+++ b/src/raster/ftrend1.c
@@ -167,7 +167,7 @@
}
else
{
- pitch = ( width + 7 ) >> 3;
+ pitch = ( ( width + 15 ) >> 4 ) << 1;
bitmap->pixel_mode = ft_pixel_mode_mono;
}
diff --git a/src/smooth/ftgrays.c b/src/smooth/ftgrays.c
index 33b8aae..749ff6d 100644
--- a/src/smooth/ftgrays.c
+++ b/src/smooth/ftgrays.c
@@ -217,8 +217,8 @@
/* need to define them to "float" or "double" when experimenting with */
/* new algorithms */
- typedef int TScan; /* integer scanline/pixel coordinate */
- typedef long TPos; /* sub-pixel coordinate */
+ typedef int TCoord; /* integer scanline/pixel coordinate */
+ typedef long TPos; /* sub-pixel coordinate */
/* determine the type used to store cell areas. This normally takes at */
/* least PIXEL_BYTES*2 + 1. On 16-bit systems, we need to use `long' */
@@ -259,10 +259,10 @@
typedef struct TCell_
{
- TScan x;
- TScan y;
- int cover;
- TArea area;
+ TCoord x;
+ TCoord y;
+ int cover;
+ TArea area;
} TCell, *PCell;
@@ -271,22 +271,22 @@
typedef struct TRaster_
{
- PCell cells;
- int max_cells;
- int num_cells;
+ PCell cells;
+ int max_cells;
+ int num_cells;
- TScan min_ex, max_ex;
- TScan min_ey, max_ey;
+ TCoord min_ex, max_ex;
+ TCoord min_ey, max_ey;
- TArea area;
- int cover;
- int invalid;
+ TArea area;
+ int cover;
+ int invalid;
- TScan ex, ey;
- TScan cx, cy;
- TPos x, y;
+ TCoord ex, ey;
+ TCoord cx, cy;
+ TPos x, y;
- TScan last_ey;
+ TCoord last_ey;
FT_Vector bez_stack[32 * 3 + 1];
int lev_stack[32];
@@ -407,8 +407,8 @@
/* Set the current cell to a new position. */
/* */
static void
- gray_set_cell( RAS_ARG_ TScan ex,
- TScan ey )
+ gray_set_cell( RAS_ARG_ TCoord ex,
+ TCoord ey )
{
int invalid, record, clean;
@@ -464,8 +464,8 @@
/* Start a new contour at a given cell. */
/* */
static void
- gray_start_cell( RAS_ARG_ TScan ex,
- TScan ey )
+ gray_start_cell( RAS_ARG_ TCoord ex,
+ TCoord ey )
{
if ( ex < ras.min_ex )
ex = ras.min_ex - 1;
@@ -486,15 +486,15 @@
/* Render a scanline as one or more cells. */
/* */
static void
- gray_render_scanline( RAS_ARG_ TScan ey,
- TPos x1,
- TScan y1,
- TPos x2,
- TScan y2 )
+ gray_render_scanline( RAS_ARG_ TCoord ey,
+ TPos x1,
+ TCoord y1,
+ TPos x2,
+ TCoord y2 )
{
- TScan ex1, ex2, fx1, fx2, delta;
- long p, first, dx;
- int incr, lift, mod, rem;
+ TCoord ex1, ex2, fx1, fx2, delta;
+ long p, first, dx;
+ int incr, lift, mod, rem;
dx = x2 - x1;
@@ -596,9 +596,9 @@
gray_render_line( RAS_ARG_ TPos to_x,
TPos to_y )
{
- TScan ey1, ey2, fy1, fy2;
- TPos dx, dy, x, x2;
- int p, rem, mod, lift, delta, first, incr;
+ TCoord ey1, ey2, fy1, fy2;
+ TPos dx, dy, x, x2;
+ int p, rem, mod, lift, delta, first, incr;
ey1 = TRUNC( ras.last_ey );
@@ -614,7 +614,7 @@
/* perform vertical clipping */
{
- TScan min, max;
+ TCoord min, max;
min = ey1;
@@ -640,9 +640,9 @@
if ( dx == 0 )
{
- TScan ex = TRUNC( ras.x );
- TScan two_fx = ( ras.x - SUBPIXELS( ex ) ) << 1;
- TPos area;
+ TCoord ex = TRUNC( ras.x );
+ TCoord two_fx = ( ras.x - SUBPIXELS( ex ) ) << 1;
+ TPos area;
first = ONE_PIXEL;
@@ -1332,10 +1332,10 @@
static void
- gray_hline( RAS_ARG_ TScan x,
- TScan y,
- TPos area,
- int acount )
+ gray_hline( RAS_ARG_ TCoord x,
+ TCoord y,
+ TPos area,
+ int acount )
{
FT_Span* span;
int count;
@@ -1431,12 +1431,13 @@
static void
gray_sweep( RAS_ARG_ FT_Bitmap* target )
{
- TScan x, y, cover;
- TArea area;
- PCell start, cur, limit;
+ TCoord x, y, cover;
+ TArea area;
+ PCell start, cur, limit;
FT_UNUSED( target );
+
if ( ras.num_cells == 0 )
return;