removing obsolete files
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 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850 3851 3852 3853 3854 3855 3856 3857 3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 3956 3957 3958 3959 3960 3961 3962 3963 3964 3965 3966 3967 3968 3969 3970 3971 3972 3973 3974 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 3990 3991 3992 3993 3994 3995 3996 3997 3998 3999 4000 4001 4002 4003 4004 4005 4006 4007 4008 4009 4010 4011 4012 4013 4014 4015 4016 4017 4018 4019 4020 4021 4022 4023 4024 4025 4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 4073 4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 4089 4090 4091 4092 4093 4094 4095 4096 4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 4148 4149 4150 4151 4152 4153 4154 4155 4156 4157 4158 4159 4160 4161 4162 4163 4164 4165 4166 4167 4168 4169 4170 4171 4172 4173 4174 4175 4176 4177 4178 4179 4180 4181 4182 4183 4184 4185 4186 4187 4188 4189 4190 4191 4192 4193 4194 4195 4196 4197 4198 4199 4200 4201 4202 4203 4204 4205 4206 4207 4208 4209 4210 4211 4212 4213 4214 4215 4216 4217 4218 4219 4220 4221 4222 4223 4224 4225 4226 4227 4228 4229 4230 4231 4232 4233 4234 4235 4236 4237 4238 4239 4240 4241 4242 4243 4244 4245 4246 4247 4248 4249 4250 4251 4252 4253 4254 4255 4256 4257 4258 4259 4260 4261 4262 4263 4264 4265 4266 4267 4268 4269 4270 4271 4272 4273 4274 4275 4276 4277 4278 4279 4280 4281 4282 4283 4284 4285 4286 4287 4288 4289 4290 4291 4292 4293 4294 4295 4296 4297 4298 4299 4300 4301 4302 4303 4304 4305 4306 4307 4308 4309 4310 4311 4312 4313 4314 4315 4316 4317 4318 4319 4320 4321 4322 4323 4324 4325 4326 4327 4328 4329 4330 4331 4332 4333 4334 4335 4336 4337 4338 4339 4340 4341 4342 4343 4344 4345 4346 4347 4348 4349 4350 4351 4352 4353 4354 4355 4356 4357 4358 4359 4360 4361 4362 4363 4364 4365 4366 4367 4368 4369 4370 4371 4372 4373 4374 4375 4376 4377 4378 4379 4380 4381 4382 4383 4384 4385 4386 4387 4388 4389 4390 4391 4392 4393 4394 4395 4396 4397 4398 4399 4400 4401 4402 4403 4404 4405 4406 4407 4408 4409 4410 4411 4412 4413 4414 4415 4416 4417 4418 4419 4420 4421 4422 4423 4424 4425 4426 4427 4428 4429 4430 4431 4432 4433 4434 4435 4436 4437 4438 4439 4440 4441 4442 4443 4444 4445 4446 4447 4448 4449 4450 4451 4452 4453 4454 4455 4456 4457 4458 4459 4460 4461 4462 4463 4464 4465 4466 4467 4468 4469 4470 4471 4472 4473 4474 4475 4476 4477 4478 4479 4480 4481 4482 4483 4484 4485 4486 4487 4488 4489 4490 4491 4492 4493 4494 4495 4496 4497 4498 4499 4500 4501 4502 4503 4504 4505 4506 4507 4508 4509 4510 4511 4512 4513 4514 4515 4516 4517 4518 4519 4520 4521 4522 4523 4524 4525 4526 4527 4528 4529 4530 4531 4532 4533 4534 4535 4536 4537 4538 4539 4540 4541 4542 4543 4544 4545 4546 4547 4548 4549 4550 4551 4552 4553 4554 4555 4556 4557 4558 4559 4560 4561 4562 4563 4564 4565 4566 4567 4568 4569 4570 4571 4572 4573 4574 4575 4576 4577 4578 4579 4580 4581 4582 4583 4584 4585 4586 4587 4588 4589 4590 4591 4592 4593 4594 4595 4596 4597 4598 4599 4600 4601 4602 4603 4604 4605 4606 4607 4608 4609 4610 4611 4612 4613 4614 4615 4616 4617 4618 4619 4620 4621 4622 4623 4624 4625 4626 4627 4628 4629 4630 4631 4632 4633 4634 4635 4636 4637 4638 4639 4640 4641 4642 4643 4644 4645 4646 4647 4648 4649 4650 4651 4652 4653 4654 4655 4656 4657 4658 4659 4660 4661 4662 4663 4664 4665 4666 4667 4668 4669 4670 4671 4672 4673 4674 4675 4676 4677 4678 4679 4680 4681 4682 4683 4684 4685 4686 4687 4688 4689 4690 4691 4692 4693 4694 4695 4696 4697 4698 4699 4700 4701 4702 4703 4704 4705 4706 4707 4708 4709 4710 4711 4712 4713 4714 4715 4716 4717 4718 4719 4720 4721 4722 4723 4724 4725 4726 4727 4728 4729 4730 4731 4732 4733 4734 4735 4736 4737 4738 4739 4740 4741 4742 4743 4744 4745 4746 4747 4748 4749 4750 4751 4752 4753 4754 4755 4756 4757 4758 4759 4760 4761 4762 4763 4764 4765 4766 4767 4768 4769 4770 4771 4772 4773 4774 4775 4776 4777 4778 4779 4780 4781 4782 4783 4784 4785 4786 4787 4788 4789 4790 4791 4792 4793 4794 4795 4796 4797 4798 4799 4800 4801 4802 4803 4804 4805 4806 4807 4808 4809 4810 4811 4812 4813 4814 4815 4816 4817 4818 4819 4820 4821 4822 4823 4824 4825 4826 4827 4828 4829 4830 4831 4832 4833 4834 4835 4836 4837 4838 4839 4840 4841 4842 4843 4844 4845 4846 4847 4848 4849 4850 4851 4852 4853 4854 4855 4856 4857 4858 4859 4860 4861 4862 4863 4864 4865 4866 4867 4868 4869 4870 4871 4872 4873 4874 4875 4876 4877 4878 4879 4880 4881 4882 4883 4884 4885 4886 4887 4888 4889 4890 4891 4892 4893 4894 4895 4896 4897 4898 4899 4900 4901 4902 4903 4904 4905 4906 4907 4908 4909 4910 4911 4912 4913 4914 4915 4916 4917 4918 4919 4920 4921 4922 4923 4924 4925 4926 4927 4928 4929 4930 4931 4932 4933 4934 4935 4936 4937 4938 4939 4940 4941 4942 4943 4944 4945 4946 4947 4948 4949 4950 4951 4952 4953 4954 4955 4956 4957 4958 4959 4960 4961 4962 4963 4964 4965 4966 4967 4968 4969 4970 4971 4972 4973 4974 4975 4976 4977 4978 4979 4980 4981 4982 4983 4984 4985 4986 4987 4988 4989 4990 4991 4992 4993 4994 4995 4996 4997 4998 4999 5000 5001 5002 5003 5004 5005 5006 5007 5008 5009 5010 5011 5012 5013 5014 5015 5016 5017 5018 5019 5020 5021 5022 5023 5024 5025 5026 5027 5028 5029 5030 5031 5032 5033 5034 5035 5036 5037 5038 5039 5040 5041 5042 5043 5044 5045 5046 5047 5048 5049 5050 5051 5052 5053 5054 5055 5056 5057 5058 5059 5060 5061 5062 5063 5064 5065 5066 5067 5068 5069 5070 5071 5072 5073 5074 5075 5076 5077 5078 5079 5080 5081 5082 5083 5084 5085 5086 5087 5088 5089 5090 5091 5092 5093 5094 5095 5096 5097 5098 5099 5100 5101 5102 5103 5104 5105 5106 5107 5108 5109 5110 5111 5112 5113 5114 5115 5116 5117 5118 5119 5120 5121 5122 5123 5124 5125 5126 5127 5128 5129 5130 5131 5132 5133 5134 5135 5136 5137 5138 5139 5140 5141 5142 5143 5144 5145 5146 5147 5148 5149 5150 5151 5152 5153 5154 5155 5156 5157 5158 5159 5160 5161 5162 5163 5164 5165 5166 5167 5168 5169 5170 5171 5172 5173 5174 5175 5176 5177 5178 5179 5180 5181 5182 5183 5184 5185 5186 5187 5188 5189 5190 5191 5192 5193 5194 5195 5196 5197 5198 5199 5200 5201 5202 5203 5204 5205 5206 5207 5208 5209 5210 5211 5212 5213 5214 5215 5216 5217 5218 5219 5220 5221 5222 5223 5224 5225 5226 5227 5228 5229 5230 5231 5232 5233 5234 5235 5236 5237 5238 5239 5240 5241 5242 5243 5244 5245 5246 5247 5248 5249 5250 5251 5252 5253 5254 5255 5256 5257 5258 5259 5260 5261 5262 5263 5264 5265 5266 5267 5268 5269 5270 5271 5272 5273 5274 5275 5276 5277 5278 5279 5280 5281 5282 5283 5284 5285 5286 5287 5288 5289 5290 5291 5292 5293 5294 5295 5296 5297 5298 5299 5300 5301 5302 5303 5304 5305 5306 5307 5308 5309 5310 5311 5312 5313 5314 5315 5316 5317 5318 5319 5320 5321 5322 5323 5324 5325 5326 5327 5328 5329 5330 5331 5332 5333 5334 5335 5336 5337 5338 5339 5340 5341 5342 5343 5344 5345 5346 5347 5348 5349 5350 5351 5352 5353 5354 5355 5356 5357 5358 5359 5360 5361 5362 5363 5364 5365 5366 5367 5368 5369 5370 5371 5372 5373 5374 5375 5376 5377 5378 5379 5380 5381 5382 5383 5384 5385 5386 5387 5388 5389 5390 5391 5392 5393 5394 5395 5396 5397 5398 5399 5400 5401 5402 5403 5404 5405 5406 5407 5408 5409 5410 5411 5412 5413 5414 5415 5416 5417 5418 5419 5420 5421 5422 5423 5424 5425 5426 5427 5428 5429 5430 5431 5432 5433 5434 5435 5436 5437 5438 5439 5440 5441 5442 5443 5444 5445 5446 5447 5448 5449 5450 5451 5452 5453 5454 5455 5456 5457 5458 5459 5460 5461 5462 5463 5464 5465 5466 5467 5468 5469 5470 5471 5472 5473 5474 5475 5476 5477 5478 5479 5480 5481 5482 5483 5484 5485 5486 5487 5488 5489 5490 5491 5492 5493 5494 5495 5496 5497 5498 5499 5500 5501 5502 5503 5504 5505 5506 5507 5508 5509 5510 5511 5512 5513 5514 5515 5516 5517 5518 5519 5520 5521 5522 5523 5524 5525 5526 5527 5528 5529 5530 5531 5532 5533 5534 5535 5536 5537 5538 5539 5540 5541 5542 5543 5544 5545 5546 5547 5548 5549 5550 5551 5552 5553 5554 5555 5556 5557 5558 5559 5560 5561 5562 5563 5564 5565 5566 5567 5568 5569 5570 5571 5572 5573 5574 5575 5576 5577 5578 5579 5580 5581 5582 5583 5584 5585 5586 5587 5588 5589 5590 5591 5592 5593 5594 5595 5596 5597 5598 5599 5600 5601 5602 5603 5604 5605 5606 5607 5608 5609 5610 5611 5612 5613 5614 5615 5616 5617 5618 5619 5620 5621 5622 5623 5624 5625 5626 5627 5628 5629 5630 5631 5632 5633 5634 5635 5636 5637 5638 5639 5640 5641 5642 5643 5644 5645 5646 5647 5648 5649 5650 5651 5652 5653 5654 5655 5656 5657 5658 5659 5660 5661 5662 5663 5664 5665 5666 5667 5668 5669 5670 5671 5672 5673 5674 5675 5676 5677 5678 5679 5680 5681 5682 5683 5684 5685 5686 5687 5688 5689 5690 5691 5692 5693 5694 5695 5696 5697 5698 5699 5700 5701 5702 5703 5704 5705 5706 5707 5708 5709 5710 5711 5712 5713 5714 5715 5716 5717 5718 5719 5720 5721 5722 5723 5724 5725 5726 5727 5728 5729 5730 5731 5732 5733 5734 5735 5736 5737 5738 5739 5740 5741 5742 5743 5744 5745 5746 5747 5748 5749 5750 5751 5752 5753 5754 5755 5756 5757 5758 5759 5760 5761 5762 5763 5764 5765 5766 5767 5768 5769 5770 5771 5772 5773 5774 5775 5776 5777 5778 5779 5780 5781 5782 5783 5784 5785 5786 5787 5788 5789 5790 5791 5792 5793 5794 5795 5796 5797 5798 5799 5800 5801 5802 5803 5804 5805 5806 5807 5808 5809 5810 5811 5812 5813 5814 5815 5816 5817 5818 5819 5820 5821 5822 5823 5824 5825 5826 5827 5828 5829 5830 5831 5832 5833 5834 5835 5836 5837 5838 5839 5840 5841 5842 5843 5844 5845 5846 5847 5848 5849 5850 5851 5852 5853 5854 5855 5856 5857 5858 5859 5860 5861 5862 5863 5864 5865 5866 5867 5868 5869 5870 5871 5872 5873 5874 5875 5876 5877 5878 5879 5880 5881 5882 5883 5884 5885 5886 5887 5888 5889 5890 5891 5892 5893 5894 5895 5896 5897 5898 5899 5900 5901 5902 5903 5904 5905 5906 5907 5908 5909 5910 5911 5912 5913 5914 5915 5916 5917 5918 5919 5920 5921 5922 5923 5924 5925 5926 5927 5928 5929 5930 5931 5932 5933 5934 5935 5936 5937 5938 5939 5940 5941 5942 5943 5944 5945 5946 5947 5948 5949 5950 5951 5952 5953 5954 5955 5956 5957 5958 5959 5960 5961 5962 5963 5964 5965 5966 5967 5968 5969 5970 5971 5972 5973 5974 5975 5976 5977 5978 5979 5980 5981 5982 5983 5984 5985 5986 5987 5988 5989 5990 5991 5992 5993 5994 5995 5996 5997 5998 5999 6000 6001 6002 6003 6004 6005 6006 6007 6008 6009 6010 6011 6012 6013 6014 6015 6016 6017 6018 6019 6020 6021 6022 6023 6024 6025 6026 6027 6028 6029 6030 6031 6032 6033 6034 6035 6036 6037 6038 6039 6040 6041 6042 6043 6044 6045 6046 6047 6048 6049 6050 6051 6052 6053 6054 6055 6056 6057 6058 6059 6060 6061 6062 6063 6064 6065 6066 6067 6068 6069 6070 6071 6072 6073 6074 6075 6076 6077 6078 6079 6080 6081 6082 6083 6084 6085 6086 6087 6088 6089 6090 6091 6092 6093 6094 6095 6096 6097 6098 6099 6100 6101 6102 6103 6104 6105 6106 6107 6108 6109 6110 6111 6112 6113 6114 6115 6116 6117 6118 6119 6120 6121 6122 6123 6124 6125 6126 6127 6128 6129 6130 6131 6132 6133 6134 6135 6136 6137 6138 6139 6140 6141 6142 6143 6144 6145 6146 6147 6148 6149 6150 6151 6152 6153 6154 6155 6156 6157 6158 6159 6160 6161 6162 6163 6164 6165 6166 6167 6168 6169 6170 6171 6172 6173 6174 6175 6176 6177 6178 6179 6180 6181 6182 6183 6184 6185 6186 6187 6188 6189 6190 6191 6192 6193 6194 6195 6196 6197 6198 6199 6200 6201 6202 6203 6204 6205 6206 6207 6208 6209 6210 6211 6212 6213 6214 6215 6216 6217 6218 6219 6220 6221 6222 6223 6224 6225 6226 6227 6228 6229 6230 6231 6232 6233 6234 6235 6236 6237 6238 6239 6240 6241 6242 6243 6244 6245 6246 6247 6248 6249 6250 6251 6252 6253 6254 6255 6256 6257 6258 6259 6260 6261 6262 6263 6264 6265 6266 6267 6268 6269 6270 6271 6272 6273 6274 6275 6276 6277 6278 6279 6280 6281 6282 6283 6284 6285 6286 6287 6288 6289 6290 6291 6292 6293 6294 6295 6296 6297 6298 6299 6300 6301 6302 6303 6304 6305 6306 6307 6308 6309 6310 6311 6312 6313 6314 6315 6316 6317 6318 6319 6320 6321 6322 6323 6324 6325 6326 6327 6328 6329 6330 6331 6332 6333 6334 6335 6336 6337 6338 6339 6340 6341 6342 6343 6344 6345 6346 6347 6348 6349 6350 6351 6352 6353 6354 6355 6356 6357 6358 6359 6360 6361 6362 6363 6364 6365 6366 6367 6368 6369 6370 6371 6372 6373 6374 6375 6376 6377 6378 6379 6380 6381 6382 6383 6384 6385 6386 6387 6388 6389 6390 6391 6392 6393 6394 6395 6396 6397 6398 6399 6400 6401 6402 6403 6404 6405 6406 6407 6408 6409 6410 6411 6412 6413 6414 6415 6416 6417 6418 6419 6420 6421 6422 6423 6424 6425 6426 6427 6428 6429 6430 6431 6432 6433 6434 6435 6436 6437 6438 6439 6440 6441 6442 6443 6444 6445 6446 6447 6448 6449 6450 6451 6452 6453 6454 6455 6456 6457 6458 6459 6460 6461 6462 6463 6464 6465 6466 6467 6468 6469 6470 6471 6472 6473 6474 6475 6476 6477 6478 6479 6480 6481 6482 6483 6484 6485 6486 6487 6488 6489 6490 6491 6492 6493 6494 6495 6496 6497 6498 6499 6500 6501 6502 6503 6504 6505 6506 6507 6508 6509 6510 6511 6512 6513 6514 6515 6516 6517 6518 6519 6520 6521 6522 6523 6524 6525 6526 6527 6528 6529 6530 6531 6532 6533 6534 6535 6536 6537 6538 6539 6540 6541 6542 6543 6544 6545 6546 6547 6548 6549 6550 6551 6552 6553 6554 6555 6556 6557 6558 6559 6560 6561 6562 6563 6564 6565 6566 6567 6568 6569 6570 6571 6572 6573 6574 6575 6576 6577 6578 6579 6580 6581 6582 6583 6584 6585 6586 6587 6588 6589 6590 6591 6592 6593 6594 6595 6596 6597 6598 6599 6600 6601 6602 6603 6604 6605 6606 6607 6608 6609 6610 6611 6612 6613 6614 6615 6616 6617 6618 6619 6620 6621 6622 6623 6624 6625 6626 6627 6628 6629 6630 6631 6632 6633 6634 6635 6636 6637 6638 6639 6640 6641 6642 6643 6644 6645 6646 6647 6648 6649 6650 6651 6652 6653 6654 6655 6656 6657 6658 6659 6660 6661 6662 6663 6664 6665 6666 6667 6668 6669 6670 6671 6672 6673 6674 6675 6676 6677 6678 6679 6680 6681 6682 6683 6684 6685 6686 6687 6688 6689 6690 6691 6692 6693 6694 6695 6696 6697 6698 6699 6700 6701 6702 6703 6704 6705 6706 6707 6708 6709 6710 6711 6712 6713 6714 6715 6716 6717 6718 6719 6720 6721 6722 6723 6724 6725 6726 6727 6728 6729 6730 6731 6732 6733 6734 6735 6736 6737 6738 6739 6740 6741 6742 6743 6744 6745 6746 6747 6748 6749 6750 6751 6752 6753 6754 6755 6756 6757 6758 6759 6760 6761 6762 6763 6764 6765 6766 6767 6768 6769 6770 6771 6772 6773 6774 6775 6776 6777 6778 6779 6780 6781 6782 6783 6784 6785 6786 6787 6788 6789 6790 6791 6792 6793 6794 6795 6796 6797 6798 6799 6800 6801 6802 6803 6804 6805 6806 6807 6808 6809 6810 6811 6812 6813 6814 6815 6816 6817 6818 6819 6820 6821 6822 6823 6824 6825 6826 6827 6828 6829 6830 6831 6832 6833 6834 6835 6836 6837 6838 6839 6840 6841 6842 6843 6844 6845 6846 6847 6848 6849 6850 6851 6852 6853 6854 6855 6856 6857 6858 6859 6860 6861 6862 6863 6864 6865 6866 6867 6868 6869 6870 6871 6872 6873 6874 6875 6876 6877 6878 6879 6880 6881 6882 6883 6884 6885 6886 6887 6888 6889 6890 6891 6892 6893 6894 6895 6896 6897 6898 6899 6900 6901 6902 6903 6904 6905 6906 6907 6908 6909 6910 6911 6912 6913 6914 6915 6916 6917 6918 6919 6920 6921 6922 6923 6924 6925 6926 6927 6928 6929 6930 6931 6932 6933 6934 6935 6936 6937 6938 6939 6940 6941 6942 6943 6944 6945 6946 6947 6948 6949 6950 6951 6952 6953 6954 6955 6956 6957 6958 6959 6960 6961 6962 6963 6964 6965 6966 6967 6968 6969 6970 6971 6972 6973 6974 6975 6976 6977 6978 6979 6980 6981 6982 6983 6984 6985 6986 6987 6988 6989 6990 6991 6992 6993 6994 6995 6996 6997 6998 6999 7000 7001 7002 7003 7004 7005 7006 7007 7008 7009 7010 7011 7012 7013 7014 7015 7016 7017 7018 7019 7020 7021 7022 7023 7024 7025 7026 7027 7028 7029 7030 7031 7032 7033 7034 7035 7036 7037 7038 7039 7040 7041 7042 7043 7044 7045 7046 7047 7048 7049 7050 7051 7052 7053 7054 7055 7056 7057 7058 7059 7060 7061 7062 7063 7064 7065 7066 7067 7068 7069 7070 7071 7072 7073 7074 7075 7076 7077 7078 7079 7080 7081 7082 7083 7084 7085 7086 7087 7088 7089 7090 7091 7092 7093 7094 7095 7096 7097 7098 7099 7100 7101 7102 7103 7104 7105 7106 7107 7108 7109 7110 7111 7112 7113 7114 7115 7116 7117 7118 7119 7120 7121 7122 7123 7124 7125 7126 7127 7128 7129 7130 7131 7132 7133 7134 7135 7136 7137 7138 7139 7140 7141 7142 7143 7144 7145 7146 7147 7148 7149 7150 7151 7152 7153 7154 7155 7156 7157 7158 7159 7160 7161 7162 7163 7164 7165 7166 7167 7168 7169 7170 7171 7172 7173 7174 7175 7176 7177 7178 7179 7180 7181 7182 7183 7184 7185 7186 7187 7188 7189 7190 7191 7192 7193 7194 7195 7196 7197 7198 7199 7200 7201 7202 7203 7204 7205 7206 7207 7208 7209 7210 7211 7212 7213 7214 7215 7216 7217 7218 7219 7220 7221 7222 7223 7224 7225 7226 7227 7228 7229 7230 7231 7232 7233 7234 7235 7236 7237 7238 7239 7240 7241 7242 7243 7244 7245 7246 7247 7248 7249 7250 7251 7252 7253 7254 7255 7256 7257 7258 7259 7260 7261 7262 7263 7264 7265 7266 7267 7268 7269 7270 7271 7272 7273 7274 7275 7276 7277 7278 7279 7280 7281 7282 7283 7284 7285 7286 7287 7288 7289 7290 7291 7292 7293 7294 7295 7296 7297 7298 7299 7300 7301 7302 7303 7304 7305 7306 7307 7308 7309 7310 7311 7312 7313 7314 7315 7316 7317 7318 7319 7320 7321 7322 7323 7324 7325 7326 7327 7328 7329 7330 7331 7332 7333 7334 7335 7336 7337 7338 7339 7340 7341 7342 7343 7344 7345 7346 7347 7348 7349 7350 7351 7352 7353 7354 7355 7356 7357 7358 7359 7360 7361 7362 7363 7364 7365 7366 7367 7368 7369 7370 7371 7372 7373 7374 7375 7376 7377 7378 7379 7380 7381 7382 7383 7384 7385 7386 7387 7388 7389 7390 7391 7392 7393 7394 7395 7396 7397 7398 7399 7400 7401 7402 7403 7404 7405 7406 7407 7408 7409 7410 7411 7412 7413 7414 7415 7416 7417 7418 7419 7420 7421 7422 7423 7424 7425 7426 7427 7428 7429 7430 7431 7432 7433 7434 7435 7436 7437 7438 7439 7440 7441 7442 7443 7444 7445 7446 7447 7448 7449 7450 7451 7452 7453 7454 7455 7456 7457 7458 7459 7460 7461 7462 7463 7464 7465 7466 7467 7468 7469 7470 7471 7472 7473 7474 7475 7476 7477 7478 7479 7480 7481 7482 7483 7484 7485 7486 7487 7488 7489 7490 7491 7492 7493 7494 7495 7496 7497 7498 7499 7500 7501 7502 7503 7504 7505 7506 7507 7508 7509 7510 7511 7512 7513 7514 7515 7516 7517 7518 7519 7520 7521 7522 7523 7524 7525 7526 7527 7528 7529 7530 7531 7532 7533 7534 7535 7536 7537 7538 7539 7540 7541 7542 7543 7544 7545 7546 7547 7548 7549 7550 7551 7552 7553 7554 7555 7556 7557 7558 7559 7560 7561 7562 7563 7564 7565 7566 7567 7568 7569 7570 7571 7572 7573 7574 7575 7576 7577 7578 7579 7580 7581 7582 7583 7584 7585 7586 7587 7588 7589 7590 7591 7592 7593 7594 7595 7596 7597 7598 7599 7600 7601 7602 7603 7604 7605 7606 7607 7608 7609 7610 7611 7612 7613 7614 7615 7616 7617 7618 7619 7620 7621 7622 7623 7624 7625 7626 7627 7628 7629 7630 7631 7632 7633 7634 7635 7636 7637 7638 7639 7640 7641 7642 7643 7644 7645 7646 7647 7648 7649 7650 7651 7652 7653 7654 7655 7656 7657 7658 7659 7660 7661 7662 7663 7664 7665 7666 7667 7668 7669 7670 7671 7672 7673 7674 7675 7676 7677 7678 7679 7680 7681 7682 7683 7684 7685 7686 7687 7688 7689 7690 7691 7692 7693 7694 7695 7696 7697 7698 7699 7700 7701 7702 7703 7704 7705 7706 7707 7708 7709 7710 7711 7712 7713 7714 7715 7716 7717 7718 7719 7720 7721 7722 7723 7724 7725 7726 7727 7728 7729 7730 7731 7732 7733 7734 7735 7736 7737 7738 7739 7740 7741 7742 7743 7744 7745 7746 7747 7748 7749 7750 7751 7752 7753 7754 7755 7756 7757 7758 7759 7760 7761 7762 7763 7764 7765 7766 7767 7768 7769 7770 7771 7772 7773 7774 7775 7776 7777 7778 7779 7780 7781 7782 7783 7784 7785 7786 7787 7788 7789 7790 7791 7792 7793 7794 7795 7796 7797 7798 7799 7800 7801 7802 7803 7804 7805 7806 7807 7808 7809 7810 7811 7812 7813 7814 7815 7816 7817 7818 7819 7820 7821 7822 7823 7824 7825 7826 7827 7828 7829 7830 7831 7832 7833 7834 7835 7836 7837 7838 7839 7840 7841 7842 7843 7844 7845 7846 7847 7848 7849 7850 7851 7852 7853 7854 7855 7856 7857 7858 7859 7860 7861 7862 7863 7864 7865 7866 7867 7868 7869 7870 7871 7872 7873 7874 7875 7876 7877 7878 7879 7880 7881 7882 7883 7884 7885 7886 7887 7888 7889 7890 7891 7892 7893 7894 7895 7896 7897 7898 7899 7900 7901 7902 7903 7904 7905 7906 7907 7908 7909 7910 7911 7912 7913 7914 7915 7916 7917 7918 7919 7920 7921 7922 7923 7924 7925 7926 7927 7928 7929 7930 7931 7932 7933 7934 7935 7936 7937 7938 7939 7940 7941 7942 7943 7944 7945 7946 7947 7948 7949 7950 7951 7952 7953 7954 7955 7956 7957 7958 7959 7960 7961 7962 7963 7964 7965 7966 7967 7968 7969 7970 7971 7972 7973 7974 7975 7976 7977 7978 7979 7980 7981 7982 7983 7984 7985 7986 7987 7988 7989 7990 7991 7992 7993 7994 7995 7996 7997 7998 7999 8000 8001 8002 8003 8004 8005 8006 8007 8008 8009 8010 8011 8012 8013 8014 8015 8016 8017 8018 8019 8020 8021 8022 8023 8024 8025 8026 8027 8028 8029 8030 8031 8032 8033 8034 8035 8036 8037 8038 8039 8040 8041 8042 8043 8044 8045 8046 8047 8048 8049 8050 8051 8052 8053 8054 8055 8056 8057 8058 8059 8060 8061 8062 8063 8064 8065 8066 8067 8068 8069 8070 8071 8072 8073 8074 8075 8076 8077 8078 8079 8080 8081 8082 8083 8084 8085 8086 8087 8088 8089 8090 8091 8092 8093 8094 8095 8096 8097 8098 8099 8100 8101 8102 8103 8104 8105 8106 8107 8108 8109 8110 8111 8112 8113 8114 8115 8116 8117 8118 8119 8120 8121 8122 8123 8124 8125 8126 8127 8128 8129 8130 8131 8132 8133 8134 8135 8136 8137 8138 8139 8140 8141 8142 8143 8144 8145 8146 8147 8148 8149 8150 8151 8152 8153 8154 8155 8156 8157 8158 8159 8160 8161 8162 8163 8164 8165 8166 8167 8168 8169 8170 8171 8172 8173 8174 8175 8176 8177 8178 8179 8180 8181 8182 8183 8184 8185 8186 8187 8188 8189 8190 8191 8192 8193 8194 8195 8196 8197 8198 8199 8200 8201 8202 8203 8204 8205 8206 8207 8208 8209 8210 8211 8212 8213 8214 8215 8216 8217 8218 8219 8220 8221 8222 8223 8224 8225 8226 8227 8228 8229 8230 8231 8232 8233 8234 8235 8236 8237 8238 8239 8240 8241 8242 8243 8244 8245 8246 8247 8248 8249 8250 8251 8252 8253 8254 8255 8256 8257 8258 8259 8260 8261 8262 8263 8264 8265 8266 8267 8268 8269 8270 8271 8272 8273 8274 8275 8276 8277 8278 8279 8280 8281 8282 8283 8284 8285 8286 8287 8288 8289 8290 8291 8292 8293 8294 8295 8296 8297 8298 8299 8300 8301 8302 8303 8304 8305 8306 8307 8308 8309 8310 8311 8312 8313 8314 8315 8316 8317 8318 8319 8320 8321 8322 8323 8324 8325 8326 8327 8328 8329 8330 8331 8332 8333 8334 8335 8336 8337 8338 8339 8340 8341 8342 8343 8344 8345 8346 8347 8348 8349 8350 8351 8352 8353 8354 8355 8356 8357 8358 8359 8360 8361 8362 8363 8364 8365 8366 8367 8368 8369 8370 8371 8372 8373 8374 8375 8376 8377 8378 8379 8380 8381 8382 8383 8384 8385 8386 8387 8388 8389 8390 8391 8392 8393 8394 8395 8396 8397 8398 8399 8400 8401 8402 8403 8404 8405 8406 8407 8408 8409 8410 8411 8412 8413 8414 8415 8416 8417 8418 8419 8420 8421 8422 8423 8424 8425 8426 8427 8428 8429 8430 8431 8432 8433 8434 8435 8436 8437 8438 8439 8440 8441 8442 8443 8444 8445 8446 8447 8448 8449 8450 8451 8452 8453 8454 8455 8456 8457 8458 8459 8460 8461 8462 8463 8464 8465 8466 8467 8468 8469 8470 8471 8472 8473 8474 8475 8476 8477 8478 8479 8480 8481 8482 8483 8484 8485 8486 8487 8488 8489 8490 8491 8492 8493 8494 8495 8496 8497 8498 8499 8500 8501 8502 8503 8504 8505 8506 8507 8508 8509 8510 8511 8512 8513 8514 8515 8516 8517 8518 8519 8520 8521 8522 8523 8524 8525 8526 8527 8528 8529 8530 8531 8532 8533 8534 8535 8536 8537 8538 8539 8540 8541 8542 8543 8544 8545 8546 8547 8548 8549 8550 8551 8552 8553 8554 8555 8556 8557 8558 8559 8560 8561 8562 8563 8564 8565 8566 8567 8568 8569 8570 8571 8572 8573 8574 8575 8576 8577 8578 8579 8580 8581 8582 8583 8584 8585 8586 8587 8588 8589 8590 8591 8592 8593 8594 8595 8596 8597 8598 8599 8600 8601 8602 8603 8604 8605 8606 8607 8608 8609 8610 8611 8612 8613 8614 8615 8616 8617 8618 8619 8620 8621 8622 8623 8624 8625 8626 8627 8628 8629 8630 8631 8632 8633 8634 8635 8636 8637 8638 8639 8640 8641 8642 8643 8644 8645 8646 8647 8648 8649 8650 8651 8652 8653 8654 8655 8656 8657 8658 8659 8660 8661 8662 8663 8664 8665 8666 8667 8668 8669 8670 8671 8672 8673 8674 8675 8676 8677 8678 8679 8680 8681 8682 8683 8684 8685 8686 8687 8688 8689 8690 8691 8692 8693 8694 8695 8696 8697 8698 8699 8700 8701 8702 8703 8704 8705 8706 8707 8708 8709 8710 8711 8712 8713 8714 8715 8716 8717 8718 8719 8720 8721 8722 8723 8724 8725 8726 8727 8728 8729 8730 8731 8732 8733 8734 8735 8736 8737 8738 8739 8740 8741 8742 8743 8744 8745 8746 8747 8748 8749 8750 8751 8752 8753 8754 8755 8756 8757 8758 8759 8760 8761 8762 8763 8764 8765 8766 8767 8768 8769 8770 8771 8772 8773 8774 8775 8776 8777 8778 8779 8780 8781 8782 8783 8784 8785 8786 8787 8788 8789 8790 8791 8792 8793 8794 8795 8796 8797 8798 8799 8800 8801 8802 8803 8804 8805 8806 8807 8808 8809 8810 8811 8812 8813 8814 8815 8816 8817 8818 8819 8820 8821 8822 8823 8824 8825 8826 8827 8828 8829 8830 8831 8832 8833 8834 8835 8836 8837 8838 8839 8840 8841 8842 8843 8844 8845 8846 8847 8848 8849 8850 8851 8852 8853 8854 8855 8856 8857 8858 8859 8860 8861 8862 8863 8864 8865 8866 8867 8868 8869 8870 8871 8872 8873 8874 8875 8876 8877 8878 8879 8880 8881 8882 8883 8884 8885 8886 8887 8888 8889 8890 8891 8892 8893 8894 8895 8896 8897 8898 8899 8900 8901 8902 8903 8904 8905 8906 8907 8908 8909 8910 8911 8912 8913 8914 8915 8916 8917 8918 8919 8920 8921 8922 8923 8924 8925 8926 8927 8928 8929 8930 8931 8932 8933 8934 8935 8936 8937 8938 8939 8940 8941 8942 8943 8944 8945 8946 8947 8948 8949 8950 8951 8952 8953 8954 8955 8956 8957 8958 8959 8960 8961 8962 8963 8964 8965 8966 8967 8968 8969 8970 8971 8972 8973 8974 8975 8976 8977 8978 8979 8980 8981 8982 8983 8984 8985 8986 8987 8988 8989 8990 8991 8992 8993 8994 8995 8996 8997 8998 8999 9000 9001 9002 9003 9004 9005 9006 9007 9008 9009 9010 9011 9012 9013 9014 9015 9016 9017 9018 9019 9020 9021 9022 9023 9024 9025 9026 9027 9028 9029 9030 9031 9032 9033 9034 9035 9036 9037 9038 9039 9040 9041 9042 9043 9044 9045 9046 9047 9048 9049 9050 9051 9052 9053 9054 9055 9056 9057 9058 9059 9060 9061 9062 9063 9064 9065 9066 9067 9068 9069 9070 9071 9072 9073 9074 9075 9076 9077 9078 9079 9080 9081 9082 9083 9084 9085 9086 9087 9088 9089 9090 9091 9092 9093 9094 9095 9096 9097 9098 9099 9100 9101 9102 9103 9104 9105 9106 9107 9108 9109 9110 9111 9112 9113 9114 9115 9116 9117 9118 9119 9120 9121 9122 9123 9124 9125 9126 9127 9128 9129 9130 9131 9132 9133 9134 9135 9136 9137 9138 9139 9140 9141 9142 9143 9144 9145 9146 9147 9148 9149 9150 9151 9152 9153 9154 9155 9156 9157 9158 9159 9160 9161 9162 9163 9164 9165 9166 9167 9168 9169 9170 9171 9172 9173 9174 9175 9176 9177 9178 9179 9180 9181 9182 9183 9184 9185 9186 9187 9188 9189 9190 9191 9192 9193 9194 9195 9196 9197 9198 9199 9200 9201 9202 9203 9204 9205 9206 9207 9208 9209 9210 9211 9212 9213 9214 9215 9216 9217 9218 9219 9220 9221 9222 9223 9224 9225 9226 9227 9228 9229 9230 9231 9232 9233 9234 9235 9236 9237 9238 9239 9240 9241 9242 9243 9244 9245 9246 9247 9248 9249 9250 9251 9252 9253 9254 9255 9256 9257 9258 9259 9260 9261 9262 9263 9264 9265 9266 9267 9268 9269 9270 9271 9272 9273 9274 9275 9276 9277 9278 9279 9280 9281 9282 9283 9284 9285 9286 9287 9288 9289 9290 9291 9292 9293 9294 9295 9296 9297 9298 9299 9300 9301 9302 9303 9304 9305 9306 9307 9308 9309 9310 9311 9312 9313 9314 9315 9316 9317 9318 9319 9320 9321 9322 9323 9324 9325 9326 9327 9328 9329 9330 9331 9332 9333 9334 9335 9336 9337 9338 9339 9340 9341 9342 9343 9344 9345 9346 9347 9348 9349 9350 9351 9352 9353 9354 9355 9356 9357 9358 9359 9360 9361 9362 9363 9364 9365 9366 9367 9368 9369 9370 9371 9372 9373 9374 9375 9376 9377 9378 9379 9380 9381 9382 9383 9384 9385 9386 9387 9388 9389 9390 9391 9392 9393 9394 9395 9396 9397 9398 9399 9400 9401 9402 9403 9404 9405 9406 9407 9408 9409 9410 9411 9412 9413 9414 9415 9416 9417 9418 9419 9420 9421 9422 9423 9424 9425 9426 9427 9428 9429 9430 9431 9432 9433 9434 9435 9436 9437 9438 9439 9440 9441 9442 9443 9444 9445 9446 9447 9448 9449 9450 9451 9452 9453 9454 9455 9456 9457 9458 9459 9460 9461 9462 9463 9464 9465 9466 9467 9468 9469 9470 9471 9472 9473 9474 9475 9476 9477 9478 9479 9480 9481 9482 9483 9484 9485 9486 9487 9488 9489 9490 9491 9492 9493 9494 9495 9496 9497 9498 9499 9500 9501 9502 9503 9504 9505 9506 9507 9508 9509 9510 9511 9512 9513 9514 9515 9516 9517 9518 9519 9520 9521 9522 9523 9524 9525 9526 9527 9528 9529 9530 9531 9532 9533 9534 9535 9536 9537 9538 9539 9540 9541 9542 9543 9544 9545 9546 9547 9548 9549 9550 9551 9552 9553 9554
diff --git a/src/type1/module.mk0 b/src/type1/module.mk0
deleted file mode 100644
index af99eae..0000000
--- a/src/type1/module.mk0
+++ /dev/null
@@ -1,6 +0,0 @@
-make_module_list: add_type1_driver
-
-add_type1_driver:
- $(OPEN_DRIVER)t1_driver_class$(CLOSE_DRIVER)
- $(ECHO_DRIVER)type1 $(ECHO_DRIVER_DESC)Postscript font files with extension *.pfa or *.pfb$(ECHO_DRIVER_DONE)
-
diff --git a/src/type1/rules.mk0 b/src/type1/rules.mk0
deleted file mode 100644
index b544446..0000000
--- a/src/type1/rules.mk0
+++ /dev/null
@@ -1,74 +0,0 @@
-#
-# FreeType 2 Type 1 driver configuration rules
-#
-
-
-# Copyright 1996-2000 by
-# David Turner, Robert Wilhelm, and Werner Lemberg.
-#
-# This file is part of the FreeType project, and may only be used, modified,
-# and distributed under the terms of the FreeType project license,
-# LICENSE.TXT. By continuing to use, modify, or distribute this file you
-# indicate that you have read the license and understand and accept it
-# fully.
-
-
-# Type1 driver directory
-#
-T1_DIR := $(SRC_)type1
-T1_DIR_ := $(T1_DIR)$(SEP)
-
-
-# compilation flags for the driver
-#
-T1_COMPILE := $(FT_COMPILE)
-
-
-# Type1 driver sources (i.e., C files)
-#
-T1_DRV_SRC := $(T1_DIR_)t1objs.c \
- $(T1_DIR_)t1load.c \
- $(T1_DIR_)t1parse.c \
- $(T1_DIR_)t1tokens.c \
- $(T1_DIR_)t1driver.c \
- $(T1_DIR_)t1hinter.c \
- $(T1_DIR_)t1afm.c \
- $(T1_DIR_)t1gload.c
-
-# Type1 driver headers
-#
-T1_DRV_H := $(T1_DRV_SRC:%.c=%.h)
-
-
-# Type1 driver object(s)
-#
-# T1_DRV_OBJ_M is used during `multi' builds
-# T1_DRV_OBJ_S is used during `single' builds
-#
-T1_DRV_OBJ_M := $(T1_DRV_SRC:$(T1_DIR_)%.c=$(OBJ_)%.$O)
-T1_DRV_OBJ_S := $(OBJ_)type1.$O
-
-# Type1 driver source file for single build
-#
-T1_DRV_SRC_S := $(T1_DIR_)type1.c
-
-
-# Type1 driver - single object
-#
-$(T1_DRV_OBJ_S): $(T1_DRV_SRC_S) $(T1_DRV_SRC) $(FREETYPE_H) $(T1_DRV_H)
- $(T1_COMPILE) $T$@ $(T1_DRV_SRC_S)
-
-
-# Type1 driver - multiple objects
-#
-$(OBJ_)%.$O: $(T1_DIR_)%.c $(FREETYPE_H) $(T1_DRV_H)
- $(T1_COMPILE) $T$@ $<
-
-
-# update main driver object lists
-#
-DRV_OBJS_S += $(T1_DRV_OBJ_S)
-DRV_OBJS_M += $(T1_DRV_OBJ_M)
-
-
-# EOF
diff --git a/src/type1/t1afm.c b/src/type1/t1afm.c
deleted file mode 100644
index a6ac1b9..0000000
--- a/src/type1/t1afm.c
+++ /dev/null
@@ -1,293 +0,0 @@
-/***************************************************************************/
-/* */
-/* t1afm.c */
-/* */
-/* AFM support for Type 1 fonts (body). */
-/* */
-/* Copyright 1996-2000 by */
-/* David Turner, Robert Wilhelm, and Werner Lemberg. */
-/* */
-/* This file is part of the FreeType project, and may only be used, */
-/* modified, and distributed under the terms of the FreeType project */
-/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
-/* this file you indicate that you have read the license and */
-/* understand and accept it fully. */
-/* */
-/***************************************************************************/
-
-
-#ifdef FT_FLAT_COMPILE
-
-#include "t1afm.h"
-
-#else
-
-#include <type1/t1afm.h>
-
-#endif
-
-
-#include <freetype/internal/ftstream.h>
-#include <freetype/internal/t1types.h>
-
-#include <stdlib.h> /* for qsort() */
-#include <string.h> /* for strcmp() */
-#include <ctype.h> /* for isalnum() */
-
-
- /*************************************************************************/
- /* */
- /* The macro FT_COMPONENT is used in trace mode. It is an implicit */
- /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */
- /* messages during execution. */
- /* */
-#undef FT_COMPONENT
-#define FT_COMPONENT trace_t1afm
-
-
- LOCAL_FUNC
- void T1_Done_AFM( FT_Memory memory,
- T1_AFM* afm )
- {
- FREE( afm->kern_pairs );
- afm->num_pairs = 0;
- }
-
-
-#undef IS_KERN_PAIR
-#define IS_KERN_PAIR( p ) ( p[0] == 'K' && p[1] == 'P' )
-
-#define IS_ALPHANUM( c ) ( isalnum( c ) || \
- c == '_' || \
- c == '.' )
-
-
- /* read a glyph name and return the equivalent glyph index */
- static
- FT_UInt afm_atoindex( FT_Byte** start,
- FT_Byte* limit,
- T1_Font* type1 )
- {
- FT_Byte* p = *start;
- FT_Int len;
- FT_UInt result = 0;
- char temp[64];
-
-
- /* skip whitespace */
- while ( ( *p == ' ' || *p == '\t' || *p == ':' || *p == ';' ) &&
- p < limit )
- p++;
- *start = p;
-
- /* now, read glyph name */
- while ( IS_ALPHANUM( *p ) && p < limit )
- p++;
-
- len = p - *start;
-
- if ( len > 0 && len < 64 )
- {
- FT_Int n;
-
-
- /* copy glyph name to intermediate array */
- MEM_Copy( temp, *start, len );
- temp[len] = 0;
-
- /* lookup glyph name in face array */
- for ( n = 0; n < type1->num_glyphs; n++ )
- {
- char* gname = (char*)type1->glyph_names[n];
-
-
- if ( gname && gname[0] == temp[0] && strcmp( gname, temp ) == 0 )
- {
- result = n;
- break;
- }
- }
- }
- *start = p;
- return result;
- }
-
-
- /* read an integer */
- static
- int afm_atoi( FT_Byte** start,
- FT_Byte* limit )
- {
- FT_Byte* p = *start;
- int sum = 0;
- int sign = 1;
-
-
- /* skip everything that is not a number */
- while ( p < limit && !isdigit( *p ) )
- {
- sign = 1;
- if ( *p == '-' )
- sign = -1;
-
- p++;
- }
-
- while ( p < limit && isdigit( *p ) )
- {
- sum = sum * 10 + ( *p - '0' );
- p++;
- }
- *start = p;
-
- return sum * sign;
- }
-
-
-#undef KERN_INDEX
-#define KERN_INDEX( g1, g2 ) ( ( (FT_ULong)g1 << 16 ) | g2 )
-
-
- /* compare two kerning pairs */
- static
- int compare_kern_pairs( const void* a,
- const void* b )
- {
- T1_Kern_Pair* pair1 = (T1_Kern_Pair*)a;
- T1_Kern_Pair* pair2 = (T1_Kern_Pair*)b;
-
- FT_ULong index1 = KERN_INDEX( pair1->glyph1, pair1->glyph2 );
- FT_ULong index2 = KERN_INDEX( pair2->glyph1, pair2->glyph2 );
-
-
- return ( index1 - index2 );
- }
-
-
- /* parse an AFM file -- for now, only read the kerning pairs */
- LOCAL_FUNC
- FT_Error T1_Read_AFM( FT_Face t1_face,
- FT_Stream stream )
- {
- FT_Error error;
- FT_Memory memory = stream->memory;
- FT_Byte* start;
- FT_Byte* limit;
- FT_Byte* p;
- FT_Int count = 0;
- T1_Kern_Pair* pair;
- T1_Font* type1 = &((T1_Face)t1_face)->type1;
- T1_AFM* afm = 0;
-
-
- if ( ACCESS_Frame( stream->size ) )
- return error;
-
- start = (FT_Byte*)stream->cursor;
- limit = (FT_Byte*)stream->limit;
- p = start;
-
- /* we are now going to count the occurences of `KP' or `KPX' in */
- /* the AFM file */
- count = 0;
- for ( p = start; p < limit - 3; p++ )
- {
- if ( IS_KERN_PAIR( p ) )
- count++;
- }
-
- /* Actually, kerning pairs are simply optional! */
- if ( count == 0 )
- goto Exit;
-
- /* allocate the pairs */
- if ( ALLOC( afm, sizeof ( *afm ) ) ||
- ALLOC_ARRAY( afm->kern_pairs, count, T1_Kern_Pair ) )
- goto Exit;
-
- /* now, read each kern pair */
- pair = afm->kern_pairs;
- afm->num_pairs = count;
-
- /* save in face object */
- ((T1_Face)t1_face)->afm_data = afm;
-
- for ( p = start; p < limit - 3; p++ )
- {
- if ( IS_KERN_PAIR( p ) )
- {
- FT_Byte* q;
-
-
- /* skip keyword (KP or KPX) */
- q = p + 2;
- if ( *q == 'X' )
- q++;
-
- pair->glyph1 = afm_atoindex( &q, limit, type1 );
- pair->glyph2 = afm_atoindex( &q, limit, type1 );
- pair->kerning.x = afm_atoi( &q, limit );
-
- pair->kerning.y = 0;
- if ( p[2] != 'X' )
- pair->kerning.y = afm_atoi( &q, limit );
-
- pair++;
- }
- }
-
- /* now, sort the kern pairs according to their glyph indices */
- qsort( afm->kern_pairs, count, sizeof ( T1_Kern_Pair ),
- compare_kern_pairs );
-
- Exit:
- if ( error )
- FREE( afm );
-
- FORGET_Frame();
-
- return error;
- }
-
-
- /* find the kerning for a given glyph pair */
- LOCAL_FUNC
- void T1_Get_Kerning( T1_AFM* afm,
- FT_UInt glyph1,
- FT_UInt glyph2,
- FT_Vector* kerning )
- {
- T1_Kern_Pair *min, *mid, *max;
- FT_ULong index = KERN_INDEX( glyph1, glyph2 );
-
-
- /* simple binary search */
- min = afm->kern_pairs;
- max = min + afm->num_pairs - 1;
-
- while ( min <= max )
- {
- FT_ULong midi;
-
-
- mid = min + ( max - min ) / 2;
- midi = KERN_INDEX( mid->glyph1, mid->glyph2 );
-
- if ( midi == index )
- {
- *kerning = mid->kerning;
- return;
- }
-
- if ( midi < index )
- min = mid + 1;
- else
- max = mid - 1;
- }
-
- kerning->x = 0;
- kerning->y = 0;
- }
-
-
-/* END */
diff --git a/src/type1/t1afm.h b/src/type1/t1afm.h
deleted file mode 100644
index 709154e..0000000
--- a/src/type1/t1afm.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/***************************************************************************/
-/* */
-/* t1afm.h */
-/* */
-/* AFM support for Type 1 fonts (specification). */
-/* */
-/* Copyright 1996-2000 by */
-/* David Turner, Robert Wilhelm, and Werner Lemberg. */
-/* */
-/* This file is part of the FreeType project, and may only be used, */
-/* modified, and distributed under the terms of the FreeType project */
-/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
-/* this file you indicate that you have read the license and */
-/* understand and accept it fully. */
-/* */
-/***************************************************************************/
-
-
-#ifndef T1AFM_H
-#define T1AFM_H
-
-#include <freetype/internal/ftobjs.h>
-
-
-#ifdef __cplusplus
- extern "C" {
-#endif
-
-
- typedef struct T1_Kern_Pair_
- {
- FT_UInt glyph1;
- FT_UInt glyph2;
- FT_Vector kerning;
-
- } T1_Kern_Pair;
-
-
- typedef struct T1_AFM_
- {
- FT_Int num_pairs;
- T1_Kern_Pair* kern_pairs;
-
- } T1_AFM;
-
-
- LOCAL_DEF
- FT_Error T1_Read_AFM( FT_Face face,
- FT_Stream stream );
-
- LOCAL_DEF
- void T1_Done_AFM( FT_Memory memory,
- T1_AFM* afm );
-
- LOCAL_DEF
- void T1_Get_Kerning( T1_AFM* afm,
- FT_UInt glyph1,
- FT_UInt glyph2,
- FT_Vector* kerning );
-
-
-#ifdef __cplusplus
- }
-#endif
-
-
-#endif /* T1AFM_H */
-
-
-/* END */
diff --git a/src/type1/t1driver.c b/src/type1/t1driver.c
deleted file mode 100644
index 764f080..0000000
--- a/src/type1/t1driver.c
+++ /dev/null
@@ -1,381 +0,0 @@
-/***************************************************************************/
-/* */
-/* t1driver.c */
-/* */
-/* Type 1 driver interface (body). */
-/* */
-/* Copyright 1996-2000 by */
-/* David Turner, Robert Wilhelm, and Werner Lemberg. */
-/* */
-/* This file is part of the FreeType project, and may only be used, */
-/* modified, and distributed under the terms of the FreeType project */
-/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
-/* this file you indicate that you have read the license and */
-/* understand and accept it fully. */
-/* */
-/***************************************************************************/
-
-
-#ifdef FT_FLAT_COMPILE
-
-#include "t1driver.h"
-#include "t1gload.h"
-#include "t1afm.h"
-
-#else
-
-#include <type1/t1driver.h>
-#include <type1/t1gload.h>
-#include <type1/t1afm.h>
-
-#endif
-
-
-#include <freetype/internal/ftdebug.h>
-#include <freetype/internal/ftstream.h>
-#include <freetype/internal/psnames.h>
-
-#include <string.h> /* for strcmp() */
-
-
- /*************************************************************************/
- /* */
- /* The macro FT_COMPONENT is used in trace mode. It is an implicit */
- /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */
- /* messages during execution. */
- /* */
-#undef FT_COMPONENT
-#define FT_COMPONENT trace_t1driver
-
-
-#ifndef T1_CONFIG_OPTION_NO_AFM
-
-
- /*************************************************************************/
- /* */
- /* <Function> */
- /* Get_Kerning */
- /* */
- /* <Description> */
- /* A driver method used to return the kerning vector between two */
- /* glyphs of the same face. */
- /* */
- /* <Input> */
- /* face :: A handle to the source face object. */
- /* */
- /* left_glyph :: The index of the left glyph in the kern pair. */
- /* */
- /* right_glyph :: The index of the right glyph in the kern pair. */
- /* */
- /* <Output> */
- /* kerning :: The kerning vector. This is in font units for */
- /* scalable formats, and in pixels for fixed-sizes */
- /* formats. */
- /* */
- /* <Return> */
- /* FreeType error code. 0 means success. */
- /* */
- /* <Note> */
- /* Only horizontal layouts (left-to-right & right-to-left) are */
- /* supported by this function. Other layouts, or more sophisticated */
- /* kernings are out of scope of this method (the basic driver */
- /* interface is meant to be simple). */
- /* */
- /* They can be implemented by format-specific interfaces. */
- /* */
- static
- FT_Error Get_Kerning( T1_Face face,
- FT_UInt left_glyph,
- FT_UInt right_glyph,
- FT_Vector* kerning )
- {
- T1_AFM* afm;
-
-
- kerning->x = 0;
- kerning->y = 0;
-
- afm = (T1_AFM*)face->afm_data;
- if ( afm )
- T1_Get_Kerning( afm, left_glyph, right_glyph, kerning );
-
- return T1_Err_Ok;
- }
-
-
-#endif /* T1_CONFIG_OPTION_NO_AFM */
-
-
- static
- FT_Error get_t1_glyph_name( T1_Face face,
- FT_UInt glyph_index,
- FT_Pointer buffer,
- FT_UInt buffer_max )
- {
- FT_String* gname;
-
-
- gname = face->type1.glyph_names[glyph_index];
-
- if ( buffer_max > 0 )
- {
- FT_UInt len = strlen( gname );
-
-
- if ( len >= buffer_max )
- len = buffer_max - 1;
-
- MEM_Copy( buffer, gname, len );
- ((FT_Byte*)buffer)[len] = 0;
- }
-
- return T1_Err_Ok;
- }
-
-
- static
- FT_Module_Interface T1_Get_Interface( FT_Module module,
- const char* interface )
- {
- FT_UNUSED( module );
-
- if ( strcmp( interface, "glyph_name" ) == 0 )
- return (FT_Module_Interface)get_t1_glyph_name;
-
- return 0;
- }
-
-
-
- /*************************************************************************/
- /* */
- /* <Function> */
- /* Set_Char_Sizes */
- /* */
- /* <Description> */
- /* A driver method used to reset a size's character sizes (horizontal */
- /* and vertical) expressed in fractional points. */
- /* */
- /* <Input> */
- /* char_width :: The character width expressed in 26.6 */
- /* fractional points. */
- /* */
- /* char_height :: The character height expressed in 26.6 */
- /* fractional points. */
- /* */
- /* horz_resolution :: The horizontal resolution of the output device. */
- /* */
- /* vert_resolution :: The vertical resolution of the output device. */
- /* */
- /* <InOut> */
- /* size :: A handle to the target size object. */
- /* */
- /* <Return> */
- /* FreeType error code. 0 means success. */
- /* */
- static
- FT_Error Set_Char_Sizes( T1_Size size,
- FT_F26Dot6 char_width,
- FT_F26Dot6 char_height,
- FT_UInt horz_resolution,
- FT_UInt vert_resolution )
- {
- FT_UNUSED( char_width );
- FT_UNUSED( char_height );
- FT_UNUSED( horz_resolution );
- FT_UNUSED( vert_resolution );
-
- size->valid = FALSE;
-
- return T1_Reset_Size( size );
- }
-
-
- /*************************************************************************/
- /* */
- /* <Function> */
- /* Set_Pixel_Sizes */
- /* */
- /* <Description> */
- /* A driver method used to reset a size's character sizes (horizontal */
- /* and vertical) expressed in integer pixels. */
- /* */
- /* <Input> */
- /* pixel_width :: The character width expressed in integer pixels. */
- /* */
- /* pixel_height :: The character height expressed in integer pixels. */
- /* */
- /* <InOut> */
- /* size :: A handle to the target size object. */
- /* */
- /* <Return> */
- /* FreeType error code. 0 means success. */
- /* */
- static
- FT_Error Set_Pixel_Sizes( T1_Size size,
- FT_Int pixel_width,
- FT_Int pixel_height )
- {
- FT_UNUSED( pixel_width );
- FT_UNUSED( pixel_height );
-
- size->valid = FALSE;
-
- return T1_Reset_Size( size );
- }
-
-
- /*************************************************************************/
- /* */
- /* <Function> */
- /* Get_Char_Index */
- /* */
- /* <Description> */
- /* Uses a charmap to return a given character code's glyph index. */
- /* */
- /* <Input> */
- /* charmap :: A handle to the source charmap object. */
- /* charcode :: The character code. */
- /* */
- /* <Return> */
- /* Glyph index. 0 means `undefined character code'. */
- /* */
- static
- FT_UInt Get_Char_Index( FT_CharMap charmap,
- FT_Long charcode )
- {
- T1_Face face;
- FT_UInt result = 0;
- PSNames_Interface* psnames;
-
-
- face = (T1_Face)charmap->face;
- psnames = (PSNames_Interface*)face->psnames;
- if ( psnames )
- switch ( charmap->encoding )
- {
- /*******************************************************************/
- /* */
- /* Unicode encoding support */
- /* */
- case ft_encoding_unicode:
- /* use the `PSNames' module to synthetize the Unicode charmap */
- result = psnames->lookup_unicode( &face->unicode_map,
- (FT_ULong)charcode );
-
- /* the function returns 0xFFFF if the Unicode charcode has */
- /* no corresponding glyph */
- if ( result == 0xFFFF )
- result = 0;
- goto Exit;
-
- /*******************************************************************/
- /* */
- /* Custom Type 1 encoding */
- /* */
- case ft_encoding_adobe_custom:
- {
- T1_Encoding* encoding = &face->type1.encoding;
-
-
- if ( charcode >= encoding->code_first &&
- charcode <= encoding->code_last )
- result = encoding->char_index[charcode];
- goto Exit;
- }
-
- /*******************************************************************/
- /* */
- /* Adobe Standard & Expert encoding support */
- /* */
- default:
- if ( charcode < 256 )
- {
- FT_UInt code;
- FT_Int n;
- const char* glyph_name;
-
-
- code = psnames->adobe_std_encoding[charcode];
- if ( charmap->encoding == ft_encoding_adobe_expert )
- code = psnames->adobe_expert_encoding[charcode];
-
- glyph_name = psnames->adobe_std_strings( code );
- if ( !glyph_name )
- break;
-
- for ( n = 0; n < face->type1.num_glyphs; n++ )
- {
- const char* gname = face->type1.glyph_names[n];
-
-
- if ( gname && gname[0] == glyph_name[0] &&
- strcmp( gname, glyph_name ) == 0 )
- {
- result = n;
- break;
- }
- }
- }
- }
- Exit:
- return result;
- }
-
-
-
- FT_CPLUSPLUS( const FT_Driver_Class ) t1_driver_class =
- {
- {
- ft_module_font_driver | ft_module_driver_scalable,
- sizeof( FT_DriverRec ),
-
- "type1", /* driver name */
- 0x10000L, /* driver version 1.0 */
- 0x20000L, /* driver requires FreeType 2.0 or above */
-
- 0, /* module specific interface */
-
- (FT_Module_Constructor)0,
- (FT_Module_Destructor) 0,
- (FT_Module_Requester) T1_Get_Interface
- },
-
- sizeof( T1_FaceRec ),
- sizeof( T1_SizeRec ),
- sizeof( T1_GlyphSlotRec ),
-
- (FTDriver_initFace) T1_Init_Face,
- (FTDriver_doneFace) T1_Done_Face,
- (FTDriver_initSize) T1_Init_Size,
- (FTDriver_doneSize) T1_Done_Size,
- (FTDriver_initGlyphSlot)T1_Init_GlyphSlot,
- (FTDriver_doneGlyphSlot)T1_Done_GlyphSlot,
-
- (FTDriver_setCharSizes) Set_Char_Sizes,
- (FTDriver_setPixelSizes)Set_Pixel_Sizes,
- (FTDriver_loadGlyph) T1_Load_Glyph,
- (FTDriver_getCharIndex) Get_Char_Index,
-
-#ifdef T1_CONFIG_OPTION_NO_AFM
- (FTDriver_getKerning) 0,
- (FTDriver_attachFile) 0,
-#else
- (FTDriver_getKerning) Get_Kerning,
- (FTDriver_attachFile) T1_Read_AFM,
-#endif
- (FTDriver_getAdvances) 0
- };
-
-
-#ifdef FT_CONFIG_OPTION_DYNAMIC_DRIVERS
-
- EXPORT_FUNC( const FT_Driver_Class* ) getDriverClass( void )
- {
- return &t1_driver_class;
- }
-
-#endif /* FT_CONFIG_OPTION_DYNAMIC_DRIVERS */
-
-
-/* END */
diff --git a/src/type1/t1driver.h b/src/type1/t1driver.h
deleted file mode 100644
index 8744b96..0000000
--- a/src/type1/t1driver.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/***************************************************************************/
-/* */
-/* t1driver.h */
-/* */
-/* High-level Type 1 driver interface (specification). */
-/* */
-/* Copyright 1996-2000 by */
-/* David Turner, Robert Wilhelm, and Werner Lemberg. */
-/* */
-/* This file is part of the FreeType project, and may only be used, */
-/* modified, and distributed under the terms of the FreeType project */
-/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
-/* this file you indicate that you have read the license and */
-/* understand and accept it fully. */
-/* */
-/***************************************************************************/
-
-
-#ifndef T1DRIVER_H
-#define T1DRIVER_H
-
-#include <freetype/internal/ftdriver.h>
-
-#ifdef __cplusplus
- extern "C" {
-#endif
-
-
- FT_EXPORT_VAR( const FT_Driver_Class ) t1_driver_class;
-
-
-#ifdef __cplusplus
- }
-#endif
-
-
-#endif /* T1DRIVER_H */
-
-
-/* END */
diff --git a/src/type1/t1gload.c b/src/type1/t1gload.c
deleted file mode 100644
index 37cfc8c..0000000
--- a/src/type1/t1gload.c
+++ /dev/null
@@ -1,1823 +0,0 @@
-/***************************************************************************/
-/* */
-/* t1gload.c */
-/* */
-/* Type 1 Glyph Loader (body). */
-/* */
-/* Copyright 1996-2000 by */
-/* David Turner, Robert Wilhelm, and Werner Lemberg. */
-/* */
-/* This file is part of the FreeType project, and may only be used, */
-/* modified, and distributed under the terms of the FreeType project */
-/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
-/* this file you indicate that you have read the license and */
-/* understand and accept it fully. */
-/* */
-/***************************************************************************/
-
-
-#ifdef FT_FLAT_COMPILE
-
-#include "t1gload.h"
-
-#ifndef T1_CONFIG_OPTION_DISABLE_HINTER
-#include "t1hinter.h"
-#endif
-
-#else /* FT_FLAT_COMPILE */
-
-#include <type1/t1gload.h>
-
-#ifndef T1_CONFIG_OPTION_DISABLE_HINTER
-#include <type1/t1hinter.h>
-#endif
-
-#endif /* FT_FLAT_COMPILE */
-
-
-#include <freetype/internal/ftdebug.h>
-#include <freetype/internal/ftstream.h>
-#include <freetype/ftoutln.h>
-
-#include <string.h> /* for strcmp() */
-
-
- /*************************************************************************/
- /* */
- /* The macro FT_COMPONENT is used in trace mode. It is an implicit */
- /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */
- /* messages during execution. */
- /* */
-#undef FT_COMPONENT
-#define FT_COMPONENT trace_t1gload
-
-
- /*************************************************************************/
- /*************************************************************************/
- /*************************************************************************/
- /********** *********/
- /********** *********/
- /********** GENERIC CHARSTRING PARSING *********/
- /********** *********/
- /********** *********/
- /*************************************************************************/
- /*************************************************************************/
- /*************************************************************************/
-
-
- static
- void T1_Reset_Builder( T1_Builder* builder,
- FT_Bool reset_base )
- {
- builder->pos_x = 0;
- builder->pos_y = 0;
-
- builder->left_bearing.x = 0;
- builder->left_bearing.y = 0;
- builder->advance.x = 0;
- builder->advance.y = 0;
-
- builder->pass = 0;
- builder->hint_point = 0;
-
- if ( builder->loader )
- {
- if ( reset_base )
- FT_GlyphLoader_Rewind( builder->loader );
-
- FT_GlyphLoader_Prepare( builder->loader );
- }
- }
-
-
- /*************************************************************************/
- /* */
- /* <Function> */
- /* T1_Init_Builder */
- /* */
- /* <Description> */
- /* Initializes a given glyph builder. */
- /* */
- /* <InOut> */
- /* builder :: A pointer to the glyph builder to initialize. */
- /* */
- /* <Input> */
- /* face :: The current face object. */
- /* */
- /* size :: The current size object. */
- /* */
- /* glyph :: The current glyph object. */
- /* */
- /* funcs :: Glyph builder functions (or `methods'). */
- /* */
- LOCAL_FUNC
- void T1_Init_Builder( T1_Builder* builder,
- T1_Face face,
- T1_Size size,
- T1_GlyphSlot glyph,
- const T1_Builder_Funcs* funcs )
- {
- builder->funcs = *funcs;
- builder->path_begun = 0;
- builder->load_points = 1;
-
- builder->face = face;
- builder->size = size;
- builder->glyph = glyph;
- builder->memory = face->root.memory;
-
- if ( glyph )
- {
- FT_GlyphLoader* loader = FT_SLOT( glyph )->loader;
-
-
- builder->loader = loader;
- builder->base = &loader->base.outline;
- builder->current = &loader->current.outline;
- }
-
- if ( size )
- {
- builder->scale_x = size->root.metrics.x_scale;
- builder->scale_y = size->root.metrics.y_scale;
- }
-
- T1_Reset_Builder( builder, 1 );
- }
-
-
- /*************************************************************************/
- /* */
- /* <Function> */
- /* T1_Done_Builder */
- /* */
- /* <Description> */
- /* Finalizes a given glyph builder. Its contents can still be used */
- /* after the call, but the function saves important information */
- /* within the corresponding glyph slot. */
- /* */
- /* <Input> */
- /* builder :: A pointer to the glyph builder to finalize. */
- /* */
- LOCAL_FUNC
- void T1_Done_Builder( T1_Builder* builder )
- {
- T1_GlyphSlot glyph = builder->glyph;
-
-
- if ( glyph )
- glyph->root.outline = *builder->base;
- }
-
-
- /*************************************************************************/
- /* */
- /* <Function> */
- /* T1_Init_Decoder */
- /* */
- /* <Description> */
- /* Initializes a given glyph decoder. */
- /* */
- /* <InOut> */
- /* decoder :: A pointer to the glyph builder to initialize. */
- /* */
- /* <Input> */
- /* funcs :: The hinting functions interface. */
- /* */
- LOCAL_FUNC
- void T1_Init_Decoder( T1_Decoder* decoder,
- const T1_Hinter_Funcs* funcs )
- {
- decoder->hinter = *funcs; /* copy hinter interface */
- decoder->top = 0;
- decoder->zone = 0;
-
- decoder->flex_state = 0;
- decoder->num_flex_vectors = 0;
-
- /* Clear loader */
- MEM_Set( &decoder->builder, 0, sizeof ( decoder->builder ) );
- }
-
-
- /*************************************************************************/
- /* */
- /* <Function> */
- /* lookup_glyph_by_stdcharcode */
- /* */
- /* <Description> */
- /* Looks up a given glyph by its StandardEncoding charcode. Used */
- /* to implement the SEAC Type 1 operator. */
- /* */
- /* <Input> */
- /* face :: The current face object. */
- /* */
- /* charcode :: The character code to look for. */
- /* */
- /* <Return> */
- /* A glyph index in the font face. Returns -1 if the corresponding */
- /* glyph wasn't found. */
- /* */
- static
- FT_Int lookup_glyph_by_stdcharcode( T1_Face face,
- FT_Int charcode )
- {
- FT_Int n;
- const FT_String* glyph_name;
- PSNames_Interface* psnames = (PSNames_Interface*)face->psnames;
-
-
- /* check range of standard char code */
- if ( charcode < 0 || charcode > 255 )
- return -1;
-
- glyph_name = psnames->adobe_std_strings(
- psnames->adobe_std_encoding[charcode] );
-
- for ( n = 0; n < face->type1.num_glyphs; n++ )
- {
- FT_String* name = (FT_String*)face->type1.glyph_names[n];
-
-
- if ( name && strcmp( name, glyph_name ) == 0 )
- return n;
- }
-
- return -1;
- }
-
-
- /*************************************************************************/
- /* */
- /* <Function> */
- /* t1operator_seac */
- /* */
- /* <Description> */
- /* Implements the `seac' Type 1 operator for a Type 1 decoder. */
- /* */
- /* <Input> */
- /* decoder :: The current CID decoder. */
- /* */
- /* asb :: The accent's side bearing. */
- /* */
- /* adx :: The horizontal offset of the accent. */
- /* */
- /* ady :: The vertical offset of the accent. */
- /* */
- /* bchar :: The base character's StandardEncoding charcode. */
- /* */
- /* achar :: The accent character's StandardEncoding charcode. */
- /* */
- /* <Return> */
- /* FreeType error code. 0 means success. */
- /* */
- static
- FT_Error t1operator_seac( T1_Decoder* decoder,
- FT_Pos asb,
- FT_Pos adx,
- FT_Pos ady,
- FT_Int bchar,
- FT_Int achar )
- {
- FT_Error error;
- FT_Int bchar_index, achar_index, n_base_points;
- FT_Outline* base = decoder->builder.base;
- FT_Vector left_bearing, advance;
- T1_Face face = decoder->builder.face;
- T1_Font* type1 = &face->type1;
-
-
- bchar_index = lookup_glyph_by_stdcharcode( face, bchar );
- achar_index = lookup_glyph_by_stdcharcode( face, achar );
-
- if ( bchar_index < 0 || achar_index < 0 )
- {
- FT_ERROR(( "t1operator_seac:" ));
- FT_ERROR(( " invalid seac character code arguments\n" ));
- return T1_Err_Syntax_Error;
- }
-
- /* if we are trying to load a composite glyph, do not load the */
- /* accent character and return the array of subglyphs. */
- if ( decoder->builder.no_recurse )
- {
- FT_GlyphSlot glyph = (FT_GlyphSlot)decoder->builder.glyph;
- FT_GlyphLoader* loader = glyph->loader;
- FT_SubGlyph* subg;
-
-
- /* reallocate subglyph array if necessary */
- error = FT_GlyphLoader_Check_Subglyphs( loader, 2 );
- if ( error )
- goto Exit;
-
- subg = loader->current.subglyphs;
-
- /* subglyph 0 = base character */
- subg->index = bchar_index;
- subg->flags = FT_SUBGLYPH_FLAG_ARGS_ARE_XY_VALUES |
- FT_SUBGLYPH_FLAG_USE_MY_METRICS;
- subg->arg1 = 0;
- subg->arg2 = 0;
- subg++;
-
- /* subglyph 1 = accent character */
- subg->index = achar_index;
- subg->flags = FT_SUBGLYPH_FLAG_ARGS_ARE_XY_VALUES;
- subg->arg1 = adx - asb;
- subg->arg2 = ady;
-
- /* set up remaining glyph fields */
- glyph->num_subglyphs = 2;
- glyph->subglyphs = loader->current.subglyphs;
- glyph->format = ft_glyph_format_composite;
-
- loader->current.num_subglyphs = 2;
- goto Exit;
- }
-
- /* First load `bchar' in builder */
- /* now load the unscaled outline */
-
- if ( decoder->builder.loader )
- FT_GlyphLoader_Prepare( decoder->builder.loader ); /* prepare loader */
-
- error = T1_Parse_CharStrings( decoder,
- type1->charstrings [bchar_index],
- type1->charstrings_len[bchar_index],
- type1->num_subrs,
- type1->subrs,
- type1->subrs_len );
- if ( error )
- goto Exit;
-
- n_base_points = base->n_points;
-
- /* save the left bearing and width of the base character */
- /* as they will be erased by the next load. */
-
- left_bearing = decoder->builder.left_bearing;
- advance = decoder->builder.advance;
-
- decoder->builder.left_bearing.x = 0;
- decoder->builder.left_bearing.y = 0;
-
- /* Now load `achar' on top of the base outline */
- error = T1_Parse_CharStrings( decoder,
- type1->charstrings [achar_index],
- type1->charstrings_len[achar_index],
- type1->num_subrs,
- type1->subrs,
- type1->subrs_len );
- if ( error )
- return error;
-
- /* restore the left side bearing and */
- /* advance width of the base character */
-
- decoder->builder.left_bearing = left_bearing;
- decoder->builder.advance = advance;
-
- /* Finally, move the accent */
- if ( decoder->builder.load_points )
- {
- FT_Outline dummy;
-
-
- dummy.n_points = base->n_points - n_base_points;
- dummy.points = base->points + n_base_points;
-
- FT_Outline_Translate( &dummy, adx - asb, ady );
- }
-
- Exit:
- return error;
- }
-
-
- /*************************************************************************/
- /* */
- /* <Function> */
- /* t1operator_flex */
- /* */
- /* <Description> */
- /* Implements the `flex' Type 1 operator for a Type 1 decoder. */
- /* */
- /* <Input> */
- /* decoder :: The current Type 1 decoder. */
- /* threshold :: The threshold. */
- /* end_x :: The horizontal position of the final flex point. */
- /* end_y :: The vertical position of the final flex point. */
- /* */
- /* <Return> */
- /* FreeType error code. 0 means success. */
- /* */
- static
- FT_Error t1operator_flex( T1_Decoder* decoder,
- FT_Pos threshold,
- FT_Pos end_x,
- FT_Pos end_y )
- {
- FT_Vector vec;
- FT_Vector* flex = decoder->flex_vectors;
- FT_Int n;
-
- FT_UNUSED( threshold );
- FT_UNUSED( end_x );
- FT_UNUSED( end_y );
-
-
- /* we don't even try to test the threshold in the non-hinting */
- /* builder, even if the flex operator is said to be a path */
- /* construction statement in the specification. This is better */
- /* left to the hinter. */
-
- flex = decoder->flex_vectors;
- vec = *flex++;
-
- for ( n = 0; n < 6; n++ )
- {
- flex->x += vec.x;
- flex->y += vec.y;
-
- vec = *flex++;
- }
-
- flex = decoder->flex_vectors;
-
- return decoder->builder.funcs.rcurve_to( &decoder->builder,
- flex[0].x, flex[0].y,
- flex[1].x, flex[1].y,
- flex[2].x, flex[2].y ) ||
-
- decoder->builder.funcs.rcurve_to( &decoder->builder,
- flex[3].x, flex[3].y,
- flex[4].x, flex[4].y,
- flex[5].x, flex[5].y );
- }
-
-
- /*************************************************************************/
- /* */
- /* <Function> */
- /* T1_Parse_CharStrings */
- /* */
- /* <Description> */
- /* Parses a given Type 1 charstrings program. */
- /* */
- /* <Input> */
- /* decoder :: The current Type 1 decoder. */
- /* */
- /* charstring_base :: The base address of the charstring stream. */
- /* */
- /* charstring_len :: The length in bytes of the charstring stream. */
- /* */
- /* num_subrs :: The number of sub-routines. */
- /* */
- /* subrs_base :: An array of sub-routines addresses. */
- /* */
- /* subrs_len :: An array of sub-routines lengths. */
- /* */
- /* <Return> */
- /* Free error code. 0 means success. */
- /* */
- LOCAL_FUNC
- FT_Error T1_Parse_CharStrings( T1_Decoder* decoder,
- FT_Byte* charstring_base,
- FT_Int charstring_len,
- FT_Int num_subrs,
- FT_Byte** subrs_base,
- FT_Int* subrs_len )
- {
- FT_Error error;
- T1_Decoder_Zone* zone;
- FT_Byte* ip;
- FT_Byte* limit;
- T1_Builder* builder = &decoder->builder;
- T1_Builder_Funcs* builds = &builder->funcs;
- T1_Hinter_Funcs* hints = &decoder->hinter;
-
- static
- const FT_Int args_count[op_max] =
- {
- 0, /* none */
- 0, /* endchar */
- 2, /* hsbw */
- 5, /* seac */
- 4, /* sbw */
- 0, /* closepath */
- 1, /* hlineto */
- 1, /* hmoveto */
- 4, /* hvcurveto */
- 2, /* rlineto */
- 2, /* rmoveto */
- 6, /* rrcurveto */
- 4, /* vhcurveto */
- 1, /* vlineto */
- 1, /* vmoveto */
- 0, /* dotsection */
- 2, /* hstem */
- 6, /* hstem3 */
- 2, /* vstem */
- 6, /* vstem3 */
- 2, /* div */
- -1, /* callothersubr */
- 1, /* callsubr */
- 0, /* pop */
- 0, /* return */
- 2 /* setcurrentpoint */
- };
-
-
- /* First of all, initialize the decoder */
- decoder->top = decoder->stack;
- decoder->zone = decoder->zones;
- zone = decoder->zones;
-
- builder->path_begun = 0;
-
- zone->base = charstring_base;
- limit = zone->limit = charstring_base + charstring_len;
- ip = zone->cursor = zone->base;
-
- error = T1_Err_Ok;
-
- /* now, execute loop */
- while ( ip < limit )
- {
- FT_Int* top = decoder->top;
- T1_Operator op = op_none;
- FT_Long value = 0;
-
-
- /* Start with the decompression of operator or value */
- switch ( *ip++ )
- {
- case 1:
- op = op_hstem;
- break;
-
- case 3:
- op = op_vstem;
- break;
- case 4:
- op = op_vmoveto;
- break;
- case 5:
- op = op_rlineto;
- break;
- case 6:
- op = op_hlineto;
- break;
- case 7:
- op = op_vlineto;
- break;
- case 8:
- op = op_rrcurveto;
- break;
- case 9:
- op = op_closepath;
- break;
- case 10:
- op = op_callsubr;
- break;
- case 11:
- op = op_return;
- break;
-
- case 13:
- op = op_hsbw;
- break;
- case 14:
- op = op_endchar;
- break;
-
- case 21:
- op = op_rmoveto;
- break;
- case 22:
- op = op_hmoveto;
- break;
-
- case 30:
- op = op_vhcurveto;
- break;
- case 31:
- op = op_hvcurveto;
- break;
-
- case 12:
- if ( ip > limit )
- {
- FT_ERROR(( "T1_Parse_CharStrings: invalid escape (12+EOF)\n" ));
- goto Syntax_Error;
- }
-
- switch ( *ip++ )
- {
- case 0:
- op = op_dotsection;
- break;
- case 1:
- op = op_vstem3;
- break;
- case 2:
- op = op_hstem3;
- break;
- case 6:
- op = op_seac;
- break;
- case 7:
- op = op_sbw;
- break;
- case 12:
- op = op_div;
- break;
- case 16:
- op = op_callothersubr;
- break;
- case 17:
- op = op_pop;
- break;
- case 33:
- op = op_setcurrentpoint;
- break;
-
- default:
- FT_ERROR(( "T1_Parse_CharStrings: invalid escape (12+%d)\n",
- ip[-1] ));
- goto Syntax_Error;
- }
- break;
-
- case 255: /* four bytes integer */
- if ( ip + 4 > limit )
- {
- FT_ERROR(( "T1_Parse_CharStrings: unexpected EOF in integer\n" ));
- goto Syntax_Error;
- }
-
- value = ( (FT_Long)ip[0] << 24 ) |
- ( (FT_Long)ip[1] << 16 ) |
- ( (FT_Long)ip[2] << 8 ) |
- ip[3];
- ip += 4;
- break;
-
- default:
- if ( ip[-1] >= 32 )
- {
- if ( ip[-1] < 247 )
- value = (FT_Long)ip[-1] - 139;
- else
- {
- if ( ++ip > limit )
- {
- FT_ERROR(( "T1_Parse_CharStrings:" ));
- FT_ERROR(( " unexpected EOF in integer\n" ));
- goto Syntax_Error;
- }
-
- if ( ip[-2] < 251 )
- value = ((FT_Long)( ip[-2] - 247 ) << 8 ) + ip[-1] + 108;
- else
- value = -( ( ( (FT_Long)ip[-2] - 251 ) << 8 ) + ip[-1] + 108 );
- }
- }
- else
- {
- FT_ERROR(( "T1_Parse_CharStrings: invalid byte (%d)\n",
- ip[-1] ));
- goto Syntax_Error;
- }
- }
-
- /* push value if necessary */
- if ( op == op_none )
- {
- if ( top - decoder->stack >= T1_MAX_CHARSTRINGS_OPERANDS )
- {
- FT_ERROR(( "T1_Parse_CharStrings: stack overflow!\n" ));
- goto Syntax_Error;
- }
-
- *top++ = value;
- decoder->top = top;
- }
-
- else if ( op == op_callothersubr ) /* check arguments differently */
- {
- if ( top - decoder->stack < 2 )
- goto Stack_Underflow;
-
- top -= 2;
-
- switch ( top[1] )
- {
- case 1: /* start flex feature */
- if ( top[0] != 0 )
- goto Unexpected_OtherSubr;
-
- decoder->flex_state = 1;
- decoder->num_flex_vectors = 0;
- decoder->flex_vectors[0].x = 0;
- decoder->flex_vectors[0].y = 0;
- break;
-
- case 2: /* add flex vector */
- {
- FT_Int index;
- FT_Vector* flex;
-
-
- if ( top[0] != 0 )
- goto Unexpected_OtherSubr;
-
- top -= 2;
- if ( top < decoder->stack )
- goto Stack_Underflow;
-
- index = decoder->num_flex_vectors++;
- if ( index >= 7 )
- {
- FT_ERROR(( "T1_Parse_CharStrings: too many flex vectors!\n" ));
- goto Syntax_Error;
- }
-
- flex = decoder->flex_vectors + index;
- flex->x += top[0];
- flex->y += top[1];
- }
- break;
-
- case 0: /* end flex feature */
- if ( decoder->flex_state == 0 ||
- decoder->num_flex_vectors != 7 )
- {
- FT_ERROR(( "T1_Parse_CharStrings: unexpected flex end\n" ));
- goto Syntax_Error;
- }
-
- if ( top[0] != 3 )
- goto Unexpected_OtherSubr;
-
- top -= 3;
- if ( top < decoder->stack )
- goto Stack_Underflow;
-
- /* now consume the remaining `pop pop setcurrentpoint' */
- if ( ip + 6 > limit ||
- ip[0] != 12 || ip[1] != 17 || /* pop */
- ip[2] != 12 || ip[3] != 17 || /* pop */
- ip[4] != 12 || ip[5] != 33 ) /* setcurrentpoint */
- {
- FT_ERROR(( "T1_Parse_CharStrings: invalid flex charstring\n" ));
- goto Syntax_Error;
- }
-
- decoder->flex_state = 0;
- decoder->top = top;
-
- error = t1operator_flex( decoder, top[0], top[1], top[2] );
- break;
-
- case 3: /* change hints */
- if ( top[0] != 1 )
- goto Unexpected_OtherSubr;
-
- /* eat the following `pop' */
- if ( ip + 2 > limit )
- {
- FT_ERROR(( "T1_Parse_CharStrings: invalid escape (12+%d)\n",
- ip[-1] ));
- goto Syntax_Error;
- }
-
- if ( ip[0] != 12 || ip[1] != 17 )
- {
- FT_ERROR(( "T1_Parse_CharStrings:" ));
- FT_ERROR(( " `pop' expected, found (%d %d)\n", ip[0], ip[1] ));
- goto Syntax_Error;
- }
-
- ip += 2;
-
- error = hints->change_hints( builder );
- break;
-
- default:
- /* invalid OtherSubrs call */
- Unexpected_OtherSubr:
- FT_ERROR(( "T1_Parse_CharStrings: unexpected OtherSubrs [%d %d]\n",
- top[0], top[1] ));
- goto Syntax_Error;
- }
- decoder->top = top;
- }
- else
- {
- FT_Int num_args = args_count[op];
-
-
- if ( top - decoder->stack < num_args )
- goto Stack_Underflow;
-
- top -= num_args;
-
- switch ( op )
- {
- case op_endchar:
- error = builds->end_char( builder );
- break;
-
- case op_hsbw:
- error = builds->set_bearing_point( builder, top[0], 0,
- top[1], 0 );
- break;
-
- case op_seac:
- /* return immediately after the processing */
- return t1operator_seac( decoder, top[0], top[1],
- top[2], top[3], top[4] );
-
- case op_sbw:
- error = builds->set_bearing_point( builder, top[0], top[1],
- top[2], top[3] );
- break;
-
- case op_closepath:
- error = builds->close_path( builder );
- break;
-
- case op_hlineto:
- error = builds->rline_to( builder, top[0], 0 );
- break;
-
- case op_hmoveto:
- error = builds->rmove_to( builder, top[0], 0 );
- break;
-
- case op_hvcurveto:
- error = builds->rcurve_to( builder, top[0], 0,
- top[1], top[2],
- 0, top[3] );
- break;
-
- case op_rlineto:
- error = builds->rline_to( builder, top[0], top[1] );
- break;
-
- case op_rmoveto:
- /* ignore operator when in flex mode */
- if ( decoder->flex_state == 0 )
- error = builds->rmove_to( builder, top[0], top[1] );
- else
- top += 2;
- break;
-
- case op_rrcurveto:
- error = builds->rcurve_to( builder, top[0], top[1],
- top[2], top[3],
- top[4], top[5] );
- break;
-
- case op_vhcurveto:
- error = builds->rcurve_to( builder, 0, top[0],
- top[1], top[2],
- top[3], 0 );
- break;
-
- case op_vlineto:
- error = builds->rline_to( builder, 0, top[0] );
- break;
-
- case op_vmoveto:
- error = builds->rmove_to( builder, 0, top[0] );
- break;
-
- case op_dotsection:
- error = hints->dot_section( builder );
- break;
-
- case op_hstem:
- error = hints->stem( builder, top[0], top[1], 0 );
- break;
-
- case op_hstem3:
- error = hints->stem3( builder, top[0], top[1], top[2],
- top[3], top[4], top[5], 0 );
- break;
-
- case op_vstem:
- error = hints->stem( builder, top[0], top[1], 1 );
- break;
-
- case op_vstem3:
- error = hints->stem3( builder, top[0], top[1], top[2],
- top[3], top[4], top[5], 1 );
- break;
-
- case op_div:
- if ( top[1] )
- {
- *top = top[0] / top[1];
- ++top;
- }
- else
- {
- FT_ERROR(( "T1_Parse_CHarStrings: division by 0\n" ));
- goto Syntax_Error;
- }
- break;
-
- case op_callsubr:
- {
- FT_Int index = top[0];
-
-
- if ( index < 0 || index >= num_subrs )
- {
- FT_ERROR(( "T1_Parse_CharStrings: invalid subrs index\n" ));
- goto Syntax_Error;
- }
-
- if ( zone - decoder->zones >= T1_MAX_SUBRS_CALLS )
- {
- FT_ERROR(( "T1_Parse_CharStrings: too many nested subrs\n" ));
- goto Syntax_Error;
- }
-
- zone->cursor = ip; /* save current instruction pointer */
-
- zone++;
- zone->base = subrs_base[index];
- zone->limit = zone->base + subrs_len[index];
- zone->cursor = zone->base;
-
- if ( !zone->base )
- {
- FT_ERROR(( "T1_Parse_CharStrings: invoking empty subrs!\n" ));
- goto Syntax_Error;
- }
-
- decoder->zone = zone;
- ip = zone->base;
- limit = zone->limit;
- }
- break;
-
- case op_pop:
- FT_ERROR(( "T1_Parse_CharStrings: unexpected POP\n" ));
- goto Syntax_Error;
-
- case op_return:
- if ( zone <= decoder->zones )
- {
- FT_ERROR(( "T1_Parse_CharStrings: unexpected return\n" ));
- goto Syntax_Error;
- }
-
- zone--;
- ip = zone->cursor;
- limit = zone->limit;
- decoder->zone = zone;
- break;
-
- case op_setcurrentpoint:
- FT_ERROR(( "T1_Parse_CharStrings:" ));
- FT_ERROR(( " unexpected `setcurrentpoint'\n" ));
- goto Syntax_Error;
- break;
-
- default:
- FT_ERROR(( "T1_Parse_CharStrings: unhandled opcode %d\n", op ));
- goto Syntax_Error;
- }
-
- decoder->top = top;
- }
- }
-
- return error;
-
- Syntax_Error:
- return T1_Err_Syntax_Error;
-
- Stack_Underflow:
- return T1_Err_Stack_Underflow;
- }
-
-
- /*************************************************************************/
- /* */
- /* <Function> */
- /* T1_Add_Points */
- /* */
- /* <Description> */
- /* Checks that there is enough room in the current load glyph outline */
- /* to accept `num_points' additional outline points. If not, this */
- /* function grows the load outline's arrays accordingly. */
- /* */
- /* <Input> */
- /* builder :: A pointer to the glyph builder object. */
- /* */
- /* num_points :: The number of points that will be added later. */
- /* */
- /* <Return> */
- /* FreeType error code. 0 means success. */
- /* */
- /* <Note> */
- /* This function does NOT update the points count in the glyph */
- /* builder. This must be done by the caller itself, after this */
- /* function has been invoked. */
- /* */
- LOCAL_FUNC
- FT_Error T1_Add_Points( T1_Builder* builder,
- FT_Int num_points )
- {
- return FT_GlyphLoader_Check_Points( builder->loader, num_points, 0 );
- }
-
-
- /*************************************************************************/
- /* */
- /* <Function> */
- /* T1_Add_Contours */
- /* */
- /* <Description> */
- /* Checks that there is enough room in the current load glyph outline */
- /* to accept `num_contours' additional contours. If not, this */
- /* function grows the load outline's arrays accordingly. */
- /* */
- /* <Input> */
- /* builder :: A pointer to the glyph builder object. */
- /* */
- /* num_contours :: The number of contours that will be added later. */
- /* */
- /* <Return> */
- /* FreeType error code. 0 means success. */
- /* */
- /* <Note> */
- /* This function does NOT update the contours count in the load glyph */
- /* This must be done by the caller itself, after this function is */
- /* invoked. */
- /* */
- LOCAL_FUNC
- FT_Error T1_Add_Contours( T1_Builder* builder,
- FT_Int num_contours )
- {
- return FT_GlyphLoader_Check_Points( builder->loader, 0, num_contours );
- }
-
-
- /*************************************************************************/
- /*************************************************************************/
- /*************************************************************************/
- /********** *********/
- /********** COMPUTE THE MAXIMUM ADVANCE WIDTH *********/
- /********** *********/
- /********** The following code is in charge of computing *********/
- /********** the maximum advance width of the font. It *********/
- /********** quickly processes each glyph charstring to *********/
- /********** extract the value from either a `sbw' or `seac' *********/
- /********** operator. *********/
- /********** *********/
- /*************************************************************************/
- /*************************************************************************/
- /*************************************************************************/
-
-
- static
- FT_Error maxadv_sbw( T1_Decoder* decoder,
- FT_Pos sbx,
- FT_Pos sby,
- FT_Pos wx,
- FT_Pos wy )
- {
- FT_UNUSED( sbx );
- FT_UNUSED( sby );
- FT_UNUSED( wy );
-
- if ( wx > decoder->builder.advance.x )
- decoder->builder.advance.x = wx;
-
- return -1; /* return an error code to exit the Type 1 parser */
- /* immediately. */
- }
-
-
- static
- FT_Int maxadv_error( void )
- {
- /* we should never reach this code, unless with a buggy font */
- return -2;
- }
-
-
- /* the maxadv_gbuilder_interface is used when computing the maximum */
- /* advance width of all glyphs in a given font. We only process the */
- /* `sbw' operator here, and return an error for all others. */
-
- /* Note that `seac' is processed by the T1_Decoder. */
- static
- const T1_Builder_Funcs maxadv_builder_interface =
- {
- (T1_Builder_EndChar) maxadv_error,
- (T1_Builder_Sbw) maxadv_sbw,
- (T1_Builder_ClosePath)maxadv_error,
- (T1_Builder_RLineTo) maxadv_error,
- (T1_Builder_RMoveTo) maxadv_error,
- (T1_Builder_RCurveTo) maxadv_error
- };
-
-
- /* the maxadv_hinter_interface always return an error. */
- static
- const T1_Hinter_Funcs maxadv_hinter_interface =
- {
- (T1_Hinter_DotSection) maxadv_error,
- (T1_Hinter_ChangeHints)maxadv_error,
- (T1_Hinter_Stem) maxadv_error,
- (T1_Hinter_Stem3) maxadv_error,
- };
-
-
- LOCAL_FUNC
- FT_Error T1_Compute_Max_Advance( T1_Face face,
- FT_Int* max_advance )
- {
- FT_Error error;
- T1_Decoder decoder;
- FT_Int glyph_index;
- T1_Font* type1 = &face->type1;
-
-
- *max_advance = 0;
-
- /* Initialize load decoder */
- T1_Init_Decoder( &decoder, &maxadv_hinter_interface );
-
- T1_Init_Builder( &decoder.builder, face, 0, 0,
- &maxadv_builder_interface );
-
- /* For each glyph, parse the glyph charstring and extract */
- /* the advance width. */
- for ( glyph_index = 0; glyph_index < type1->num_glyphs; glyph_index++ )
- {
- /* now get load the unscaled outline */
- error = T1_Parse_CharStrings( &decoder,
- type1->charstrings [glyph_index],
- type1->charstrings_len[glyph_index],
- type1->num_subrs,
- type1->subrs,
- type1->subrs_len );
- /* ignore the error if one occured - skip to next glyph */
- }
-
- *max_advance = decoder.builder.advance.x;
- return T1_Err_Ok;
- }
-
-
- /*************************************************************************/
- /*************************************************************************/
- /*************************************************************************/
- /********** *********/
- /********** UNHINTED GLYPH LOADER *********/
- /********** *********/
- /********** The following code is in charge of loading a *********/
- /********** single outline. It completely ignores hinting *********/
- /********** and is used when FT_LOAD_NO_HINTING is set. *********/
- /********** *********/
- /********** The Type 1 hinter is located in `t1hint.c' *********/
- /********** *********/
- /*************************************************************************/
- /*************************************************************************/
- /*************************************************************************/
-
-
- static
- FT_Error close_open_path( T1_Builder* builder )
- {
- FT_Error error;
- FT_Outline* cur = builder->current;
- FT_Int num_points;
- FT_Int first_point;
-
-
- /* Some fonts, like Hershey, are made of `open paths' which are */
- /* now managed directly by FreeType. In this case, it is necessary */
- /* to close the path by duplicating its points in reverse order, */
- /* which is precisely the purpose of this function. */
-
- /* first compute the number of points to duplicate */
- if ( cur->n_contours > 1 )
- first_point = cur->contours[cur->n_contours - 2] + 1;
- else
- first_point = 0;
-
- num_points = cur->n_points - first_point - 2;
- if ( num_points > 0 )
- {
- FT_Vector* source_point;
- char* source_tags;
- FT_Vector* point;
- char* tags;
-
-
- error = T1_Add_Points( builder, num_points );
- if ( error )
- return error;
-
- point = cur->points + cur->n_points;
- tags = cur->tags + cur->n_points;
-
- source_point = point - 2;
- source_tags = tags - 2;
-
- cur->n_points += num_points;
-
- if ( builder->load_points )
- do
- {
- *point++ = *source_point--;
- *tags++ = *source_tags--;
- num_points--;
-
- } while ( num_points > 0 );
- }
-
- builder->path_begun = 0;
- return T1_Err_Ok;
- }
-
-
- static
- FT_Error gload_closepath( T1_Builder* builder )
- {
- FT_Outline* cur = builder->current;
-
-
- /* XXXX: We must not include the last point in the path if it */
- /* is located on the first point. */
- if ( cur->n_points > 1 )
- {
- FT_Int first = 0;
- FT_Vector* p1 = cur->points + first;
- FT_Vector* p2 = cur->points + cur->n_points - 1;
-
-
- if ( cur->n_contours > 1 )
- {
- first = cur->contours[cur->n_contours - 2] + 1;
- p1 = cur->points + first;
- }
-
- if ( p1->x == p2->x && p1->y == p2->y )
- cur->n_points--;
- }
-
- /* save current contour, if any */
- if ( cur->n_contours > 0 )
- cur->contours[cur->n_contours - 1] = cur->n_points - 1;
-
-#ifndef T1_CONFIG_OPTION_DISABLE_HINTER
- /* hint last points if necessary -- this is not strictly required */
- /* there, but it helps for debugging, and doesn't affect performance */
- if ( builder->pass == 1 )
- T1_Hint_Points( builder );
-#endif
-
- builder->path_begun = 0;
- return T1_Err_Ok;
- }
-
-
- static
- FT_Error gload_endchar( T1_Builder* builder )
- {
- FT_Error error;
-
-
- /* close path if needed */
- if ( builder->path_begun )
- {
- error = close_open_path( builder );
- if ( error )
- return error;
- }
-
- error = gload_closepath( builder );
-
- FT_GlyphLoader_Add( builder->loader );
-
- return error;
- }
-
-
- static
- FT_Error gload_sbw( T1_Builder* builder,
- FT_Pos sbx,
- FT_Pos sby,
- FT_Pos wx,
- FT_Pos wy )
- {
- builder->left_bearing.x += sbx;
- builder->left_bearing.y += sby;
- builder->advance.x = wx;
- builder->advance.y = wy;
-
- builder->last.x = sbx;
- builder->last.y = sby;
-
- return 0;
- }
-
-
- static
- FT_Error gload_rlineto( T1_Builder* builder,
- FT_Pos dx,
- FT_Pos dy )
- {
- FT_Error error;
- FT_Outline* cur = builder->current;
- FT_Vector vec;
-
-
- /* grow buffer if necessary */
- error = T1_Add_Points( builder, 1 );
- if ( error )
- return error;
-
- if ( builder->load_points )
- {
- /* save point */
- vec.x = builder->last.x + dx;
- vec.y = builder->last.y + dy;
-
- cur->points[cur->n_points] = vec;
- cur->tags [cur->n_points] = FT_Curve_Tag_On;
-
- builder->last = vec;
- }
- cur->n_points++;
-
- builder->path_begun = 1;
-
- return T1_Err_Ok;
- }
-
-
- static
- FT_Error gload_rmoveto( T1_Builder* builder,
- FT_Pos dx,
- FT_Pos dy )
- {
- FT_Error error;
- FT_Outline* cur = builder->current;
- FT_Vector vec;
-
-
- /* in the case where `path_begun' is set, we have an `rmoveto' */
- /* after some normal path definition. If the face's paint type */
- /* is set to 1, this means that we have an `open path', also */
- /* called a `stroke'. The FreeType raster doesn't support */
- /* opened paths, so we'll close it explicitely there. */
-
- if ( builder->path_begun && builder->face->type1.paint_type == 1 )
- {
- if ( builder->face->type1.paint_type == 1 )
- {
- error = close_open_path( builder );
- if ( error )
- return error;
- }
- }
-
- /* grow buffer if necessary */
- error = T1_Add_Contours( builder, 1 ) ||
- T1_Add_Points ( builder, 1 );
- if ( error )
- return error;
-
- /* save current contour, if any */
- if ( cur->n_contours > 0 )
- cur->contours[cur->n_contours - 1] = cur->n_points - 1;
-
- if ( builder->load_points )
- {
- /* save point */
- vec.x = builder->last.x + dx;
- vec.y = builder->last.y + dy;
- cur->points[cur->n_points] = vec;
- cur->tags [cur->n_points] = FT_Curve_Tag_On;
-
- builder->last = vec;
- }
-
- cur->n_contours++;
- cur->n_points++;
-
- return T1_Err_Ok;
- }
-
-
- static
- FT_Error gload_rrcurveto( T1_Builder* builder,
- FT_Pos dx1,
- FT_Pos dy1,
- FT_Pos dx2,
- FT_Pos dy2,
- FT_Pos dx3,
- FT_Pos dy3 )
- {
- FT_Error error;
- FT_Outline* cur = builder->current;
- FT_Vector vec;
- FT_Vector* points;
- char* tags;
-
-
- /* grow buffer if necessary */
- error = T1_Add_Points( builder, 3 );
- if ( error )
- return error;
-
- if ( builder->load_points )
- {
- /* save point */
- points = cur->points + cur->n_points;
- tags = cur->tags + cur->n_points;
-
- vec.x = builder->last.x + dx1;
- vec.y = builder->last.y + dy1;
- points[0] = vec;
- tags[0] = FT_Curve_Tag_Cubic;
-
- vec.x += dx2;
- vec.y += dy2;
- points[1] = vec;
- tags[1] = FT_Curve_Tag_Cubic;
-
- vec.x += dx3;
- vec.y += dy3;
- points[2] = vec;
- tags[2] = FT_Curve_Tag_On;
-
- builder->last = vec;
- }
-
- cur->n_points += 3;
- builder->path_begun = 1;
-
- return T1_Err_Ok;
- }
-
-
- static
- FT_Error gload_ignore( void )
- {
- return 0;
- }
-
-
- static
- const T1_Builder_Funcs gload_builder_interface =
- {
- gload_endchar,
- gload_sbw,
- gload_closepath,
- gload_rlineto,
- gload_rmoveto,
- gload_rrcurveto
- };
-
-
- static
- const T1_Builder_Funcs gload_builder_interface_null =
- {
- (T1_Builder_EndChar) gload_ignore,
- (T1_Builder_Sbw) gload_sbw, /* record left bearing */
- (T1_Builder_ClosePath)gload_ignore,
- (T1_Builder_RLineTo) gload_ignore,
- (T1_Builder_RMoveTo) gload_ignore,
- (T1_Builder_RCurveTo) gload_ignore
- };
-
-
- static
- const T1_Hinter_Funcs gload_hinter_interface =
- {
- (T1_Hinter_DotSection) gload_ignore, /* dotsection */
- (T1_Hinter_ChangeHints)gload_ignore, /* changehints */
- (T1_Hinter_Stem) gload_ignore, /* hstem & vstem */
- (T1_Hinter_Stem3) gload_ignore, /* hstem3 & vestem3 */
- };
-
-
-#ifndef T1_CONFIG_OPTION_DISABLE_HINTER
-
-
- /*************************************************************************/
- /* */
- /* Hinter overview: */
- /* */
- /* This is a two-pass hinter. On the first pass, the hints are all */
- /* recorded by the hinter, and no point is loaded in the outline. */
- /* */
- /* When the first pass is finished, all stems hints are grid-fitted */
- /* at once. */
- /* */
- /* Then, a second pass is performed to load the outline points as */
- /* well as hint/scale them correctly. */
- /* */
- /*************************************************************************/
-
-
- static
- FT_Error t1_load_hinted_glyph( T1_Decoder* decoder,
- FT_UInt glyph_index,
- FT_Bool recurse )
- {
- T1_Builder* builder = &decoder->builder;
- T1_GlyphSlot glyph = builder->glyph;
- T1_Font* type1 = &builder->face->type1;
- FT_UInt old_points, old_contours;
- FT_GlyphLoader* loader = decoder->builder.loader;
- FT_Error error;
-
-
- /* Pass 1 -- try to load first glyph, simply recording points */
- old_points = loader->base.outline.n_points;
- old_contours = loader->base.outline.n_contours;
-
- FT_GlyphLoader_Prepare( decoder->builder.loader );
-
- T1_Reset_Builder( builder, 0 );
-
- builder->no_recurse = recurse;
- builder->pass = 0;
- glyph->hints->hori_stems.num_stems = 0;
- glyph->hints->vert_stems.num_stems = 0;
-
- error = T1_Parse_CharStrings( decoder,
- type1->charstrings [glyph_index],
- type1->charstrings_len[glyph_index],
- type1->num_subrs,
- type1->subrs,
- type1->subrs_len );
- if ( error )
- goto Exit;
-
- /* check for composite (i.e. `seac' operator) */
- if ( glyph->root.format == ft_glyph_format_composite )
- {
- /* this is a composite glyph, we must then load the first one, */
- /* then load the second one on top of it and translate it by a */
- /* fixed amount. */
- FT_UInt n_base_points;
- FT_SubGlyph* subglyph = loader->base.subglyphs;
- T1_Size size = builder->size;
- FT_Pos dx, dy;
- FT_Vector left_bearing, advance;
-
-
- /* clean glyph format */
- glyph->root.format = ft_glyph_format_none;
-
- /* First load `bchar' in builder */
- builder->no_recurse = 0;
- error = t1_load_hinted_glyph( decoder, subglyph->index, 0 );
- if ( error )
- goto Exit;
-
- /* save the left bearing and width of the base character */
- /* as they will be erased by the next load */
- left_bearing = builder->left_bearing;
- advance = builder->advance;
-
- /* Then load `achar' in builder */
- n_base_points = builder->base->n_points;
- subglyph++;
- error = t1_load_hinted_glyph( decoder, subglyph->index, 0 );
- if ( error )
- goto Exit;
-
- /* Finally, move the accent */
- dx = FT_MulFix( subglyph->arg1, size->root.metrics.x_scale );
- dy = FT_MulFix( subglyph->arg2, size->root.metrics.y_scale );
- dx = ( dx + 32 ) & -64;
- dy = ( dy + 32 ) & -64;
- {
- FT_Outline dummy;
-
-
- dummy.n_points = loader->base.outline.n_points - n_base_points;
- dummy.points = loader->base.outline.points + n_base_points;
-
- FT_Outline_Translate( &dummy, dx, dy );
- }
-
- /* restore the left side bearing and */
- /* advance width of the base character */
- builder->left_bearing = left_bearing;
- builder->advance = advance;
- }
- else
- {
- /* All right, pass 1 is finished, now grid-fit all stem hints */
- T1_Hint_Stems( &decoder->builder );
-
- /* undo the end-char */
- builder->base->n_points = old_points;
- builder->base->n_contours = old_contours;
-
- /* Pass 2 -- record and scale/hint the points */
- T1_Reset_Builder( builder, 0 );
-
- builder->pass = 1;
- builder->no_recurse = 0;
-
- error = T1_Parse_CharStrings( decoder,
- type1->charstrings [glyph_index],
- type1->charstrings_len[glyph_index],
- type1->num_subrs,
- type1->subrs,
- type1->subrs_len );
- }
-
- /* save new glyph tables */
- if ( recurse )
- T1_Done_Builder( builder );
-
- Exit:
- return error;
- }
-
-
-#endif /* !T1_CONFIG_OPTION_DISABLE_HINTER */
-
-
- LOCAL_FUNC
- FT_Error T1_Load_Glyph( T1_GlyphSlot glyph,
- T1_Size size,
- FT_Int glyph_index,
- FT_Int load_flags )
- {
- FT_Error error;
- T1_Decoder decoder;
- T1_Face face = (T1_Face)glyph->root.face;
- FT_Bool hinting;
- T1_Font* type1 = &face->type1;
-
-
- if ( load_flags & FT_LOAD_NO_RECURSE )
- load_flags |= FT_LOAD_NO_SCALE | FT_LOAD_NO_HINTING;
-
- glyph->x_scale = size->root.metrics.x_scale;
- glyph->y_scale = size->root.metrics.y_scale;
-
- glyph->root.outline.n_points = 0;
- glyph->root.outline.n_contours = 0;
-
- glyph->root.format = ft_glyph_format_outline; /* by default */
-
- hinting = 0;
-
-#ifndef T1_CONFIG_OPTION_DISABLE_HINTER
-
- hinting = ( load_flags & ( FT_LOAD_NO_SCALE | FT_LOAD_NO_HINTING ) ) == 0;
-
- if ( hinting )
- {
- T1_Init_Decoder( &decoder, &t1_hinter_funcs );
- T1_Init_Builder( &decoder.builder, face, size, glyph,
- &gload_builder_interface );
-
- error = t1_load_hinted_glyph( &decoder, glyph_index, 1 );
- }
- else
-
-#endif /* !T1_CONFIG_OPTION_DISABLE_HINTER */
-
- {
- T1_Init_Decoder( &decoder, &gload_hinter_interface );
-
- T1_Init_Builder( &decoder.builder, face, size, glyph,
- &gload_builder_interface );
-
- decoder.builder.no_recurse = ( load_flags & FT_LOAD_NO_RECURSE ) != 0;
-
- /* now load the unscaled outline */
- error = T1_Parse_CharStrings( &decoder,
- type1->charstrings [glyph_index],
- type1->charstrings_len[glyph_index],
- type1->num_subrs,
- type1->subrs,
- type1->subrs_len );
-
- /* save new glyph tables */
- T1_Done_Builder( &decoder.builder );
- }
-
- /* Now, set the metrics -- this is rather simple, as */
- /* the left side bearing is the xMin, and the top side */
- /* bearing the yMax */
- if ( !error )
- {
- /* for composite glyphs, return only the left side bearing and the */
- /* advance width */
- if ( glyph->root.format == ft_glyph_format_composite )
- {
- glyph->root.metrics.horiBearingX = decoder.builder.left_bearing.x;
- glyph->root.metrics.horiAdvance = decoder.builder.advance.x;
- }
- else
- {
- FT_BBox cbox;
- FT_Glyph_Metrics* metrics = &glyph->root.metrics;
-
-
- /* apply the font matrix */
- FT_Outline_Transform( &glyph->root.outline,
- &face->type1.font_matrix );
-
- FT_Outline_Get_CBox( &glyph->root.outline, &cbox );
-
- /* grid fit the bounding box if necessary */
- if ( hinting )
- {
- cbox.xMin &= -64;
- cbox.yMin &= -64;
- cbox.xMax = ( cbox.xMax + 63 ) & -64;
- cbox.yMax = ( cbox.yMax + 63 ) & -64;
- }
-
- metrics->width = cbox.xMax - cbox.xMin;
- metrics->height = cbox.yMax - cbox.yMin;
-
- metrics->horiBearingX = cbox.xMin;
- metrics->horiBearingY = cbox.yMax;
-
- /* copy the _unscaled_ advance width */
- metrics->horiAdvance = decoder.builder.advance.x;
-
- /* make up vertical metrics */
- metrics->vertBearingX = 0;
- metrics->vertBearingY = 0;
- metrics->vertAdvance = 0;
-
- glyph->root.format = ft_glyph_format_outline;
-
- glyph->root.outline.flags = 0;
-
- if ( size->root.metrics.y_ppem < 24 )
- glyph->root.outline.flags |= ft_outline_high_precision;
-
- glyph->root.outline.flags |= ft_outline_reverse_fill;
-
- if ( hinting )
- {
- /* adjust the advance width */
- /* XXX TODO: consider stem hints grid-fit */
- metrics->horiAdvance = FT_MulFix( metrics->horiAdvance,
- glyph->x_scale );
- }
- else if ( ( load_flags & FT_LOAD_NO_SCALE ) == 0 )
- {
- /* scale the outline and the metrics */
- FT_Int n;
- FT_Outline* cur = decoder.builder.base;
- FT_Vector* vec = cur->points;
- FT_Fixed x_scale = glyph->x_scale;
- FT_Fixed y_scale = glyph->y_scale;
-
-
- /* First of all, scale the points */
- for ( n = cur->n_points; n > 0; n--, vec++ )
- {
- vec->x = FT_MulFix( vec->x, x_scale );
- vec->y = FT_MulFix( vec->y, y_scale );
- }
-
- /* Then scale the metrics */
- metrics->width = FT_MulFix( metrics->width, x_scale );
- metrics->height = FT_MulFix( metrics->height, y_scale );
-
- metrics->horiBearingX = FT_MulFix( metrics->horiBearingX, x_scale );
- metrics->horiBearingY = FT_MulFix( metrics->horiBearingY, y_scale );
-
- metrics->vertBearingX = FT_MulFix( metrics->vertBearingX, x_scale );
- metrics->vertBearingY = FT_MulFix( metrics->vertBearingY, y_scale );
-
- metrics->horiAdvance = FT_MulFix( metrics->horiAdvance, x_scale );
- metrics->vertAdvance = FT_MulFix( metrics->vertAdvance, y_scale );
- }
- }
- }
-
- return error;
- }
-
-
-/* END */
diff --git a/src/type1/t1gload.h b/src/type1/t1gload.h
deleted file mode 100644
index 658a929..0000000
--- a/src/type1/t1gload.h
+++ /dev/null
@@ -1,326 +0,0 @@
-/***************************************************************************/
-/* */
-/* t1gload.h */
-/* */
-/* Type 1 Glyph Loader (specification). */
-/* */
-/* Copyright 1996-2000 by */
-/* David Turner, Robert Wilhelm, and Werner Lemberg. */
-/* */
-/* This file is part of the FreeType project, and may only be used, */
-/* modified, and distributed under the terms of the FreeType project */
-/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
-/* this file you indicate that you have read the license and */
-/* understand and accept it fully. */
-/* */
-/***************************************************************************/
-
-
-#ifndef T1GLOAD_H
-#define T1GLOAD_H
-
-
-#ifdef FT_FLAT_COMPILE
-
-#include "t1objs.h"
-
-#else
-
-#include <type1/t1objs.h>
-
-#endif
-
-
-#ifdef __cplusplus
- extern "C" {
-#endif
-
-
- typedef struct T1_Builder_ T1_Builder;
-
- typedef FT_Error (*T1_Builder_EndChar)( T1_Builder* loader );
-
- typedef FT_Error (*T1_Builder_Sbw)( T1_Builder* loader,
- FT_Pos sbx,
- FT_Pos sby,
- FT_Pos wx,
- FT_Pos wy );
-
- typedef FT_Error (*T1_Builder_ClosePath)( T1_Builder* loader );
-
- typedef FT_Error (*T1_Builder_RLineTo)( T1_Builder* loader,
- FT_Pos dx,
- FT_Pos dy );
-
- typedef FT_Error (*T1_Builder_RMoveTo)( T1_Builder* loader,
- FT_Pos dx,
- FT_Pos dy );
-
- typedef FT_Error (*T1_Builder_RCurveTo)( T1_Builder* loader,
- FT_Pos dx1,
- FT_Pos dy1,
- FT_Pos dx2,
- FT_Pos dy2,
- FT_Pos dx3,
- FT_Pos dy3 );
-
-
- /*************************************************************************/
- /* */
- /* <Structure> */
- /* T1_Builder_Funcs */
- /* */
- /* <Description> */
- /* A structure to store the address of various functions used by a */
- /* glyph builder to implement the outline's `path construction'. */
- /* */
- typedef struct T1_Builder_Funcs_
- {
- T1_Builder_EndChar end_char;
- T1_Builder_Sbw set_bearing_point;
- T1_Builder_ClosePath close_path;
- T1_Builder_RLineTo rline_to;
- T1_Builder_RMoveTo rmove_to;
- T1_Builder_RCurveTo rcurve_to;
-
- } T1_Builder_Funcs;
-
-
- /*************************************************************************/
- /* */
- /* <Structure> */
- /* T1_Builder */
- /* */
- /* <Description> */
- /* A structure used during glyph loading to store its outline. */
- /* */
- /* <Fields> */
- /* memory :: The current memory object. */
- /* */
- /* face :: The current face object. */
- /* */
- /* size :: The current size object. */
- /* */
- /* glyph :: The current glyph slot. */
- /* */
- /* loader :: The current glyph loader. */
- /* */
- /* current :: The current glyph outline. */
- /* */
- /* base :: The base glyph outline. */
- /* */
- /* last :: The last point position. */
- /* */
- /* scale_x :: The horizontal scale (FUnits to sub-pixels). */
- /* */
- /* scale_y :: The vertical scale (FUnits to sub-pixels). */
- /* */
- /* pos_x :: The horizontal translation (for composite glyphs). */
- /* */
- /* pos_y :: The vertical translation (for composite glyphs). */
- /* */
- /* left_bearing :: The left side bearing point. */
- /* */
- /* advance :: The horizontal advance vector. */
- /* */
- /* no_recurse :: */
- /* */
- /* bbox :: The glyph's bounding box. */
- /* */
- /* path_begun :: A flag which indicates that a new path has begun. */
- /* */
- /* load_points :: A flag which indicates, if not set, that no points */
- /* are loaded. */
- /* */
- /* pass :: The pass number for multi-pass hinters. */
- /* */
- /* hint_point :: The index of the next point to hint. */
- /* */
- /* funcs :: A table of builder functions used to perform the */
- /* outline's path construction. */
- /* */
- struct T1_Builder_
- {
- FT_Memory memory;
- T1_Face face;
- T1_Size size;
- T1_GlyphSlot glyph;
- FT_GlyphLoader* loader;
-
- FT_Outline* current; /* the current glyph outline */
- FT_Outline* base; /* the composite glyph outline */
-
- FT_Vector last;
-
- FT_Fixed scale_x;
- FT_Fixed scale_y;
-
- FT_Pos pos_x;
- FT_Pos pos_y;
-
- FT_Vector left_bearing;
- FT_Vector advance;
- FT_Bool no_recurse;
-
- FT_BBox bbox; /* bounding box */
- FT_Bool path_begun;
- FT_Bool load_points;
-
- FT_Int pass;
- FT_Int hint_point;
-
- /* path construction function interface */
- T1_Builder_Funcs funcs;
- };
-
-
- typedef FT_Error (*T1_Hinter_ChangeHints)( T1_Builder* builder );
-
- typedef FT_Error (*T1_Hinter_DotSection)( T1_Builder* builder );
-
- typedef FT_Error (*T1_Hinter_Stem)( T1_Builder* builder,
- FT_Pos pos,
- FT_Pos width,
- FT_Bool vertical );
-
- typedef FT_Error (*T1_Hinter_Stem3)( T1_Builder* builder,
- FT_Pos pos0,
- FT_Pos width0,
- FT_Pos pos1,
- FT_Pos width1,
- FT_Pos pos2,
- FT_Pos width2,
- FT_Bool vertical );
-
-
- /*************************************************************************/
- /* */
- /* <Structure> */
- /* T1_Hinter_Funcs */
- /* */
- /* <Description> */
- /* A structure to store the address of various functions used by a */
- /* Type 1 hinter to perform outline hinting. */
- /* */
- typedef struct T1_Hinter_Func_
- {
- T1_Hinter_ChangeHints change_hints;
- T1_Hinter_DotSection dot_section;
- T1_Hinter_Stem stem;
- T1_Hinter_Stem3 stem3;
-
- } T1_Hinter_Funcs;
-
-
- typedef enum T1_Operator_
- {
- op_none = 0,
- op_endchar,
- op_hsbw,
- op_seac,
- op_sbw,
- op_closepath,
- op_hlineto,
- op_hmoveto,
- op_hvcurveto,
- op_rlineto,
- op_rmoveto,
- op_rrcurveto,
- op_vhcurveto,
- op_vlineto,
- op_vmoveto,
- op_dotsection,
- op_hstem,
- op_hstem3,
- op_vstem,
- op_vstem3,
- op_div,
- op_callothersubr,
- op_callsubr,
- op_pop,
- op_return,
- op_setcurrentpoint,
-
- op_max /* never remove this one */
-
- } T1_Operator;
-
-
- /* execution context charstring zone */
- typedef struct T1_Decoder_Zone_
- {
- FT_Byte* base;
- FT_Byte* limit;
- FT_Byte* cursor;
-
- } T1_Decoder_Zone;
-
-
- typedef struct T1_Decoder_
- {
- T1_Builder builder;
- T1_Hinter_Funcs hinter;
-
- FT_Int stack[T1_MAX_CHARSTRINGS_OPERANDS];
- FT_Int* top;
-
- T1_Decoder_Zone zones[T1_MAX_SUBRS_CALLS + 1];
- T1_Decoder_Zone* zone;
-
- FT_Int flex_state;
- FT_Int num_flex_vectors;
- FT_Vector flex_vectors[7];
-
- } T1_Decoder;
-
-
- LOCAL_DEF
- void T1_Init_Builder( T1_Builder* builder,
- T1_Face face,
- T1_Size size,
- T1_GlyphSlot glyph,
- const T1_Builder_Funcs* funcs );
-
- LOCAL_DEF
- void T1_Done_Builder( T1_Builder* builder );
-
- LOCAL_DEF
- void T1_Init_Decoder( T1_Decoder* decoder,
- const T1_Hinter_Funcs* funcs );
-
- LOCAL_DEF
- FT_Error T1_Compute_Max_Advance( T1_Face face,
- FT_Int* max_advance );
-
- LOCAL_DEF
- FT_Error T1_Parse_CharStrings( T1_Decoder* decoder,
- FT_Byte* charstring_base,
- FT_Int charstring_len,
- FT_Int num_subrs,
- FT_Byte** subrs_base,
- FT_Int* subrs_len );
-
- LOCAL_DEF
- FT_Error T1_Add_Points( T1_Builder* builder,
- FT_Int num_points );
-
- LOCAL_DEF
- FT_Error T1_Add_Contours( T1_Builder* builder,
- FT_Int num_contours );
-
- LOCAL_DEF
- FT_Error T1_Load_Glyph( T1_GlyphSlot glyph,
- T1_Size size,
- FT_Int glyph_index,
- FT_Int load_flags );
-
-
-#ifdef __cplusplus
- }
-#endif
-
-
-#endif /* T1GLOAD_H */
-
-
-/* END */
diff --git a/src/type1/t1hinter.c b/src/type1/t1hinter.c
deleted file mode 100644
index 7ce7462..0000000
--- a/src/type1/t1hinter.c
+++ /dev/null
@@ -1,1347 +0,0 @@
-/***************************************************************************/
-/* */
-/* t1hinter.c */
-/* */
-/* Type 1 hinter (body). */
-/* */
-/* Copyright 1996-2000 by */
-/* David Turner, Robert Wilhelm, and Werner Lemberg. */
-/* */
-/* This file is part of the FreeType project, and may only be used, */
-/* modified, and distributed under the terms of the FreeType project */
-/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
-/* this file you indicate that you have read the license and */
-/* understand and accept it fully. */
-/* */
-/***************************************************************************/
-
-
- /*************************************************************************/
- /* */
- /* The Hinter is in charge of fitting th scaled outline to the pixel */
- /* grid in order to considerably improve the quality of the Type 1 font */
- /* driver's output. */
- /* */
- /*************************************************************************/
-
-
-#include <freetype/internal/ftdebug.h>
-
-
-#ifdef FT_FLAT_COMPILE
-
-#include "t1objs.h"
-#include "t1hinter.h"
-
-#else
-
-#include <type1/t1objs.h>
-#include <type1/t1hinter.h>
-
-#endif
-
-
- /*************************************************************************/
- /* */
- /* The macro FT_COMPONENT is used in trace mode. It is an implicit */
- /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */
- /* messages during execution. */
- /* */
-#undef FT_COMPONENT
-#define FT_COMPONENT trace_t1hint
-
-
-#undef ONE_PIXEL
-#define ONE_PIXEL 64
-
-#undef ROUND
-#define ROUND( x ) ( ( x + ONE_PIXEL / 2 ) & -ONE_PIXEL )
-
-#undef SCALE
-#define SCALE( val ) FT_MulFix( val, scale )
-
-/* various constants used to describe the alignment of a horizontal */
-/* stem with regards to the blue zones */
-
-#define T1_ALIGN_NONE 0
-#define T1_ALIGN_BOTTOM 1
-#define T1_ALIGN_TOP 2
-#define T1_ALIGN_BOTH 3
-
-
- /* very simple bubble sort (not a lot of elements, mostly */
- /* pre-sorted, no need for quicksort) */
-
- static
- void t1_sort_blues( FT_Int* blues,
- FT_Int count )
- {
- FT_Int i, swap;
- FT_Int* cur;
-
-
- for ( i = 2; i < count; i += 2 )
- {
- cur = blues + i;
- do
- {
- if ( cur[-1] < cur[0] )
- break;
-
- swap = cur[-2]; cur[-2] = cur[0]; cur[0] = swap;
- swap = cur[-1]; cur[-1] = cur[1]; cur[1] = swap;
- cur -= 2;
-
- } while ( cur > blues );
- }
- }
-
-
- /*************************************************************************/
- /* */
- /* <Function> */
- /* t1_set_blue_zones */
- /* */
- /* <Description> */
- /* Sets a size object's blue zones during reset. This will compute */
- /* the `snap' zone corresponding to each blue zone. */
- /* */
- /* <InOut> */
- /* size :: A handle to target size object. */
- /* */
- /* <Return> */
- /* FreeType error code. 0 means success. */
- /* */
- /* <Note> */
- /* This functions does the following: */
- /* */
- /* 1. It extracts the bottom and top blue zones from the face object. */
- /* */
- /* 2. Each zone is then grown by `BlueFuzz', overlapping is */
- /* eliminated by adjusting the zone edges appropriately. */
- /* */
- /* 3. For each zone, we keep its original font units position, its */
- /* original scaled position, as well as its grown/adjusted edges. */
- /* */
- static
- FT_Error t1_set_blue_zones( T1_Size size )
- {
- T1_Face face = (T1_Face)size->root.face;
- T1_Private* priv = &face->type1.private_dict;
- FT_Int n;
- FT_Int blues[24];
- FT_Int num_bottom;
- FT_Int num_top;
- FT_Int num_blues;
- T1_Size_Hints* hints = size->hints;
- T1_Snap_Zone* zone;
- FT_Pos pix, orus;
- FT_Pos min, max, threshold;
- FT_Fixed scale;
- FT_Bool is_bottom;
-
-
- /***********************************************************************/
- /* */
- /* copy bottom and top blue zones in local arrays */
- /* */
-
- /* First of all, check the sizes of the /BlueValues and /OtherBlues */
- /* tables. They all must contain an even number of arguments. */
- if ( priv->num_other_blues & 1 ||
- priv->num_blue_values & 1 )
- {
- FT_ERROR(( "t1_set_blue_zones: odd number of blue values\n" ));
- return T1_Err_Syntax_Error;
- }
-
- /* copy the bottom blue zones from /OtherBlues */
- num_top = 0;
- num_bottom = priv->num_other_blues;
-
- for ( n = 0; n < num_bottom; n++ )
- blues[n] = priv->other_blues[n];
-
- /* add the first blue zone in /BlueValues to the table */
- num_top = priv->num_blue_values - 2;
- if ( num_top >= 0 )
- {
- blues[num_bottom ] = priv->blue_values[0];
- blues[num_bottom + 1] = priv->blue_values[1];
-
- num_bottom += 2;
- }
-
- /* sort the bottom blue zones */
- t1_sort_blues( blues, num_bottom );
-
- hints->num_bottom_zones = num_bottom >> 1;
-
- /* now copy the /BlueValues to the top of the blues array */
- if ( num_top > 0 )
- {
- for ( n = 0; n < num_top; n++ )
- blues[num_bottom + n] = priv->blue_values[n + 2];
-
- /* sort the top blue zones */
- t1_sort_blues( blues + num_bottom, num_top );
- }
- else
- num_top = 0;
-
- num_blues = num_top + num_bottom;
- hints->num_blue_zones = ( num_blues ) >> 1;
-
- /***********************************************************************/
- /* */
- /* build blue snap zones from the local blues arrays */
- /* */
-
- scale = size->root.metrics.y_scale;
- zone = hints->blue_zones;
- threshold = ONE_PIXEL / 4; /* 0.25 pixels */
-
- for ( n = 0; n < num_blues; n += 2, zone++ )
- {
- is_bottom = n < num_bottom ? 1 : 0;
-
- orus = blues[n + is_bottom]; /* get alignement coordinate */
- pix = SCALE( orus ); /* scale it */
-
- min = SCALE( blues[n ] - priv->blue_fuzz );
- max = SCALE( blues[n + 1] + priv->blue_fuzz );
-
- if ( min > pix - threshold )
- min = pix - threshold;
- if ( max < pix + threshold )
- max = pix + threshold;
-
- zone->orus = orus;
- zone->pix = pix;
- zone->min = min;
- zone->max = max;
- }
-
- /* adjust edges in case of overlap */
- zone = hints->blue_zones;
- for ( n = 0; n < num_blues - 2; n += 2, zone++ )
- {
- if ( n != num_bottom - 2 &&
- zone[0].max > zone[1].min )
- zone[0].max = zone[1].min = ( zone[0].pix + zone[1].pix ) / 2;
- }
-
- /* compare the current pixel size with the BlueScale value */
- /* to know whether to supress overshoots */
-
- hints->supress_overshoots =
- size->root.metrics.y_ppem < FT_MulFix( 1000, priv->blue_scale );
-
-#ifdef FT_DEBUG_LEVEL_TRACE
-
- /* now print the new blue values in tracing mode */
-
- FT_TRACE2(( "Blue Zones for size object at $%08lx:\n", (long)size ));
- FT_TRACE2(( " orus pix min max\n" ));
- FT_TRACE2(( "-------------------------------\n" ));
-
- zone = hints->blue_zones;
- for ( n = 0; n < hints->num_blue_zones; n++ )
- {
- FT_TRACE2(( " %3d %.2f %.2f %.2f\n",
- zone->orus,
- zone->pix / 64.0,
- zone->min / 64.0,
- zone->max / 64.0 ));
- zone++;
- }
- FT_TRACE2(( "\nOvershoots are %s\n\n",
- hints->supress_overshoots ? "supressed" : "active" ));
-
-#endif /* DEBUG_LEVEL_TRACE */
-
- return T1_Err_Ok;
- }
-
-
- /*************************************************************************/
- /* */
- /* <Function> */
- /* t1_set_snap_zones */
- /* */
- /* <Description> */
- /* This function set a size object's stem snap zones. */
- /* */
- /* <InOut> */
- /* size :: A handle to the target size object. */
- /* */
- /* <Return> */
- /* FreeType error code. 0 means success. */
- /* */
- /* <Note> */
- /* This function performs the following: */
- /* */
- /* 1. It reads and scales the stem snap widths from the parent face. */
- /* */
- /* 2. A `snap zone' is computed for each snap width, by `growing' it */
- /* with a threshold of 1/2 pixel. Overlapping is avoided through */
- /* proper edge adjustment. */
- /* */
- /* 3. Each width whose zone contain the scaled standard set width is */
- /* removed from the table. */
- /* */
- /* 4. Finally, the standard set width is scaled, and its correponding */
- /* `snap zone' is inserted into the sorted snap zones table. */
- /* */
- static
- FT_Error t1_set_snap_zones( T1_Size size )
- {
- FT_Int n, direction, n_zones, num_zones;
- T1_Snap_Zone* zone;
- T1_Snap_Zone* base_zone;
- FT_Short* orgs;
- FT_Pos standard_width;
- FT_Fixed scale;
-
- T1_Face face = (T1_Face)size->root.face;
- T1_Private* priv = &face->type1.private_dict;
- T1_Size_Hints* hints = size->hints;
-
-
- /* start with horizontal snap zones */
- direction = 0;
- standard_width = priv->standard_width[0];
- n_zones = priv->num_snap_widths;
- base_zone = hints->snap_widths;
- orgs = priv->snap_widths;
- scale = size->root.metrics.x_scale;
-
- while ( direction < 2 )
- {
- /*********************************************************************/
- /* */
- /* Read and scale stem snap widths table from the physical font */
- /* record. */
- /* */
-
- FT_Pos prev, orus, pix, min, max, threshold;
-
-
- threshold = ONE_PIXEL / 4;
- zone = base_zone;
-
- if ( n_zones > 0 )
- {
- orus = *orgs++;
- pix = SCALE( orus );
- min = pix - threshold;
- max = pix + threshold;
-
- zone->orus = orus;
- zone->pix = pix;
- zone->min = min;
- prev = pix;
-
- for ( n = 1; n < n_zones; n++ )
- {
- orus = *orgs++;
- pix = SCALE( orus );
-
- if ( pix - prev < 2 * threshold )
- {
- min = max = ( pix + prev ) / 2;
- }
- else
- min = pix - threshold;
-
- zone->max = max;
- zone++;
- zone->orus = orus;
- zone->pix = pix;
- zone->min = min;
-
- max = pix + threshold;
- prev = pix;
- }
- zone->max = max;
- }
-
-#ifdef FT_DEBUG_LEVEL_TRACE
-
- /* print the scaled stem snap values in tracing mode */
-
- FT_TRACE2(( "Set_Snap_Zones: first %s pass\n",
- direction ? "vertical" : "horizontal" ));
-
- FT_TRACE2(( "Scaled original stem snap zones:\n" ));
- FT_TRACE2(( " orus pix min max\n" ));
- FT_TRACE2(( "-----------------------------\n" ));
-
- zone = base_zone;
- for ( n = 0; n < n_zones; n++, zone++ )
- FT_TRACE2(( " %3d %.2f %.2f %.2f\n",
- zone->orus,
- zone->pix / 64.0,
- zone->min / 64.0,
- zone->max / 64.0 ));
- FT_TRACE2(( "\n" ));
-
- FT_TRACE2(( "Standard width = %d\n", standard_width ));
-
-#endif /* FT_DEBUG_LEVEL_TRACE */
-
- /*********************************************************************/
- /* */
- /* Now, each snap width which is in the range of the standard set */
- /* width will be removed from the list. */
- /* */
-
- if ( standard_width > 0 )
- {
- T1_Snap_Zone* parent;
- FT_Pos std_pix, std_min, std_max;
-
-
- std_pix = SCALE( standard_width );
-
- std_min = std_pix - threshold;
- std_max = std_pix + threshold;
-
- num_zones = 0;
- zone = base_zone;
- parent = base_zone;
-
- for ( n = 0; n < n_zones; n++ )
- {
- if ( zone->pix >= std_min && zone->pix <= std_max )
- {
- /* this zone must be removed from the list */
- if ( std_min > zone->min )
- std_min = zone->min;
- if ( std_max < zone->max )
- std_max = zone->max;
- }
- else
- {
- *parent++ = *zone;
- num_zones++;
- }
- zone++;
- }
-
- /*******************************************************************/
- /* */
- /* Now, insert the standard width zone */
- /* */
-
- zone = base_zone + num_zones;
- while ( zone > base_zone && zone[-1].pix > std_max )
- {
- zone[0] = zone[-1];
- zone--;
- }
-
- /* check border zones */
- if ( zone > base_zone && zone[-1].max > std_min )
- zone[-1].max = std_min;
-
- if ( zone < base_zone + num_zones && zone[1].min < std_max )
- zone[1].min = std_max;
-
- zone->orus = standard_width;
- zone->pix = std_pix;
- zone->min = std_min;
- zone->max = std_max;
-
- num_zones++;
- }
- else
- num_zones = n_zones;
-
- /* save total number of stem snaps now */
- if ( direction )
- hints->num_snap_heights = num_zones;
- else
- hints->num_snap_widths = num_zones;
-
-#ifdef FT_DEBUG_LEVEL_TRACE
-
- /* print the scaled stem snap values in tracing mode */
-
- FT_TRACE2(( "Set_Snap_Zones: second %s pass\n",
- direction ? "vertical" : "horizontal" ));
-
- FT_TRACE2(( "Scaled clipped stem snap zones:\n" ));
- FT_TRACE2(( " orus pix min max\n" ));
- FT_TRACE2(( "-----------------------------\n" ));
-
- zone = base_zone;
- for ( n = 0; n < num_zones; n++, zone++ )
- FT_TRACE2(( " %3d %.2f %.2f %.2f\n",
- zone->orus,
- zone->pix / 64.0,
- zone->min / 64.0,
- zone->max / 64.0 ));
- FT_TRACE2(( "\n" ));
-
- FT_TRACE2(( "Standard width = %d\n", standard_width ));
-
-#endif /* FT_DEBUG_LEVEL_TRACE */
-
- /* continue with vertical snap zone */
- direction++;
- standard_width = priv->standard_height[0];
- n_zones = priv->num_snap_heights;
- base_zone = hints->snap_heights;
- orgs = priv->snap_heights;
- scale = size->root.metrics.y_scale;
- }
-
- return T1_Err_Ok;
- }
-
-
- /*************************************************************************/
- /* */
- /* <Function> */
- /* T1_New_Size_Hinter */
- /* */
- /* <Description> */
- /* Allocates a new hinter structure for a given size object. */
- /* */
- /* <InOut> */
- /* size :: A handle to the target size object. */
- /* */
- /* <Return> */
- /* FreeType Error code. 0 means success. */
- /* */
- LOCAL_FUNC
- FT_Error T1_New_Size_Hinter( T1_Size size )
- {
- FT_Memory memory = size->root.face->memory;
-
-
- return MEM_Alloc( size->hints, sizeof ( *size->hints ) );
- }
-
-
- /*************************************************************************/
- /* */
- /* <Function> */
- /* T1_Done_Size_Hinter */
- /* */
- /* <Description> */
- /* Releases a given size object's hinter structure. */
- /* */
- /* <Input> */
- /* size :: A handle to the target size object. */
- /* */
- LOCAL_FUNC
- void T1_Done_Size_Hinter( T1_Size size )
- {
- FT_Memory memory = size->root.face->memory;
-
-
- FREE( size->hints );
- }
-
-
- /*************************************************************************/
- /* */
- /* <Function> */
- /* T1_Reset_Size_Hinter */
- /* */
- /* <Description> */
- /* Recomputes hinting information when a given size object has */
- /* changed its resolutions/char sizes/pixel sizes. */
- /* */
- /* <InOut> */
- /* size :: A handle to the size object. */
- /* */
- /* <Return> */
- /* FreeType error code. 0 means success. */
- /* */
- LOCAL_FUNC
- FT_Error T1_Reset_Size_Hinter( T1_Size size )
- {
- return t1_set_blue_zones( size ) || t1_set_snap_zones( size );
- }
-
-
- /*************************************************************************/
- /* */
- /* <Function> */
- /* T1_New_Glyph_Hinter */
- /* */
- /* <Description> */
- /* Allocates a new hinter structure for a given glyph slot. */
- /* */
- /* <InOut> */
- /* glyph :: A handle to the target glyph slot. */
- /* */
- /* <Return> */
- /* FreeType error code. 0 means success. */
- /* */
- LOCAL_FUNC
- FT_Error T1_New_Glyph_Hinter( T1_GlyphSlot glyph )
- {
- FT_Memory memory = glyph->root.face->memory;
-
-
- return MEM_Alloc( glyph->hints, sizeof ( *glyph->hints ) );
- }
-
-
- /*************************************************************************/
- /* */
- /* <Function> */
- /* T1_Done_Glyph_Hinter */
- /* */
- /* <Description> */
- /* Releases a given glyph slot's hinter structure. */
- /* */
- /* <Input> */
- /* glyph :: A handle to the glyph slot. */
- /* */
- LOCAL_FUNC
- void T1_Done_Glyph_Hinter( T1_GlyphSlot glyph )
- {
- FT_Memory memory = glyph->root.face->memory;
-
-
- FREE( glyph->hints );
- }
-
-
- /*************************************************************************/
- /*************************************************************************/
- /*************************************************************************/
- /********** **********/
- /********** HINTED GLYPH LOADER **********/
- /********** **********/
- /********** The following code is in charge of the first **********/
- /********** and second pass when loading a single outline **********/
- /********** **********/
- /*************************************************************************/
- /*************************************************************************/
- /*************************************************************************/
-
-
- static
- FT_Error t1_hinter_ignore( void )
- {
- /* do nothing, used for `dotsection' which is unsupported for now */
- return 0;
- }
-
-
- static
- FT_Error t1_hinter_stem( T1_Builder* builder,
- FT_Pos pos,
- FT_Int width,
- FT_Bool vertical )
- {
- T1_Stem_Table* stem_table;
- T1_Stem_Hint* stems;
- T1_Stem_Hint* cur_stem;
- FT_Int min, max, n, num_stems;
- FT_Bool new_stem;
- T1_Glyph_Hints* hinter = builder->glyph->hints;
-
-
- /* select the appropriate stem array */
- stem_table = vertical ? &hinter->vert_stems : &hinter->hori_stems;
- stems = stem_table->stems;
- num_stems = stem_table->num_stems;
-
- /* Compute minimum and maximum coord for the stem */
- min = pos + ( vertical
- ? builder->left_bearing.x
- : builder->left_bearing.y );
-
- if ( width >= 0 )
- max = min + width;
- else
- {
- /* a negative width indicates a `ghost' stem */
- if ( width == -21 )
- min += width;
-
- max = min;
- }
-
- /* Now scan the array. If we find a stem with the same borders */
- /* simply activate it. */
- cur_stem = stems;
- new_stem = 1;
-
- for ( n = 0; n < num_stems; n++, cur_stem++ )
- {
- if ( cur_stem->min_edge.orus == min &&
- cur_stem->max_edge.orus == max )
- {
- /* This stem is already in the table, simply activate it */
- if ( ( cur_stem->hint_flags & T1_HINT_FLAG_ACTIVE ) == 0 )
- {
- cur_stem->hint_flags |= T1_HINT_FLAG_ACTIVE;
- stem_table->num_active++;
- }
- new_stem = 0;
- break;
- }
- }
-
- /* add a new stem to the array if necessary */
- if ( new_stem )
- {
- if ( cur_stem >= stems + T1_HINTER_MAX_EDGES )
- {
- FT_ERROR(( "t1_hinter_stem: too many stems in glyph charstring\n" ));
- return T1_Err_Syntax_Error;
- }
-
- /* on the first pass, we record the stem, otherwise, this is */
- /* a bug in the glyph loader! */
- if ( builder->pass == 0 )
- {
- cur_stem->min_edge.orus = min;
- cur_stem->max_edge.orus = max;
- cur_stem->hint_flags = T1_HINT_FLAG_ACTIVE;
-
- stem_table->num_stems++;
- stem_table->num_active++;
- }
- else
- {
- FT_ERROR(( "t1_hinter_stem:" ));
- FT_ERROR(( " fatal glyph loader bug -- pass2-stem\n" ));
- return T1_Err_Syntax_Error;
- }
- }
-
- return T1_Err_Ok;
- }
-
-
- static
- FT_Error t1_hinter_stem3( T1_Builder* builder,
- FT_Pos pos0,
- FT_Int width0,
- FT_Pos pos1,
- FT_Int width1,
- FT_Pos pos2,
- FT_Int width2,
- FT_Bool vertical )
- {
- /* For now, simply call `stem' 3 times */
- return t1_hinter_stem( builder, pos0, width0, vertical ) ||
- t1_hinter_stem( builder, pos1, width1, vertical ) ||
- t1_hinter_stem( builder, pos2, width2, vertical );
- }
-
-
- static
- FT_Error t1_hinter_changehints( T1_Builder* builder )
- {
- FT_Int dimension;
- T1_Stem_Table* stem_table;
- T1_Glyph_Hints* hinter = builder->glyph->hints;
-
-
- /* If we are in the second pass of glyph hinting, we must */
- /* call the function T1_Hint_Points() on the builder in order */
- /* to force the fit the latest points to the pixel grid. */
- if ( builder->pass == 1 )
- T1_Hint_Points( builder );
-
- /* Simply de-activate all hints in all arrays */
- stem_table = &hinter->hori_stems;
-
- for ( dimension = 2; dimension > 0; dimension-- )
- {
- T1_Stem_Hint* cur = stem_table->stems;
- T1_Stem_Hint* limit = cur + stem_table->num_stems;
-
-
- for ( ; cur < limit; cur++ )
- cur->hint_flags &= ~T1_HINT_FLAG_ACTIVE;
-
- stem_table->num_active = 0;
- stem_table = &hinter->vert_stems;
- }
-
- return T1_Err_Ok;
- }
-
-
- const T1_Hinter_Funcs t1_hinter_funcs =
- {
- (T1_Hinter_ChangeHints)t1_hinter_changehints,
- (T1_Hinter_DotSection) t1_hinter_ignore,
- (T1_Hinter_Stem) t1_hinter_stem,
- (T1_Hinter_Stem3) t1_hinter_stem3
- };
-
-
- /*************************************************************************/
- /*************************************************************************/
- /*************************************************************************/
- /********** *********/
- /********** *********/
- /********** STEM HINTS MANAGEMENT *********/
- /********** *********/
- /********** The following code is in charge of computing *********/
- /********** the placement of each scaled stem hint. *********/
- /********** *********/
- /*************************************************************************/
- /*************************************************************************/
- /*************************************************************************/
-
-
- /*************************************************************************/
- /* */
- /* <Function> */
- /* t1_sort_hints */
- /* */
- /* <Description> */
- /* Sorta the list of active stems in increasing order, through the */
- /* `sort' indexing table. */
- /* */
- /* <InOut> */
- /* table :: A stem hints table. */
- /* */
- static
- void t1_sort_hints( T1_Stem_Table* table )
- {
- FT_Int num_stems = table->num_stems;
- FT_Int num_active = 0;
- FT_Int* sort = table->sort;
- T1_Stem_Hint* stems = table->stems;
- FT_Int n;
-
-
- /* record active stems in sort table */
- for ( n = 0; n < num_stems; n++ )
- {
- if ( stems[n].hint_flags & T1_HINT_FLAG_ACTIVE )
- sort[num_active++] = n;
- }
-
- /* Now sort the indices. There are usually very few stems, */
- /* and they are pre-sorted in 90% cases, so we choose a */
- /* simple bubble sort (quicksort would be slower). */
- for ( n = 1; n < num_active; n++ )
- {
- FT_Int p = n - 1;
- T1_Stem_Hint* cur = stems + sort[n];
-
-
- do
- {
- FT_Int swap;
- T1_Stem_Hint* prev = stems + sort[p];
-
-
- /* note that by definition, the active stems cannot overlap */
- /* so we simply compare their `min' to sort them (we could compare */
- /* their max values also; this wouldn't change anything). */
- if ( prev->min_edge.orus <= cur->min_edge.orus )
- break;
-
- /* swap elements */
- swap = sort[p ];
- sort[p ] = sort[p + 1];
- sort[p + 1] = swap;
- p--;
-
- } while ( p >= 0 );
- }
-
- table->num_active = num_active;
- }
-
-
- /*************************************************************************/
- /* */
- /* <Function> */
- /* t1_hint_horizontal_stems */
- /* */
- /* <Description> */
- /* Computes the location of each scaled horizontal stem hint. This */
- /* takes care of the blue zones and the horizontal stem snap table. */
- /* */
- /* <Input> */
- /* table :: The horizontal stem hints table. */
- /* */
- /* hints :: The current size's hint structure. */
- /* */
- /* blueShift :: The value of the /BlueShift as taken from the face */
- /* object. */
- /* */
- /* scale :: The 16.16 scale used to convert outline units to */
- /* 26.6 pixels. */
- /* */
- /* <Note> */
- /* For now, all stems are hinted independently from each other. It */
- /* might be necessary, for better performance, to introduce the */
- /* notion of `controlled' hints describing things like counter-stems, */
- /* stem3, as well as overlapping stems control. */
- /* */
- static
- void t1_hint_horizontal_stems( T1_Stem_Table* table,
- T1_Size_Hints* hints,
- FT_Pos blueShift,
- FT_Fixed scale )
- {
- T1_Stem_Hint* stem = table->stems;
- T1_Stem_Hint* limit = stem + table->num_stems;
-
-
- /* first of all, scale the blueShift */
- blueShift = SCALE( blueShift );
-
- /* then scan the horizontal stem table */
- for ( ; stem < limit; stem++ )
- {
- FT_Pos bottom_orus = stem->min_edge.orus;
- FT_Pos top_orus = stem->max_edge.orus;
-
- FT_Pos top_pix = SCALE( top_orus );
- FT_Pos bottom_pix = SCALE( bottom_orus );
- FT_Pos width_pix = top_pix - bottom_pix;
-
- FT_Pos bottom = bottom_pix;
- FT_Pos top = top_pix;
- FT_Int align = T1_ALIGN_NONE;
-
-
- /*********************************************************************/
- /* */
- /* Snap pixel width if in stem snap range */
- /* */
-
- {
- T1_Snap_Zone* zone = hints->snap_heights;
- T1_Snap_Zone* zone_limit = zone + hints->num_snap_heights;
- FT_Pos best_dist = 32000;
- T1_Snap_Zone* best_zone = 0;
-
-
- for ( ; zone < zone_limit; zone++ )
- {
- FT_Pos dist;
-
-
- dist = width_pix - zone->min;
- if ( dist < 0 )
- dist = -dist;
- if ( dist < best_dist )
- {
- best_zone = zone;
- best_dist = dist;
- }
- }
-
- if ( best_zone )
- {
- if ( width_pix > best_zone->pix )
- {
- width_pix -= 0x20;
- if ( width_pix < best_zone->pix )
- width_pix = best_zone->pix;
- }
- else
- {
- width_pix += 0x20;
- if ( width_pix > best_zone->pix )
- width_pix = best_zone->pix;
- }
- }
- }
-
- /*********************************************************************/
- /* */
- /* round width - minimum 1 pixel if this isn't a ghost stem */
- /* */
-
- if ( width_pix > 0 )
- width_pix = width_pix < ONE_PIXEL ? ONE_PIXEL : ROUND( width_pix );
-
-
- /*********************************************************************/
- /* */
- /* Now check for bottom blue zones alignement */
- /* */
-
- {
- FT_Int num_blues = hints->num_bottom_zones;
- T1_Snap_Zone* blue = hints->blue_zones;
- T1_Snap_Zone* blue_limit = blue + num_blues;
-
-
- for ( ; blue < blue_limit; blue++ )
- {
- if ( bottom_pix < blue->min )
- break;
-
- if ( bottom_pix <= blue->max )
- {
- align = T1_ALIGN_BOTTOM;
- bottom = ROUND( blue->pix );
-
- /* implement blue shift */
- if ( !hints->supress_overshoots )
- {
- FT_Pos delta = blue->pix - bottom_pix;
-
-
- delta = delta < blueShift ? 0 : ROUND( delta );
- bottom -= delta;
- }
- }
- }
- }
-
- /*********************************************************************/
- /* */
- /* check for top blue zones alignement */
- /* */
-
- {
- FT_Int num_blues = hints->num_blue_zones -
- hints->num_bottom_zones;
-
- T1_Snap_Zone* blue = hints->blue_zones +
- hints->num_bottom_zones;
-
- T1_Snap_Zone* blue_limit = blue + num_blues;
-
-
- for ( ; blue < blue_limit; blue++ )
- {
- if ( top_pix < blue->min )
- break;
-
- if ( top_pix <= blue->max )
- {
- align |= T1_ALIGN_TOP;
- top = ROUND( blue->pix );
-
- /* implement blue shift */
- if ( !hints->supress_overshoots )
- {
- FT_Pos delta = top - blue->pix;
-
-
- delta = delta < blueShift ? 0 : ROUND( delta );
- top += delta;
- }
- }
- }
- }
-
- /*********************************************************************/
- /* */
- /* compute the hinted stem position, according to its alignment */
- /* */
-
- switch ( align )
- {
- case T1_ALIGN_BOTTOM: /* bottom zone alignment */
- bottom_pix = bottom;
- top_pix = bottom + width_pix;
- break;
-
- case T1_ALIGN_TOP: /* top zone alignment */
- top_pix = top;
- bottom_pix = top - width_pix;
- break;
-
- case T1_ALIGN_BOTH: /* bottom+top zone alignment */
- bottom_pix = bottom;
- top_pix = top;
- break;
-
- default: /* no alignment */
- /* XXX TODO: Add management of controlled stems */
- bottom = ( SCALE( bottom_orus + top_orus ) - width_pix ) / 2;
-
- bottom_pix = ROUND( bottom );
- top_pix = bottom_pix + width_pix;
- }
-
- stem->min_edge.pix = bottom_pix;
- stem->max_edge.pix = top_pix;
- }
- }
-
-
- /*************************************************************************/
- /* */
- /* <Function> */
- /* t1_hint_vertical_stems */
- /* */
- /* <Description> */
- /* Computes the location of each scaled vertical stem hint. This */
- /* takes care of the vertical stem snap table. */
- /* */
- /* <Input> */
- /* table :: The vertical stem hints table. */
- /* hints :: The current size's hint structure. */
- /* scale :: The 16.16 scale used to convert outline units to */
- /* 26.6 pixels. */
- /* */
- /* <Note> */
- /* For now, all stems are hinted independently from each other. It */
- /* might be necessary, for better performance, to introduce the */
- /* notion of `controlled' hints describing things like counter-stems, */
- /* stem3 as well as overlapping stems control. */
- /* */
- static
- void t1_hint_vertical_stems( T1_Stem_Table* table,
- T1_Size_Hints* hints,
- FT_Fixed scale )
- {
- T1_Stem_Hint* stem = table->stems;
- T1_Stem_Hint* limit = stem + table->num_stems;
-
-
- for ( ; stem < limit; stem++ )
- {
- FT_Pos stem_left = stem->min_edge.orus;
- FT_Pos stem_right = stem->max_edge.orus;
- FT_Pos width_pix, left;
-
-
- width_pix = SCALE( stem_right - stem_left );
-
- /* Snap pixel width if in stem snap range */
- {
- T1_Snap_Zone* zone = hints->snap_heights;
- T1_Snap_Zone* zone_limit = zone + hints->num_snap_heights;
- FT_Pos best_dist = 32000;
- T1_Snap_Zone* best_zone = 0;
-
-
- for ( ; zone < zone_limit; zone++ )
- {
- FT_Pos dist;
-
-
- dist = width_pix - zone->min;
- if ( dist < 0 )
- dist = -dist;
- if ( dist < best_dist )
- {
- best_zone = zone;
- best_dist = dist;
- }
- }
-
- if ( best_zone )
- {
- if ( width_pix > best_zone->pix )
- {
- width_pix -= 0x20;
- if ( width_pix < best_zone->pix )
- width_pix = best_zone->pix;
- }
- else
- {
- width_pix += 0x20;
- if ( width_pix > best_zone->pix )
- width_pix = best_zone->pix;
- }
- }
- }
-
- /* round width - minimum 1 pixel if this isn't a ghost stem */
- if ( width_pix > 0 )
- width_pix = width_pix < ONE_PIXEL ? ONE_PIXEL
- : ROUND( width_pix );
-
- /* now place the snapped and rounded stem */
-
- /* XXX TODO: implement controlled stems for the overlapping */
- /* cases */
-
- left = ( SCALE( stem_left + stem_right ) - width_pix ) / 2;
-
- stem->min_edge.pix = ROUND( left );
- stem->max_edge.pix = stem->min_edge.pix + width_pix;
- }
- }
-
-
- /*************************************************************************/
- /* */
- /* <Function> */
- /* t1_hint_point */
- /* */
- /* <Description> */
- /* Grid-fit a coordinate with regards to a given stem hints table. */
- /* */
- /* <Input> */
- /* table :: The source stem hints table. */
- /* coord :: The original coordinate, expressed in font units. */
- /* scale :: The 16.16 scale used to convert font units into */
- /* 26.6 pixels. */
- /* */
- /* <Return> */
- /* The hinted/scaled value in 26.6 pixels. */
- /* */
- /* <Note> */
- /* For now, all stems are hinted independently from each other. It */
- /* might be necessary, for better performance, to introduce the */
- /* notion of `controlled' hints describing things like counter-stems, */
- /* stem3 as well as overlapping stems control. */
- /* */
- static
- FT_Pos t1_hint_point( T1_Stem_Table* table,
- FT_Pos coord,
- FT_Fixed scale )
- {
- FT_Int num_active = table->num_active;
- FT_Int n;
- T1_Stem_Hint* prev = 0;
- T1_Stem_Hint* cur = 0;
- T1_Edge* min;
- T1_Edge* max;
- FT_Pos delta;
-
-
- /* only hint when there is at least one stem defined */
- if ( num_active <= 0 )
- return SCALE( coord );
-
- /* scan the stem table to determine placement of coordinate */
- /* relative to the list of sorted and stems */
- for ( n = 0; n < num_active; n++, prev = cur )
- {
- cur = table->stems + table->sort[n];
-
- /* is it on the left of the current edge? */
- delta = cur->min_edge.orus - coord;
- if ( delta == 0 )
- return cur->min_edge.pix;
-
- if ( delta > 0 )
- {
- /* if this is the left of the first edge, simply shift */
- if ( !prev )
- return cur->min_edge.pix - SCALE( delta );
-
- /* otherwise, interpolate between the maximum of the */
- /* previous stem, and the minimum of the current one */
- min = &prev->max_edge;
- max = &cur->min_edge;
-
- goto Interpolate;
- }
-
- /* is it within the current edge? */
- delta = cur->max_edge.orus - coord;
- if ( delta == 0 )
- return cur->max_edge.pix;
-
- if ( delta > 0 )
- {
- /* interpolate within the stem */
- min = &cur->min_edge;
- max = &cur->max_edge;
-
- goto Interpolate;
- }
- }
-
- /* apparently, this coordinate is on the right of the last stem */
- delta = coord - cur->max_edge.orus;
- return cur->max_edge.pix + SCALE( delta );
-
- Interpolate:
- return min->pix + FT_MulDiv( coord - min->orus,
- max->pix - min->pix,
- max->orus - min->orus );
- }
-
-
- /*************************************************************************/
- /* */
- /* <Function> */
- /* T1_Hint_Points */
- /* */
- /* <Description> */
- /* This function grid-fits several points in a given Type 1 builder */
- /* at once. */
- /* */
- /* <Input> */
- /* builder :: A handle to target Type 1 builder. */
- /* */
- LOCAL_FUNC
- void T1_Hint_Points( T1_Builder* builder )
- {
- FT_Int first = builder->hint_point;
- FT_Int last = builder->current->n_points - 1;
-
- T1_Size size = builder->size;
- FT_Fixed scale_x = size->root.metrics.x_scale;
- FT_Fixed scale_y = size->root.metrics.y_scale;
-
- T1_Glyph_Hints* hints = builder->glyph->hints;
- T1_Stem_Table* hori_stems = &hints->hori_stems;
- T1_Stem_Table* vert_stems = &hints->vert_stems;
-
- FT_Vector* cur = builder->current->points + first;
- FT_Vector* limit = cur + last - first + 1;
-
-
- /* first of all, sort the active stem hints */
- t1_sort_hints( hori_stems );
- t1_sort_hints( vert_stems );
-
- for ( ; cur < limit; cur++ )
- {
- cur->x = t1_hint_point( vert_stems, cur->x, scale_x );
- cur->y = t1_hint_point( hori_stems, cur->y, scale_y );
- }
-
- builder->hint_point = builder->current->n_points;
- }
-
-
- /*************************************************************************/
- /* */
- /* <Function> */
- /* T1_Hint_Stems */
- /* */
- /* <Description> */
- /* This function is used to compute the location of each stem hint */
- /* between the first and second passes of the glyph loader on the */
- /* charstring. */
- /* */
- /* <Input> */
- /* builder :: A handle to the target builder. */
- /* */
- LOCAL_FUNC
- void T1_Hint_Stems( T1_Builder* builder )
- {
- T1_Glyph_Hints* hints = builder->glyph->hints;
- T1_Private* priv = &builder->face->type1.private_dict;
-
- T1_Size size = builder->size;
- FT_Fixed scale_x = size->root.metrics.x_scale;
- FT_Fixed scale_y = size->root.metrics.y_scale;
-
-
- t1_hint_horizontal_stems( &hints->hori_stems,
- builder->size->hints,
- priv->blue_shift,
- scale_y );
-
- t1_hint_vertical_stems( &hints->vert_stems,
- builder->size->hints,
- scale_x );
- }
-
-
-/* END */
diff --git a/src/type1/t1hinter.h b/src/type1/t1hinter.h
deleted file mode 100644
index a82882e..0000000
--- a/src/type1/t1hinter.h
+++ /dev/null
@@ -1,273 +0,0 @@
-/***************************************************************************/
-/* */
-/* t1hinter.h */
-/* */
-/* Type 1 hinter (body). */
-/* */
-/* Copyright 1996-2000 by */
-/* David Turner, Robert Wilhelm, and Werner Lemberg. */
-/* */
-/* This file is part of the FreeType project, and may only be used, */
-/* modified, and distributed under the terms of the FreeType project */
-/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
-/* this file you indicate that you have read the license and */
-/* understand and accept it fully. */
-/* */
-/***************************************************************************/
-
-
-#ifndef T1HINTER_H
-#define T1HINTER_H
-
-
-#ifdef FT_FLAT_COMPILE
-
-#include "t1objs.h"
-#include "t1gload.h"
-
-#else
-
-#include <type1/t1objs.h>
-#include <type1/t1gload.h>
-
-#endif
-
-
-#ifdef __cplusplus
- extern "C" {
-#endif
-
-
- /*************************************************************************/
- /* */
- /* <Struct> */
- /* T1_Snap_Zone */
- /* */
- /* <Description> */
- /* A `snap zone' is used to model either a blue zone or a stem width */
- /* at a given character size. It is made of a minimum and maximum */
- /* edge, defined in 26.6 pixels, as well as an `original' and */
- /* `scaled' position. */
- /* */
- /* The position corresponds to the stem width (for stem snap zones) */
- /* or to the blue position (for blue zones). */
- /* */
- /* <Fields> */
- /* orus :: The original position in font units. */
- /* */
- /* pix :: The current position in sub-pixel units. */
- /* */
- /* min :: The minimum boundary in sub-pixel units. */
- /* */
- /* max :: The maximum boundary in sub-pixel units. */
- /* */
- typedef struct T1_Snap_Zone_
- {
- FT_Pos orus;
- FT_Pos pix;
- FT_Pos min;
- FT_Pos max;
-
- } T1_Snap_Zone;
-
-
- /*************************************************************************/
- /* */
- /* <Struct> */
- /* T1_Edge */
- /* */
- /* <Description> */
- /* A very simple structure used to model a stem edge. */
- /* */
- /* <Fields> */
- /* orus :: The original edge position in font units. */
- /* */
- /* pix :: The scaled edge position in sub-pixel units. */
- /* */
- typedef struct T1_Edge_
- {
- FT_Pos orus;
- FT_Pos pix;
-
- } T1_Edge;
-
-
- /*************************************************************************/
- /* */
- /* <Struct> */
- /* T1_Stem_Hint */
- /* */
- /* <Description> */
- /* A simple structure used to model a stem hint. */
- /* */
- /* <Fields> */
- /* min_edge :: The hint's minimum edge. */
- /* */
- /* max_edge :: The hint's maximum edge. */
- /* */
- /* hint_flags :: Some flags describing the stem properties. */
- /* */
- /* <Note> */
- /* The min and max edges of a ghost stem have the same position, even */
- /* if they are coded in a weird way in the charstrings. */
- /* */
- typedef struct T1_Stem_Hint_
- {
- T1_Edge min_edge;
- T1_Edge max_edge;
- FT_Int hint_flags;
-
- } T1_Stem_Hint;
-
-
-#define T1_HINT_FLAG_ACTIVE 1 /* indicates an active stem */
-#define T1_HINT_FLAG_MIN_BORDER 2 /* unused for now */
-#define T1_HINT_FLAG_MAX_BORDER 4 /* unused for now */
-
- /* hinter's configuration constants */
-#define T1_HINTER_MAX_BLUES 24 /* maximum number of blue zones */
-#define T1_HINTER_MAX_SNAPS 16 /* maximum number of stem snap zones */
-#define T1_HINTER_MAX_EDGES 64 /* maximum number of stem hints */
-
-
- /*************************************************************************/
- /* */
- /* <Struct> */
- /* T1_Size_Hints */
- /* */
- /* <Description> */
- /* A structure used to model the hinting information related to a size */
- /* object. */
- /* */
- /* <Fields> */
- /* supress_overshoots :: A boolean flag to tell whether overshoot */
- /* supression should occur. */
- /* */
- /* num_blue_zones :: The total number of blue zones (top+bottom). */
- /* */
- /* num_bottom_zones :: The number of bottom zones. */
- /* */
- /* blue_zones :: The blue zones table. Bottom zones are */
- /* stored first in the table, followed by all */
- /* top zones. */
- /* */
- /* num_snap_widths :: The number of horizontal stem snap zones. */
- /* */
- /* snap_widths :: An array of horizontal stem snap zones. */
- /* */
- /* num_snap_heights :: The number of vertical stem snap zones. */
- /* */
- /* snap_heights :: An array of vertical stem snap zones. */
- /* */
- struct T1_Size_Hints_
- {
- FT_Bool supress_overshoots;
-
- FT_Int num_blue_zones;
- FT_Int num_bottom_zones;
- T1_Snap_Zone blue_zones[T1_HINTER_MAX_BLUES];
-
- FT_Int num_snap_widths;
- T1_Snap_Zone snap_widths[T1_HINTER_MAX_SNAPS];
-
- FT_Int num_snap_heights;
- T1_Snap_Zone snap_heights[T1_HINTER_MAX_SNAPS];
- };
-
-
- /*************************************************************************/
- /* */
- /* <Struct> */
- /* T1_Stem_Table */
- /* */
- /* <Description> */
- /* A simple structure used to model a set of stem hints in a single */
- /* direction during the loading of a given glyph outline. Not all */
- /* stem hints are active at a time. Moreover, stems must be sorted */
- /* regularly. */
- /* */
- /* <Fields> */
- /* num_stems :: The total number of stems in the table. */
- /* */
- /* num_active :: The number of active stems in the table. */
- /* */
- /* stems :: A table of all stems. */
- /* */
- /* sort :: A table of indices into the stems table, used to */
- /* keep a sorted list of the active stems. */
- /* */
- typedef struct T1_Stem_Table_
- {
- FT_Int num_stems;
- FT_Int num_active;
-
- T1_Stem_Hint stems[T1_HINTER_MAX_EDGES];
- FT_Int sort [T1_HINTER_MAX_EDGES];
-
- } T1_Stem_Table;
-
-
- /*************************************************************************/
- /* */
- /* <Struct> */
- /* T1_Glyph_Hints */
- /* */
- /* <Description> */
- /* A structure used to model the stem hints of a given glyph outline */
- /* during glyph loading. */
- /* */
- /* <Fields> */
- /* hori_stems :: The horizontal stem hints table. */
- /* vert_stems :: The vertical stem hints table. */
- /* */
- struct T1_Glyph_Hints_
- {
- T1_Stem_Table hori_stems;
- T1_Stem_Table vert_stems;
- };
-
-
- /*************************************************************************/
- /* */
- /* <Data> */
- /* t1_hinter_funcs */
- /* */
- /* <Description> */
- /* A table containing the address of various functions used during */
- /* the loading of an hinted scaled outline. */
- /* */
- extern const T1_Hinter_Funcs t1_hinter_funcs;
-
-
- LOCAL_DEF
- FT_Error T1_New_Size_Hinter( T1_Size size );
-
- LOCAL_DEF
- void T1_Done_Size_Hinter( T1_Size size );
-
- LOCAL_DEF
- FT_Error T1_Reset_Size_Hinter( T1_Size size );
-
- LOCAL_DEF
- FT_Error T1_New_Glyph_Hinter( T1_GlyphSlot glyph );
-
- LOCAL_DEF
- void T1_Done_Glyph_Hinter( T1_GlyphSlot glyph );
-
-
- LOCAL_DEF
- void T1_Hint_Points( T1_Builder* builder );
-
- LOCAL_DEF
- void T1_Hint_Stems( T1_Builder* builder );
-
-
-#ifdef __cplusplus
- }
-#endif
-
-
-#endif /* T1HINTER_H */
-
-
-/* END */
diff --git a/src/type1/t1load.c b/src/type1/t1load.c
deleted file mode 100644
index 00a56a2..0000000
--- a/src/type1/t1load.c
+++ /dev/null
@@ -1,1594 +0,0 @@
-/***************************************************************************/
-/* */
-/* t1load.c */
-/* */
-/* Type 1 font loader (body). */
-/* */
-/* Copyright 1996-2000 by */
-/* David Turner, Robert Wilhelm, and Werner Lemberg. */
-/* */
-/* This file is part of the FreeType project, and may only be used, */
-/* modified, and distributed under the terms of the FreeType project */
-/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
-/* this file you indicate that you have read the license and */
-/* understand and accept it fully. */
-/* */
-/***************************************************************************/
-
-
-#include <freetype/config/ftconfig.h>
-#include <freetype/internal/ftdebug.h>
-#include <freetype/internal/t1types.h>
-
-
-#ifdef FT_FLAT_COMPILE
-
-#include "t1tokens.h"
-#include "t1parse.h"
-
-#else
-
-#include <type1/t1tokens.h>
-#include <type1/t1parse.h>
-
-#endif
-
-
-#include <stdio.h>
-
-#include <string.h> /* for strncpy(), strncmp(), strlen() */
-
-
- /*************************************************************************/
- /* */
- /* The macro FT_COMPONENT is used in trace mode. It is an implicit */
- /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */
- /* messages during execution. */
- /* */
-#undef FT_COMPONENT
-#define FT_COMPONENT trace_t1load
-
-
- typedef FT_Error (*T1_Parse_Func)( T1_Parser* parser );
-
-
- /*************************************************************************/
- /* */
- /* <Function> */
- /* Init_T1_Parser */
- /* */
- /* <Description> */
- /* Initializes a given parser object to build a given T1_Face. */
- /* */
- /* <InOut> */
- /* parser :: A handle to the newly built parser object. */
- /* */
- /* <Input> */
- /* face :: A handle to the target Type 1 face object. */
- /* */
- /* tokenizer :: A handle to the target Type 1 token manager. */
- /* */
- LOCAL_FUNC
- void Init_T1_Parser( T1_Parser* parser,
- T1_Face face,
- T1_Tokenizer tokenizer )
- {
- parser->error = 0;
- parser->face = face;
- parser->tokenizer = tokenizer;
- parser->top = parser->stack;
- parser->limit = parser->stack + T1_MAX_STACK_DEPTH;
-
- parser->state_index = 0;
- parser->state_stack[0] = dict_none;
-
- parser->encoding_type = t1_encoding_none;
- parser->encoding_names = 0;
- parser->encoding_offsets = 0;
- parser->encoding_lengths = 0;
-
- parser->dump_tokens = 0;
- face->type1.private_dict.lenIV = 4; /* XXX : is it sure? */
- }
-
-
- /*************************************************************************/
- /* */
- /* <Function> */
- /* Next_T1_Token */
- /* */
- /* <Description> */
- /* Grabs the next significant token from a parser's input stream. */
- /* This function ignores a number of tokens, and translates */
- /* alternate forms into their common ones. */
- /* */
- /* <Input> */
- /* parser :: A handle to the source parser. */
- /* */
- /* <Output> */
- /* token :: The extracted token descriptor. */
- /* */
- /* <Return> */
- /* FreeTyoe error code. 0 means success. */
- /* */
- LOCAL_FUNC
- FT_Error Next_T1_Token( T1_Parser* parser,
- T1_Token* token )
- {
- FT_Error error;
- T1_Tokenizer tokzer = parser->tokenizer;
-
-
- L1:
- error = Read_Token( tokzer );
- if ( error )
- return error;
-
- /* we now must ignore a number of tokens like `dup', `executeonly', */
- /* `readonly', etc. */
- *token = tokzer->token;
- if ( token->kind == tok_keyword )
- switch( token->kind2 )
- {
- case key_dup:
- case key_execonly:
- case key_readonly:
- case key_noaccess:
- case key_userdict:
- /* do nothing - loop */
- goto L1;
-
- /* we also translate some other keywords from their alternative */
- /* to their `normal' form */
-
- case key_NP_alternate:
- token->kind2 = key_NP;
- break;
-
- case key_RD_alternate:
- token->kind2 = key_RD;
- break;
-
- case key_ND_alternate:
- token->kind2 = key_ND;
- break;
-
- default:
- ;
- }
-
-#if defined( FT_DEBUG_LEVEL_ERROR ) || defined( FT_DEBUG_LEVEL_TRACE )
-
- /* Dump the token when requested. This feature is only available */
- /* in the `error' and `trace' debug levels. */
- if ( parser->dump_tokens )
- {
- FT_String temp_string[128];
- FT_Int len;
-
-
- len = token->len;
- if ( len > 127 )
- len = 127;
- strncpy( temp_string,
- (FT_String*)tokzer->base + token->start,
- len );
- temp_string[len] = '\0';
- FT_ERROR(( "%s\n", temp_string ));
- }
-
-#endif /* FT_DEBUG_LEVEL_ERROR or FT_DEBUG_LEVEL_TRACE */
-
- return T1_Err_Ok;
- }
-
-
- static
- FT_Error Expect_Keyword( T1_Parser* parser,
- T1_TokenType keyword )
- {
- T1_Token token;
- FT_Error error;
-
-
- error = Next_T1_Token( parser, &token );
- if ( error )
- goto Exit;
-
- if ( token.kind != tok_keyword ||
- token.kind2 != keyword )
- {
- error = T1_Err_Syntax_Error;
- FT_ERROR(( "Expect_Keyword: keyword `%s' expected.\n",
- t1_keywords[keyword - key_first_] ));
- }
-
- Exit:
- return error;
- }
-
-
- static
- FT_Error Expect_Keyword2( T1_Parser* parser,
- T1_TokenType keyword1,
- T1_TokenType keyword2 )
- {
- T1_Token token;
- FT_Error error;
-
-
- error = Next_T1_Token( parser, &token );
- if ( error )
- goto Exit;
-
- if ( token.kind != tok_keyword ||
- ( token.kind2 != keyword1 &&
- token.kind2 != keyword2 ) )
- {
- error = T1_Err_Syntax_Error;
- FT_ERROR(( "Expect_Keyword2: keyword `%s' or `%s' expected.\n",
- t1_keywords[keyword1 - key_first_],
- t1_keywords[keyword2 - key_first_] ));
- }
-
- Exit:
- return error;
- }
-
-
- static
- void Parse_Encoding( T1_Parser* parser )
- {
- T1_Token* token = parser->top+1;
- FT_Memory memory = parser->face->root.memory;
- T1_Encoding* encode = &parser->face->type1.encoding;
- FT_Error error = 0;
-
-
- if ( token->kind == tok_keyword &&
- ( token->kind2 == key_StandardEncoding ||
- token->kind2 == key_ExpertEncoding ) )
- {
- encode->num_chars = 256;
- encode->code_first = 32;
- encode->code_last = 255;
-
- if ( ALLOC_ARRAY( encode->char_index, 256, FT_Short ) )
- goto Exit;
-
- encode->char_name = 0; /* no need to store glyph names */
-
- /* Now copy the encoding */
- switch ( token->kind2 )
- {
- case key_ExpertEncoding:
- parser->encoding_type = t1_encoding_expert;
- break;
-
- default:
- parser->encoding_type = t1_encoding_standard;
- break;
- }
- }
- else
- {
- FT_ERROR(( "Parse_Encoding: invalid encoding type\n" ));
- error = T1_Err_Syntax_Error;
- }
-
- Exit:
- parser->error = error;
- }
-
-
- /*************************************************************************/
- /* */
- /* */
- /* IMPLEMENTATION OF THE `DEF' KEYWORD DEPENDING ON */
- /* CURRENT DICTIONARY STATE */
- /* */
- /* */
- /*************************************************************************/
-
-
- /*************************************************************************/
- /* */
- /* <Function> */
- /* Do_Def_Font */
- /* */
- /* <Description> */
- /* This function performs a `def' if in the Font dictionary. Its */
- /* purpose is to build the T1_Face attributes directly from the */
- /* stream. */
- /* */
- /* <InOut> */
- /* parser :: A handle to the current parser. */
- /* */
- /* <Return> */
- /* FreeType error code. 0 means success. */
- /* */
- static
- FT_Error Do_Def_Font( T1_Parser* parser )
- {
- T1_Token* top = parser->top;
- T1_Face face = parser->face;
- T1_Font* type1 = &face->type1;
-
-
- switch ( top[0].kind2 )
- {
- case imm_FontName:
- /* in some cases, the /FontName is an immediate like */
- /* /TimesNewRoman. In this case, we simply copy the */
- /* token string (without the /). */
- if ( top[1].kind == tok_immediate )
- {
- FT_Memory memory = parser->tokenizer->memory;
- FT_Error error;
- FT_Int len = top[1].len;
-
-
- if ( ALLOC( type1->font_name, len + 1 ) )
- {
- parser->error = error;
- return error;
- }
-
- MEM_Copy( type1->font_name,
- parser->tokenizer->base + top[1].start,
- len );
- type1->font_name[len] = '\0';
- }
- else
- type1->font_name = CopyString( parser );
- break;
-
- case imm_Encoding:
- Parse_Encoding( parser );
- break;
-
- case imm_PaintType:
- type1->paint_type = (FT_Byte)CopyInteger( parser );
- break;
-
- case imm_FontType:
- type1->font_type = (FT_Byte)CopyInteger( parser );
- break;
-
- case imm_FontMatrix:
- CopyMatrix( parser, &type1->font_matrix );
- break;
-
- case imm_FontBBox:
- CopyBBox( parser, &type1->font_bbox );
- break;
-
- case imm_UniqueID:
- type1->private_dict.unique_id = CopyInteger( parser );
- break;
-
- case imm_StrokeWidth:
- type1->stroke_width = CopyInteger( parser );
- break;
-
- case imm_FontID:
- type1->font_id = CopyInteger( parser );
- break;
-
- default:
- /* ignore all other things */
- parser->error = T1_Err_Ok;
- }
-
- return parser->error;
- }
-
-
- /*************************************************************************/
- /* */
- /* <Function> */
- /* Do_Def_FontInfo */
- /* */
- /* <Description> */
- /* This function performs a `def' if in the FontInfo dictionary. Its */
- /* purpose is to build the T1_FontInfo structure directly from the */
- /* stream. */
- /* */
- /* <InOut> */
- /* parser :: A handle to the current parser. */
- /* */
- /* <Return> */
- /* FreeTyoe error code. 0 means success. */
- /* */
- static
- FT_Error Do_Def_FontInfo( T1_Parser* parser )
- {
- T1_Token* top = parser->top;
- T1_FontInfo* info = &parser->face->type1.font_info;
-
-
- switch ( top[0].kind2 )
- {
- case imm_version:
- info->version = CopyString( parser );
- break;
-
- case imm_Notice:
- info->notice = CopyString( parser );
- break;
-
- case imm_FullName:
- info->full_name = CopyString( parser );
- break;
-
- case imm_FamilyName:
- info->family_name = CopyString( parser );
- break;
-
- case imm_Weight:
- info->weight = CopyString( parser );
- break;
-
- case imm_ItalicAngle:
- info->italic_angle = CopyInteger( parser );
- break;
-
- case imm_isFixedPitch:
- info->is_fixed_pitch = CopyBoolean( parser );
- break;
-
- case imm_UnderlinePosition:
- info->underline_position = (FT_Short)CopyInteger( parser );
- break;
-
- case imm_UnderlineThickness:
- info->underline_thickness = (FT_Short)CopyInteger( parser );
- break;
-
- default:
- /* ignore all other things */
- parser->error = T1_Err_Ok;
- }
-
- return parser->error;
- }
-
-
- /*************************************************************************/
- /* */
- /* <Function> */
- /* Do_Def_Private */
- /* */
- /* <Description> */
- /* This function performs a `def' if in the Private dictionary. Its */
- /* purpose is to build the T1_Private structure directly from the */
- /* stream. */
- /* */
- /* <InOut> */
- /* parser :: A handle to the current parser. */
- /* */
- /* <Return> */
- /* FreeTyoe error code. 0 means success. */
- /* */
- static
- FT_Error Do_Def_Private( T1_Parser* parser )
- {
- T1_Token* top = parser->top;
- T1_Private* priv = &parser->face->type1.private_dict;
-
-
- switch ( top[0].kind2 )
- {
- /* Ignore the definitions of RD, NP, ND, and their alternate forms */
- case imm_RD:
- case imm_RD_alternate:
- case imm_ND:
- case imm_ND_alternate:
- case imm_NP:
- case imm_NP_alternate:
- parser->error = T1_Err_Ok;
- break;
-
- case imm_BlueValues:
- CopyArray( parser, &priv->num_blue_values,
- priv->blue_values, 14 );
- break;
-
- case imm_OtherBlues:
- CopyArray( parser, &priv->num_other_blues,
- priv->other_blues, 10 );
- break;
-
- case imm_FamilyBlues:
- CopyArray( parser, &priv->num_family_blues,
- priv->family_blues, 14 );
- break;
-
- case imm_FamilyOtherBlues:
- CopyArray( parser, &priv->num_family_other_blues,
- priv->family_other_blues, 10 );
- break;
-
- case imm_BlueScale:
- priv->blue_scale = CopyFloat( parser, 0x10000L );
- break;
-
- case imm_BlueShift:
- priv->blue_shift = CopyInteger( parser );
- break;
-
- case imm_BlueFuzz:
- priv->blue_fuzz = CopyInteger( parser );
- break;
-
- case imm_StdHW:
- CopyArray( parser, 0, (FT_Short*)&priv->standard_width, 1 );
- break;
-
- case imm_StdVW:
- CopyArray( parser, 0, (FT_Short*)&priv->standard_height, 1 );
- break;
-
- case imm_StemSnapH:
- CopyArray( parser, &priv->num_snap_widths,
- priv->snap_widths, 12 );
- break;
-
- case imm_StemSnapV:
- CopyArray( parser, &priv->num_snap_heights,
- priv->snap_heights, 12 );
- break;
-
- case imm_ForceBold:
- priv->force_bold = CopyBoolean( parser );
- break;
-
- case imm_LanguageGroup:
- priv->language_group = CopyInteger( parser );
- break;
-
- case imm_password:
- priv->password = CopyInteger( parser );
- break;
-
- case imm_UniqueID:
- priv->unique_id = CopyInteger( parser );
- break;
-
- case imm_lenIV:
- priv->lenIV = CopyInteger( parser );
- break;
-
- case imm_MinFeature:
- CopyArray( parser, 0, priv->min_feature, 2 );
- break;
-
- default:
- /* ignore all other things */
- parser->error = T1_Err_Ok;
- }
-
- return parser->error;
- }
-
-
- /*************************************************************************/
- /* */
- /* <Function> */
- /* Do_Def_Error */
- /* */
- /* <Description> */
- /* This function returns a simple syntax error when invoked. It is */
- /* used for the `def' keyword if in the `encoding', `subrs', */
- /* `othersubrs', and `charstrings' dictionary states. */
- /* */
- /* <InOut> */
- /* parser :: A handle to the current parser. */
- /* */
- /* <Return> */
- /* FreeType error code. 0 means success. */
- /* */
- static
- FT_Error Do_Def_Error( T1_Parser* parser )
- {
- FT_ERROR(( "Do_Def_Error:" ));
- FT_ERROR(( " `def' keyword encountered in bad dictionary/array\n" ));
-
- parser->error = T1_Err_Syntax_Error;
-
- return parser->error;
- }
-
-
- static
- FT_Error Do_Def_Ignore( T1_Parser* parser )
- {
- FT_UNUSED( parser );
- return T1_Err_Ok;
- }
-
-
- static
- T1_Parse_Func def_funcs[dict_max] =
- {
- Do_Def_Error,
- Do_Def_Font,
- Do_Def_FontInfo,
- Do_Def_Ignore,
- Do_Def_Private,
- Do_Def_Ignore,
- Do_Def_Ignore,
- Do_Def_Ignore,
- Do_Def_Ignore,
- Do_Def_Ignore,
- Do_Def_Ignore,
- };
-
-
- /*************************************************************************/
- /* */
- /* */
- /* IMPLEMENTATION OF THE `PUT' KEYWORD DEPENDING ON */
- /* CURRENT DICTIONARY STATE */
- /* */
- /* */
- /*************************************************************************/
-
-
- /*************************************************************************/
- /* */
- /* <Function> */
- /* Do_Put_Encoding */
- /* */
- /* <Description> */
- /* This function performs a `put' if in the Encoding array. The */
- /* glyph name is copied into the T1 recorder, and the charcode and */
- /* glyph name pointer are written into the face object encoding. */
- /* */
- /* <InOut> */
- /* parser :: A handle to the current parser. */
- /* */
- /* <Return> */
- /* FreeType error code. 0 means success. */
- /* */
- static
- FT_Error Do_Put_Encoding( T1_Parser* parser )
- {
- FT_Error error = T1_Err_Ok;
- T1_Face face = parser->face;
- T1_Token* top = parser->top;
- T1_Encoding* encode = &face->type1.encoding;
- FT_Int index;
-
-
- /* record and check the character code */
- if ( top[0].kind != tok_number )
- {
- FT_TRACE4(( "Do_Put_Encoding: number expected\n" ));
- goto Syntax_Error;
- }
- index = (FT_Int)CopyInteger( parser );
- if ( parser->error )
- return parser->error;
-
- if ( index < 0 || index >= encode->num_chars )
- {
- FT_TRACE4(( "Do_Put_Encoding: invalid character code\n" ));
- goto Syntax_Error;
- }
-
- /* record the immediate name */
- if ( top[1].kind != tok_immediate )
- {
- FT_TRACE4(( "Do_Put_Encoding: immediate name expected\n" ));
- goto Syntax_Error;
- }
-
- /* if the glyph name is `.notdef', store a NULL char name; */
- /* otherwise, record the glyph name */
- if ( top[1].kind == imm_notdef )
- {
- parser->table.elements[index] = 0;
- parser->table.lengths [index] = 0;
- }
- else
- {
- FT_String temp_name[128];
- T1_Token* token = top + 1;
- FT_Int len = token->len - 1;
-
-
- /* copy immediate name */
- if ( len > 127 )
- len = 127;
- MEM_Copy( temp_name, parser->tokenizer->base + token->start + 1, len );
- temp_name[len] = '\0';
-
- error = T1_Add_Table( &parser->table, index,
- (FT_Byte*)temp_name, len + 1 );
-
- /* adjust code_first and code_last */
- if ( index < encode->code_first ) encode->code_first = index;
- if ( index > encode->code_last ) encode->code_last = index;
- }
- return error;
-
- Syntax_Error:
- /* ignore the error, and simply clear the stack */
- FT_TRACE4(( "Do_Put_Encoding: invalid syntax encountered\n" ));
- parser->top = parser->stack;
-
- return T1_Err_Ok;
- }
-
-
- /*************************************************************************/
- /* */
- /* */
- /* IMPLEMENTATION OF THE "RD" KEYWORD DEPENDING ON */
- /* CURRENT DICTIONARY STATE */
- /* */
- /* */
- /*************************************************************************/
-
-
- /*************************************************************************/
- /* */
- /* <Function> */
- /* Do_RD_Subrs */
- /* */
- /* <Description> */
- /* This function performs an `RD' if in the Subrs dictionary. It */
- /* simply records the array of bytecodes/charstrings corresponding to */
- /* the sub-routine. */
- /* */
- /* <InOut> */
- /* parser :: A handle to the current parser. */
- /* */
- /* <Return> */
- /* FreeType error code. 0 means success. */
- /* */
- static
- FT_Error Do_RD_Subrs( T1_Parser* parser )
- {
- FT_Error error = T1_Err_Ok;
- T1_Face face = parser->face;
- T1_Token* top = parser->top;
- T1_Tokenizer tokzer = parser->tokenizer;
- FT_Int index, count;
-
-
- /* record and check the character code */
- if ( top[0].kind != tok_number ||
- top[1].kind != tok_number )
- {
- FT_ERROR(( "Do_RD_Subrs: number expected\n" ));
- goto Syntax_Error;
- }
- index = (FT_Int)CopyInteger( parser );
- error = parser->error;
- if ( error )
- goto Exit;
-
- count = (FT_Int)CopyInteger( parser );
- error = parser->error;
- if ( error )
- goto Exit;
-
- if ( index < 0 || index >= face->type1.num_subrs )
- {
- FT_ERROR(( "Do_RD_Subrs: invalid character code\n" ));
- goto Syntax_Error;
- }
-
- /* decrypt charstring and skip it */
- {
- FT_Byte* base = tokzer->base + tokzer->cursor;
-
-
- tokzer->cursor += count;
-
- /* some fonts use a value of -1 for lenIV to indicate that */
- /* the charstrings are unencoded. */
- /* */
- /* Thanks to Tom Kacvinsky for pointing this out. */
- /* */
- if ( face->type1.private_dict.lenIV >= 0 )
- {
- t1_decrypt( base, count, 4330 );
-
- base += face->type1.private_dict.lenIV;
- count -= face->type1.private_dict.lenIV;
- }
-
- error = T1_Add_Table( &parser->table, index, base, count );
- }
-
- /* consume the closing NP or `put' */
- error = Expect_Keyword2( parser, key_NP, key_put );
-
- Exit:
- return error;
-
- Syntax_Error:
- return T1_Err_Syntax_Error;
- }
-
-
- /*************************************************************************/
- /* */
- /* <Function> */
- /* Do_RD_CharStrings */
- /* */
- /* <Description> */
- /* This function performs an `RD' if in the CharStrings dictionary. */
- /* It simply records the array of bytecodes/charstrings corresponding */
- /* to the glyph program string. */
- /* */
- /* <InOut> */
- /* parser :: A handle to the current parser. */
- /* */
- /* <Return> */
- /* FreeType error code. 0 means success. */
- /* */
- static
- FT_Error Do_RD_Charstrings( T1_Parser* parser )
- {
- FT_Error error = T1_Err_Ok;
- T1_Face face = parser->face;
- T1_Token* top = parser->top;
- T1_Tokenizer tokzer = parser->tokenizer;
- FT_Int index, count;
-
-
- /* check the character name argument */
- if ( top[0].kind != tok_immediate )
- {
- FT_ERROR(( "Do_RD_Charstrings: immediate character name expected\n" ));
- goto Syntax_Error;
- }
-
- /* check the count argument */
- if ( top[1].kind != tok_number )
- {
- FT_ERROR(( "Do_RD_Charstrings: number expected\n" ));
- goto Syntax_Error;
- }
-
- parser->args++;
- count = (FT_Int)CopyInteger( parser );
- error = parser->error;
- if ( error )
- goto Exit;
-
- /* record the glyph name and get the corresponding glyph index */
- if ( top[0].kind2 == imm_notdef )
- index = 0;
- else
- {
- FT_String temp_name[128];
- T1_Token* token = top;
- FT_Int len = token->len - 1;
-
-
- /* copy immediate name */
- if ( len > 127 )
- len = 127;
- MEM_Copy( temp_name, parser->tokenizer->base + token->start + 1, len );
- temp_name[len] = '\0';
-
- index = parser->cur_name++;
- error = T1_Add_Table( &parser->table, index * 2,
- (FT_Byte*)temp_name, len + 1 );
- if ( error )
- goto Exit;
- }
-
- /* decrypt and record charstring, then skip them */
- {
- FT_Byte* base = tokzer->base + tokzer->cursor;
-
-
- tokzer->cursor += count; /* skip */
-
- if ( face->type1.private_dict.lenIV >= 0 )
- {
- t1_decrypt( base, count, 4330 );
-
- base += face->type1.private_dict.lenIV;
- count -= face->type1.private_dict.lenIV;
- }
-
- error = T1_Add_Table( &parser->table, index * 2 + 1, base, count );
- }
-
- /* consume the closing `ND' */
- if ( !error )
- error = Expect_Keyword( parser, key_ND );
-
- Exit:
- return error;
-
- Syntax_Error:
- return T1_Err_Syntax_Error;
- }
-
-
- static
- FT_Error Expect_Dict_Arguments( T1_Parser* parser,
- FT_Int num_args,
- T1_TokenType immediate,
- T1_DictState new_state,
- FT_Int* count )
- {
- /* check that we have enough arguments in the stack, including */
- /* the `dict' keyword */
- if ( parser->top - parser->stack < num_args )
- {
- FT_ERROR(( "Expect_Dict_Arguments: expecting at least %d arguments",
- num_args ));
- goto Syntax_Error;
- }
-
- /* check that we have the correct immediate, if needed */
- if ( num_args == 2 )
- {
- if ( parser->top[-2].kind != tok_immediate ||
- parser->top[-2].kind2 != immediate )
- {
- FT_ERROR(( "Expect_Dict_Arguments: expecting `/%s' dictionary\n",
- t1_immediates[immediate - imm_first_] ));
- goto Syntax_Error;
- }
- }
-
- parser->args = parser->top-1;
-
- /* check that the count argument is a number */
- if ( parser->args->kind != tok_number )
- {
- FT_ERROR(( "Expect_Dict_Arguments:" ));
- FT_ERROR(( " expecting numerical count argument for `dict'\n" ));
- goto Syntax_Error;
- }
-
- if ( count )
- {
- *count = CopyInteger( parser );
- if ( parser->error )
- return parser->error;
- }
-
- /* save the dictionary state */
- parser->state_stack[++parser->state_index] = new_state;
-
- /* consume the `begin' keyword and clear the stack */
- parser->top -= num_args;
- return Expect_Keyword( parser, key_begin );
-
- Syntax_Error:
- return T1_Err_Syntax_Error;
- }
-
-
- static
- FT_Error Expect_Array_Arguments( T1_Parser* parser )
- {
- T1_Token* top = parser->top;
- FT_Error error = T1_Err_Ok;
- T1_DictState new_state;
- FT_Int count;
- T1_Face face = parser->face;
- FT_Memory memory = face->root.memory;
-
-
- /* Check arguments format */
- if ( top - parser->stack < 2 )
- {
- FT_ERROR(( "Expect_Array_Arguments: two arguments expected\n" ));
- error = T1_Err_Stack_Underflow;
- goto Exit;
- }
-
- parser->top -= 2;
- top -= 2;
- parser->args = top + 1;
-
- if ( top[0].kind != tok_immediate )
- {
- FT_ERROR(( "Expect_Array_Arguments:" ));
- FT_ERROR(( " first argument must be an immediate name\n" ));
- goto Syntax_Error;
- }
-
- if ( top[1].kind != tok_number )
- {
- FT_ERROR(( "Expect_Array_Arguments:" ));
- FT_ERROR(( " second argument must be a number\n" ));
- goto Syntax_Error;
- }
-
- count = (FT_Int)CopyInteger( parser );
-
- /* Is this an array we know about? */
- switch ( top[0].kind2 )
- {
- case imm_Encoding:
- {
- T1_Encoding* encode = &face->type1.encoding;
-
-
- new_state = dict_encoding;
-
- encode->code_first = count;
- encode->code_last = 0;
- encode->num_chars = count;
-
- /* Allocate the table of character indices. The table of */
- /* character names is allocated through init_t1_recorder(). */
- if ( ALLOC_ARRAY( encode->char_index, count, FT_Short ) )
- return error;
-
- error = T1_New_Table( &parser->table, count, memory );
- if ( error )
- goto Exit;
-
- parser->encoding_type = t1_encoding_array;
- }
- break;
-
- case imm_Subrs:
- new_state = dict_subrs;
- face->type1.num_subrs = count;
-
- error = T1_New_Table( &parser->table, count, memory );
- if ( error )
- goto Exit;
- break;
-
- case imm_CharStrings:
- new_state = dict_charstrings;
- break;
-
- default:
- new_state = dict_unknown_array;
- }
-
- parser->state_stack[++parser->state_index] = new_state;
-
- Exit:
- return error;
-
- Syntax_Error:
- return T1_Err_Syntax_Error;
- }
-
-
- static
- FT_Error Finalize_Parsing( T1_Parser* parser )
- {
- T1_Face face = parser->face;
- T1_Font* type1 = &face->type1;
- FT_Memory memory = face->root.memory;
- T1_Table* strings = &parser->table;
- PSNames_Interface* psnames = (PSNames_Interface*)face->psnames;
-
- FT_Int num_glyphs;
- FT_Int n;
- FT_Error error;
-
-
- num_glyphs = type1->num_glyphs = parser->cur_name;
-
- /* allocate glyph names and charstrings arrays */
- if ( ALLOC_ARRAY( type1->glyph_names, num_glyphs, FT_String* ) ||
- ALLOC_ARRAY( type1->charstrings, num_glyphs, FT_Byte* ) ||
- ALLOC_ARRAY( type1->charstrings_len, num_glyphs, FT_Int* ) )
- return error;
-
- /* copy glyph names and charstrings offsets and lengths */
- type1->charstrings_block = strings->block;
- for ( n = 0; n < num_glyphs; n++ )
- {
- type1->glyph_names[n] = (FT_String*)strings->elements[2 * n];
- type1->charstrings[n] = strings->elements[2 * n + 1];
- type1->charstrings_len[n] = strings->lengths [2 * n + 1];
- }
-
- /* now free the old tables */
- FREE( strings->elements );
- FREE( strings->lengths );
-
- if ( !psnames )
- {
- FT_ERROR(( "Finalize_Parsing: `PSNames' module missing!\n" ));
- return T1_Err_Unimplemented_Feature;
- }
-
- /* compute encoding if required */
- if ( parser->encoding_type == t1_encoding_none )
- {
- FT_ERROR(( "Finalize_Parsing: no encoding specified in font file\n" ));
- return T1_Err_Syntax_Error;
- }
-
- {
- FT_Int n;
- T1_Encoding* encode = &type1->encoding;
-
-
- encode->code_first = encode->num_chars - 1;
- encode->code_last = 0;
-
- for ( n = 0; n < encode->num_chars; n++ )
- {
- FT_String** names;
- FT_Int index;
- FT_Int m;
-
-
- switch ( parser->encoding_type )
- {
- case t1_encoding_standard:
- index = psnames->adobe_std_encoding[n];
- names = 0;
- break;
-
- case t1_encoding_expert:
- index = psnames->adobe_expert_encoding[n];
- names = 0;
- break;
-
- default:
- index = n;
- names = (FT_String**)parser->encoding_offsets;
- }
-
- encode->char_index[n] = 0;
-
- if ( index )
- {
- FT_String* name;
-
-
- if ( names )
- name = names[index];
- else
- name = (FT_String*)psnames->adobe_std_strings(index);
-
- if ( name )
- {
- FT_Int len = strlen( name );
-
-
- /* lookup glyph index from name */
- for ( m = 0; m < num_glyphs; m++ )
- {
- if ( strncmp( type1->glyph_names[m], name, len ) == 0 )
- {
- encode->char_index[n] = m;
- break;
- }
- }
-
- if ( n < encode->code_first ) encode->code_first = n;
- if ( n > encode->code_last ) encode->code_last = n;
- }
- }
- }
-
- parser->encoding_type = t1_encoding_none;
-
- FREE( parser->encoding_names );
- FREE( parser->encoding_lengths );
- FREE( parser->encoding_offsets );
- }
-
- return T1_Err_Ok;
- }
-
-
- /*************************************************************************/
- /* */
- /* <Function> */
- /* Parse_T1_FontProgram */
- /* */
- /* <Description> */
- /* Parses a given Type 1 font file and builds its face object. */
- /* */
- /* <InOut> */
- /* parser :: A handle to the target parser object. */
- /* */
- /* <Return> */
- /* FreeType error code. 0 means success. */
- /* */
- /* <Note> */
- /* The parser contains a handle to the target face object. */
- /* */
- LOCAL_FUNC
- FT_Error Parse_T1_FontProgram( T1_Parser* parser )
- {
- FT_Error error;
- T1_Font* type1 = &parser->face->type1;
-
-
- for (;;)
- {
- T1_Token token;
- T1_Token* top;
- T1_DictState dict_state;
- FT_Int dict_index;
-
-
- error = Next_T1_Token( parser, &token );
- top = parser->top;
- dict_index = parser->state_index;
- dict_state = parser->state_stack[dict_index];
-
- switch ( token.kind )
- {
- /* a keyword has been detected */
- case tok_keyword:
- switch ( token.kind2 )
- {
- case key_dict:
- switch ( dict_state )
- {
- case dict_none:
- /* All right, we are beginning the font dictionary. */
- /* Check that we only have one number argument, then */
- /* consume the `begin' and change to `dict_font' */
- /* state. */
- error = Expect_Dict_Arguments( parser, 1, tok_error,
- dict_font, 0 );
- if ( error )
- goto Exit;
-
- /* clear stack from all the previous content. This */
- /* could be some stupid Postscript code. */
- parser->top = parser->stack;
- break;
-
- case dict_font:
- /* This must be the /FontInfo dictionary, so check */
- /* that we have at least two arguments, that they */
- /* are `/FontInfo' and a number, then change the */
- /* dictionary state. */
- error = Expect_Dict_Arguments( parser, 2, imm_FontInfo,
- dict_fontinfo, 0 );
- if ( error )
- goto Exit;
- break;
-
- case dict_none2:
- error = Expect_Dict_Arguments( parser, 2, imm_Private,
- dict_private, 0 );
- if ( error )
- goto Exit;
- break;
-
- case dict_private:
- {
- T1_Face face = parser->face;
- FT_Int count;
-
-
- error = Expect_Dict_Arguments( parser, 2, imm_CharStrings,
- dict_charstrings, &count );
- if ( error )
- goto Exit;
-
- type1->num_glyphs = count;
- error = T1_New_Table( &parser->table, count * 2,
- face->root.memory );
- if ( error )
- goto Exit;
-
- /* record `.notdef' as the first glyph in the font */
- error = T1_Add_Table( &parser->table, 0,
- (FT_Byte*)".notdef", 8 );
- parser->cur_name = 1;
- /* XXX: DO SOMETHING HERE */
- }
- break;
-
- default:
- /* All other uses are invalid */
- FT_ERROR(( "Parse_T1_FontProgram:" ));
- FT_ERROR(( " invalid use of `dict' keyword\n" ));
- goto Syntax_Error;
- }
- break;
-
- case key_array:
- /* Are we in an array yet? If so, raise an error */
- switch ( dict_state )
- {
- case dict_encoding:
- case dict_subrs:
- case dict_othersubrs:
- case dict_charstrings:
- case dict_unknown_array:
- FT_ERROR(( "Parse_T1_FontProgram: nested array definitions\n" ));
- goto Syntax_Error;
-
- default:
- ;
- }
- error = Expect_Array_Arguments( parser );
- if ( error )
- goto Exit;
- break;
-
- case key_ND:
- case key_NP:
- case key_def:
- /* Are we in an array? If so, finalize it. */
- switch ( dict_state )
- {
- case dict_encoding: /* finish encoding array */
- /* copy table names to the face object */
- T1_Done_Table( &parser->table );
-
- parser->encoding_names = parser->table.block;
- parser->encoding_lengths = parser->table.lengths;
- parser->encoding_offsets = parser->table.elements;
-
- parser->state_index--;
- break;
-
- case dict_subrs:
- /* copy recorder sub-routines */
- T1_Done_Table( &parser->table );
-
- parser->subrs = parser->table.block;
- type1->subrs = parser->table.elements;
- type1->subrs_len = parser->table.lengths;
- type1->subrs_block = parser->table.block;
-
- parser->state_index--;
- break;
-
- case dict_charstrings:
- case dict_othersubrs:
- case dict_unknown_array:
- FT_ERROR(( "Parse_T1_FontProgram: unsupported array\n" ));
- goto Syntax_Error;
- break;
-
- default: /* normal `def' processing */
- /* Check that we have sufficient operands in the stack */
- if ( top >= parser->stack + 2 )
- {
- /* Now check that the first operand is an immediate. */
- /* If so, call the appropriate `def' routine based */
- /* on the current parser state. */
- if ( top[-2].kind == tok_immediate )
- {
- parser->top -= 2;
- parser->args = parser->top + 1;
- error = def_funcs[dict_state](parser);
- }
- else
- {
- /* This is an error, but some fonts contain */
- /* stupid Postscript code. We simply ignore */
- /* an invalid `def' by clearing the stack. */
-#if 0
- FT_ERROR(( "Parse_T1_FontProgram: immediate expected\n" ));
- goto Syntax_Error;
-#else
- parser->top = parser->stack;
-#endif
- }
- }
- else
- {
- FT_ERROR(( "Parse_T1_FontProgram: not enough arguments\n" ));
- goto Stack_Underflow;
- }
- }
- break;
-
- case key_index:
- if ( top <= parser->stack )
- {
- FT_ERROR(( "Parse_T1_FontProgram: not enough arguments\n" ));
- goto Stack_Underflow;
- }
-
- /* simply ignore? */
- parser->top --;
- break;
-
- case key_put:
- /* Check that we have sufficient operands in stack */
- if ( top < parser->stack + 2 )
- {
- FT_ERROR(( "Parse_T1_FontProgram: not enough arguments\n" ));
- goto Stack_Underflow;
- }
-
- parser->top -= 2;
- parser->args = parser->top;
-
- switch ( dict_state )
- {
- case dict_encoding:
- error = Do_Put_Encoding( parser );
- if ( error )
- goto Exit;
- break;
-
- case dict_unknown_array: /* ignore the `put' */
- break;
-
- default:
-#if 0
- FT_ERROR(( "Parse_T1_FontProgram: invalid context\n" ));
- goto Syntax_Error;
-#else
- /* invalid context; simply ignore the `put' and */
- /* clear the stack (stupid Postscript code) */
- FT_TRACE4(( "Parse_T1_FontProgram: invalid context ignored.\n" ));
- parser->top = parser->stack;
-#endif
- }
- break;
-
- case key_RD:
- /* Check that we have sufficient operands in stack */
- if ( top < parser->stack + 2 )
- {
- FT_ERROR(( "Parse_T1_FontProgram: not enough arguments\n" ));
- goto Stack_Underflow;
- }
-
- parser->top -= 2;
- parser->args = parser->top;
- switch ( dict_state )
- {
- case dict_subrs:
- error = Do_RD_Subrs( parser );
- if ( error )
- goto Exit;
- break;
-
- case dict_charstrings:
- error = Do_RD_Charstrings( parser );
- if ( error )
- goto Exit;
- break;
-
- default:
- FT_ERROR(( "Parse_T1_FontProgram: invalid context\n" ));
- goto Syntax_Error;
- }
- break;
-
- case key_end:
- /* Were we in a dictionary or in an array? */
- if ( dict_index <= 0 )
- {
- FT_ERROR(( "Parse_T1_FontProgram: no dictionary defined\n" ));
- goto Syntax_Error;
- }
-
- switch ( dict_state )
- {
- /* jump to the private dictionary if we are closing the */
- /* `/Font' dictionary */
- case dict_font:
- goto Open_Private;
-
- /* exit the parser when closing the CharStrings dictionary */
- case dict_charstrings:
- return Finalize_Parsing( parser );
-
- default:
- /* Pop the current dictionary state and return to previous */
- /* one. Consume the `def'. */
-
- /* Because some buggy fonts (BitStream) have incorrect */
- /* syntax, we never escape from the private dictionary */
- if ( dict_state != dict_private )
- parser->state_index--;
-
- /* many fonts use `NP' instead of `def' or `put', so */
- /* we simply ignore the next token */
-#if 0
- error = Expect_Keyword2( parser, key_def, key_put );
- if ( error )
- goto Exit;
-#else
- (void)Expect_Keyword2( parser, key_def, key_put );
-#endif
- }
- break;
-
- case key_for:
- /* check that we have four arguments and simply */
- /* ignore them */
- if ( top - parser->stack < 4 )
- {
- FT_ERROR(( "Parse_T1_FontProgram: not enough arguments\n" ));
- goto Stack_Underflow;
- }
-
- parser->top -= 4;
- break;
-
- case key_currentdict:
- Open_Private:
- parser->state_index = 0;
- parser->state_stack[0] = dict_none2;
- error = Open_PrivateDict( parser->tokenizer );
- if ( error )
- goto Exit;
- break;
-
- case key_true:
- case key_false:
- case key_StandardEncoding:
- case key_ExpertEncoding:
- goto Push_Element;
-
- default:
- FT_ERROR(( "Parse_T1_FontProgram:" ));
- FT_ERROR(( " invalid keyword in context\n" ));
- error = T1_Err_Syntax_Error;
- }
- break;
-
- /* check for the presence of `/BlendAxisTypes' -- we cannot deal */
- /* with multiple master fonts, so we must return a correct error */
- /* code to allow another driver to load them */
- case tok_immediate:
- if ( token.kind2 == imm_BlendAxisTypes )
- {
- error = FT_Err_Unknown_File_Format;
- goto Exit;
- }
- /* fallthrough */
-
- /* A number was detected */
- case tok_string:
- case tok_program:
- case tok_array:
- case tok_hexarray:
- case tok_any:
- case tok_number: /* push number on stack */
-
- Push_Element:
- if ( top >= parser->limit )
- {
- error = T1_Err_Stack_Overflow;
- goto Exit;
- }
- else
- *parser->top++ = token;
- break;
-
- /* anything else is an error per se the spec, but we */
- /* frequently encounter stupid postscript code in fonts, */
- /* so just ignore them */
- default:
- error = T1_Err_Ok; /* ignore token */
- }
-
- if ( error )
- return error;
- }
-
- Exit:
- return error;
-
- Syntax_Error:
- return T1_Err_Syntax_Error;
-
- Stack_Underflow:
- return T1_Err_Stack_Underflow;
- }
-
-
-/* END */
diff --git a/src/type1/t1load.h b/src/type1/t1load.h
deleted file mode 100644
index d278374..0000000
--- a/src/type1/t1load.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/***************************************************************************/
-/* */
-/* t1load.h */
-/* */
-/* Type 1 font loader (specification). */
-/* */
-/* Copyright 1996-2000 by */
-/* David Turner, Robert Wilhelm, and Werner Lemberg. */
-/* */
-/* This file is part of the FreeType project, and may only be used, */
-/* modified, and distributed under the terms of the FreeType project */
-/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
-/* this file you indicate that you have read the license and */
-/* understand and accept it fully. */
-/* */
-/***************************************************************************/
-
-
-#ifndef T1LOAD_H
-#define T1LOAD_H
-
-#include <freetype/internal/ftstream.h>
-
-
-#ifdef FT_FLAT_COMPILE
-
-#include "t1parse.h"
-
-#else
-
-#include <type1/t1parse.h>
-
-#endif
-
-
-#ifdef __cplusplus
- extern "C" {
-#endif
-
- LOCAL_DEF
- void Init_T1_Parser( T1_Parser* parser,
- T1_Face face,
- T1_Tokenizer tokenizer );
-
-
- LOCAL_DEF
- FT_Error Parse_T1_FontProgram( T1_Parser* parser );
-
-
-#ifdef __cplusplus
- }
-#endif
-
-#endif /* T1LOAD_H */
-
-
-/* END */
diff --git a/src/type1/t1objs.c b/src/type1/t1objs.c
deleted file mode 100644
index 1e6f9ca..0000000
--- a/src/type1/t1objs.c
+++ /dev/null
@@ -1,544 +0,0 @@
-/***************************************************************************/
-/* */
-/* t1objs.c */
-/* */
-/* Type 1 objects manager (body). */
-/* */
-/* Copyright 1996-2000 by */
-/* David Turner, Robert Wilhelm, and Werner Lemberg. */
-/* */
-/* This file is part of the FreeType project, and may only be used, */
-/* modified, and distributed under the terms of the FreeType project */
-/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
-/* this file you indicate that you have read the license and */
-/* understand and accept it fully. */
-/* */
-/***************************************************************************/
-
-
-#include <freetype/internal/ftdebug.h>
-#include <freetype/internal/ftstream.h>
-
-
-#ifdef FT_FLAT_COMPILE
-
-#include "t1gload.h"
-#include "t1load.h"
-#include "t1afm.h"
-
-#ifndef T1_CONFIG_OPTION_DISABLE_HINTER
-#include "t1hinter.h"
-#endif
-
-#else /* FT_FLAT_COMPILE */
-
-#include <type1/t1gload.h>
-#include <type1/t1load.h>
-#include <type1/t1afm.h>
-
-#ifndef T1_CONFIG_OPTION_DISABLE_HINTER
-#include <type1/t1hinter.h>
-#endif
-
-#endif /* FT_FLAT_COMPILE */
-
-
-#include <freetype/internal/psnames.h>
-
-
- /*************************************************************************/
- /* */
- /* The macro FT_COMPONENT is used in trace mode. It is an implicit */
- /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */
- /* messages during execution. */
- /* */
-#undef FT_COMPONENT
-#define FT_COMPONENT trace_t1objs
-
-
- /*************************************************************************/
- /* */
- /* SIZE FUNCTIONS */
- /* */
- /*************************************************************************/
-
-
- /*************************************************************************/
- /* */
- /* <Function> */
- /* T1_Done_Size */
- /* */
- /* <Description> */
- /* The Type 1 size object destructor. Used to discard a given size */
- /* object. */
- /* */
- /* <Input> */
- /* size :: A handle to the target size object. */
- /* */
- LOCAL_FUNC
- void T1_Done_Size( T1_Size size )
- {
- if ( size )
- {
-
-#ifndef T1_CONFIG_OPTION_DISABLE_HINTER
- T1_Done_Size_Hinter( size );
-#endif
-
- size->valid = 0;
- }
- }
-
-
- /*************************************************************************/
- /* */
- /* <Function> */
- /* T1_Init_Size */
- /* */
- /* <Description> */
- /* The size object initializer. */
- /* */
- /* <Input> */
- /* size :: A handle to the target size object. */
- /* */
- /* <Return> */
- /* FreeTrue error code. 0 means success. */
- /* */
- LOCAL_DEF
- FT_Error T1_Init_Size( T1_Size size )
- {
- FT_Error error;
-
-
- size->valid = 0;
-
-#ifndef T1_CONFIG_OPTION_DISABLE_HINTER
- error = T1_New_Size_Hinter( size );
-
- return error;
-#else
-
- FT_UNUSED( error );
-
- return T1_Err_Ok;
-
-#endif
- }
-
-
- /*************************************************************************/
- /* */
- /* <Function> */
- /* T1_Reset_Size */
- /* */
- /* <Description> */
- /* Resets an instance to a new pointsize/transform. This function is */
- /* in charge of resetting the blue zones,a s well as the stem snap */
- /* tables for a given size. */
- /* */
- /* <Input> */
- /* size :: The target size object. */
- /* */
- /* <Output> */
- /* FreeType error code. 0 means success. */
- /* */
- LOCAL_FUNC
- FT_Error T1_Reset_Size( T1_Size size )
- {
- /* recompute ascender, descender, etc. */
- T1_Face face = (T1_Face)size->root.face;
- FT_Size_Metrics* metrics = &size->root.metrics;
-
-
- if ( metrics->x_ppem < 1 || metrics->y_ppem < 1 )
- return FT_Err_Invalid_Argument;
-
- /* Compute root ascender, descender, test height, and max_advance */
- metrics->ascender = ( FT_MulFix( face->root.ascender,
- metrics->y_scale ) + 32 ) & -64;
- metrics->descender = ( FT_MulFix( face->root.descender,
- metrics->y_scale ) + 32 ) & -64;
- metrics->height = ( FT_MulFix( face->root.height,
- metrics->y_scale ) + 32 ) & -64;
- metrics->max_advance = ( FT_MulFix( face->root.max_advance_width,
- metrics->x_scale ) + 32 ) & -64;
-
-#ifndef T1_CONFIG_OPTION_DISABLE_HINTER
- return T1_Reset_Size_Hinter( size );
-#else
- return 0;
-#endif
- }
-
-
- /*************************************************************************/
- /* */
- /* FACE FUNCTIONS */
- /* */
- /*************************************************************************/
-
-
- /*************************************************************************/
- /* */
- /* <Function> */
- /* T1_Done_Face */
- /* */
- /* <Description> */
- /* The face object destructor. */
- /* */
- /* <Input> */
- /* face :: A typeless pointer to the face object to destroy. */
- /* */
- LOCAL_FUNC
- void T1_Done_Face( T1_Face face )
- {
- FT_Memory memory;
- T1_Font* type1 = &face->type1;
-
-
- if ( face )
- {
- memory = face->root.memory;
-
- /* release font info strings */
- {
- T1_FontInfo* info = &type1->font_info;
-
-
- FREE( info->version );
- FREE( info->notice );
- FREE( info->full_name );
- FREE( info->family_name );
- FREE( info->weight );
- }
-
- /* release top dictionary */
- FREE( type1->charstrings_len );
- FREE( type1->charstrings );
- FREE( type1->glyph_names );
-
- FREE( type1->subrs );
- FREE( type1->subrs_len );
-
- FREE( type1->subrs_block );
- FREE( type1->charstrings_block );
- FREE( type1->glyph_names_block );
-
- FREE( type1->encoding.char_index );
- FREE( type1->font_name );
-
-#ifndef T1_CONFIG_OPTION_NO_AFM
- /* release afm data if present */
- if ( face->afm_data )
- T1_Done_AFM( memory, (T1_AFM*)face->afm_data );
-#endif
-
- /* release unicode map, if any */
- FREE( face->unicode_map.maps );
- face->unicode_map.num_maps = 0;
-
- face->root.family_name = 0;
- face->root.style_name = 0;
- }
- }
-
-
- /*************************************************************************/
- /* */
- /* <Function> */
- /* T1_Init_Face */
- /* */
- /* <Description> */
- /* The face object constructor. */
- /* */
- /* <Input> */
- /* stream :: input stream where to load font data. */
- /* */
- /* face_index :: The index of the font face in the resource. */
- /* */
- /* num_params :: Number of additional generic parameters. Ignored. */
- /* */
- /* params :: Additional generic parameters. Ignored. */
- /* */
- /* <InOut> */
- /* face :: The face record to build. */
- /* */
- /* <Return> */
- /* FreeType error code. 0 means success. */
- /* */
- LOCAL_FUNC
- FT_Error T1_Init_Face( FT_Stream stream,
- T1_Face face,
- FT_Int face_index,
- FT_Int num_params,
- FT_Parameter* params )
- {
- T1_Tokenizer tokenizer;
- FT_Error error;
- PSNames_Interface* psnames;
-
- FT_UNUSED( num_params );
- FT_UNUSED( params );
- FT_UNUSED( face_index );
- FT_UNUSED( face );
-
-
- face->root.num_faces = 1;
-
- psnames = (PSNames_Interface*)face->psnames;
- if ( !psnames )
- {
- psnames = (PSNames_Interface*)
- FT_Get_Module_Interface( FT_FACE_LIBRARY( face ),
- "psnames" );
-
- face->psnames = psnames;
- }
-
- /* open the tokenizer, this will also check the font format */
- error = New_Tokenizer( stream, &tokenizer );
- if ( error )
- goto Fail;
-
- /* if we just wanted to check the format, leave successfully now */
- if ( face_index < 0 )
- goto Leave;
-
- /* check the face index */
- if ( face_index != 0 )
- {
- FT_ERROR(( "T1_Init_Face: invalid face index\n" ));
- error = T1_Err_Invalid_Argument;
- goto Leave;
- }
-
- /* Now, load the font program into the face object */
- {
- T1_Parser parser;
-
-
- Init_T1_Parser( &parser, face, tokenizer );
- error = Parse_T1_FontProgram( &parser );
- if ( error )
- goto Leave;
-
- /* Init the face object fields */
- /* Now set up root face fields */
- {
- FT_Face root = (FT_Face)&face->root;
- T1_Font* type1 = &face->type1;
-
-
- root->num_glyphs = type1->num_glyphs;
- root->num_charmaps = 1;
-
- root->face_index = face_index;
- root->face_flags = FT_FACE_FLAG_SCALABLE;
-
- root->face_flags |= FT_FACE_FLAG_HORIZONTAL;
-
- root->face_flags |= FT_FACE_FLAG_GLYPH_NAMES;
-
- if ( type1->font_info.is_fixed_pitch )
- root->face_flags |= FT_FACE_FLAG_FIXED_WIDTH;
-
- /* XXX: TODO -- add kerning with .afm support */
-
- /* get style name - be careful, some broken fonts only */
- /* have a `/FontName' dictionary entry! */
- root->family_name = type1->font_info.family_name;
- if ( root->family_name )
- {
- char* full = type1->font_info.full_name;
- char* family = root->family_name;
-
-
- while ( *family && *full == *family )
- {
- family++;
- full++;
- }
-
- root->style_name = ( *full == ' ' ? full + 1
- : (char *)"Regular" );
- }
- else
- {
- /* do we have a `/FontName'? */
- if (type1->font_name)
- {
- root->family_name = type1->font_name;
- root->style_name = "Regular";
- }
- }
-
- /* no embedded bitmap support */
- root->num_fixed_sizes = 0;
- root->available_sizes = 0;
-
- root->bbox = type1->font_bbox;
- root->units_per_EM = 1000;
- root->ascender = (FT_Short)type1->font_bbox.yMax;
- root->descender = -(FT_Short)type1->font_bbox.yMin;
- root->height = ( ( root->ascender + root->descender) * 12 )
- / 10;
-
- /* now compute the maximum advance width */
-
- root->max_advance_width = type1->private_dict.standard_width[0];
-
- /* compute max advance width for proportional fonts */
- if ( !type1->font_info.is_fixed_pitch )
- {
- FT_Int max_advance;
-
-
- error = T1_Compute_Max_Advance( face, &max_advance );
-
- /* in case of error, keep the standard width */
- if ( !error )
- root->max_advance_width = max_advance;
- else
- error = 0; /* clear error */
- }
-
- root->max_advance_height = root->height;
-
- root->underline_position = type1->font_info.underline_position;
- root->underline_thickness = type1->font_info.underline_thickness;
-
- root->max_points = 0;
- root->max_contours = 0;
- }
- }
-
- /* charmap support - synthetize unicode charmap when possible */
- {
- FT_Face root = &face->root;
- FT_CharMap charmap = face->charmaprecs;
-
-
- /* synthesize a Unicode charmap if there is support in the `PSNames' */
- /* module.. */
- if ( face->psnames )
- {
- PSNames_Interface* psnames = (PSNames_Interface*)face->psnames;
-
-
- if ( psnames->unicode_value )
- {
- error = psnames->build_unicodes(
- root->memory,
- face->type1.num_glyphs,
- (const char**)face->type1.glyph_names,
- &face->unicode_map );
- if ( !error )
- {
- root->charmap = charmap;
- charmap->face = (FT_Face)face;
- charmap->encoding = ft_encoding_unicode;
- charmap->platform_id = 3;
- charmap->encoding_id = 1;
- charmap++;
- }
-
- /* simply clear the error in case of failure (which really) */
- /* means that out of memory or no unicode glyph names */
- error = 0;
- }
- }
-
- /* now, support either the standard, expert, or custom encodings */
- charmap->face = (FT_Face)face;
- charmap->platform_id = 7; /* a new platform id for Adobe fonts ?? */
-
- switch ( face->type1.encoding_type )
- {
- case t1_encoding_standard:
- charmap->encoding = ft_encoding_adobe_standard;
- charmap->encoding_id = 0;
- break;
-
- case t1_encoding_expert:
- charmap->encoding = ft_encoding_adobe_expert;
- charmap->encoding_id = 1;
- break;
-
- default:
- charmap->encoding = ft_encoding_adobe_custom;
- charmap->encoding_id = 2;
- break;
- }
-
- root->charmaps = face->charmaps;
- root->num_charmaps = charmap - face->charmaprecs + 1;
- face->charmaps[0] = &face->charmaprecs[0];
- face->charmaps[1] = &face->charmaprecs[1];
- }
-
- Leave:
- Done_Tokenizer( tokenizer );
-
- Fail:
- return error;
- }
-
-
- /*************************************************************************/
- /* */
- /* <Function> */
- /* T1_Done_GlyphSlot */
- /* */
- /* <Description> */
- /* The glyph slot object destructor. */
- /* */
- /* <Input> */
- /* glyph :: The glyph slot handle to destroy. */
- /* */
- LOCAL_FUNC
- void T1_Done_GlyphSlot( T1_GlyphSlot glyph )
- {
-#ifndef T1_CONFIG_OPTION_DISABLE_HINTER
-
- T1_Done_Glyph_Hinter( glyph );
-
-#else
-
- FT_UNUSED( glyph );
-
-#endif
- }
-
-
- /*************************************************************************/
- /* */
- /* <Function> */
- /* T1_Init_GlyphSlot */
- /* */
- /* <Description> */
- /* The glyph slot object constructor. */
- /* */
- /* <Input> */
- /* glyph :: The glyph slot handle to initialize. */
- /* */
- LOCAL_FUNC
- FT_Error T1_Init_GlyphSlot( T1_GlyphSlot glyph )
- {
- FT_Error error = FT_Err_Ok;
-
-
-#ifndef T1_CONFIG_OPTION_DISABLE_HINTER
-
- error = T1_New_Glyph_Hinter( glyph );
-
-#else
-
- FT_UNUSED( glyph );
-
-#endif
-
- return error;
- }
-
-
-/* END */
diff --git a/src/type1/t1objs.h b/src/type1/t1objs.h
deleted file mode 100644
index 47b0a37..0000000
--- a/src/type1/t1objs.h
+++ /dev/null
@@ -1,172 +0,0 @@
-/***************************************************************************/
-/* */
-/* t1objs.h */
-/* */
-/* Type 1 objects manager (specification). */
-/* */
-/* Copyright 1996-2000 by */
-/* David Turner, Robert Wilhelm, and Werner Lemberg. */
-/* */
-/* This file is part of the FreeType project, and may only be used, */
-/* modified, and distributed under the terms of the FreeType project */
-/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
-/* this file you indicate that you have read the license and */
-/* understand and accept it fully. */
-/* */
-/***************************************************************************/
-
-
-#ifndef T1OBJS_H
-#define T1OBJS_H
-
-#include <freetype/config/ftconfig.h>
-#include <freetype/internal/ftobjs.h>
-#include <freetype/internal/t1types.h>
-
-#include <freetype/internal/t1errors.h>
-
-#ifdef __cplusplus
- extern "C" {
-#endif
-
-
- /* The following structures must be defined by the hinter */
- typedef struct T1_Size_Hints_ T1_Size_Hints;
- typedef struct T1_Glyph_Hints_ T1_Glyph_Hints;
-
-
- /*************************************************************************/
- /* */
- /* <Type> */
- /* T1_Driver */
- /* */
- /* <Description> */
- /* A handle to a Type 1 driver object. */
- /* */
- typedef struct T1_DriverRec_* T1_Driver;
-
-
- /*************************************************************************/
- /* */
- /* <Type> */
- /* T1_Size */
- /* */
- /* <Description> */
- /* A handle to a Type 1 size object. */
- /* */
- typedef struct T1_SizeRec_* T1_Size;
-
-
- /*************************************************************************/
- /* */
- /* <Type> */
- /* T1_GlyphSlot */
- /* */
- /* <Description> */
- /* A handle to a Type 1 glyph slot object. */
- /* */
- typedef struct T1_GlyphSlotRec_* T1_GlyphSlot;
-
-
- /*************************************************************************/
- /* */
- /* <Type> */
- /* T1_CharMap */
- /* */
- /* <Description> */
- /* A handle to a Type 1 character mapping object. */
- /* */
- /* <Note> */
- /* The Type 1 format doesn't use a charmap but an encoding table. */
- /* The driver is responsible for making up charmap objects */
- /* corresponding to these tables. */
- /* */
- typedef struct T1_CharMapRec_* T1_CharMap;
-
-
- /*************************************************************************/
- /* */
- /* HERE BEGINS THE TYPE1 SPECIFIC STUFF */
- /* */
- /*************************************************************************/
-
-
- /*************************************************************************/
- /* */
- /* <Type> */
- /* T1_SizeRec */
- /* */
- /* <Description> */
- /* Type 1 size record. */
- /* */
- typedef struct T1_SizeRec_
- {
- FT_SizeRec root;
- FT_Bool valid;
- T1_Size_Hints* hints; /* defined in the hinter. This allows */
- /* us to experiment with different */
- /* hinting schemes without having to */
- /* change `t1objs' each time. */
- } T1_SizeRec;
-
-
- /*************************************************************************/
- /* */
- /* <Type> */
- /* T1_GlyphSlotRec */
- /* */
- /* <Description> */
- /* Type 1 glyph slot record. */
- /* */
- typedef struct T1_GlyphSlotRec_
- {
- FT_GlyphSlotRec root;
-
- FT_Bool hint;
- FT_Bool scaled;
-
- FT_Int max_points;
- FT_Int max_contours;
-
- FT_Fixed x_scale;
- FT_Fixed y_scale;
-
- T1_Glyph_Hints* hints; /* defined in the hinter */
-
- } T1_GlyphSlotRec;
-
-
- LOCAL_DEF
- FT_Error T1_Init_Face( FT_Stream stream,
- T1_Face face,
- FT_Int face_index,
- FT_Int num_params,
- FT_Parameter* params );
-
- LOCAL_DEF
- void T1_Done_Face( T1_Face face );
-
- LOCAL_DEF
- FT_Error T1_Init_Size( T1_Size size );
-
- LOCAL_DEF
- void T1_Done_Size( T1_Size size );
-
- LOCAL_DEF
- FT_Error T1_Reset_Size( T1_Size size );
-
- LOCAL_DEF
- FT_Error T1_Init_GlyphSlot( T1_GlyphSlot slot );
-
- LOCAL_DEF
- void T1_Done_GlyphSlot( T1_GlyphSlot slot );
-
-
-#ifdef __cplusplus
- }
-#endif
-
-#endif /* T1OBJS_H */
-
-
-/* END */
diff --git a/src/type1/t1parse.c b/src/type1/t1parse.c
deleted file mode 100644
index 8b7ca25..0000000
--- a/src/type1/t1parse.c
+++ /dev/null
@@ -1,761 +0,0 @@
-/***************************************************************************/
-/* */
-/* t1parse.c */
-/* */
-/* Type 1 parser (body). */
-/* */
-/* Copyright 1996-2000 by */
-/* David Turner, Robert Wilhelm, and Werner Lemberg. */
-/* */
-/* This file is part of the FreeType project, and may only be used, */
-/* modified, and distributed under the terms of the FreeType project */
-/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
-/* this file you indicate that you have read the license and */
-/* understand and accept it fully. */
-/* */
-/***************************************************************************/
-
-
-#include <freetype/internal/ftdebug.h>
-#include <freetype/internal/t1types.h>
-
-
-#ifdef FT_FLAT_COMPILE
-
-#include "t1parse.h"
-
-#else
-
-#include <type1/t1parse.h>
-
-#endif
-
-
-#include <stdio.h> /* for sscanf() */
-#include <string.h> /* for strncpy() */
-
-
- /*************************************************************************/
- /* */
- /* <Function> */
- /* T1_New_Table */
- /* */
- /* <Description> */
- /* Initializes a T1_Table structure. */
- /* */
- /* <InOut> */
- /* table :: The address of the target table. */
- /* */
- /* <Input> */
- /* count :: The table size (i.e. maximum number of elements). */
- /* memory :: The memory object to use for all subsequent */
- /* reallocations. */
- /* */
- /* <Return> */
- /* FreeType error code. 0 means success. */
- /* */
- LOCAL_FUNC
- FT_Error T1_New_Table( T1_Table* table,
- FT_Int count,
- FT_Memory memory )
- {
- FT_Error error;
-
-
- table->memory = memory;
-
- if ( ALLOC_ARRAY( table->elements, count, FT_Byte* ) )
- return error;
-
- if ( ALLOC_ARRAY( table->lengths, count, FT_Byte* ) )
- {
- FREE( table->elements );
- return error;
- }
-
- table->max_elems = count;
- table->num_elems = 0;
-
- table->block = 0;
- table->capacity = 0;
- table->cursor = 0;
-
- return error;
- }
-
-
- static
- FT_Error reallocate_t1_table( T1_Table* table,
- FT_Int new_size )
- {
- FT_Memory memory = table->memory;
- FT_Byte* old_base = table->block;
- FT_Error error;
-
-
- /* reallocate the base block */
- if ( REALLOC( table->block, table->capacity, new_size ) )
- return error;
- table->capacity = new_size;
-
- /* shift all offsets if necessary */
- if ( old_base )
- {
- FT_Long delta = table->block - old_base;
- FT_Byte** offset = table->elements;
- FT_Byte** limit = offset + table->max_elems;
-
-
- if ( delta )
- for ( ; offset < limit; offset ++ )
- if (offset[0])
- offset[0] += delta;
- }
-
- return T1_Err_Ok;
- }
-
-
- /*************************************************************************/
- /* */
- /* <Function> */
- /* T1_Add_Table */
- /* */
- /* <Description> */
- /* Adds an object to a T1_Table, possibly growing its memory block. */
- /* */
- /* <InOut> */
- /* table :: The target table. */
- /* */
- /* <Input> */
- /* index :: The index of the object in the table. */
- /* */
- /* object :: The address of the object to copy in memory. */
- /* */
- /* length :: The length in bytes of the source object. */
- /* */
- /* <Return> */
- /* FreeType error code. 0 means success. An error is returned if a */
- /* reallocation failed. */
- /* */
- LOCAL_FUNC
- FT_Error T1_Add_Table( T1_Table* table,
- FT_Int index,
- void* object,
- FT_Int length )
- {
- if ( index < 0 || index > table->max_elems )
- {
- FT_ERROR(( "T1_Add_Table: invalid index\n" ));
- return T1_Err_Syntax_Error;
- }
-
- /* grow the base block if needed */
- if ( table->cursor + length > table->capacity )
- {
- FT_Error error;
- FT_Int new_size = table->capacity;
-
-
- while ( new_size < table->cursor + length )
- new_size += 1024;
-
- error = reallocate_t1_table( table, new_size );
- if ( error )
- return error;
- }
-
- /* add the object to the base block and adjust offset */
- table->elements[index] = table->block + table->cursor;
- table->lengths [index] = length;
- MEM_Copy( table->block + table->cursor, object, length );
-
- table->cursor += length;
-
- return T1_Err_Ok;
- }
-
-
- /*************************************************************************/
- /* */
- /* <Function> */
- /* T1_Done_Table */
- /* */
- /* <Description> */
- /* Finalize a T1_Table (reallocate it to its current cursor). */
- /* */
- /* <Input> */
- /* table :: The target table. */
- /* */
- /* <Note> */
- /* This function does NOT release the heap's memory block. It is up */
- /* to the caller to clean it, or reference it in its own structures. */
- /* */
- LOCAL_FUNC
- void T1_Done_Table( T1_Table* table )
- {
- FT_Memory memory = table->memory;
- FT_Error error;
- FT_Byte* old_base;
-
-
- /* should never fail, as rec.cursor <= rec.size */
- old_base = table->block;
- if ( !old_base )
- return;
-
- (void)REALLOC( table->block, table->capacity, table->cursor );
- table->capacity = table->cursor;
-
- if ( old_base != table->block )
- {
- FT_Long delta = table->block - old_base;
- FT_Byte** element = table->elements;
- FT_Byte** limit = element + table->max_elems;
-
-
- for ( ; element < limit; element++ )
- if ( element[0] )
- element[0] += delta;
- }
- }
-
-
- LOCAL_FUNC
- FT_String* CopyString( T1_Parser* parser )
- {
- FT_String* string = NULL;
- T1_Token* token = parser->args++;
- FT_Memory memory = parser->tokenizer->memory;
- FT_Error error;
-
-
- if ( token->kind == tok_string )
- {
- FT_Int len = token->len - 2;
-
-
- if ( ALLOC( string, len + 1 ) )
- {
- parser->error = error;
- return 0;
- }
-
- MEM_Copy( string, parser->tokenizer->base + token->start + 1, len );
- string[len] = '\0';
-
- parser->error = T1_Err_Ok;
- }
- else
- {
- FT_ERROR(( "T1_CopyString: syntax error, string token expected!\n" ));
- parser->error = T1_Err_Syntax_Error;
- }
-
- return string;
- }
-
-
- static
- FT_Error parse_int( FT_Byte* base,
- FT_Byte* limit,
- FT_Long* result )
- {
- FT_Bool sign = 0;
- FT_Long sum = 0;
-
-
- if ( base >= limit )
- goto Fail;
-
- /* check sign */
- if ( *base == '+' )
- base++;
-
- else if ( *base == '-' )
- {
- sign++;
- base++;
- }
-
- /* parse digits */
- if ( base >= limit )
- goto Fail;
-
- do
- {
- sum = ( 10 * sum + ( *base++ - '0' ) );
-
- } while ( base < limit );
-
- if ( sign )
- sum = -sum;
-
- *result = sum;
- return T1_Err_Ok;
-
- Fail:
- FT_ERROR(( "parse_int: integer expected\n" ));
- *result = 0;
- return T1_Err_Syntax_Error;
- }
-
-
- static
- FT_Error parse_float( FT_Byte* base,
- FT_Byte* limit,
- FT_Long scale,
- FT_Long* result )
- {
-#if 1
-
- /* XXX: We are simply much too lazy to code this function */
- /* properly for now. We will do that when the rest of */
- /* the driver works properly. */
- char temp[32];
- int len = limit - base;
- double value;
-
-
- if ( len > 31 )
- goto Fail;
-
- strncpy( temp, (char*)base, len );
- temp[len] = '\0';
- if ( sscanf( temp, "%lf", &value ) != 1 )
- goto Fail;
-
- *result = (FT_Long)( scale * value );
- return 0;
-
-#else
-
- FT_Byte* cur;
- FT_Bool sign = 0; /* sign */
- FT_Long number_int = 0; /* integer part */
- FT_Long number_frac = 0; /* fractional part */
- FT_Long exponent = 0; /* exponent value */
- FT_Int num_frac = 0; /* number of fractional digits */
-
-
- /* check sign */
- if ( *base == '+' )
- base++;
-
- else if ( *base == '-' )
- {
- sign++;
- base++;
- }
-
- /* find integer part */
- cur = base;
- while ( cur < limit )
- {
- FT_Byte c = *cur;
-
-
- if ( c == '.' || c == 'e' || c == 'E' )
- break;
-
- cur++;
- }
-
- if ( cur > base )
- {
- error = parse_integer( base, cur, &number_int );
- if ( error )
- goto Fail;
- }
-
- /* read fractional part, if any */
- if ( *cur == '.' )
- {
- cur++;
- base = cur;
- while ( cur < limit )
- {
- FT_Byte c = *cur;
-
-
- if ( c == 'e' || c == 'E' )
- break;
- cur++;
- }
-
- num_frac = cur - base;
-
- if ( cur > base )
- {
- error = parse_integer( base, cur, &number_frac );
- if ( error )
- goto Fail;
- base = cur;
- }
- }
-
- /* read exponent, if any */
- if ( *cur == 'e' || *cur == 'E' )
- {
- cur++;
- base = cur;
- error = parse_integer( base, limit, &exponent );
- if ( error )
- goto Fail;
-
- /* now check that exponent is within `correct bounds' */
- /* i.e. between -6 and 6 */
- if ( exponent < -6 || exponent > 6 )
- goto Fail;
- }
-
- /* now adjust integer value and exponent for fractional part */
- while ( num_frac > 0 )
- {
- number_int *= 10;
- exponent--;
- num_frac--;
- }
-
- number_int += num_frac;
-
- /* skip point if any, read fractional part */
- if ( cur + 1 < limit )
- {
- if (*cur..
- }
-
- /* now compute scaled float value */
- /* XXX: incomplete! */
-
-#endif /* 1 */
-
- Fail:
- FT_ERROR(( "parse_float: syntax error!\n" ));
- return T1_Err_Syntax_Error;
- }
-
-
- static
- FT_Error parse_integer( FT_Byte* base,
- FT_Byte* limit,
- FT_Long* result )
- {
- FT_Byte* cur;
-
-
- /* the lexical analyser accepts floats as well as integers */
- /* now; check that we really have an int in this token */
- cur = base;
- while ( cur < limit )
- {
- FT_Byte c = *cur++;
-
-
- if ( c == '.' || c == 'e' || c == 'E' )
- goto Float_Number;
- }
-
- /* now read the number's value */
- return parse_int( base, limit, result );
-
- Float_Number:
- /* we really have a float there; simply call parse_float in this */
- /* case with a scale of `10' to perform round */
- {
- FT_Error error;
-
-
- error = parse_float( base, limit, 10, result );
- if ( !error )
- {
- if ( *result >= 0 )
- *result = ( *result + 5 ) / 10; /* round value */
- else
- *result = -( ( 5 - *result ) / 10 );
- }
- return error;
- }
- }
-
-
- LOCAL_FUNC
- FT_Long CopyInteger( T1_Parser* parser )
- {
- FT_Long sum = 0;
- T1_Token* token = parser->args++;
-
-
- if ( token->kind == tok_number )
- {
- FT_Byte* base = parser->tokenizer->base + token->start;
- FT_Byte* limit = base + token->len;
-
-
- /* now read the number's value */
- parser->error = parse_integer( base, limit, &sum );
- return sum;
- }
-
- FT_ERROR(( "CopyInteger: number expected\n" ));
- parser->args--;
- parser->error = T1_Err_Syntax_Error;
- return 0;
- }
-
-
- LOCAL_FUNC
- FT_Bool CopyBoolean( T1_Parser* parser )
- {
- FT_Error error = T1_Err_Ok;
- FT_Bool result = 0;
- T1_Token* token = parser->args++;
-
-
- if ( token->kind == tok_keyword )
- {
- if ( token->kind2 == key_false )
- result = 0;
-
- else if ( token->kind2 == key_true )
- result = !0;
-
- else
- goto Fail;
- }
- else
- {
- Fail:
- FT_ERROR(( "CopyBoolean:" ));
- FT_ERROR(( " syntax error; `false' or `true' expected\n" ));
- error = T1_Err_Syntax_Error;
- }
- parser->error = error;
- return result;
- }
-
-
- LOCAL_FUNC
- FT_Long CopyFloat( T1_Parser* parser,
- FT_Int scale )
- {
- FT_Error error;
- FT_Long sum = 0;
- T1_Token* token = parser->args++;
-
-
- if ( token->kind == tok_number )
- {
- FT_Byte* base = parser->tokenizer->base + token->start;
- FT_Byte* limit = base + token->len;
-
-
- error = parser->error = parse_float( base, limit, scale, &sum );
- if ( error )
- goto Fail;
-
- return sum;
- }
-
- Fail:
- FT_ERROR(( "CopyFloat: syntax error!\n" ));
- parser->error = T1_Err_Syntax_Error;
- return 0;
- }
-
-
- LOCAL_FUNC
- void CopyBBox( T1_Parser* parser,
- FT_BBox* bbox )
- {
- T1_Token* token = parser->args++;
- FT_Int n;
- FT_Error error;
-
-
- if ( token->kind == tok_program ||
- token->kind == tok_array )
- {
- /* get rid of `['/`]', or `{'/`}' */
- FT_Byte* base = parser->tokenizer->base + token->start + 1;
- FT_Byte* limit = base + token->len - 2;
- FT_Byte* cur;
- FT_Byte* start;
-
-
- /* read each parameter independently */
- cur = base;
- for ( n = 0; n < 4; n++ )
- {
- FT_Long* result;
-
-
- /* skip whitespace */
- while ( cur < limit && *cur == ' ' )
- cur++;
-
- /* skip numbers */
- start = cur;
- while ( cur < limit && *cur != ' ' )
- cur++;
-
- /* compute result address */
- switch ( n )
- {
- case 0:
- result = &bbox->xMin;
- break;
- case 1:
- result = &bbox->yMin;
- break;
- case 2:
- result = &bbox->xMax;
- break;
- default:
- result = &bbox->yMax;
- }
-
- error = parse_integer( start, cur, result );
- if ( error )
- goto Fail;
- }
- parser->error = 0;
- return;
- }
-
- Fail:
- FT_ERROR(( "CopyBBox: syntax error!\n" ));
- parser->error = T1_Err_Syntax_Error;
- }
-
-
- LOCAL_FUNC
- void CopyMatrix( T1_Parser* parser,
- FT_Matrix* matrix )
- {
- T1_Token* token = parser->args++;
- FT_Error error;
-
-
- if ( token->kind == tok_array )
- {
- /* get rid of `[' and `]' */
- FT_Byte* base = parser->tokenizer->base + token->start + 1;
- FT_Byte* limit = base + token->len - 2;
- FT_Byte* cur;
- FT_Byte* start;
- FT_Int n;
-
-
- /* read each parameter independently */
- cur = base;
- for ( n = 0; n < 4; n++ )
- {
- FT_Long* result;
-
-
- /* skip whitespace */
- while ( cur < limit && *cur == ' ' )
- cur++;
-
- /* skip numbers */
- start = cur;
- while ( cur < limit && *cur != ' ')
- cur++;
-
- /* compute result address */
- switch ( n )
- {
- case 0:
- result = &matrix->xx;
- break;
- case 1:
- result = &matrix->yx;
- break;
- case 2:
- result = &matrix->xy;
- break;
- default:
- result = &matrix->yy;
- }
-
- error = parse_float( start, cur, 65536000L, result );
- if ( error )
- goto Fail;
- }
- parser->error = 0;
- return;
- }
-
- Fail:
- FT_ERROR(( "CopyMatrix: syntax error!\n" ));
- parser->error = T1_Err_Syntax_Error;
- }
-
-
- LOCAL_FUNC
- void CopyArray( T1_Parser* parser,
- FT_Byte* num_elements,
- FT_Short* elements,
- FT_Int max_elements )
- {
- T1_Token* token = parser->args++;
- FT_Error error;
-
-
- if ( token->kind == tok_array ||
- token->kind == tok_program ) /* in the case of MinFeature */
- {
- /* get rid of `['/`]', or `{'/`}' */
- FT_Byte* base = parser->tokenizer->base + token->start + 1;
- FT_Byte* limit = base + token->len - 2;
- FT_Byte* cur;
- FT_Byte* start;
- FT_Int n;
-
-
- /* read each parameter independently */
- cur = base;
- for ( n = 0; n < max_elements; n++ )
- {
- FT_Long result;
-
-
- /* test end of string */
- if ( cur >= limit )
- break;
-
- /* skip whitespace */
- while ( cur < limit && *cur == ' ' )
- cur++;
-
- /* end of list? */
- if ( cur >= limit )
- break;
-
- /* skip numbers */
- start = cur;
- while ( cur < limit && *cur != ' ' )
- cur++;
-
- error = parse_integer( start, cur, &result );
- if ( error )
- goto Fail;
-
- *elements++ = (FT_Short)result;
- }
-
- if ( num_elements )
- *num_elements = (FT_Byte)n;
-
- parser->error = 0;
- return;
- }
-
- Fail:
- FT_ERROR(( "CopyArray: syntax error!\n" ));
- parser->error = T1_Err_Syntax_Error;
- }
-
-
-/* END */
diff --git a/src/type1/t1parse.h b/src/type1/t1parse.h
deleted file mode 100644
index 2c42b8c..0000000
--- a/src/type1/t1parse.h
+++ /dev/null
@@ -1,261 +0,0 @@
-/***************************************************************************/
-/* */
-/* t1parse.h */
-/* */
-/* Type 1 parser (specification). */
-/* */
-/* Copyright 1996-2000 by */
-/* David Turner, Robert Wilhelm, and Werner Lemberg. */
-/* */
-/* This file is part of the FreeType project, and may only be used, */
-/* modified, and distributed under the terms of the FreeType project */
-/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
-/* this file you indicate that you have read the license and */
-/* understand and accept it fully. */
-/* */
-/***************************************************************************/
-
-
- /*************************************************************************/
- /* */
- /* The Type1 parser component is in charge of simply parsing the font */
- /* input stream and convert simple tokens and elements into integers, */
- /* floats, matrices, strings, etc. */
- /* */
- /* It is used by the Type1 loader. */
- /* */
- /*************************************************************************/
-
-
-#ifndef T1PARSE_H
-#define T1PARSE_H
-
-#include <freetype/internal/ftstream.h>
-
-
-#ifdef FT_FLAT_COMPILE
-
-#include "t1tokens.h"
-
-#else
-
-#include <type1/t1tokens.h>
-
-#endif
-
-
-#ifdef __cplusplus
- extern "C" {
-#endif
-
-
- /*************************************************************************/
- /* */
- /* <Enum> */
- /* T1_DictState */
- /* */
- /* <Description> */
- /* An enumeration used to describe the Type 1 parser's state, i.e. */
- /* which dictionary (or array) it is scanning and processing at the */
- /* current moment. */
- /* */
- typedef enum T1_DictState_
- {
- dict_none = 0,
- dict_font, /* parsing the font dictionary */
- dict_fontinfo, /* parsing the font info dictionary */
- dict_none2, /* beginning to parse the encrypted section */
- dict_private, /* parsing the private dictionary */
- dict_encoding, /* parsing the encoding array */
- dict_subrs, /* parsing the subrs array */
- dict_othersubrs, /* parsing the othersubrs array (?) */
- dict_charstrings, /* parsing the charstrings dictionary */
- dict_unknown_array, /* parsing/ignoring an unknown array */
- dict_unknown_dict, /* parsing/ignoring an unknown dictionary */
-
- dict_max /* do not remove from list */
-
- } T1_DictState;
-
-
- /*************************************************************************/
- /* */
- /* <Struct> */
- /* T1_Table */
- /* */
- /* <Description> */
- /* A T1_Table is a simple object used to store an array of objects in */
- /* a single memory block. */
- /* */
- /* <Fields> */
- /* block :: The address in memory of the growheap's block. This */
- /* can change between two object adds, due to */
- /* reallocation. */
- /* */
- /* cursor :: The current top of the grow heap within its block. */
- /* */
- /* capacity :: The current size of the heap block. Increments by */
- /* 1kByte chunks. */
- /* */
- /* max_elems :: The maximum number of elements in table. */
- /* */
- /* num_elems :: The current number of elements in table. */
- /* */
- /* elements :: A table of element addresses within the block. */
- /* */
- /* lengths :: A table of element sizes within the block. */
- /* */
- /* memory :: The object used for memory operations */
- /* (alloc/realloc). */
- /* */
- typedef struct T1_Table_
- {
- FT_Byte* block; /* current memory block */
- FT_Int cursor; /* current cursor in memory block */
- FT_Int capacity; /* current size of memory block */
-
- FT_Int max_elems;
- FT_Int num_elems;
- FT_Byte** elements; /* addresses of table elements */
- FT_Int* lengths; /* lengths of table elements */
-
- FT_Memory memory;
-
- } T1_Table;
-
-
- /*************************************************************************/
- /* */
- /* <Struct> */
- /* T1_Parser */
- /* */
- /* <Description> */
- /* A Type 1 parser. This object is in charge of parsing Type 1 ASCII */
- /* streams and builds dictionaries for a T1_Face object. */
- /* */
- /* <Fields> */
- /* error :: The current error code. 0 means success. */
- /* */
- /* face :: The target T1_Face object being built. */
- /* */
- /* tokenizer :: The tokenizer (lexical analyser) used for */
- /* processing the input stream. */
- /* */
- /* dump_tokens :: XXX */
- /* */
- /* stack :: The current token stack. Note that we don't */
- /* use intermediate Postscript objects here! */
- /* */
- /* top :: The current top of token stack. */
- /* */
- /* limit :: The current upper bound of the token stack. */
- /* Used for overflow checks. */
- /* */
- /* args :: The arguments of a given operator. Used and */
- /* increased by the various CopyXXX() functions. */
- /* */
- /* state_index :: The index of the top of the dictionary state */
- /* stack. */
- /* */
- /* state_stack :: The dictionary states stack. */
- /* */
- /* table :: A T1_Table object used to record various kinds */
- /* of dictionaries or arrays (like `/Encoding', */
- /* `/Subrs', `/CharStrings'). */
- /* */
- /* cur_name :: XXX */
- /* */
- /* encoding_type :: XXX */
- /* */
- /* encoding_names :: XXX */
- /* */
- /* encoding_lengths :: XXX */
- /* */
- /* encoding_offsets :: XXX */
- /* */
- /* subrs :: XXX */
- /* */
- /* charstrings :: XXX */
- /* */
- typedef struct T1_Parser_
- {
- FT_Error error;
- T1_Face face;
-
- T1_Tokenizer tokenizer;
- FT_Bool dump_tokens;
-
- T1_Token stack[T1_MAX_STACK_DEPTH];
- T1_Token* top;
- T1_Token* limit;
- T1_Token* args;
-
- FT_Int state_index;
- T1_DictState state_stack[T1_MAX_DICT_DEPTH];
-
- T1_Table table;
-
- FT_Int cur_name;
-
- T1_EncodingType encoding_type;
- FT_Byte* encoding_names;
- FT_Int* encoding_lengths;
- FT_Byte** encoding_offsets;
-
- FT_Byte* subrs;
- FT_Byte* charstrings;
-
- } T1_Parser;
-
-
- LOCAL_DEF
- FT_Error T1_New_Table( T1_Table* table,
- FT_Int count,
- FT_Memory memory );
-
- LOCAL_DEF
- FT_Error T1_Add_Table( T1_Table* table,
- FT_Int index,
- void* object,
- FT_Int length );
-
- LOCAL_DEF
- void T1_Done_Table( T1_Table* table );
-
-
- LOCAL_DEF
- FT_String* CopyString( T1_Parser* parser );
-
- LOCAL_DEF
- FT_Long CopyInteger( T1_Parser* parser );
-
- LOCAL_DEF
- FT_Bool CopyBoolean( T1_Parser* parser );
-
- LOCAL_DEF
- FT_Long CopyFloat( T1_Parser* parser,
- FT_Int scale );
-
- LOCAL_DEF
- void CopyBBox( T1_Parser* parser,
- FT_BBox* bbox );
-
- LOCAL_DEF
- void CopyMatrix( T1_Parser* parser,
- FT_Matrix* matrix );
-
- LOCAL_DEF
- void CopyArray( T1_Parser* parser,
- FT_Byte* num_elements,
- FT_Short* elements,
- FT_Int max_elements );
-
-
-#ifdef __cplusplus
- }
-#endif
-
-#endif /* T1PARSE_H */
-
-
-/* END */
diff --git a/src/type1/t1tokens.c b/src/type1/t1tokens.c
deleted file mode 100644
index 2953322..0000000
--- a/src/type1/t1tokens.c
+++ /dev/null
@@ -1,1101 +0,0 @@
-/***************************************************************************/
-/* */
-/* t1parse.c */
-/* */
-/* Type 1 parser (body). */
-/* */
-/* Copyright 1996-2000 by */
-/* David Turner, Robert Wilhelm, and Werner Lemberg. */
-/* */
-/* This file is part of the FreeType project, and may only be used, */
-/* modified, and distributed under the terms of the FreeType project */
-/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
-/* this file you indicate that you have read the license and */
-/* understand and accept it fully. */
-/* */
-/***************************************************************************/
-
-
- /*************************************************************************/
- /* */
- /* The tokenizer is in charge of loading and reading a Type1 font file */
- /* (either in PFB or PFA format), and extracting successive tokens and */
- /* keywords from its two streams (i.e. the font program, and the private */
- /* dictionary). */
- /* */
- /* Eexec decryption is performed automatically when entering the private */
- /* dictionary, or when retrieving char strings. */
- /* */
- /*************************************************************************/
-
-
-#include <freetype/internal/ftstream.h>
-#include <freetype/internal/ftdebug.h>
-
-
-#ifdef FT_FLAT_COMPILE
-
-#include "t1tokens.h"
-#include "t1load.h"
-
-#else
-
-#include <type1/t1tokens.h>
-#include <type1/t1load.h>
-
-#endif
-
-
-#include <string.h> /* for strncmp() */
-
-
-#undef READ_BUFFER_INCREMENT
-#define READ_BUFFER_INCREMENT 0x400
-
-
- /*************************************************************************/
- /* */
- /* The macro FT_COMPONENT is used in trace mode. It is an implicit */
- /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */
- /* messages during execution. */
- /* */
-#undef FT_COMPONENT
-#define FT_COMPONENT trace_t1load
-
-
- /* An array of Type1 keywords supported by this engine. This table */
- /* places the keyword in lexicographical order. It should always */
- /* correspond to the enums `key_xxx'! */
- /* */
- const char* t1_keywords[key_max - key_first_] =
- {
- "-|", "ExpertEncoding", "ND", "NP", "RD", "StandardEncoding", "array",
- "begin", "closefile", "currentdict", "currentfile", "def", "dict", "dup",
- "eexec", "end", "executeonly", "false", "for", "index", "noaccess",
- "put", "readonly", "true", "userdict", "|", "|-"
- };
-
-
- const char* t1_immediates[imm_max - imm_first_] =
- {
- "-|", ".notdef", "BlendAxisTypes", "BlueFuzz", "BlueScale", "BlueShift",
- "BlueValues", "CharStrings", "Encoding", "FamilyBlues", "FamilyName",
- "FamilyOtherBlues", "FID", "FontBBox", "FontID", "FontInfo", "FontMatrix",
- "FontName", "FontType", "ForceBold", "FullName", "ItalicAngle",
- "LanguageGroup", "Metrics", "MinFeature", "ND", "NP", "Notice",
- "OtherBlues", "OtherSubrs", "PaintType", "Private", "RD", "RndStemUp",
- "StdHW", "StdVW", "StemSnapH", "StemSnapV", "StrokeWidth", "Subrs",
- "UnderlinePosition", "UnderlineThickness", "UniqueID", "Weight",
- "isFixedPitch", "lenIV", "password", "version", "|", "|-"
- };
-
-
- /* lexicographic comparison of two strings */
- static
- int lexico_strcmp( const char* str1,
- int str1_len,
- const char* str2 )
- {
- int c2 = 0;
-
-
- for ( ; str1_len > 0; str1_len-- )
- {
- int c1, diff;
-
-
- c1 = *str1++;
- c2 = *str2++;
-
- diff = c1 - c2;
- if ( diff )
- return diff;
- };
-
- return -*str2;
- }
-
-
- /* find a given token/name, performing binary search */
- static
- int Find_Name( char* base,
- int length,
- const char** table,
- int table_len )
- {
- int left, right;
-
-
- left = 0;
- right = table_len - 1;
-
- while ( right - left > 1 )
- {
- int middle = left + ( ( right - left ) >> 1 );
- int cmp;
-
-
- cmp = lexico_strcmp( base, length, table[middle] );
- if ( !cmp )
- return middle;
-
- if ( cmp < 0 )
- right = middle;
- else
- left = middle;
- }
-
- if ( !lexico_strcmp( base, length, table[left ] ) )
- return left;
- if ( !lexico_strcmp( base, length, table[right] ) )
- return right;
-
- return -1;
- }
-
-
- /* read the small PFB section header */
- static
- FT_Error Read_PFB_Tag( FT_Stream stream,
- FT_UShort* atag,
- FT_ULong* asize )
- {
- FT_UShort tag;
- FT_ULong size;
- FT_Error error;
-
-
- FT_TRACE2(( "Read_PFB_Tag: reading\n" ));
-
- if ( ACCESS_Frame( 6L ) )
- return error;
-
- tag = GET_UShort();
- size = GET_ULong();
-
- FORGET_Frame();
-
- *atag = tag;
- *asize = ( ( size & 0xFF ) << 24 ) |
- ( ( ( size >> 8 ) & 0xFF ) << 16 ) |
- ( ( ( size >> 16 ) & 0xFF ) << 8 ) |
- ( ( ( size >> 24 ) & 0xFF ) );
-
- FT_TRACE2(( " tag = %04x\n", tag ));
- FT_TRACE4(( " asze = %08x\n", size ));
- FT_TRACE2(( " size = %08x\n", *asize ));
-
- return T1_Err_Ok;
- }
-
-
- static
- FT_Error grow( T1_Tokenizer tokzer )
- {
- FT_Error error;
- FT_Long left_bytes;
- FT_Memory memory = tokzer->memory;
-
-
- left_bytes = tokzer->max - tokzer->limit;
-
- if ( left_bytes > 0 )
- {
- FT_Stream stream = tokzer->stream;
-
-
- if ( left_bytes > READ_BUFFER_INCREMENT )
- left_bytes = READ_BUFFER_INCREMENT;
-
- FT_TRACE2(( "Growing tokenizer buffer by %d bytes\n", left_bytes ));
-
- if ( !REALLOC( tokzer->base, tokzer->limit,
- tokzer->limit + left_bytes ) &&
- !FILE_Read( tokzer->base + tokzer->limit, left_bytes ) )
- tokzer->limit += left_bytes;
- }
- else
- {
- FT_ERROR(( "Unexpected end of Type1 fragment!\n" ));
- error = T1_Err_Invalid_File_Format;
- }
-
- tokzer->error = error;
- return error;
- }
-
-
- /*************************************************************************/
- /* */
- /* <Function> */
- /* t1_decrypt */
- /* */
- /* <Description> */
- /* Performs the Type 1 charstring decryption process. */
- /* */
- /* <Input> */
- /* buffer :: The base address of the data to decrypt. */
- /* length :: The number of bytes to decrypt (beginning from the base */
- /* address. */
- /* seed :: The encryption seed (4330 for charstrings). */
- /* */
- LOCAL_FUNC
- void t1_decrypt( FT_Byte* buffer,
- FT_Int length,
- FT_UShort seed )
- {
- while ( length > 0 )
- {
- FT_Byte plain;
-
-
- plain = ( *buffer ^ ( seed >> 8 ) );
- seed = ( *buffer + seed ) * 52845 + 22719;
- *buffer++ = plain;
- length--;
- }
- }
-
-
- /*************************************************************************/
- /* */
- /* <Function> */
- /* New_Tokenizer */
- /* */
- /* <Description> */
- /* Creates a new tokenizer from a given input stream. This function */
- /* automatically recognizes `pfa' or `pfb' files. The function */
- /* Read_Token() can then be used to extract successive tokens from */
- /* the stream. */
- /* */
- /* <Input> */
- /* stream :: The input stream. */
- /* */
- /* <Output> */
- /* tokenizer :: A handle to a new tokenizer object. */
- /* */
- /* <Return> */
- /* FreeType error code. 0 means success. */
- /* */
- /* <Note> */
- /* This function copies the stream handle within the object. Callers */
- /* should not discard `stream'. This is done by the Done_Tokenizer() */
- /* function. */
- /* */
- LOCAL_FUNC
- FT_Error New_Tokenizer( FT_Stream stream,
- T1_Tokenizer* tokenizer )
- {
- FT_Memory memory = stream->memory;
- T1_Tokenizer tokzer;
- FT_Error error;
- FT_UShort tag;
- FT_ULong size;
-
- FT_Byte* tok_base;
- FT_ULong tok_limit;
- FT_ULong tok_max;
-
-
- *tokenizer = 0;
-
- /* allocate object */
- if ( FILE_Seek( 0L ) ||
- ALLOC( tokzer, sizeof ( *tokzer ) ) )
- return error;
-
- tokzer->stream = stream;
- tokzer->memory = stream->memory;
-
- tokzer->in_pfb = 0;
- tokzer->in_private = 0;
-
- tok_base = 0;
- tok_limit = 0;
- tok_max = stream->size;
-
- error = Read_PFB_Tag( stream, &tag, &size );
- if ( error )
- goto Fail;
-
- if ( tag != 0x8001 )
- {
- /* assume that it is a PFA file -- an error will be produced later */
- /* if a character with value > 127 is encountered */
-
- /* rewind to start of file */
- if ( FILE_Seek( 0L ) )
- goto Fail;
-
- size = stream->size;
- }
- else
- tokzer->in_pfb = 1;
-
- /* if it is a memory-based resource, set up pointer */
- if ( !stream->read )
- {
- tok_base = (FT_Byte*)stream->base + stream->pos;
- tok_limit = size;
- tok_max = size;
-
- /* check that the `size' field is valid */
- if ( FILE_Skip( size ) )
- goto Fail;
- }
- else if ( tag == 0x8001 )
- {
- /* read segment in memory */
- if ( ALLOC( tok_base, size ) )
- goto Fail;
-
- if ( FILE_Read( tok_base, size ) )
- {
- FREE( tok_base );
- goto Fail;
- }
-
- tok_limit = size;
- tok_max = size;
- }
-
- tokzer->base = tok_base;
- tokzer->limit = tok_limit;
- tokzer->max = tok_max;
- tokzer->cursor = 0;
-
- *tokenizer = tokzer;
-
- /* now check font format; we must see `%!PS-AdobeFont-1' */
- /* or `%!FontType' */
- {
- if ( 16 > tokzer->limit )
- grow( tokzer );
-
- if ( tokzer->limit <= 16 ||
- ( strncmp( (const char*)tokzer->base, "%!PS-AdobeFont-1", 16 ) &&
- strncmp( (const char*)tokzer->base, "%!FontType", 10 ) ) )
- {
- FT_TRACE2(( "[not a Type1 font]\n" ));
- error = FT_Err_Unknown_File_Format;
- goto Fail;
- }
- }
- return T1_Err_Ok;
-
- Fail:
- FREE( tokzer->base );
- FREE( tokzer );
- return error;
- }
-
-
- /* return the value of an hexadecimal digit */
- static
- int hexa_value( char c )
- {
- unsigned int d;
-
-
- d = (unsigned int)( c - '0' );
- if ( d <= 9 )
- return (int)d;
-
- d = (unsigned int)( c - 'a' );
- if ( d <= 5 )
- return (int)( d + 10 );
-
- d = (unsigned int)( c - 'A' );
- if ( d <= 5 )
- return (int)( d + 10 );
-
- return -1;
- }
-
-
- /*************************************************************************/
- /* */
- /* <Function> */
- /* Done_Tokenizer */
- /* */
- /* <Description> */
- /* Closes a given tokenizer. This function will also close the */
- /* stream embedded in the object. */
- /* */
- /* <Input> */
- /* tokenizer :: The target tokenizer object. */
- /* */
- /* <Return> */
- /* FreeType error code. 0 means success. */
- /* */
- LOCAL_FUNC
- FT_Error Done_Tokenizer( T1_Tokenizer tokenizer )
- {
- FT_Memory memory = tokenizer->memory;
-
-
- /* clear read buffer if needed (disk-based resources) */
- if ( tokenizer->in_private || !tokenizer->stream->base )
- FREE( tokenizer->base );
-
- FREE( tokenizer );
- return T1_Err_Ok;
- }
-
-
- /*************************************************************************/
- /* */
- /* <Function> */
- /* Open_PrivateDict */
- /* */
- /* <Description> */
- /* This function must be called to set the tokenizer to the private */
- /* section of the Type1 file. It recognizes automatically the */
- /* the kind of eexec encryption used (ascii or binary). */
- /* */
- /* <Input> */
- /* tokenizer :: The target tokenizer object. */
- /* lenIV :: The value of the `lenIV' variable. */
- /* */
- /* <Return> */
- /* FreeType error code. 0 means success. */
- /* */
- LOCAL_FUNC
- FT_Error Open_PrivateDict( T1_Tokenizer tokenizer )
- {
- T1_Tokenizer tokzer = tokenizer;
- FT_Stream stream = tokzer->stream;
- FT_Memory memory = tokzer->memory;
- FT_Error error = 0;
-
- FT_UShort tag;
- FT_ULong size;
-
- FT_Byte* private_dict;
-
- /* are we already in the private dictionary ? */
- if ( tokzer->in_private )
- return 0;
-
- if ( tokzer->in_pfb )
- {
- /* in the case of the PFB format, the private dictionary can be */
- /* made of several segments. We thus first read the number of */
- /* segments to compute the total size of the private dictionary */
- /* then re-read them into memory. */
- FT_Long start_pos = FILE_Pos();
- FT_ULong private_dict_size = 0;
-
-
- for (;;)
- {
- error = Read_PFB_Tag( stream, &tag, &size );
- if ( error || tag != 0x8002 )
- break;
-
- private_dict_size += size;
-
- if ( FILE_Skip( size ) )
- goto Fail;
- }
-
- /* check that we have a private dictionary there */
- /* and allocate private dictionary buffer */
- if ( private_dict_size == 0 )
- {
- FT_ERROR(( "Open_PrivateDict:" ));
- FT_ERROR(( " invalid private dictionary section\n" ));
- error = T1_Err_Invalid_File_Format;
- goto Fail;
- }
-
- if ( ALLOC( private_dict, private_dict_size ) )
- goto Fail;
-
- /* read all sections into buffer */
- if ( FILE_Seek( start_pos ) )
- goto Fail_Private;
-
- private_dict_size = 0;
- for (;;)
- {
- error = Read_PFB_Tag( stream, &tag, &size );
- if ( error || tag != 0x8002 )
- {
- error = 0;
- break;
- }
-
- if ( FILE_Read( private_dict + private_dict_size, size ) )
- goto Fail_Private;
-
- private_dict_size += size;
- }
-
- /* we must free the field `tokzer.base' if we are in a disk-based */
- /* PFB file. */
- if ( stream->read )
- FREE( tokzer->base );
-
- tokzer->base = private_dict;
- tokzer->cursor = 0;
- tokzer->limit = private_dict_size;
- tokzer->max = private_dict_size;
- }
- else
- {
- char* base;
-
-
- /* we are in a PFA file; read each token until we find `eexec' */
- while ( tokzer->token.kind2 != key_eexec )
- {
- error = Read_Token( tokzer );
- if ( error )
- goto Fail;
- }
-
- /* now determine whether the private dictionary is encoded in binary */
- /* or hexadecimal ASCII format. */
-
- /* we need to access the next 4 bytes (after the final \r following */
- /* the `eexec' keyword); if they all are hexadecimal digits, then */
- /* we have a case of ASCII storage. */
- while ( tokzer->cursor + 5 > tokzer->limit )
- {
- error = grow( tokzer );
- if ( error )
- goto Fail;
- }
-
- /* skip whitespace/line feed after `eexec' */
- base = (char*)tokzer->base + tokzer->cursor + 1;
- if ( ( hexa_value( base[0] ) | hexa_value( base[1] ) |
- hexa_value( base[2] ) | hexa_value( base[3] ) ) < 0 )
- {
- /* binary encoding -- `simply' read the stream */
-
- /* if it is a memory-based resource, we need to allocate a new */
- /* storage buffer for the private dictionary, as it must be */
- /* decrypted later */
- if ( stream->base )
- {
- size = stream->size - tokzer->cursor - 1; /* remaining bytes */
-
- if ( ALLOC( private_dict, size ) ) /* alloc private dict buffer */
- goto Fail;
-
- /* copy eexec-encrypted bytes */
- MEM_Copy( private_dict, tokzer->base + tokzer->cursor + 1, size );
-
- /* reset pointers - forget about file mapping */
- tokzer->base = private_dict;
- tokzer->limit = size;
- tokzer->max = size;
- tokzer->cursor = 0;
- }
- /* On the opposite, for disk based resources, we simply grow */
- /* the current buffer until its completion, and decrypt the */
- /* bytes within it. In all cases, the `base' buffer will be */
- /* discarded on DoneTokenizer if we are in the private dict. */
- else
- {
- /* grow the read buffer to the full file */
- while ( tokzer->limit < tokzer->max )
- {
- error = grow( tokenizer );
- if ( error )
- goto Fail;
- }
-
- /* set up cursor to first encrypted byte */
- tokzer->cursor++;
- }
- }
- else
- {
- /* ASCII hexadecimal encoding. This sucks... */
- FT_Byte* write;
- FT_Byte* cur;
- FT_Byte* limit;
- FT_Int count;
-
-
- /* allocate a buffer, read each one byte at a time */
- count = stream->size - tokzer->cursor;
- size = count / 2;
-
- if ( ALLOC( private_dict, size ) ) /* alloc private dict buffer */
- goto Fail;
-
- write = private_dict;
- cur = tokzer->base + tokzer->cursor;
- limit = tokzer->base + tokzer->limit;
-
- /* read each bytes */
- while ( count > 0 )
- {
- /* ensure that we can read the next 2 bytes! */
- while ( cur + 2 > limit )
- {
- int cursor = cur - tokzer->base;
-
-
- error = grow( tokzer );
- if ( error )
- goto Fail_Private;
- cur = tokzer->base + cursor;
- limit = tokzer->base + tokzer->limit;
- }
-
- /* check for new line */
- if ( cur[0] == '\r' || cur[0] == '\n' )
- {
- cur++;
- count--;
- }
- else
- {
- int hex1 = hexa_value(cur[0]);
-
-
- /* exit if we have a non-hexadecimal digit which isn't */
- /* a new-line character */
- if ( hex1 < 0 )
- break;
-
- /* otherwise, store byte */
- *write++ = ( hex1 << 4 ) | hexa_value( cur[1] );
- cur += 2;
- count -= 2;
- }
- }
-
- /* get rid of old buffer in the case of disk-based resources */
- if ( !stream->base )
- FREE( tokzer->base );
-
- /* set up pointers */
- tokzer->base = private_dict;
- tokzer->limit = size;
- tokzer->max = size;
- tokzer->cursor = 0;
- }
- }
-
- /* finally, decrypt the private dictionary - and skip the lenIV bytes */
- t1_decrypt( tokzer->base, tokzer->limit, 55665 );
- tokzer->cursor += 4;
-
- Fail:
- return error;
-
- Fail_Private:
- FREE( private_dict );
- goto Fail;
- }
-
-
- /*************************************************************************/
- /* */
- /* <Function> */
- /* Read_Token */
- /* */
- /* <Description> */
- /* Reads a new token from the current input stream. This function */
- /* extracts a token from the font program until Open_PrivateDict() */
- /* has been called. After this, it returns tokens from the */
- /* (eexec-encrypted) private dictionary. */
- /* */
- /* <Input> */
- /* tokenizer :: The target tokenizer object. */
- /* */
- /* <Return> */
- /* FreeType error code. 0 means success. */
- /* */
- /* <Note> */
- /* Use the function Read_CharStrings() to read the binary charstrings */
- /* from the private dict. */
- /* */
- LOCAL_FUNC
- FT_Error Read_Token( T1_Tokenizer tokenizer )
- {
- T1_Tokenizer tok = tokenizer;
- FT_Long cur, limit;
- FT_Byte* base;
- char c, starter, ender;
- FT_Bool token_started;
-
- T1_TokenType kind;
-
-
- tok->error = T1_Err_Ok;
- tok->token.kind = tok_any;
-
- base = tok->base;
- limit = tok->limit;
- cur = tok->cursor;
-
- token_started = 0;
-
- for (;;)
- {
- if ( cur >= limit )
- {
- if ( grow( tok ) )
- goto Exit;
- base = tok->base;
- limit = tok->limit;
- }
-
- c = (char)base[cur++];
-
- /* check that we have an ASCII character */
- if ( (FT_Byte)c > 127 )
- {
- FT_ERROR(( "Read_Token:" ));
- FT_ERROR(( " unexpected binary data in Type1 fragment!\n" ));
- tok->error = T1_Err_Invalid_File_Format;
- goto Exit;
- }
-
- switch ( c )
- {
- case '\r':
- case '\n':
- case ' ' :
- case '\t': /* skip initial whitespace => skip to next */
- if ( token_started )
- {
- /* possibly a name, keyword, wathever */
- tok->token.kind = tok_any;
- tok->token.len = cur-tok->token.start - 1;
- goto Exit;
- }
- /* otherwise, skip everything */
- break;
-
- case '%': /* this is a comment -- skip everything */
- for (;;)
- {
- FT_Int left = limit - cur;
-
-
- while ( left > 0 )
- {
- c = (char)base[cur++];
- if ( c == '\r' || c == '\n' )
- goto Next;
- left--;
- }
-
- if ( grow( tokenizer ) )
- goto Exit;
- base = tok->base;
- limit = tok->limit;
- }
-
- case '(': /* a Postscript string */
- kind = tok_string;
- ender = ')';
-
- L1:
- if ( !token_started )
- {
- token_started = 1;
- tok->token.start = cur - 1;
- }
-
- {
- FT_Int nest_level = 1;
-
-
- starter = c;
- for (;;)
- {
- FT_Int left = limit - cur;
-
-
- while ( left > 0 )
- {
- c = (char)base[cur++];
-
- if ( c == starter )
- nest_level++;
-
- else if ( c == ender )
- {
- nest_level--;
- if ( nest_level <= 0 )
- {
- tok->token.kind = kind;
- tok->token.len = cur - tok->token.start;
- goto Exit;
- }
- }
- left--;
- }
-
- if ( grow( tok ) )
- goto Exit;
- base = tok->base;
- limit = tok->limit;
- }
- }
-
- case '[': /* a Postscript array */
- if ( token_started )
- goto Any_Token;
-
- kind = tok_array;
- ender = ']';
- goto L1;
- break;
-
- case '{': /* a Postscript program */
- if ( token_started )
- goto Any_Token;
-
- kind = tok_program;
- ender = '}';
- goto L1;
- break;
-
- case '<': /* a Postscript hex byte array? */
- if ( token_started )
- goto Any_Token;
-
- kind = tok_hexarray;
- ender = '>';
- goto L1;
- break;
-
- case '0': /* any number */
- case '1':
- case '2':
- case '3':
- case '4':
- case '5':
- case '6':
- case '7':
- case '8':
- case '9':
- if ( token_started )
- goto Next;
-
- tok->token.kind = tok_number;
- token_started = 1;
- tok->token.start = cur - 1;
-
- L2:
- for (;;)
- {
- FT_Int left = limit-cur;
-
-
- while ( left > 0 )
- {
- c = (char)base[cur++];
-
- switch ( c )
- {
- case '[': /* ] */
- case '{': /* } */
- case '(': /* ) */
- case '<':
- case '/':
- goto Any_Token;
-
- case ' ':
- case '\r':
- case '\t':
- case '\n':
- tok->token.len = cur - tok->token.start - 1;
- goto Exit;
-
- default:
- ;
- }
- left--;
- }
-
- if ( grow( tok ) )
- goto Exit;
- base = tok->base;
- limit = tok->limit;
- }
-
- case '.': /* maybe a number */
- case '-':
- case '+':
- if ( token_started )
- goto Next;
-
- token_started = 1;
- tok->token.start = cur - 1;
-
- for (;;)
- {
- FT_Int left = limit - cur;
-
-
- if ( left > 0 )
- {
- /* test for any following digit, interpreted as number */
- c = (char)base[cur];
- tok->token.kind = ( c >= '0' && c <= '9' ? tok_number : tok_any );
- goto L2;
- }
-
- if ( grow( tok ) )
- goto Exit;
- base = tok->base;
- limit = tok->limit;
- }
-
- case '/': /* maybe an immediate name */
- if ( !token_started )
- {
- token_started = 1;
- tok->token.start = cur - 1;
-
- for (;;)
- {
- FT_Int left = limit - cur;
-
-
- if ( left > 0 )
- {
- /* test for single '/', interpreted as garbage */
- c = (char)base[cur];
- tok->token.kind = ( c == ' ' || c == '\t' ||
- c == '\r' || c == '\n' ) ? tok_any
- : tok_immediate;
- goto L2;
- }
-
- if ( grow( tok ) )
- goto Exit;
- base = tok->base;
- limit = tok->limit;
- }
- }
- else
- {
- Any_Token: /* possibly a name or wathever */
- cur--;
- tok->token.len = cur - tok->token.start;
- goto Exit;
- }
-
- default:
- if ( !token_started )
- {
- token_started = 1;
- tok->token.start = cur - 1;
- }
- }
-
- Next:
- ;
- }
-
- Exit:
- tok->cursor = cur;
-
- if ( !tok->error )
- {
- /* now, tries to match keywords and immediate names */
- FT_Int index;
-
-
- switch ( tok->token.kind )
- {
- case tok_immediate: /* immediate name */
- index = Find_Name( (char*)( tok->base + tok->token.start + 1 ),
- tok->token.len - 1,
- t1_immediates,
- imm_max - imm_first_ );
- tok->token.kind2 = ( index >= 0 )
- ? (T1_TokenType)( imm_first_ + index )
- : tok_error;
- break;
-
- case tok_any: /* test for keyword */
- index = Find_Name( (char*)( tok->base + tok->token.start ),
- tok->token.len,
- t1_keywords,
- key_max - key_first_ );
- if ( index >= 0 )
- {
- tok->token.kind = tok_keyword;
- tok->token.kind2 = (T1_TokenType)( key_first_ + index );
- }
- else
- tok->token.kind2 = tok_error;
- break;
-
- default:
- tok->token.kind2 = tok_error;
- }
- }
- return tokenizer->error;
- }
-
-
-#if 0
-
- /*************************************************************************/
- /* */
- /* <Function> */
- /* Read_CharStrings */
- /* */
- /* <Description> */
- /* Reads a charstrings element from the current input stream. These */
- /* are binary bytes that encode each individual glyph outline. */
- /* */
- /* The caller is responsible for skipping the `lenIV' bytes at the */
- /* start of the record. */
- /* */
- /* <Input> */
- /* tokenizer :: The target tokenizer object. */
- /* num_chars :: The number of binary bytes to read. */
- /* */
- /* <Output> */
- /* buffer :: The target array of bytes. These are */
- /* eexec-decrypted. */
- /* */
- /* <Return> */
- /* FreeType error code. 0 means success. */
- /* */
- /* <Note> */
- /* Use the function Read_CharStrings() to read binary charstrings */
- /* from the private dict. */
- /* */
- LOCAL_FUNC
- FT_Error Read_CharStrings( T1_Tokenizer tokenizer,
- FT_Int num_chars,
- FT_Byte* buffer )
- {
- for (;;)
- {
- FT_Int left = tokenizer->limit - tokenizer->cursor;
-
-
- if ( left >= num_chars )
- {
- MEM_Copy( buffer, tokenizer->base + tokenizer->cursor, num_chars );
- t1_decrypt( buffer, num_chars, 4330 );
- tokenizer->cursor += num_chars;
- return T1_Err_Ok;
- }
-
- if ( grow( tokenizer ) )
- return tokenizer->error;
- }
- }
-
-#endif /* 0 */
-
-
-/* END */
diff --git a/src/type1/t1tokens.h b/src/type1/t1tokens.h
deleted file mode 100644
index 119c54b..0000000
--- a/src/type1/t1tokens.h
+++ /dev/null
@@ -1,258 +0,0 @@
-/***************************************************************************/
-/* */
-/* t1tokens.h */
-/* */
-/* Type 1 tokenizer (specification). */
-/* */
-/* Copyright 1996-2000 by */
-/* David Turner, Robert Wilhelm, and Werner Lemberg. */
-/* */
-/* This file is part of the FreeType project, and may only be used, */
-/* modified, and distributed under the terms of the FreeType project */
-/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
-/* this file you indicate that you have read the license and */
-/* understand and accept it fully. */
-/* */
-/***************************************************************************/
-
-
-#ifndef T1TOKENS_H
-#define T1TOKENS_H
-
-
-#ifdef FT_FLAT_COMPILE
-
-#include "t1objs.h"
-
-#else
-
-#include <type1/t1objs.h>
-
-#endif
-
-
-#ifdef __cplusplus
- extern "C" {
-#endif
-
-
- /* enum value of first keyword */
-#define key_first_ 100
-
- /* enum value of first immediate name */
-#define imm_first_ 200
-
-
- typedef enum T1_TokenType_
- {
- tok_error = 0,
-
- tok_eof, /* end of file */
-
- /* simple token types */
-
- tok_keyword, /* keyword */
- tok_number, /* number (integer or real) */
- tok_string, /* postscript string */
- tok_program, /* postscript program */
- tok_immediate, /* any immediate name */
- tok_array, /* matrix, array, etc.. */
- tok_hexarray, /* array of hexadecimal nibbles */
- tok_any, /* anything else */
-
- /* Postscript keywords -- placed in lexicographical order */
-
- key_RD_alternate = key_first_, /* `-|' = alternate form of RD */
- key_ExpertEncoding,
- key_ND,
- key_NP,
- key_RD,
- key_StandardEncoding,
- key_array,
- key_begin,
- key_closefile,
- key_currentdict,
- key_currentfile,
- key_def,
- key_dict,
- key_dup,
- key_eexec,
- key_end,
- key_execonly,
- key_false,
- key_for,
- key_index,
- key_noaccess,
- key_put,
- key_readonly,
- key_true,
- key_userdict,
- key_NP_alternate, /* `|' = alternate form of NP */
- key_ND_alternate, /* `|-' = alternate form of ND */
-
- key_max, /* always keep this value there */
-
- /* Postscript immediate names -- other names will be ignored, except */
- /* in charstrings */
-
- imm_RD_alternate = imm_first_, /* `-|' = alternate form of RD */
- imm_notdef, /* `/.notdef' immediate */
- imm_BlendAxisTypes,
- imm_BlueFuzz,
- imm_BlueScale,
- imm_BlueShift,
- imm_BlueValues,
- imm_CharStrings,
- imm_Encoding,
- imm_FamilyBlues,
- imm_FamilyName,
- imm_FamilyOtherBlues,
- imm_FID,
- imm_FontBBox,
- imm_FontID,
- imm_FontInfo,
- imm_FontMatrix,
- imm_FontName,
- imm_FontType,
- imm_ForceBold,
- imm_FullName,
- imm_ItalicAngle,
- imm_LanguageGroup,
- imm_Metrics,
- imm_MinFeature,
- imm_ND,
- imm_NP,
- imm_Notice,
- imm_OtherBlues,
- imm_OtherSubrs,
- imm_PaintType,
- imm_Private,
- imm_RD,
- imm_RndStemUp,
- imm_StdHW,
- imm_StdVW,
- imm_StemSnapH,
- imm_StemSnapV,
- imm_StrokeWidth,
- imm_Subrs,
- imm_UnderlinePosition,
- imm_UnderlineThickness,
- imm_UniqueID,
- imm_Weight,
-
- imm_isFixedPitch,
- imm_lenIV,
- imm_password,
- imm_version,
-
- imm_NP_alternate, /* `|' = alternate form of NP */
- imm_ND_alternate, /* `|-' = alternate form of ND */
-
- imm_max /* always keep this value here */
-
- } T1_TokenType;
-
-
- /* these arrays are visible for debugging purposes */
- extern const char* t1_keywords[];
- extern const char* t1_immediates[];
-
-
- /*************************************************************************/
- /* */
- /* <Struct> */
- /* T1_Token */
- /* */
- /* <Description> */
- /* A structure used to describe a token in the current input stream. */
- /* Note that the Type1 driver doesn't try to interpret tokens until */
- /* it really needs to. */
- /* */
- /* <Fields> */
- /* kind :: The token type. Describes the token to the loader. */
- /* */
- /* kind2 :: Detailed token type. */
- /* */
- /* start :: The index of the first character of token in the input */
- /* stream. */
- /* */
- /* len :: The length of the token in characters. */
- /* */
- typedef struct T1_Token_
- {
- T1_TokenType kind; /* simple type */
- T1_TokenType kind2; /* detailed type */
- FT_Int start; /* index of first token character */
- FT_Int len; /* length of token in chars */
-
- } T1_Token;
-
-
- typedef struct T1_TokenParser_
- {
- FT_Memory memory;
- FT_Stream stream;
-
- FT_Bool in_pfb; /* true if PFB file, PFA otherwise */
- FT_Bool in_private; /* true if in private dictionary */
-
- FT_Byte* base; /* base address of current read buffer */
- FT_Long cursor; /* current position in read buffer */
- FT_Long limit; /* limit of current read buffer */
- FT_Long max; /* maximum size of read buffer */
-
- FT_Error error; /* last error */
- T1_Token token; /* last token read */
-
- } T1_TokenParser;
-
-
- /*************************************************************************/
- /* */
- /* <Type> */
- /* T1_Tokenizer */
- /* */
- /* <Description> */
- /* A handle to an object used to extract tokens from the input. The */
- /* object is able to perform PFA/PFB recognition, eexec decryption of */
- /* the private dictionary, as well as eexec decryption of the */
- /* charstrings. */
- /* */
- typedef T1_TokenParser* T1_Tokenizer;
-
-
- LOCAL_DEF
- FT_Error New_Tokenizer( FT_Stream stream,
- T1_Tokenizer* tokenizer );
-
- LOCAL_DEF
- FT_Error Done_Tokenizer( T1_Tokenizer tokenizer );
-
- LOCAL_DEF
- FT_Error Open_PrivateDict( T1_Tokenizer tokenizer );
-
- LOCAL_DEF
- FT_Error Read_Token( T1_Tokenizer tokenizer );
-
-
-#if 0
- LOCAL_DEF
- FT_Error Read_CharStrings( T1_Tokenizer tokenizer,
- FT_Int num_chars,
- FT_Byte* buffer );
-#endif /* 0 */
-
- LOCAL_DEF
- void t1_decrypt( FT_Byte* buffer,
- FT_Int length,
- FT_UShort seed );
-
-
-#ifdef __cplusplus
- }
-#endif
-
-#endif /* T1TOKENS_H */
-
-
-/* END */
diff --git a/src/type1/type1.c b/src/type1/type1.c
deleted file mode 100644
index d2058d6..0000000
--- a/src/type1/type1.c
+++ /dev/null
@@ -1,59 +0,0 @@
-/***************************************************************************/
-/* */
-/* type1.c */
-/* */
-/* FreeType Type 1 driver component (body only). */
-/* */
-/* Copyright 1996-2000 by */
-/* David Turner, Robert Wilhelm, and Werner Lemberg. */
-/* */
-/* This file is part of the FreeType project, and may only be used, */
-/* modified, and distributed under the terms of the FreeType project */
-/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
-/* this file you indicate that you have read the license and */
-/* understand and accept it fully. */
-/* */
-/***************************************************************************/
-
-
-#define FT_MAKE_OPTION_SINGLE_OBJECT
-
-
-#ifdef FT_FLAT_COMPILE
-
-#include "t1driver.c"
-#include "t1objs.c"
-#include "t1load.c"
-#include "t1gload.c"
-#include "t1tokens.c"
-#include "t1parse.c"
-
-#ifndef T1_CONFIG_OPTION_DISABLE_HINTER
-#include "t1hinter.c"
-#endif
-
-#ifndef T1_CONFIG_OPTION_NO_AFM
-#include "t1afm.c"
-#endif
-
-#else /* FT_FLAT_COMPILE */
-
-#include <type1/t1driver.c>
-#include <type1/t1objs.c>
-#include <type1/t1load.c>
-#include <type1/t1gload.c>
-#include <type1/t1tokens.c>
-#include <type1/t1parse.c>
-
-#ifndef T1_CONFIG_OPTION_DISABLE_HINTER
-#include <type1/t1hinter.c>
-#endif
-
-#ifndef T1_CONFIG_OPTION_NO_AFM
-#include <type1/t1afm.c>
-#endif
-
-#endif /* FT_FLAT_COMPILE */
-
-
-/* END */