- various performance enhancements - fixing apinames.c, adding support for Watcom and Borland compilers - adding generation of exported symbols list to the build system, including the Unix one !! sorry Werner, I have no time to document this in ChangeLog at the moment
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 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748
diff --git a/Jamfile b/Jamfile
index 5dcf528..2a3a2fb 100644
--- a/Jamfile
+++ b/Jamfile
@@ -155,12 +155,14 @@ SubInclude FT2_TOP $(FT2_SRC_DIR) tools ;
rule GenExportSymbols
{
- local headers = [ Glob $(2) : *.h ] ;
+ local apinames = apinames$(SUFEXE) ;
+ local headers = [ Glob $(2) : *.h ] ;
APINAMES on $(1) = apinames$(SUFEXE) ;
- Depends $(1) : $(headers) ;
+ Depends $(1) : $(apinames) $(headers) ;
GenExportSymbols1 $(1) : $(headers) ;
+ Clean clean : $(1) ;
}
actions GenExportSymbols1 bind APINAMES
diff --git a/builds/compiler/visualc.mk b/builds/compiler/visualc.mk
index 92d71a9..498f5b9 100644
--- a/builds/compiler/visualc.mk
+++ b/builds/compiler/visualc.mk
@@ -55,6 +55,9 @@ L := /Fl
#
T := /Fo
+# Target executable flag
+#
+TE := /Fe
# C flags
#
diff --git a/builds/dos/dos-def.mk b/builds/dos/dos-def.mk
index d6bc72e..faed1ac 100644
--- a/builds/dos/dos-def.mk
+++ b/builds/dos/dos-def.mk
@@ -19,6 +19,10 @@ BUILD_DIR := $(TOP_DIR)/builds/dos
PLATFORM := dos
+# The executable file extension (for tools). NOTE: WE INCLUDE THE DOT HERE !!
+#
+E := .exe
+
# The directory where all object files are placed.
#
# This lets you build the library in your own directory with something like
diff --git a/builds/freetype.mk b/builds/freetype.mk
index ff1b19e..e152075 100644
--- a/builds/freetype.mk
+++ b/builds/freetype.mk
@@ -142,6 +142,9 @@ FT_COMPILE = $(CC) $(ANSIFLAGS) $(FT_CFLAGS)
#
include $(TOP_DIR)/builds/modules.mk
+# Includes the 'exports' rules file.
+#
+include $(TOP_DIR)/builds/exports.mk
# Initialize the list of objects.
#
@@ -247,6 +250,8 @@ objects: $(OBJECTS_LIST)
library: $(PROJECT_LIBRARY)
+dll: $(PROJECT_LIBRARY) exported_symbols
+
.c.$O:
$(FT_COMPILE) $T$(subst /,$(COMPILER_SEP),$@ $<)
@@ -283,7 +288,7 @@ distclean_project_std: clean_project_std
# working correctly on Win9x.
#
clean_project_dos:
- -$(DELETE) $(subst /,\,$(OBJ)/*.$O $(CLEAN) $(NO_OUTPUT))
+ -$(DELETE) $(subst /,\,$(OBJ_DIR)/*.$O $(CLEAN) $(NO_OUTPUT))
distclean_project_dos: clean_project_dos
-$(DELETE) $(subst /,\,$(PROJECT_LIBRARY) $(DISTCLEAN) $(NO_OUTPUT))
diff --git a/builds/os2/os2-def.mk b/builds/os2/os2-def.mk
index 26bf6a9..b59710c 100644
--- a/builds/os2/os2-def.mk
+++ b/builds/os2/os2-def.mk
@@ -18,6 +18,9 @@ SEP := $(strip \ )
BUILD_DIR := $(TOP_DIR)/builds/os2
PLATFORM := os2
+# The executable file extension (for tools). NOTE: WE INCLUDE THE DOT HERE !!
+#
+E := .exe
# The directory where all object files are placed.
#
diff --git a/builds/unix/ftsystem.c b/builds/unix/ftsystem.c
index a3520a8..d69312c 100644
--- a/builds/unix/ftsystem.c
+++ b/builds/unix/ftsystem.c
@@ -280,27 +280,27 @@
else
{
ssize_t total_read_count;
-
+
FT_ERROR(( "FT_Stream_Open:" ));
FT_ERROR(( " could not `mmap' file `%s'\n", filepathname ));
-
+
stream->base = (unsigned char*)ft_alloc( NULL, stream->size );
-
+
if ( !stream->base )
{
FT_ERROR(( "FT_Stream_Open:" ));
FT_ERROR(( " could not `alloc' memory\n" ));
goto Fail_Map;
}
-
+
total_read_count = 0;
do {
ssize_t read_count;
- read_count = read( file,
- stream->base + total_read_count,
+ read_count = read( file,
+ stream->base + total_read_count,
stream->size - total_read_count );
if ( ( read_count == -1 ) )
diff --git a/builds/unix/unix-cc.in b/builds/unix/unix-cc.in
index 2d1f17e..c488ee0 100644
--- a/builds/unix/unix-cc.in
+++ b/builds/unix/unix-cc.in
@@ -90,11 +90,16 @@ CC := $(LIBTOOL) --mode=compile $(CCraw)
LDFLAGS := @LDFLAGS@
+# export symbols (XXX: HOW TO DEAL WITH CROSS COMPILATION ?)
+#
+EXPORTS_LIST := $(OBJ_DIR)/ftexport.sym
+CCexe := $(CCraw) # used to compile "apinames" only
+
+
# Library linking
#
LINK_LIBRARY = $(LIBTOOL) --mode=link $(CCraw) -o $@ $(OBJECTS_LIST) \
-rpath $(libdir) -version-info $(version_info) \
- $(LDFLAGS)
-
+ $(LDFLAGS) -export-symbols $(EXPORTS_LIST)
# EOF
diff --git a/builds/unix/unixddef.mk b/builds/unix/unixddef.mk
index 803ce75..947673e 100644
--- a/builds/unix/unixddef.mk
+++ b/builds/unix/unixddef.mk
@@ -51,5 +51,4 @@ LIB_DIR := $(OBJ_DIR)
NO_OUTPUT := 2> /dev/null
-
# EOF
diff --git a/builds/win32/w32-bcc.mk b/builds/win32/w32-bcc.mk
index 522d6b3..5525dff 100644
--- a/builds/win32/w32-bcc.mk
+++ b/builds/win32/w32-bcc.mk
@@ -12,6 +12,11 @@
# indicate that you have read the license and understand and accept it
# fully.
+# default definitions of the export list
+#
+EXPORTS_LIST = $(OBJ_DIR)/freetype.def
+EXPORTS_OPTIONS = /DEF:$(EXPORTS_LIST)
+APINAMES_OPTIONS := -dfreetype.dll -wB
include $(TOP_DIR)/builds/win32/win32-def.mk
include $(TOP_DIR)/builds/compiler/bcc.mk
diff --git a/builds/win32/w32-gcc.mk b/builds/win32/w32-gcc.mk
index 91d1133..6f0a0e9 100644
--- a/builds/win32/w32-gcc.mk
+++ b/builds/win32/w32-gcc.mk
@@ -12,6 +12,11 @@
# indicate that you have read the license and understand and accept it
# fully.
+# default definitions of the export list
+#
+EXPORTS_LIST = $(OBJ_DIR)/freetype.def
+EXPORTS_OPTIONS = $(EXPORTS_LIST)
+APINAMES_OPTIONS := -dfreetype.dll -w
# include Win32-specific definitions
include $(TOP_DIR)/builds/win32/win32-def.mk
diff --git a/builds/win32/w32-icc.mk b/builds/win32/w32-icc.mk
index 1e18202..2f61c25 100644
--- a/builds/win32/w32-icc.mk
+++ b/builds/win32/w32-icc.mk
@@ -12,6 +12,11 @@
# indicate that you have read the license and understand and accept it
# fully.
+# default definitions of the export list
+#
+EXPORTS_LIST = $(OBJ_DIR)/freetype.def
+EXPORTS_OPTIONS = /DEF:$(EXPORTS_LIST)
+APINAMES_OPTIONS := -dfreetype.dll -w
include $(TOP_DIR)/builds/win32/win32-def.mk
include $(TOP_DIR)/builds/compiler/visualage.mk
diff --git a/builds/win32/w32-intl.mk b/builds/win32/w32-intl.mk
index 5c42ad3..1c4a4bc 100644
--- a/builds/win32/w32-intl.mk
+++ b/builds/win32/w32-intl.mk
@@ -12,6 +12,11 @@
# indicate that you have read the license and understand and accept it
# fully.
+# default definitions of the export list
+#
+EXPORTS_LIST = $(OBJ_DIR)/freetype.def
+EXPORTS_OPTIONS = /DEF:$(EXPORTS_LIST)
+APINAMES_OPTIONS := -dfreetype.dll -w
include $(TOP_DIR)/builds/win32/win32-def.mk
include $(TOP_DIR)/builds/compiler/intelc.mk
diff --git a/builds/win32/w32-mingw32.mk b/builds/win32/w32-mingw32.mk
index 01f71b3..aa22be9 100644
--- a/builds/win32/w32-mingw32.mk
+++ b/builds/win32/w32-mingw32.mk
@@ -12,6 +12,11 @@
# indicate that you have read the license and understand and accept it
# fully.
+# default definitions of the export list
+#
+EXPORTS_LIST = $(OBJ_DIR)/freetype.def
+EXPORTS_OPTIONS = $(EXPORTS_LIST)
+APINAMES_OPTIONS := -dfreetype.dll -w
# include Win32-specific definitions
include $(TOP_DIR)/builds/win32/win32-def.mk
diff --git a/builds/win32/w32-vcc.mk b/builds/win32/w32-vcc.mk
index 37bfec3..010a4d5 100644
--- a/builds/win32/w32-vcc.mk
+++ b/builds/win32/w32-vcc.mk
@@ -12,6 +12,11 @@
# indicate that you have read the license and understand and accept it
# fully.
+# definitions of the export list
+#
+EXPORTS_LIST = $(OBJ_DIR)/freetype.def
+EXPORTS_OPTIONS = /DEF:$(EXPORTS_LIST)
+APINAMES_OPTIONS := -dfreetype.dll -w
include $(TOP_DIR)/builds/win32/win32-def.mk
include $(TOP_DIR)/builds/compiler/visualc.mk
diff --git a/builds/win32/w32-wat.mk b/builds/win32/w32-wat.mk
index accafc5..1debcab 100644
--- a/builds/win32/w32-wat.mk
+++ b/builds/win32/w32-wat.mk
@@ -12,6 +12,11 @@
# indicate that you have read the license and understand and accept it
# fully.
+# redefine export symbol definitions
+#
+EXPORTS_LIST = $(OBJ_DIR)/watcom-ftexports.lbc
+EXPORTS_OPTIONS = -\"export @$(EXPORTS_LIST)\"-
+APINAMES_OPTIONS := -wW
include $(TOP_DIR)/builds/win32/win32-def.mk
include $(TOP_DIR)/builds/compiler/watcom.mk
diff --git a/builds/win32/win32-def.mk b/builds/win32/win32-def.mk
index a9db459..cd3e681 100644
--- a/builds/win32/win32-def.mk
+++ b/builds/win32/win32-def.mk
@@ -18,6 +18,9 @@ SEP := $(strip \ )
BUILD_DIR := $(TOP_DIR)/builds/win32
PLATFORM := win32
+# The executable file extension (for tools). NOTE: WE INCLUDE THE DOT HERE !!
+#
+E := .exe
# The directory where all object files are placed.
#
diff --git a/include/freetype/internal/ftgloadr.h b/include/freetype/internal/ftgloadr.h
index abc56e2..50c557f 100644
--- a/include/freetype/internal/ftgloadr.h
+++ b/include/freetype/internal/ftgloadr.h
@@ -59,7 +59,7 @@ FT_BEGIN_HEADER
FT_Int arg1;
FT_Int arg2;
FT_Matrix transform;
-
+
} FT_SubGlyphRec;
@@ -117,6 +117,22 @@ FT_BEGIN_HEADER
FT_UInt n_points,
FT_UInt n_contours );
+#define FT_GLYPHLOADER_CHECK_P(_loader,_count) \
+ ( (_count) == 0 || (int)((_loader)->base.outline.n_points + \
+ (_loader)->current.outline.n_points + \
+ (_count)) <= (int)(_loader)->max_points )
+
+#define FT_GLYPHLOADER_CHECK_C(_loader,_count) \
+ ( (_count) == 0 || (int)((_loader)->base.outline.n_contours + \
+ (_loader)->current.outline.n_contours + \
+ (_count)) <= (int)(_loader)->max_contours )
+
+#define FT_GLYPHLOADER_CHECK_POINTS(_loader,_points,_contours) \
+ ( ( FT_GLYPHLOADER_CHECK_P(_loader,_points) && \
+ FT_GLYPHLOADER_CHECK_C(_loader,_contours) ) \
+ ? 0 \
+ : FT_GlyphLoader_CheckPoints( (_loader), (_points), (_contours) ) )
+
/* check that there is enough space to add `n_subs' sub-glyphs to */
/* a glyph loader */
FT_BASE( FT_Error )
diff --git a/src/autofit/afhints.c b/src/autofit/afhints.c
index a3095ee..4e071cd 100644
--- a/src/autofit/afhints.c
+++ b/src/autofit/afhints.c
@@ -265,11 +265,55 @@
#endif /* AF_DEBUG */
+
/* compute the direction value of a given vector */
FT_LOCAL_DEF( AF_Direction )
af_direction_compute( FT_Pos dx,
FT_Pos dy )
{
+#if 1
+ AF_Direction dir = AF_DIR_NONE;
+
+ if ( dx < 0 )
+ {
+ if ( dy < 0 )
+ {
+ if ( -dx*12 < -dy )
+ dir = AF_DIR_DOWN;
+
+ else if ( -dy*12 < -dx )
+ dir = AF_DIR_LEFT;
+ }
+ else /* dy >= 0 */
+ {
+ if ( -dx*12 < dy )
+ dir = AF_DIR_UP;
+
+ else if ( dy*12 < -dx )
+ dir = AF_DIR_LEFT;
+ }
+ }
+ else /* dx >= 0 */
+ {
+ if ( dy < 0 )
+ {
+ if ( dx*12 < -dy )
+ dir = AF_DIR_DOWN;
+
+ else if ( -dy*12 < dx )
+ dir = AF_DIR_RIGHT;
+ }
+ else /* dy >= 0 */
+ {
+ if ( dx*12 < dy )
+ dir = AF_DIR_UP;
+
+ else if ( dy*12 < dx )
+ dir = AF_DIR_RIGHT;
+ }
+ }
+ return dir;
+#else
AF_Direction dir;
FT_Pos ax = FT_ABS( dx );
FT_Pos ay = FT_ABS( dy );
@@ -291,6 +335,7 @@
}
return dir;
+#endif
}
@@ -350,7 +395,8 @@
} while ( angle_in == angle_seg );
first = start;
- diff_in = af_angle_diff( angle_in, angle_seg );
+
+ AF_ANGLE_DIFF( diff_in, angle_in, angle_seg );
/* now, process all segments in the contour */
do
@@ -373,7 +419,7 @@
} while ( angle_out == angle_seg );
- diff_out = af_angle_diff( angle_seg, angle_out );
+ AF_ANGLE_DIFF( diff_out, angle_seg, angle_out );
if ( ( diff_in ^ diff_out ) < 0 )
{
@@ -657,7 +703,8 @@
angle_in = af_angle_atan( in_x, in_y );
angle_out = af_angle_atan( out_x, out_y );
- delta = af_angle_diff( angle_in, angle_out );
+
+ AF_ANGLE_DIFF( delta, angle_in, angle_out );
if ( delta < 2 && delta > -2 )
goto Is_Weak_Point;
diff --git a/src/autofit/afloader.c b/src/autofit/afloader.c
index c3f3b2c..520a9ce 100644
--- a/src/autofit/afloader.c
+++ b/src/autofit/afloader.c
@@ -138,9 +138,9 @@
/* copy the outline points in the loader's current */
/* extra points which is used to keep original glyph coordinates */
- error = FT_GlyphLoader_CheckPoints( gloader,
- slot->outline.n_points + 4,
- slot->outline.n_contours );
+ error = FT_GLYPHLOADER_CHECK_POINTS( gloader,
+ slot->outline.n_points + 4,
+ slot->outline.n_contours );
if ( error )
goto Exit;
diff --git a/src/autofit/aftypes.h b/src/autofit/aftypes.h
index c9323e7..68fafdb 100644
--- a/src/autofit/aftypes.h
+++ b/src/autofit/aftypes.h
@@ -133,6 +133,20 @@ FT_BEGIN_HEADER
af_angle_diff( AF_Angle angle1,
AF_Angle angle2 );
+#define AF_ANGLE_DIFF(result,angle1,angle2) \
+ FT_BEGIN_STMNT \
+ AF_Angle _delta = (angle2) - (angle1); \
+ \
+ \
+ _delta %= AF_ANGLE_2PI; \
+ if ( _delta < 0 ) \
+ _delta += AF_ANGLE_2PI; \
+ \
+ if ( _delta > AF_ANGLE_PI ) \
+ _delta -= AF_ANGLE_2PI; \
+ \
+ result = _delta; \
+ FT_END_STMNT
/*************************************************************************/
/*************************************************************************/
diff --git a/src/base/ftcalc.c b/src/base/ftcalc.c
index 6e19e55..3ade4ac 100644
--- a/src/base/ftcalc.c
+++ b/src/base/ftcalc.c
@@ -394,6 +394,38 @@
FT_MulFix( FT_Long a,
FT_Long b )
{
+#if 1
+ FT_Long sa, sb;
+ FT_ULong ua, ub;
+
+
+ if ( a == 0 || b == 0x10000L )
+ return a;
+
+ sa = (a >> (sizeof(a)*8 - 1)); a = (a^sa) - sa;
+ sb = (b >> (sizeof(b)*8 - 1)); b = (b^sb) - sb;
+
+ ua = (FT_ULong)a;
+ ub = (FT_ULong)b;
+
+ if ( ua <= 2048 && ub <= 1048576L )
+ {
+ ua = ( ua * ub + 0x8000 ) >> 16;
+ }
+ else
+ {
+ FT_ULong al = ua & 0xFFFF;
+
+
+ ua = ( ua >> 16 ) * ub + al * ( ub >> 16 ) +
+ ( ( al * ( ub & 0xFFFF ) + 0x8000 ) >> 16 );
+ }
+
+ sa ^= sb,
+ ua = (FT_ULong)((ua ^ sa) - sa);
+
+ return (FT_Long)ua;
+#else
FT_Long s;
FT_ULong ua, ub;
@@ -421,6 +453,7 @@
}
return ( s < 0 ? -(FT_Long)ua : (FT_Long)ua );
+#endif
}
diff --git a/src/base/ftgloadr.c b/src/base/ftgloadr.c
index 980609a..81ecd8e 100644
--- a/src/base/ftgloadr.c
+++ b/src/base/ftgloadr.c
@@ -195,7 +195,7 @@
FT_Error error = FT_Err_Ok;
FT_Outline* base = &loader->base.outline;
FT_Outline* current = &loader->current.outline;
- FT_Bool adjust = 1;
+ FT_Bool adjust = 0;
FT_UInt new_max, old_max;
diff --git a/src/base/fttrigon.c b/src/base/fttrigon.c
index 1ab3438..bc6c45b 100644
--- a/src/base/fttrigon.c
+++ b/src/base/fttrigon.c
@@ -109,6 +109,46 @@
z = ( ( x >= 0 ) ? x : - x ) | ( (y >= 0) ? y : -y );
shift = 0;
+#if 1
+ /* determine msb bit index in 'shift' */
+ if ( z >= (1L << 16 ) )
+ {
+ z >>= 16;
+ shift += 16;
+ }
+ if ( z >= (1L << 8) )
+ {
+ z >>= 8;
+ shift += 8;
+ }
+ if ( z >= (1L << 4) )
+ {
+ z >>= 4;
+ shift += 4;
+ }
+ if ( z >= (1L << 2) )
+ {
+ z >>= 2;
+ shift += 2;
+ }
+ if ( z >= 1 )
+ shift += 1;
+
+ if ( shift < 28 )
+ {
+ shift = 28-shift;
+
+ vec->x = x << shift;
+ vec->y = y << shift;
+ }
+ else if ( shift > 28 )
+ {
+ shift -= 28;
+ vec->x = x >> shift;
+ vec->y = y >> shift;
+ shift = -shift;
+ }
+#else
if ( z < ( 1L << 27 ) )
{
do
@@ -116,7 +156,6 @@
shift++;
z <<= 1;
} while ( z < ( 1L << 27 ) );
-
vec->x = x << shift;
vec->y = y << shift;
}
@@ -132,6 +171,7 @@
vec->y = y >> shift;
shift = -shift;
}
+#endif
return shift;
}
diff --git a/src/cff/cffgload.c b/src/cff/cffgload.c
index cdb7482..f4e7753 100644
--- a/src/cff/cffgload.c
+++ b/src/cff/cffgload.c
@@ -403,7 +403,7 @@
check_points( CFF_Builder* builder,
FT_Int count )
{
- return FT_GlyphLoader_CheckPoints( builder->loader, count, 0 );
+ return FT_GLYPHLOADER_CHECK_POINTS( builder->loader, count, 0 );
}
@@ -465,7 +465,7 @@
return CFF_Err_Ok;
}
- error = FT_GlyphLoader_CheckPoints( builder->loader, 0, 1 );
+ error = FT_GLYPHLOADER_CHECK_POINTS( builder->loader, 0, 1 );
if ( !error )
{
if ( outline->n_contours > 0 )
diff --git a/src/pfr/pfrgload.c b/src/pfr/pfrgload.c
index f961582..18d7a22 100644
--- a/src/pfr/pfrgload.c
+++ b/src/pfr/pfrgload.c
@@ -133,7 +133,7 @@
/* check that we have begun a new path */
FT_ASSERT( glyph->path_begun != 0 );
- error = FT_GlyphLoader_CheckPoints( loader, 1, 0 );
+ error = FT_GLYPHLOADER_CHECK_POINTS( loader, 1, 0 );
if ( !error )
{
FT_UInt n = outline->n_points;
@@ -163,7 +163,7 @@
/* check that we have begun a new path */
FT_ASSERT( glyph->path_begun != 0 );
- error = FT_GlyphLoader_CheckPoints( loader, 3, 0 );
+ error = FT_GLYPHLOADER_CHECK_POINTS( loader, 3, 0 );
if ( !error )
{
FT_Vector* vec = outline->points + outline->n_points;
@@ -199,7 +199,7 @@
glyph->path_begun = 1;
/* check that there is space for a new contour and a new point */
- error = FT_GlyphLoader_CheckPoints( loader, 1, 1 );
+ error = FT_GLYPHLOADER_CHECK_POINTS( loader, 1, 1 );
if ( !error )
/* add new start point */
error = pfr_glyph_line_to( glyph, to );
diff --git a/src/pfr/pfrload.c b/src/pfr/pfrload.c
index 6961dc4..656444d 100644
--- a/src/pfr/pfrload.c
+++ b/src/pfr/pfrload.c
@@ -609,148 +609,6 @@
}
-#ifndef FT_OPTIMIZE_MEMORY
-
- /*
- * The kerning data embedded in a PFR font are (charcode,charcode)
- * pairs; we need to translate them to (gindex,gindex) and sort
- * the resulting array.
- */
- static FT_UInt
- pfr_get_gindex( PFR_Char chars,
- FT_UInt count,
- FT_UInt charcode )
- {
- FT_UInt min = 0;
- FT_UInt max = count;
-
-
- while ( min < max )
- {
- FT_UInt mid = ( min + max ) >> 1;
- PFR_Char c = chars + mid;
-
-
- if ( c->char_code == charcode )
- return mid + 1;
-
- if ( c->char_code < charcode )
- min = mid + 1;
- else
- max = mid;
- }
- return 0;
- }
-
-
- FT_CALLBACK_DEF( int )
- pfr_compare_kern_pairs( const void* pair1,
- const void* pair2 )
- {
- FT_UInt32 p1 = PFR_KERN_PAIR_INDEX( (PFR_KernPair)pair1 );
- FT_UInt32 p2 = PFR_KERN_PAIR_INDEX( (PFR_KernPair)pair2 );
-
-
- if ( p1 < p2 )
- return -1;
- if ( p1 > p2 )
- return 1;
- return 0;
- }
-
-
- static FT_Error
- pfr_sort_kerning_pairs( FT_Stream stream,
- PFR_PhyFont phy_font )
- {
- FT_Error error;
- FT_Memory memory = stream->memory;
- PFR_KernPair pairs;
- PFR_KernItem item;
- PFR_Char chars = phy_font->chars;
- FT_UInt num_chars = phy_font->num_chars;
- FT_UInt count;
-
-
- /* create kerning pairs array */
- if ( FT_NEW_ARRAY( phy_font->kern_pairs, phy_font->num_kern_pairs ) )
- goto Exit;
-
- /*
- * load all kerning items into the array,
- * converting character codes into glyph indices
- */
- pairs = phy_font->kern_pairs;
- item = phy_font->kern_items;
- count = 0;
-
- for ( ; item; item = item->next )
- {
- FT_UInt limit = count + item->pair_count;
- FT_Byte* p;
-
-
- if ( limit > phy_font->num_kern_pairs )
- {
- error = PFR_Err_Invalid_Table;
- goto Exit;
- }
-
- if ( FT_STREAM_SEEK( item->offset ) ||
- FT_FRAME_ENTER( item->pair_count * item->pair_size ) )
- goto Exit;
-
- p = stream->cursor;
-
- for ( ; count < limit; count++ )
- {
- PFR_KernPair pair = pairs + count;
- FT_UInt char1, char2;
- FT_Int kerning;
-
-
- if ( item->flags & PFR_KERN_2BYTE_CHAR )
- {
- char1 = FT_NEXT_USHORT( p );
- char2 = FT_NEXT_USHORT( p );
- }
- else
- {
- char1 = FT_NEXT_BYTE( p );
- char2 = FT_NEXT_BYTE( p );
- }
-
- if ( item->flags & PFR_KERN_2BYTE_ADJ )
- kerning = item->base_adj + FT_NEXT_SHORT( p );
- else
- kerning = item->base_adj + FT_NEXT_BYTE( p );
-
- pair->glyph1 = pfr_get_gindex( chars, num_chars, char1 );
- pair->glyph2 = pfr_get_gindex( chars, num_chars, char2 );
- pair->kerning = kerning;
- }
-
- FT_FRAME_EXIT();
- }
-
- /* sort the resulting array */
- ft_qsort( pairs, count,
- sizeof ( PFR_KernPairRec ),
- pfr_compare_kern_pairs );
-
- Exit:
- if ( error )
- {
- /* disable kerning data in case of error
- */
- phy_font->num_kern_pairs = 0;
- }
-
- return error;
- }
-
-#endif /* !FT_OPTIMIZE_MEMORY */
-
static const PFR_ExtraItemRec pfr_phy_font_extra_items[] =
{
@@ -829,10 +687,6 @@
FT_FREE( phy_font->blue_values );
phy_font->num_blue_values = 0;
-#ifndef FT_OPTIMIZE_MEMORY
- FT_FREE( phy_font->kern_pairs );
-#endif
-
{
PFR_KernItem item, next;
@@ -1071,11 +925,6 @@
phy_font->bct_offset = FT_STREAM_POS();
phy_font->cursor = NULL;
-#ifndef FT_OPTIMIZE_MEMORY
- /* now sort kerning pairs */
- error = pfr_sort_kerning_pairs( stream, phy_font );
-#endif
-
Exit:
return error;
diff --git a/src/pfr/pfrobjs.c b/src/pfr/pfrobjs.c
index a4eefb0..124291c 100644
--- a/src/pfr/pfrobjs.c
+++ b/src/pfr/pfrobjs.c
@@ -422,8 +422,6 @@
/*************************************************************************/
/*************************************************************************/
-#ifdef FT_OPTIMIZE_MEMORY
-
FT_LOCAL_DEF( FT_Error )
pfr_face_get_kerning( FT_Face pfrface, /* PFR_Face */
FT_UInt glyph1,
@@ -546,51 +544,4 @@
return error;
}
-#else /* !FT_OPTIMIZE_MEMORY */
-
- FT_LOCAL_DEF( FT_Error )
- pfr_face_get_kerning( FT_Face pfrface, /* PFR_Face */
- FT_UInt glyph1,
- FT_UInt glyph2,
- FT_Vector* kerning )
- {
- PFR_Face face = (PFR_Face)pfrface;
- FT_Error error = PFR_Err_Ok;
- PFR_PhyFont phy_font = &face->phy_font;
- PFR_KernPair pairs = phy_font->kern_pairs;
- FT_UInt32 idx = PFR_KERN_INDEX( glyph1, glyph2 );
- FT_UInt min, max;
-
-
- kerning->x = 0;
- kerning->y = 0;
-
- min = 0;
- max = phy_font->num_kern_pairs;
-
- while ( min < max )
- {
- FT_UInt mid = ( min + max ) >> 1;
- PFR_KernPair pair = pairs + mid;
- FT_UInt32 pidx = PFR_KERN_PAIR_INDEX( pair );
-
-
- if ( pidx == idx )
- {
- kerning->x = pair->kerning;
- break;
- }
-
- if ( pidx < idx )
- min = mid + 1;
- else
- max = mid;
- }
-
- return error;
- }
-
-#endif /* !FT_OPTIMIZE_MEMORY */
-
-
/* END */
diff --git a/src/pfr/pfrtypes.h b/src/pfr/pfrtypes.h
index b8bd557..df12ecf 100644
--- a/src/pfr/pfrtypes.h
+++ b/src/pfr/pfrtypes.h
@@ -217,14 +217,6 @@ FT_BEGIN_HEADER
( (FT_UInt32)p[-2] << 16 ) | p[-1] )
- typedef struct PFR_KernPairRec_
- {
- FT_UInt glyph1;
- FT_UInt glyph2;
- FT_Int kerning;
-
- } PFR_KernPairRec, *PFR_KernPair;
-
/************************************************************************/
typedef struct PFR_PhyFontRec_
@@ -266,9 +258,6 @@ FT_BEGIN_HEADER
FT_UInt num_kern_pairs;
PFR_KernItem kern_items;
PFR_KernItem* kern_items_tail;
-#ifndef FT_OPTIMIZE_MEMORY
- PFR_KernPair kern_pairs;
-#endif
/* not part of the spec, but used during load */
FT_UInt32 bct_offset;
diff --git a/src/psaux/psobjs.c b/src/psaux/psobjs.c
index 19a1830..5676ac2 100644
--- a/src/psaux/psobjs.c
+++ b/src/psaux/psobjs.c
@@ -1623,7 +1623,7 @@
t1_builder_check_points( T1_Builder builder,
FT_Int count )
{
- return FT_GlyphLoader_CheckPoints( builder->loader, count, 0 );
+ return FT_GLYPHLOADER_CHECK_POINTS( builder->loader, count, 0 );
}
@@ -1689,7 +1689,7 @@
return PSaux_Err_Ok;
}
- error = FT_GlyphLoader_CheckPoints( builder->loader, 0, 1 );
+ error = FT_GLYPHLOADER_CHECK_POINTS( builder->loader, 0, 1 );
if ( !error )
{
if ( outline->n_contours > 0 )
diff --git a/src/tools/apinames.c b/src/tools/apinames.c
index 4f151eb..e4383cf 100644
--- a/src/tools/apinames.c
+++ b/src/tools/apinames.c
@@ -1,323 +1,441 @@
-/*
- * This little program is used to parse the FreeType headers and
- * find the declaration of all public API. This is easy, because
- * they all look like the following:
- *
- * FT_EXPORT( return_type )
- * function_name( function arguments );
- *
- * You must pass the list of header files as arguments. Wildcards are
- * accepted if you are using GCC for compilation (and probably by
- * other compilers too).
- *
- * Author: David Turner, 2005
- *
- * This code is explicitly placed into the public domain.
- *
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-
-#define PROGRAM_NAME "apinames"
-#define PROGRAM_VERSION "0.1"
-
-#define LINEBUFF_SIZE 1024
-
-static void
-panic( const char* message )
-{
- fprintf( stderr, "PANIC: %s\n", message );
- exit(2);
-}
-
-
-typedef struct
-{
- char* name;
- unsigned int hash;
-
-} NameRec, *Name;
-
-static Name the_names;
-static int num_names;
-static int max_names;
-
-static void
-names_add( const char* name,
- const char* end )
-{
- int nn, len, h;
- Name nm;
-
- if ( end <= name )
- return;
-
- /* compute hash value */
- len = (int)(end - name);
- h = 0;
- for ( nn = 0; nn < len; nn++ )
- h = h*33 + name[nn];
-
- /* check for an pre-existing name */
- for ( nn = 0; nn < num_names; nn++ )
- {
- nm = the_names + nn;
-
- if ( nm->hash == h &&
- memcmp( name, nm->name, len ) == 0 &&
- nm->name[len] == 0 )
- return;
- }
-
- /* add new name */
- if ( num_names >= max_names )
- {
- max_names += (max_names >> 1) + 4;
- the_names = realloc( the_names, sizeof(the_names[0])*max_names );
- if ( the_names == NULL )
- panic( "not enough memory" );
- }
- nm = &the_names[num_names++];
-
- nm->hash = h;
- nm->name = malloc( len+1 );
- if ( nm->name == NULL )
- panic( "not enough memory" );
-
- memcpy( nm->name, name, len );
- nm->name[len] = 0;
-}
-
-
-static int
-name_compare( const void* name1,
- const void* name2 )
-{
- Name n1 = (Name)name1;
- Name n2 = (Name)name2;
-
- return strcmp( n1->name, n2->name );
-}
-
-static void
-names_sort( void )
-{
- qsort( the_names, (size_t)num_names, sizeof(the_names[0]), name_compare );
-}
-
-static void
-names_dump( FILE* out )
-{
- int nn;
-
- for ( nn = 0; nn < num_names; nn++ )
- fprintf( out, "%s\n", the_names[nn].name );
-}
-
-
-static void
-names_dump_windef( FILE* out )
-{
- int nn;
-
- /* note that we assume that __cdecl was used when compiling the
- * DLL object files.
- */
- fprintf( out, "DESCRIPTION FreeType 2 DLL\n" );
- fprintf( out, "EXPORTS\n" );
- for ( nn = 0; nn < num_names; nn++ )
- fprintf( out, " %s\n", the_names[nn].name );
-}
-
-
-/* states of the line parser */
-
-typedef enum
-{
- STATE_START = 0, /* waiting for FT_EXPORT keyword and return type */
- STATE_TYPE, /* type was read, waiting for function name */
-
-} State;
-
-static int
-read_header_file( FILE* file, int verbose )
-{
- static char buff[ LINEBUFF_SIZE+1 ];
- State state = STATE_START;
-
- while ( !feof( file ) )
- {
- char* p;
-
- if ( !fgets( buff, LINEBUFF_SIZE, file ) )
- break;
-
- p = buff;
-
- while ( *p && (*p == ' ' || *p == '\\') ) /* skip leading whitespace */
- p++;
-
- if ( *p == '\n' || *p == '\r' ) /* skip empty lines */
- continue;
-
- switch ( state )
- {
- case STATE_START:
- {
- if ( memcmp( p, "FT_EXPORT(", 10 ) != 0 )
- break;
-
- p += 10;
- for (;;)
- {
- if ( *p == 0 || *p == '\n' || *p == '\r' )
- goto NextLine;
-
- if ( *p == ')' )
- {
- p++;
- break;
- }
-
- p++;
- }
-
- state = STATE_TYPE;
-
- /* sometimes, the name is just after the FT_EXPORT(...), so
- * skip whitespace, and fall-through if we find an alphanumeric
- * character
- */
- while ( *p == ' ' || *p == '\t' )
- p++;
-
- if ( !isalpha(*p) )
- break;
- }
- /* fall-through */
-
- case STATE_TYPE:
- {
- char* name = p;
- size_t func_len;
-
- while ( isalpha(*p) || *p == '_' )
- p++;
-
- if ( p > name )
- {
- if ( verbose )
- fprintf( stderr, ">>> %.*s\n", p-name, name );
-
- names_add( name, p );
- }
-
- state = STATE_START;
- }
- break;
-
- default:
- ;
- }
-
- NextLine:
- ;
- }
-
- return 0;
-}
-
-
-static void
-usage( void )
-{
- fprintf( stderr,
- "%s %s: extract FreeType API names from header files\n\n"
- "this program is used to extract the list of public FreeType API\n"
- "functions. It receives the list of header files as argument and\n"
- "generates a sorted list of unique identifiers\n\n"
-
- "usage: %s header1 [options] [header2 ...]\n\n"
-
- "options: - : parse the content of stdin, ignore arguments\n"
- " -v : verbose mode\n",
- " -w : output windows .DEF file\n"
- ,
- PROGRAM_NAME,
- PROGRAM_VERSION,
- PROGRAM_NAME
- );
- exit(1);
-}
-
-
-int main( int argc, const char* const* argv )
-{
- int from_stdin = 0;
- int verbose = 0;
- int do_win_def = 0;
-
- if ( argc < 2 )
- usage();
-
- /* '-' used as a single argument means read source file from stdin */
- while ( argc > 1 && argv[1][0] == '-' )
- {
- switch ( argv[1][1] )
- {
- case 'v':
- verbose = 1;
- break;
-
- case 'w':
- do_win_def = 1;
- break;
-
- case 0:
- from_stdin = 1;
- break;
-
- default:
- usage();
- }
-
- argc--;
- argv++;
- }
-
- if ( from_stdin )
- {
- read_header_file( stdin, verbose );
- }
- else
- {
- for ( --argc, argv++; argc > 0; argc--, argv++ )
- {
- FILE* file = fopen( argv[0], "rb" );
-
- if ( file == NULL )
- fprintf( stderr, "unable to open '%s'\n", argv[0] );
- else
- {
- if ( verbose )
- fprintf( stderr, "opening '%s'\n", argv[0] );
-
- read_header_file( file, verbose );
- fclose( file );
- }
- }
- }
-
- if ( num_names == 0 )
- panic( "could not find exported functions !!\n" );
-
- names_sort();
-
- if ( do_win_def )
- names_dump_windef( stdout );
- else
- names_dump( stdout );
-
- return 0;
-}
+/*
+ * This little program is used to parse the FreeType headers and
+ * find the declaration of all public API. This is easy, because
+ * they all look like the following:
+ *
+ * FT_EXPORT( return_type )
+ * function_name( function arguments );
+ *
+ * You must pass the list of header files as arguments. Wildcards are
+ * accepted if you are using GCC for compilation (and probably by
+ * other compilers too).
+ *
+ * Author: David Turner, 2005
+ *
+ * This code is explicitly placed into the public domain.
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#define PROGRAM_NAME "apinames"
+#define PROGRAM_VERSION "0.1"
+
+#define LINEBUFF_SIZE 1024
+
+typedef enum
+{
+ OUTPUT_LIST = 0, /* output the list of names, one per line */
+ OUTPUT_WINDOWS_DEF, /* output a Windows .DEF file for Visual C++ or Mingw */
+ OUTPUT_BORLAND_DEF, /* output a Windows .DEF file for Borland C++ */
+ OUTPUT_WATCOM_LBC /* output a Watcom Linker Command File */
+
+} OutputFormat;
+
+
+static void
+panic( const char* message )
+{
+ fprintf( stderr, "PANIC: %s\n", message );
+ exit(2);
+}
+
+
+typedef struct
+{
+ char* name;
+ unsigned int hash;
+
+} NameRec, *Name;
+
+static Name the_names;
+static int num_names;
+static int max_names;
+
+static void
+names_add( const char* name,
+ const char* end )
+{
+ int nn, len, h;
+ Name nm;
+
+ if ( end <= name )
+ return;
+
+ /* compute hash value */
+ len = (int)(end - name);
+ h = 0;
+ for ( nn = 0; nn < len; nn++ )
+ h = h*33 + name[nn];
+
+ /* check for an pre-existing name */
+ for ( nn = 0; nn < num_names; nn++ )
+ {
+ nm = the_names + nn;
+
+ if ( nm->hash == h &&
+ memcmp( name, nm->name, len ) == 0 &&
+ nm->name[len] == 0 )
+ return;
+ }
+
+ /* add new name */
+ if ( num_names >= max_names )
+ {
+ max_names += (max_names >> 1) + 4;
+ the_names = realloc( the_names, sizeof(the_names[0])*max_names );
+ if ( the_names == NULL )
+ panic( "not enough memory" );
+ }
+ nm = &the_names[num_names++];
+
+ nm->hash = h;
+ nm->name = malloc( len+1 );
+ if ( nm->name == NULL )
+ panic( "not enough memory" );
+
+ memcpy( nm->name, name, len );
+ nm->name[len] = 0;
+}
+
+
+static int
+name_compare( const void* name1,
+ const void* name2 )
+{
+ Name n1 = (Name)name1;
+ Name n2 = (Name)name2;
+
+ return strcmp( n1->name, n2->name );
+}
+
+static void
+names_sort( void )
+{
+ qsort( the_names, (size_t)num_names, sizeof(the_names[0]), name_compare );
+}
+
+
+static void
+names_dump( FILE* out,
+ OutputFormat format,
+ const char* dll_name )
+{
+ int nn;
+
+ switch ( format )
+ {
+ case OUTPUT_WINDOWS_DEF:
+ if ( dll_name )
+ fprintf( out, "LIBRARY %s\n", dll_name );
+
+ fprintf( out, "DESCRIPTION FreeType 2 DLL\n" );
+ fprintf( out, "EXPORTS\n" );
+ for ( nn = 0; nn < num_names; nn++ )
+ fprintf( out, " %s\n", the_names[nn].name );
+ break;
+
+ case OUTPUT_BORLAND_DEF:
+ if ( dll_name )
+ fprintf( out, "LIBRARY %s\n", dll_name );
+
+ fprintf( out, "DESCRIPTION FreeType 2 DLL\n" );
+ fprintf( out, "EXPORTS\n" );
+ for ( nn = 0; nn < num_names; nn++ )
+ fprintf( out, " _%s\n", the_names[nn].name );
+ break;
+
+ case OUTPUT_WATCOM_LBC:
+ {
+ /* we must omit the .dll suffix from the library name */
+ char temp[512];
+ char* dot;
+
+ if ( dll_name == NULL )
+ {
+ fprintf( stderr,
+ "you must provide a DLL name with the -d option !!\n" );
+ exit(4);
+ }
+
+ dot = strchr( dll_name, '.' );
+ if ( dot != NULL )
+ {
+ int len = (dot - dll_name);
+ if ( len > sizeof(temp)-1 )
+ len = sizeof(temp)-1;
+
+ memcpy( temp, dll_name, len );
+ temp[len] = 0;
+
+ dll_name = (const char*)temp;
+ }
+
+ for ( nn = 0; nn < num_names; nn++ )
+ fprintf( out, "++_%s.%s.%s\n", the_names[nn].name, dll_name,
+ the_names[nn].name );
+ }
+ break;
+
+ default: /* LIST */
+ for ( nn = 0; nn < num_names; nn++ )
+ fprintf( out, "%s\n", the_names[nn].name );
+ }
+}
+
+
+
+
+/* states of the line parser */
+
+typedef enum
+{
+ STATE_START = 0, /* waiting for FT_EXPORT keyword and return type */
+ STATE_TYPE, /* type was read, waiting for function name */
+
+} State;
+
+static int
+read_header_file( FILE* file, int verbose )
+{
+ static char buff[ LINEBUFF_SIZE+1 ];
+ State state = STATE_START;
+
+ while ( !feof( file ) )
+ {
+ char* p;
+
+ if ( !fgets( buff, LINEBUFF_SIZE, file ) )
+ break;
+
+ p = buff;
+
+ while ( *p && (*p == ' ' || *p == '\\') ) /* skip leading whitespace */
+ p++;
+
+ if ( *p == '\n' || *p == '\r' ) /* skip empty lines */
+ continue;
+
+ switch ( state )
+ {
+ case STATE_START:
+ {
+ if ( memcmp( p, "FT_EXPORT(", 10 ) != 0 )
+ break;
+
+ p += 10;
+ for (;;)
+ {
+ if ( *p == 0 || *p == '\n' || *p == '\r' )
+ goto NextLine;
+
+ if ( *p == ')' )
+ {
+ p++;
+ break;
+ }
+
+ p++;
+ }
+
+ state = STATE_TYPE;
+
+ /* sometimes, the name is just after the FT_EXPORT(...), so
+ * skip whitespace, and fall-through if we find an alphanumeric
+ * character
+ */
+ while ( *p == ' ' || *p == '\t' )
+ p++;
+
+ if ( !isalpha(*p) )
+ break;
+ }
+ /* fall-through */
+
+ case STATE_TYPE:
+ {
+ char* name = p;
+ size_t func_len;
+
+ while ( isalnum(*p) || *p == '_' )
+ p++;
+
+ if ( p > name )
+ {
+ if ( verbose )
+ fprintf( stderr, ">>> %.*s\n", p-name, name );
+
+ names_add( name, p );
+ }
+
+ state = STATE_START;
+ }
+ break;
+
+ default:
+ ;
+ }
+
+ NextLine:
+ ;
+ }
+
+ return 0;
+}
+
+
+static void
+usage( void )
+{
+ fprintf( stderr,
+ "%s %s: extract FreeType API names from header files\n\n"
+ "this program is used to extract the list of public FreeType API\n"
+ "functions. It receives the list of header files as argument and\n"
+ "generates a sorted list of unique identifiers\n\n"
+
+ "usage: %s header1 [options] [header2 ...]\n\n"
+
+ "options: - : parse the content of stdin, ignore arguments\n"
+ " -v : verbose mode, output sent to standard error\n",
+ " -oFILE : write output to FILE instead of standard output\n"
+ " -dNAME : indicate DLL file name, 'freetype.dll' by default\n"
+ " -w : output .DEF file for Visual C++ and Mingw\n"
+ " -wB : output .DEF file for Borland C++\n"
+ " -wW : output Watcom Linker Response File\n"
+ "\n"
+ ,
+ PROGRAM_NAME,
+ PROGRAM_VERSION,
+ PROGRAM_NAME
+ );
+ exit(1);
+}
+
+
+int main( int argc, const char* const* argv )
+{
+ int from_stdin = 0;
+ int verbose = 0;
+ OutputFormat format = OUTPUT_LIST; /* the default */
+ FILE* out = stdout;
+ const char* library_name = NULL;
+
+ if ( argc < 2 )
+ usage();
+
+ /* '-' used as a single argument means read source file from stdin */
+ while ( argc > 1 && argv[1][0] == '-' )
+ {
+ const char* arg = argv[1];
+
+ switch ( arg[1] )
+ {
+ case 'v':
+ verbose = 1;
+ break;
+
+ case 'o':
+ if ( arg[2] == 0 )
+ {
+ if ( argc < 2 )
+ usage();
+
+ arg = argv[2];
+ argv++;
+ argc--;
+ }
+ else
+ arg += 2;
+
+ out = fopen( arg, "wt" );
+ if ( out == NULL )
+ {
+ fprintf( stderr, "could not open '%s' for writing\n", argv[2] );
+ exit(3);
+ }
+ break;
+
+ case 'd':
+ if ( arg[2] == 0 )
+ {
+ if ( argc < 2 )
+ usage();
+
+ arg = argv[2];
+ argv++;
+ argc--;
+ }
+ else
+ arg += 2;
+
+ library_name = arg;
+ break;
+
+ case 'w':
+ format = OUTPUT_WINDOWS_DEF;
+ switch ( arg[2] )
+ {
+ case 'B':
+ format = OUTPUT_BORLAND_DEF;
+ break;
+
+ case 'W':
+ format = OUTPUT_WATCOM_LBC;
+ break;
+
+ case 0:
+ break;
+
+ default:
+ usage();
+ }
+ break;
+
+ case 0:
+ from_stdin = 1;
+ break;
+
+ default:
+ usage();
+ }
+
+ argc--;
+ argv++;
+ }
+
+ if ( from_stdin )
+ {
+ read_header_file( stdin, verbose );
+ }
+ else
+ {
+ for ( --argc, argv++; argc > 0; argc--, argv++ )
+ {
+ FILE* file = fopen( argv[0], "rb" );
+
+ if ( file == NULL )
+ fprintf( stderr, "unable to open '%s'\n", argv[0] );
+ else
+ {
+ if ( verbose )
+ fprintf( stderr, "opening '%s'\n", argv[0] );
+
+ read_header_file( file, verbose );
+ fclose( file );
+ }
+ }
+ }
+
+ if ( num_names == 0 )
+ panic( "could not find exported functions !!\n" );
+
+ names_sort();
+ names_dump( out, format, library_name );
+
+ if ( out != stdout )
+ fclose( out );
+
+ return 0;
+}
diff --git a/src/truetype/ttgload.c b/src/truetype/ttgload.c
index a779fb6..bdd0a06 100644
--- a/src/truetype/ttgload.c
+++ b/src/truetype/ttgload.c
@@ -420,7 +420,7 @@
/* check that we can add the contours to the glyph */
- error = FT_GlyphLoader_CheckPoints( gloader, 0, n_contours );
+ error = FT_GLYPHLOADER_CHECK_POINTS( gloader, 0, n_contours );
if ( error )
goto Fail;
@@ -441,7 +441,7 @@
n_points = cont[-1] + 1;
/* note that we will add four phantom points later */
- error = FT_GlyphLoader_CheckPoints( gloader, n_points + 4, 0 );
+ error = FT_GLYPHLOADER_CHECK_POINTS( gloader, n_points + 4, 0 );
if ( error )
goto Fail;
@@ -1106,9 +1106,9 @@
outline = &loader->gloader->base.outline;
/* make room for phantom points */
- error = FT_GlyphLoader_CheckPoints( loader->gloader,
- outline->n_points + 4,
- 0 );
+ error = FT_GLYPHLOADER_CHECK_POINTS( loader->gloader,
+ outline->n_points + 4,
+ 0 );
if ( error )
return error;