major changes to the library: - there is now a "convenience" API to manage glyphs in "include/ftglyph.h". See the demo program "ftstring" for an example.. - the raster interface has been changed in order to allow direct composition through user-provided callbacks. This has been tested but isn't demonstrated for now in "demos" - the FT_LOAD_NO_RECURSE flag is supported, as this is required by some new code in the auto-hinting engine - some bug fixed in FT_MulFix which made FT_xxx_Transform return incorrect results..
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
diff --git a/config/ftoption.h b/config/ftoption.h
index 2caf98b..0a4134c 100644
--- a/config/ftoption.h
+++ b/config/ftoption.h
@@ -46,6 +46,24 @@
/*************************************************************************/
/* */
+ /* Convenience functions support */
+ /* */
+ /* Some functions of the FreeType 2 API are provided as a convenience */
+ /* for client applications and developers. However, they are not */
+ /* required to build and run the library itself. */
+ /* */
+ /* By defining this configuration macro, you'll disable the */
+ /* compilation of these functions at build time. This can be useful */
+ /* to reduce the library's code size when you don't need any of */
+ /* these functions.. */
+ /* */
+ /* All convenience functions are declared as such in their */
+ /* documentation. */
+ /* */
+#undef FT_CONFIG_OPTION_NO_CONVENIENCE_FUNCS
+
+ /*************************************************************************/
+ /* */
/* Alternate Glyph Image Format support */
/* */
/* By default, the glyph images returned by the FreeType glyph loader */
diff --git a/config/unix/detect.mk b/config/unix/detect.mk
index 72b3b86..2ce47e5 100644
--- a/config/unix/detect.mk
+++ b/config/unix/detect.mk
@@ -18,9 +18,13 @@
ifeq ($(PLATFORM),ansi)
- has_inittab := $(strip $(wildcard /etc/inittab))
- ifneq ($(has_inittab),)
+# Some Unix systems like *BSD do not have a /etc/inittab so we commented
+# the line.. (thanks to Yamano-uchi, Hidetoshi for pointing this out)..
+#
+# has_inittab := $(strip $(wildcard /etc/inittab))
+ has_init := $(strip $(wildcard /sbin/init))
+ ifneq ($(has_init),)
PLATFORM := unix
COPY := cp
diff --git a/demos/Makefile b/demos/Makefile
index 4020c93..5cac17d 100644
--- a/demos/Makefile
+++ b/demos/Makefile
@@ -152,7 +152,7 @@ else
#
# The list of demonstration programs to build.
#
- EXES := ftlint ftview fttimer
+ EXES := ftlint ftview fttimer compos ftstring
ifneq ($(findstring $(PLATFORM),os2 unix),)
EXES += ttdebug
@@ -182,9 +182,15 @@ else
$(OBJ_)ftlint.$O: $(SRC_DIR_)ftlint.c
$(COMPILE) $T$@ $<
+ $(OBJ_)compos.$O: $(SRC_DIR_)compos.c
+ $(COMPILE) $T$@ $<
+
$(OBJ_)ftgrays.$O: $(SRC_DIR_)ftgrays.c
$(COMPILE) $T$@ $<
+ $(OBJ_)ftgrays2.$O: $(SRC_DIR_)ftgrays2.c
+ $(COMPILE) $T$@ $<
+
$(OBJ_)fttry.$O: $(SRC_DIR_)fttry.c
$(COMPILE) $T$@ $<
@@ -192,9 +198,19 @@ else
$(OBJ_)ftview.$O: $(SRC_DIR_)ftview.c $(GRAPH_LIB)
$(COMPILE) $(GRAPH_INCLUDES:%=$I%) $T$@ $<
+ $(OBJ_)ftstring.$O: $(SRC_DIR_)ftstring.c $(GRAPH_LIB)
+ $(COMPILE) $(GRAPH_INCLUDES:%=$I%) $T$@ $<
+
+ $(OBJ_)try.$O: $(SRC_DIR_)try.c $(GRAPH_LIB)
+ $(COMPILE) $(GRAPH_INCLUDES:%=$I%) $T$@ $<
+
$(OBJ_)fttimer.$O: $(SRC_DIR_)fttimer.c $(GRAPH_LIB)
$(COMPILE) $(GRAPH_INCLUDES:%=$I%) $T$@ $<
+ $(OBJ_)fttimer2.$O: $(SRC_DIR_)fttimer2.c $(GRAPH_LIB)
+ $(COMPILE) $(GRAPH_INCLUDES:%=$I%) $T$@ $<
+
+
# $(OBJ_)ftsbit.$O: $(SRC_DIR)/ftsbit.c $(GRAPH_LIB)
# $(COMPILE) $T$@ $<
@@ -233,6 +249,9 @@ else
$(BIN_)ftlint$E: $(OBJ_)ftlint.$O $(FTLIB) $(COMMON_OBJ)
$(COMMON_LINK)
+ $(BIN_)compos$E: $(OBJ_)compos.$O $(FTLIB) $(COMMON_OBJ)
+ $(COMMON_LINK)
+
$(BIN_)fttry$E: $(OBJ_)fttry.$O $(FTLIB)
$(LINK)
@@ -249,9 +268,20 @@ else
$(BIN_)ftview$E: $(OBJ_)ftview.$O $(FTLIB) $(GRAPH_LIB) $(COMMON_OBJ) $(OBJ_)ftgrays.$O
$(GRAPH_LINK) $(OBJ_)ftgrays.$O
+ $(BIN_)ftstring$E: $(OBJ_)ftstring.$O $(FTLIB) $(GRAPH_LIB) $(COMMON_OBJ) $(OBJ_)ftgrays.$O
+ $(GRAPH_LINK) $(OBJ_)ftgrays.$O
+
+
+ $(BIN_)try$E: $(OBJ_)try.$O $(FTLIB) $(GRAPH_LIB) $(COMMON_OBJ) $(OBJ_)ftgrays2.$O
+ $(GRAPH_LINK) $(OBJ_)ftgrays2.$O
+
$(BIN_)fttimer$E: $(OBJ_)fttimer.$O $(FTLIB) $(GRAPH_LIB) $(COMMON_OBJ) $(OBJ_)ftgrays.$O
$(GRAPH_LINK) $(OBJ_)ftgrays.$O
+ $(BIN_)fttimer2$E: $(OBJ_)fttimer2.$O $(FTLIB) $(GRAPH_LIB) $(COMMON_OBJ) $(OBJ_)ftgrays2.$O
+ $(GRAPH_LINK) $(OBJ_)ftgrays2.$O
+
+
endif
# EOF
diff --git a/demos/src/ftgrays.c b/demos/src/ftgrays.c
index a24196a..be36853 100644
--- a/demos/src/ftgrays.c
+++ b/demos/src/ftgrays.c
@@ -55,6 +55,11 @@
#define ErrRaster_Invalid_Outline -1
#include "ftgrays.h"
+#ifdef _STANDALONE_
+#error "implementation of FT_Outline_Decompose missing !!!"
+#else
+#include <freetype.h> /* to link to FT_Outline_Decompose */
+#endif
#define xxxDEBUG_GRAYS
@@ -91,6 +96,70 @@
#define UPSCALE(x) (PIXEL_BITS >= 6 ? (x) << (PIXEL_BITS-6) : (x) >> (6-PIXEL_BITS))
#define DOWNSCALE(x) (PIXEL_BITS >= 6 ? (x) >> (PIXEL_BITS-6) : (x) << (6-PIXEL_BITS))
+
+
+
+/****************************************************************************/
+/* */
+/* TYPE DEFINITIONS */
+/* */
+
+typedef int TScan;
+typedef long TPos;
+typedef float TDist;
+
+#define FT_MAX_GRAY_SPANS 32
+
+
+typedef struct TCell_
+{
+ TScan x;
+ TScan y;
+ int area;
+ int cover;
+
+} TCell, *PCell;
+
+
+typedef struct TRaster_
+{
+ PCell cells;
+ int max_cells;
+ int num_cells;
+
+ TScan min_ex, max_ex;
+ TScan min_ey, max_ey;
+
+ int area;
+ int cover;
+ int invalid;
+
+ TScan ex, ey;
+ TScan cx, cy;
+ TPos x, y;
+
+ TScan last_ey;
+
+ FT_Vector bez_stack[32*3];
+ int lev_stack[32];
+
+ FT_Outline outline;
+ FT_Bitmap target;
+
+ FT_Span gray_spans[ FT_MAX_GRAY_SPANS ];
+ int num_gray_spans;
+
+ FT_Raster_Span_Func render_span;
+ void* render_span_data;
+ int span_y;
+
+ void* memory;
+
+} TRaster, *PRaster;
+
+
+
+
/****************************************************************************/
/* */
/* INITIALIZE THE CELLS TABLE */
@@ -783,399 +852,6 @@ int check_sort( PCell cells, int count )
#endif
#endif
-#if 0
- static
- int FT_Decompose_Outline( FT_Outline* outline,
- FT_Outline_Funcs* interface,
- void* user )
- {
- typedef enum _phases
- {
- phase_point,
- phase_conic,
- phase_cubic,
- phase_cubic2
-
- } TPhase;
-
- FT_Vector v_first;
- FT_Vector v_last;
- FT_Vector v_control;
- FT_Vector v_start;
-
- FT_Vector* point;
- FT_Vector* limit;
- char* tags;
-
- int n; /* index of contour in outline */
- int first; /* index of first point in contour */
- int error;
- char tag; /* current point's state */
-
-
- first = 0;
-
- for ( n = 0; n < outline->n_contours; n++ )
- {
- int last; /* index of last point in contour */
-
- last = outline->contours[n];
- limit = outline->points + last;
-
- v_first = outline->points[first];
- v_last = outline->points[last];
-
- v_start = v_control = v_first;
-
- point = outline->points + first;
- tags = outline->tags + first;
- tag = FT_CURVE_TAG( tags[0] );
-
- /* A contour cannot start with a cubic control point! */
- if ( tag == FT_Curve_Tag_Cubic )
- goto Invalid_Outline;
-
- /* check first point to determine origin */
- if ( tag == FT_Curve_Tag_Conic )
- {
- /* first point is conic control. Yes, this happens. */
- if ( FT_CURVE_TAG( outline->tags[last] ) == FT_Curve_Tag_On )
- {
- /* start at last point if it is on the curve */
- v_start = v_last;
- limit--;
- }
- else
- {
- /* if both first and last points are conic, */
- /* start at their middle and record its position */
- /* for closure */
- v_start.x = ( v_start.x + v_last.x ) / 2;
- v_start.y = ( v_start.y + v_last.y ) / 2;
-
- v_last = v_start;
- }
- point--;
- tags--;
- }
-
- error = interface->move_to( &v_start, user );
- if (error) goto Exit;
-
- while (point < limit)
- {
- point++;
- tags++;
-
- tag = FT_CURVE_TAG( tags[0] );
- switch (tag)
- {
- case FT_Curve_Tag_On: /* emit a single line_to */
- {
- error = interface->line_to( point, user );
- if (error) goto Exit;
- continue;
- }
-
-
- case FT_Curve_Tag_Conic: /* consume conic arcs */
- {
- v_control = point[0];
-
- Do_Conic:
- if (point < limit)
- {
- FT_Vector v_middle;
-
- point++;
- tags++;
- tag = FT_CURVE_TAG( tags[0] );
-
- if (tag == FT_Curve_Tag_On)
- {
- error = interface->conic_to( &v_control, point, user );
- if (error) goto Exit;
- continue;
- }
-
- if (tag != FT_Curve_Tag_Conic)
- goto Invalid_Outline;
-
- v_middle.x = (v_control.x + point->x)/2;
- v_middle.y = (v_control.y + point->y)/2;
-
- error = interface->conic_to( &v_control, &v_middle, user );
- if (error) goto Exit;
-
- v_control = point[0];
- goto Do_Conic;
- }
-
- error = interface->conic_to( &v_control, &v_start, user );
- goto Close;
- }
-
- default: /* FT_Curve_Tag_Cubic */
- {
- if ( point+1 > limit ||
- FT_CURVE_TAG( tags[1] ) != FT_Curve_Tag_Cubic )
- goto Invalid_Outline;
-
- point += 2;
- tags += 2;
-
- if (point <= limit)
- {
- error = interface->cubic_to( point-2, point-1, point, user );
- if (error) goto Exit;
- continue;
- }
-
- error = interface->cubic_to( point-2, point-1, &v_start, user );
- goto Close;
- }
- }
- }
-
- /* close the contour with a line segment */
- error = interface->line_to( &v_start, user );
-
- Close:
- if (error) goto Exit;
- first = last+1;
- }
-
- return 0;
- Exit:
- return error;
-
- Invalid_Outline:
- return -1;
- }
-#else
- static
- int FT_Decompose_Outline( FT_Outline* outline,
- FT_Outline_Funcs* interface,
- void* user )
- {
- typedef enum _phases
- {
- phase_point,
- phase_conic,
- phase_cubic,
- phase_cubic2
-
- } TPhase;
-
- FT_Vector v_first;
- FT_Vector v_last;
- FT_Vector v_control;
- FT_Vector v_control2;
- FT_Vector v_start;
-
- FT_Vector* point;
- char* tags;
-
- int n; /* index of contour in outline */
- int first; /* index of first point in contour */
- int index; /* current point's index */
-
- int error;
-
- char tag; /* current point's state */
- TPhase phase;
-
-
- first = 0;
-
- for ( n = 0; n < outline->n_contours; n++ )
- {
- int last; /* index of last point in contour */
-
-
- last = outline->contours[n];
-
- v_first = outline->points[first];
- v_last = outline->points[last];
-
- v_start = v_control = v_first;
-
- tag = FT_CURVE_TAG( outline->tags[first] );
- index = first;
-
- /* A contour cannot start with a cubic control point! */
-
- if ( tag == FT_Curve_Tag_Cubic )
- return ErrRaster_Invalid_Outline;
-
-
- /* check first point to determine origin */
-
- if ( tag == FT_Curve_Tag_Conic )
- {
- /* first point is conic control. Yes, this happens. */
- if ( FT_CURVE_TAG( outline->tags[last] ) == FT_Curve_Tag_On )
- {
- /* start at last point if it is on the curve */
- v_start = v_last;
- }
- else
- {
- /* if both first and last points are conic, */
- /* start at their middle and record its position */
- /* for closure */
- v_start.x = ( v_start.x + v_last.x ) / 2;
- v_start.y = ( v_start.y + v_last.y ) / 2;
-
- v_last = v_start;
- }
- phase = phase_conic;
- }
- else
- phase = phase_point;
-
-
- /* Begin a new contour with MOVE_TO */
-
- error = interface->move_to( &v_start, user );
- if ( error )
- return error;
-
- point = outline->points + first;
- tags = outline->tags + first;
-
- /* now process each contour point individually */
-
- while ( index < last )
- {
- index++;
- point++;
- tags++;
-
- tag = FT_CURVE_TAG( tags[0] );
-
- switch ( phase )
- {
- case phase_point: /* the previous point was on the curve */
-
- switch ( tag )
- {
- /* two succesive on points -> emit segment */
- case FT_Curve_Tag_On:
- error = interface->line_to( point, user );
- break;
-
- /* on point + conic control -> remember control point */
- case FT_Curve_Tag_Conic:
- v_control = point[0];
- phase = phase_conic;
- break;
-
- /* on point + cubic control -> remember first control */
- default:
- v_control = point[0];
- phase = phase_cubic;
- break;
- }
- break;
-
- case phase_conic: /* the previous point was a conic control */
-
- switch ( tag )
- {
- /* conic control + on point -> emit conic arc */
- case FT_Curve_Tag_On:
- error = interface->conic_to( &v_control, point, user );
- phase = phase_point;
- break;
-
- /* two successive conics -> emit conic arc `in between' */
- case FT_Curve_Tag_Conic:
- {
- FT_Vector v_middle;
-
-
- v_middle.x = (v_control.x + point->x)/2;
- v_middle.y = (v_control.y + point->y)/2;
-
- error = interface->conic_to( &v_control,
- &v_middle, user );
- v_control = point[0];
- }
- break;
-
- default:
- error = ErrRaster_Invalid_Outline;
- }
- break;
-
- case phase_cubic: /* the previous point was a cubic control */
-
- /* this point _must_ be a cubic control too */
- if ( tag != FT_Curve_Tag_Cubic )
- return ErrRaster_Invalid_Outline;
-
- v_control2 = point[0];
- phase = phase_cubic2;
- break;
-
-
- case phase_cubic2: /* the two previous points were cubics */
-
- /* this point _must_ be an on point */
- if ( tag != FT_Curve_Tag_On )
- error = ErrRaster_Invalid_Outline;
- else
- error = interface->cubic_to( &v_control, &v_control2,
- point, user );
- phase = phase_point;
- break;
- }
-
- /* lazy error testing */
- if ( error )
- return error;
- }
-
- /* end of contour, close curve cleanly */
- error = 0;
-
- tag = FT_CURVE_TAG( outline->tags[first] );
-
- switch ( phase )
- {
- case phase_point:
- if ( tag == FT_Curve_Tag_On )
- error = interface->line_to( &v_first, user );
- break;
-
- case phase_conic:
- error = interface->conic_to( &v_control, &v_start, user );
- break;
-
- case phase_cubic2:
- if ( tag == FT_Curve_Tag_On )
- error = interface->cubic_to( &v_control, &v_control2,
- &v_first, user );
- else
- error = ErrRaster_Invalid_Outline;
- break;
-
- default:
- error = ErrRaster_Invalid_Outline;
- break;
- }
-
- if ( error )
- return error;
-
- first = last + 1;
- }
-
- return 0;
- }
-
-#endif
static
int Move_To( FT_Vector* to,
@@ -1224,7 +900,7 @@ int check_sort( PCell cells, int count )
static
- void grays_render_span( int y, int count, FT_GraySpan* spans, PRaster raster )
+ void grays_render_span( int y, int count, FT_Span* spans, PRaster raster )
{
unsigned char *p, *q, *limit;
FT_Bitmap* map = &raster->target;
@@ -1270,21 +946,12 @@ int check_sort( PCell cells, int count )
}
#endif
-#if 0
- static
- void grays_hline( RAS_ARG_ TScan x, TScan y, TPos area, int count )
- {
- if (area)
- fprintf( stderr, "hline( %3d, %3d, %2d, %5.2f )\n",
- y, x, count, (float)area/(2.0*ONE_PIXEL*ONE_PIXEL) );
- }
-#else
static
void grays_hline( RAS_ARG_ TScan x, TScan y, TPos area, int acount )
{
- FT_GraySpan* span;
- int count;
- int coverage;
+ FT_Span* span;
+ int count;
+ int coverage;
/* compute the coverage line's coverage, depending on the */
/* outline fill rule.. */
@@ -1331,7 +998,8 @@ int check_sort( PCell cells, int count )
if ( ras.span_y != y || count >= FT_MAX_GRAY_SPANS)
{
if (ras.render_span)
- ras.render_span( ras.span_y, count, ras.gray_spans, ras.render_span_closure );
+ ras.render_span( ras.span_y, count, ras.gray_spans,
+ ras.render_span_data );
/* ras.render_span( span->y, ras.gray_spans, count ); */
#ifdef DEBUG_GRAYS
@@ -1341,7 +1009,8 @@ int check_sort( PCell cells, int count )
fprintf( stderr, "y=%3d ", ras.span_y );
span = ras.gray_spans;
for (n = 0; n < count; n++, span++)
- fprintf( stderr, "[%d..%d]:%02x ", span->x, span->x + span->len-1, span->coverage );
+ fprintf( stderr, "[%d..%d]:%02x ",
+ span->x, span->x + span->len-1, span->coverage );
fprintf( stderr, "\n" );
}
#endif
@@ -1362,7 +1031,7 @@ int check_sort( PCell cells, int count )
ras.num_gray_spans++;
}
}
-#endif
+
static
void grays_sweep( RAS_ARG_ FT_Bitmap* target )
@@ -1427,7 +1096,7 @@ int check_sort( PCell cells, int count )
if (ras.render_span && ras.num_gray_spans > 0)
ras.render_span( ras.span_y, ras.num_gray_spans,
- ras.gray_spans, ras.render_span_closure );
+ ras.gray_spans, ras.render_span_data );
#ifdef DEBUG_GRAYS
{
int n;
@@ -1465,7 +1134,7 @@ int check_sort( PCell cells, int count )
ras.num_cells = 0;
/* Now decompose curve */
- if ( FT_Decompose_Outline( outline, &interface, &ras ) )
+ if ( FT_Outline_Decompose( outline, &interface, &ras ) )
return 1;
/* XXX: the error condition is in ras.error */
@@ -1475,10 +1144,12 @@ int check_sort( PCell cells, int count )
extern
- int grays_raster_render( TRaster* raster,
- FT_Outline* outline,
- FT_Bitmap* target_map )
+ int grays_raster_render( PRaster raster,
+ FT_Raster_Params* params )
{
+ FT_Outline* outline = (FT_Outline*)params->source;
+ FT_Bitmap* target_map = params->target;
+
if ( !raster || !raster->cells || !raster->max_cells )
return -1;
@@ -1495,6 +1166,10 @@ int check_sort( PCell cells, int count )
if ( !target_map || !target_map->buffer )
return -1;
+ /* XXXX: this version does not support monochrome rendering yet ! */
+ if ( !(params->flags & ft_raster_flag_aa) )
+ return -1;
+
ras.outline = *outline;
ras.target = *target_map;
ras.num_cells = 0;
@@ -1513,49 +1188,90 @@ int check_sort( PCell cells, int count )
check_sort( ras.cells, ras.num_cells );
dump_cells( RAS_VAR );
#endif
- ras.render_span = (FT_GraySpan_Func)grays_render_span;
- ras.render_span_closure = &ras;
+
+ ras.render_span = (FT_Raster_Span_Func)grays_render_span;
+ ras.render_span_data = &ras;
+ if ( params->flags & ft_raster_flag_direct )
+ {
+ ras.render_span = (FT_Raster_Span_Func)params->gray_spans;
+ ras.render_span_data = params->user;
+ }
grays_sweep( (PRaster)raster, target_map );
return 0;
}
+ /**** RASTER OBJECT CREATION : in standalone mode, we simply use *****/
+ /**** a static object .. *****/
+#ifdef _STANDALONE_
+
+ static
+ int grays_raster_new( void* memory, FT_Raster *araster )
+ {
+ static FT_RasterRec_ the_raster;
+ *araster = &the_raster;
+ memset( &the_raster, sizeof(the_raster), 0 );
+ return 0;
+ }
+ static
+ void grays_raster_done( FT_Raster raster )
+ {
+ /* nothing */
+ (void)raster;
+ }
+#else
+#include "ftobjs.h"
- extern
- int grays_raster_init( FT_Raster raster,
- const char* pool_base,
- long pool_size )
+ static
+ int grays_raster_new( FT_Memory memory, FT_Raster* araster )
+ {
+ FT_Error error;
+ PRaster raster;
+
+ *araster = 0;
+ if ( !ALLOC( raster, sizeof(TRaster) ))
+ {
+ raster->memory = memory;
+ *araster = (FT_Raster)raster;
+ }
+
+ return error;
+ }
+
+ static
+ void grays_raster_done( FT_Raster raster )
{
-/* static const char default_palette[5] = { 0, 1, 2, 3, 4 }; */
+ FT_Memory memory = (FT_Memory)((PRaster)raster)->memory;
+ FREE( raster );
+ }
+
+#endif
- /* check the object address */
- if ( !raster )
- return -1;
- /* check the render pool - we won't go under 4 Kb */
- if ( !pool_base || pool_size < 4096 )
- return -1;
- /* save the pool */
- init_cells( (PRaster)raster, (char*)pool_base, pool_size );
- return 0;
+ static
+ void grays_raster_reset( FT_Raster raster,
+ const char* pool_base,
+ long pool_size )
+ {
+ if (raster && pool_base && pool_size >= 4096)
+ init_cells( (PRaster)raster, (char*)pool_base, pool_size );
}
-
- FT_Raster_Interface ft_grays_raster =
+ FT_Raster_Funcs ft_grays_raster =
{
- sizeof( TRaster ),
ft_glyph_format_outline,
-
- (FT_Raster_Init_Proc) grays_raster_init,
- (FT_Raster_Set_Mode_Proc) 0,
- (FT_Raster_Render_Proc) grays_raster_render
+
+ (FT_Raster_New_Func) grays_raster_new,
+ (FT_Raster_Reset_Func) grays_raster_reset,
+ (FT_Raster_Set_Mode_Func) 0,
+ (FT_Raster_Render_Func) grays_raster_render,
+ (FT_Raster_Done_Func) grays_raster_done
};
-
diff --git a/demos/src/ftgrays.h b/demos/src/ftgrays.h
index 5e9eb00..b9c8dc3 100644
--- a/demos/src/ftgrays.h
+++ b/demos/src/ftgrays.h
@@ -1,78 +1,7 @@
#ifndef FTGRAYS_H
#define FTGRAYS_H
-typedef int TScan;
-typedef long TPos;
-typedef float TDist;
-#define FT_MAX_GRAY_SPANS 32
-
-typedef struct FT_GraySpan_
-{
- short x;
- short len;
- unsigned char coverage;
-
-} FT_GraySpan;
-
-typedef int (*FT_GraySpan_Func)( int y,
- int count,
- FT_GraySpan* spans,
- void* user );
-
-
-typedef struct TCell_
-{
- TScan x;
- TScan y;
- int area;
- int cover;
-
-} TCell, *PCell;
-
-
-typedef struct TRaster_
-{
- PCell cells;
- int max_cells;
- int num_cells;
-
- TScan min_ex, max_ex;
- TScan min_ey, max_ey;
-
- int area;
- int cover;
- int invalid;
-
- TScan ex, ey;
- TScan cx, cy;
- TPos x, y;
-
- TScan last_ey;
-
- FT_Vector bez_stack[32*3];
- int lev_stack[32];
-
- FT_Outline outline;
- FT_Bitmap target;
-
- FT_GraySpan gray_spans[ FT_MAX_GRAY_SPANS ];
- int num_gray_spans;
-
- FT_GraySpan_Func render_span;
- void* render_span_closure;
- int span_y;
-
-} TRaster, *PRaster;
-
- extern
- int grays_raster_render( TRaster* raster,
- FT_Outline* outline,
- FT_Bitmap* target_map );
-
- extern
- int grays_raster_init( FT_Raster raster,
- const char* pool_base,
- long pool_size );
+ extern FT_Raster_Funcs ft_grays_raster;
#endif
diff --git a/demos/src/ftgrays2.c b/demos/src/ftgrays2.c
index 073e657..80aba2a 100644
--- a/demos/src/ftgrays2.c
+++ b/demos/src/ftgrays2.c
@@ -8,7 +8,7 @@
/* */
/* After writing a "perfect" anti-aliaser (see ftgrays.c), it is clear */
/* that the standard FreeType renderer is better at generating glyph images */
-/* because it uses an approximation that simply produced more contrasted */
+/* because it uses an approximation that simply produces more contrasted */
/* edges, making its output more legible.. */
/* */
/* This code is an attempt to rewrite the standard renderer in order to */
@@ -19,14 +19,22 @@
/* of span in successive scan-lines (the standard code is forced to use */
/* an intermediate buffer, and this is just _bad_ :-) */
/* */
+/* */
+/* This thing works, but it's slower than the original ftraster.c, */
+/* probably because the bezier intersection code is different.. */
+/* */
+/* Note that Type 1 fonts, using a reverse fill algorithm are not */
+/* supported for now (this should come soon though..) */
+/* */
#include <ftimage.h>
#define _STANDALONE_
-#define xxxDEBUG_GRAYS
-#define SPECIAL
-#define HORZ
+#define DEBUG_GRAYS
+#define DIRECT_BEZIER
+#define PRECISION_STEP ONE_HALF
+#define xxxDYNAMIC_BEZIER_STEPS
#define ErrRaster_Invalid_Outline -1
#define ErrRaster_Overflow -2
@@ -42,6 +50,99 @@
#include <stdio.h>
#endif
+typedef int TScan;
+typedef long TPos;
+typedef float TDist;
+
+#define FT_MAX_GRAY_SPANS 32
+
+typedef struct FT_GraySpan_
+{
+ short x;
+ short len;
+ unsigned char coverage;
+
+} FT_GraySpan;
+
+typedef int (*FT_GraySpan_Func)( int y,
+ int count,
+ FT_GraySpan* spans,
+ void* user );
+
+typedef enum {
+
+ dir_up = 0,
+ dir_down = 1,
+ dir_right = 2,
+ dir_left = 3,
+
+ dir_horizontal = 2,
+ dir_reverse = 1,
+ dir_silent = 4,
+
+ dir_unknown = 8
+
+} TDir;
+
+
+typedef struct TCell_
+{
+ unsigned short x;
+ unsigned short y;
+ unsigned short pos;
+ TDir dir;
+
+} TCell, *PCell;
+
+
+
+typedef struct TRaster_
+{
+ PCell cells;
+ PCell cursor;
+ PCell cell_limit;
+ int max_cells;
+ int num_cells;
+
+ TScan min_ex, max_ex;
+ TScan min_ey, max_ey;
+ TPos min_x, min_y;
+ TPos max_x, max_y;
+
+ TScan ex, ey;
+ TScan cx, cy;
+ TPos x, y;
+
+ PCell contour_cell; /* first contour cell */
+
+ char joint;
+ char horizontal;
+ TDir dir;
+ PCell last;
+
+ FT_Vector starter;
+ FT_Vector* start;
+
+ int error;
+
+ FT_Vector* arc;
+ FT_Vector bez_stack[32*3];
+ int lev_stack[32];
+
+ FT_Outline outline;
+ FT_Bitmap target;
+
+ FT_GraySpan gray_spans[ FT_MAX_GRAY_SPANS ];
+ int num_gray_spans;
+
+ FT_GraySpan_Func render_span;
+ void* render_span_closure;
+ int span_y;
+
+} TRaster, *PRaster;
+
+
+
#ifndef FT_STATIC_RASTER
#define RAS_ARG PRaster raster
@@ -122,8 +223,8 @@ int write_cell( RAS_ARG_ PCell cell, TPos u, TPos v, TDir dir )
/* get rid of horizontal cells with pos == 0, they're irrelevant */
if ( FRAC(u) == 0 ) goto Nope;
- cell->y = TRUNC( u - ras.min_y );
- cell->x = TRUNC( v - ras.min_x );
+ cell->y = (unsigned short)TRUNC( u - ras.min_y );
+ cell->x = (unsigned short)TRUNC( v - ras.min_x );
}
else
{
@@ -137,8 +238,8 @@ int write_cell( RAS_ARG_ PCell cell, TPos u, TPos v, TDir dir )
/* all cells that are on the left of the clipping box are located */
/* on the same virtual "border" cell.. */
if (u < 0) u = -1;
- cell->x = TRUNC( u );
- cell->y = TRUNC( v );
+ cell->x = (unsigned short)TRUNC( u );
+ cell->y = (unsigned short)TRUNC( v );
}
cell->dir = dir;
cell->pos = FRAC(u);
@@ -257,6 +358,10 @@ Exit:
du = u2 - u1;
dv = v2 - v1;
+ /* set the silent flag */
+ if (du > dv)
+ dir |= dir_silent;
+
/* compute the first scanline in "e1" */
e1 = CEILING(v1);
if (e1 == v1 && ras.joint)
@@ -424,6 +529,35 @@ void split_conic( FT_Vector* base )
static
+void split_cubic( FT_Vector* base )
+{
+ TPos a, b, c, d;
+
+ base[6].x = base[3].x;
+ c = base[1].x;
+ d = base[2].x;
+ base[1].x = a = ( base[0].x + c ) / 2;
+ base[5].x = b = ( base[3].x + d ) / 2;
+ c = ( c + d ) / 2;
+ base[2].x = a = ( a + c ) / 2;
+ base[4].x = b = ( b + c ) / 2;
+ base[3].x = ( a + b ) / 2;
+
+ base[6].y = base[3].y;
+ c = base[1].y;
+ d = base[2].y;
+ base[1].y = a = ( base[0].y + c ) / 2;
+ base[5].y = b = ( base[3].y + d ) / 2;
+ c = ( c + d ) / 2;
+ base[2].y = a = ( a + c ) / 2;
+ base[4].y = b = ( b + c ) / 2;
+ base[3].y = ( a + b ) / 2;
+}
+
+
+
+#ifndef DIRECT_BEZIER
+static
int render_conic( RAS_ARG_ TPos x1, TPos y1, TPos x2, TPos y2 )
{
TPos x0, y0;
@@ -484,32 +618,6 @@ int render_conic( RAS_ARG_ TPos x1, TPos y1, TPos x2, TPos y2 )
static
-void split_cubic( FT_Vector* base )
-{
- TPos a, b, c, d;
-
- base[6].x = base[3].x;
- c = base[1].x;
- d = base[2].x;
- base[1].x = a = ( base[0].x + c ) / 2;
- base[5].x = b = ( base[3].x + d ) / 2;
- c = ( c + d ) / 2;
- base[2].x = a = ( a + c ) / 2;
- base[4].x = b = ( b + c ) / 2;
- base[3].x = ( a + b ) / 2;
-
- base[6].y = base[3].y;
- c = base[1].y;
- d = base[2].y;
- base[1].y = a = ( base[0].y + c ) / 2;
- base[5].y = b = ( base[3].y + d ) / 2;
- c = ( c + d ) / 2;
- base[2].y = a = ( a + c ) / 2;
- base[4].y = b = ( b + c ) / 2;
- base[3].y = ( a + b ) / 2;
-}
-
-static
int render_cubic( RAS_ARG_ TPos x1, TPos y1,
TPos x2, TPos y2,
TPos x3, TPos y3 )
@@ -581,6 +689,390 @@ int render_cubic( RAS_ARG_ TPos x1, TPos y1,
}
}
}
+#else /* !DIRECT_BEZIER */
+ /* A function type describing the functions used to split bezier arcs */
+ typedef void (*TSplitter)( FT_Vector* base );
+
+#ifdef DYNAMIC_BEZIER_STEPS
+ static
+ TPos Dynamic_Bezier_Threshold( RAS_ARG_ int degree, FT_Vector* arc )
+ {
+ TPos min_x, max_x, min_y, max_y, A, B;
+ TPos wide_x, wide_y, threshold;
+
+ FT_Vector* cur = arc;
+ FT_Vector* limit = cur + degree;
+
+ /* first of all, set the threshold to the maximum x or y extent */
+ min_x = max_x = arc[0].x;
+ min_y = max_y = arc[0].y;
+ cur++;
+ for ( ; cur < limit; cur++ )
+ {
+ TPos x = cur->x;
+ TPos y = cur->y;
+
+ if ( x < min_x ) min_x = x;
+ if ( x > max_x ) max_x = x;
+
+ if ( y < min_y ) min_y = y;
+ if ( y > max_y ) max_y = y;
+ }
+ wide_x = (max_x - min_x) << 4;
+ wide_y = (max_y - min_y) << 4;
+
+ threshold = wide_x;
+ if (threshold < wide_y) threshold = wide_y;
+
+ /* now compute the second and third order error values */
+
+ wide_x = arc[0].x + arc[1].x - arc[2].x*2;
+ wide_y = arc[0].y + arc[1].y - arc[2].y*2;
+
+ if (wide_x < 0) wide_x = -wide_x;
+ if (wide_y < 0) wide_y = -wide_y;
+
+ A = wide_x; if ( A < wide_y ) A = wide_y;
+
+ if (degree >= 3)
+ {
+ wide_x = arc[3].x - arc[0].x + 3*(arc[2].x - arc[3].x);
+ wide_y = arc[3].y - arc[0].y + 3*(arc[2].y - arc[3].y);
+
+ if (wide_x < 0) wide_x = -wide_x;
+ if (wide_y < 0) wide_y = -wide_y;
+
+ B = wide_x; if ( B < wide_y ) B = wide_y;
+ }
+ else
+ B = 0;
+
+ while ( A > 0 || B > 0 )
+ {
+ threshold >>= 1;
+ A >>= 2;
+ B >>= 3;
+ }
+
+ if (threshold < PRECISION_STEP)
+ threshold = PRECISION_STEP;
+
+ return threshold;
+ }
+#endif /* DYNAMIC_BEZIER_STEPS */
+
+ static
+ int render_bezier( RAS_ARG_ int degree,
+ TSplitter splitter,
+ TPos minv,
+ TPos maxv,
+ TDir dir )
+ {
+ TPos v1, v2, u, v, e1, e2, threshold;
+ int reverse;
+
+ FT_Vector* arc;
+ FT_Vector init;
+
+ PCell top;
+
+ arc = ras.arc;
+ init = arc[0];
+
+ arc[0].y -= ONE_HALF;
+ arc[1].y -= ONE_HALF;
+ arc[2].y -= ONE_HALF;
+ maxv -= ONE_PIXEL;
+
+ top = ras.cursor;
+
+ /* ensure that our segment is ascending */
+ v1 = arc[degree].y;
+ v2 = arc[0].y;
+ reverse = 0;
+ if ( v2 < v1 )
+ {
+ TPos tmp;
+ v1 = -v1;
+ v2 = -v2;
+ arc[0].y = v2;
+ arc[1].y = -arc[1].y;
+ arc[degree].y = v1;
+ if (degree > 2)
+ arc[2].y = -arc[2].y;
+
+ tmp = minv; minv = -maxv; maxv = -tmp;
+ reverse = 1;
+ }
+
+ if ( v2 < minv || v1 > maxv )
+ goto Fin;
+
+ /* compute the first scanline in "e1" */
+ e1 = CEILING(v1);
+ if (e1 == v1 && ras.joint)
+ e1 += ONE_PIXEL;
+
+ /* compute the last scanline in "e2" */
+ if (v2 <= maxv)
+ {
+ e2 = FLOOR(v2);
+ ras.joint = (v2 == e2);
+ }
+ else
+ {
+ e2 = maxv;
+ ras.joint = 0;
+ }
+
+ /* exit if the current scanline is already above the max scanline */
+ if ( e2 < e1 )
+ goto Fin;
+
+ /* check for overflow */
+ if ( ( top + TRUNC(e2-e1)+1 ) >= ras.cell_limit )
+ {
+ ras.cursor = top;
+ ras.error = ErrRaster_Overflow;
+ return 1;
+ }
+
+#ifdef DYNAMIC_BEZIER_STEPS
+ /* compute dynamic bezier step threshold */
+ threshold = Dynamic_Bezier_Threshold( RAS_VAR_ degree, arc );
+#else
+ threshold = PRECISION_STEP;
+#endif
+
+ /* loop while there is still an arc on the bezier stack */
+ /* and the current scan line is below y max == e2 */
+ while ( arc >= ras.arc && e1 <= e2 )
+ {
+ ras.joint = 0;
+
+ v2 = arc[0].y; /* final y of the top-most arc */
+
+ if ( v2 > e1 ) /* the arc intercepts the current scanline */
+ {
+ v1 = arc[degree].y; /* start y of top-most arc */
+
+ if ( v2 >= e1 + ONE_PIXEL || v2 - v1 >= threshold )
+ {
+ /* if the arc's height is too great, split it */
+ splitter( arc );
+ arc += degree;
+ }
+ else
+ {
+ /* otherwise, approximate it as a segment and compute */
+ /* its intersection with the current scanline */
+ u = arc[degree].x +
+ FMulDiv( arc[0].x-arc[degree].x,
+ e1 - v1,
+ v2 - v1 );
+
+ v = e1; if (reverse) v = -e1;
+ v += ONE_HALF;
+ if (WRITE_CELL( top, u, v, dir ))
+ top++;
+
+ arc -= degree; /* pop the arc */
+ e1 += ONE_PIXEL; /* go to next scanline */
+ }
+ }
+ else
+ {
+ if ( v2 == e1 ) /* if the arc falls on the scanline */
+ { /* record its _joint_ intersection */
+ ras.joint = 1;
+ u = arc[degree].x;
+ v = e1; if (reverse) v = -e1;
+ v += ONE_HALF;
+ if (WRITE_CELL( top, u, v, dir ))
+ top++;
+
+ e1 += ONE_PIXEL; /* go to next scanline */
+ }
+ arc -= degree; /* pop the arc */
+ }
+ }
+
+ Fin:
+ ras.arc[0] = init;
+ ras.cursor = top;
+ return 0;
+ }
+
+
+static
+int render_conic( RAS_ARG_ TPos x1, TPos y1, TPos x2, TPos y2 )
+{
+ TPos x0, y0;
+ TPos minv, maxv;
+ FT_Vector* arc;
+
+ x0 = ras.x;
+ y0 = ras.y;
+
+ minv = ras.min_y;
+ maxv = ras.max_y;
+ if (ras.horizontal)
+ {
+ minv = ras.min_x;
+ maxv = ras.max_x;
+ }
+
+ arc = ras.bez_stack;
+ arc[2].x = ras.x; arc[2].y = ras.y;
+ arc[1].x = x1; arc[1].y = y1;
+ arc[0].x = x2; arc[0].y = y2;
+
+ do
+ {
+ TDir dir;
+ TPos ymin, ymax;
+
+ y0 = arc[2].y;
+ y1 = arc[1].y;
+ y2 = arc[0].y;
+ x2 = arc[0].x;
+
+ /* first, categorize the Bezier arc */
+ ymin = y0;
+ ymax = y2;
+ if (ymin > ymax)
+ {
+ ymin = y2;
+ ymax = y0;
+ }
+
+ if (y1 < ymin || y1 > ymax)
+ {
+ /* this arc isn't y-monotonous, split it */
+ split_conic( arc );
+ arc += 2;
+ }
+ else if ( y0 == y2 )
+ {
+ /* this arc is flat, ignore it */
+ arc -= 2;
+ }
+ else
+ {
+ /* the arc is y-monotonous, either ascending or descending */
+ /* detect a change of direction */
+ dir = ( y0 < y2 ) ? dir_up : dir_down;
+ if (ras.horizontal) dir |= dir_horizontal;
+ if (dir != ras.dir)
+ {
+ ras.joint = 0;
+ ras.dir = dir;
+ }
+
+ ras.arc = arc;
+ if (render_bezier( RAS_VAR_ 2, split_conic, minv, maxv, dir ))
+ goto Fail;
+ arc -= 2;
+ }
+ } while ( arc >= ras.bez_stack );
+
+ ras.x = x2;
+ ras.y = y2;
+ return 0;
+Fail:
+ return 1;
+}
+
+static
+int render_cubic( RAS_ARG_ TPos x1, TPos y1, TPos x2, TPos y2, TPos x3, TPos y3 )
+{
+ TPos x0, y0;
+ TPos minv, maxv;
+ FT_Vector* arc;
+
+ x0 = ras.x;
+ y0 = ras.y;
+
+ minv = ras.min_y;
+ maxv = ras.max_y;
+ if (ras.horizontal)
+ {
+ minv = ras.min_x;
+ maxv = ras.max_x;
+ }
+
+ arc = ras.bez_stack;
+ arc[0].x = ras.x; arc[0].y = ras.y;
+ arc[1].x = x1; arc[1].y = y1;
+ arc[2].x = x2; arc[2].y = y2;
+ arc[3].x = x3; arc[3].y = y3;
+
+ do
+ {
+ TDir dir;
+ TPos ymin1, ymax1, ymin2, ymax2;
+
+ y0 = arc[3].y;
+ y1 = arc[2].y;
+ y2 = arc[1].y;
+ y3 = arc[0].y;
+ x3 = arc[0].x;
+
+ /* first, categorize the Bezier arc */
+ ymin1 = y0;
+ ymax1 = y3;
+ if (ymin1 > ymax1)
+ {
+ ymin1 = y3;
+ ymax1 = y0;
+ }
+
+ ymin2 = y1;
+ ymax2 = y2;
+ if (ymin2 > ymax2)
+ {
+ ymin2 = y2;
+ ymax2 = y1;
+ }
+
+ if ( ymin2 < ymin1 || ymax2 > ymax1)
+ {
+ /* this arc isn't y-monotonous, split it */
+ split_cubic( arc );
+ arc += 3;
+ }
+ else if ( y0 == y3 )
+ {
+ /* this arc is flat, ignore it */
+ arc -= 3;
+ }
+ else
+ {
+ /* the arc is y-monotonous, either ascending or descending */
+ /* detect a change of direction */
+ dir = ( y0 < y3 ) ? dir_up : dir_down;
+ if (ras.horizontal) dir |= dir_horizontal;
+ if (dir != ras.dir)
+ {
+ ras.joint = 0;
+ ras.dir = dir;
+ }
+
+ ras.arc = arc;
+ if (render_bezier( RAS_VAR_ 3, split_cubic, minv, maxv, dir ))
+ goto Fail;
+ arc -= 3;
+ }
+ } while ( arc >= ras.bez_stack );
+
+ ras.x = x2;
+ ras.y = y2;
+ return 0;
+Fail:
+ return 1;
+}
+
+#endif /* !DIRECT_BEZIER */
static
@@ -592,8 +1084,8 @@ int is_less_than( PCell a, PCell b )
if (a->x < b->x) goto Yes;
if (a->x == b->x)
{
- TDir ad = a->dir & dir_horizontal;
- TDir bd = b->dir & dir_horizontal;
+ TDir ad = a->dir & (dir_horizontal|dir_silent);
+ TDir bd = b->dir & (dir_horizontal|dir_silent);
if ( ad < bd ) goto Yes;
if ( ad == bd && a->pos < b->pos) goto Yes;
}
@@ -1308,7 +1800,7 @@ int check_sort( PCell cells, int count )
q = p + spans->x;
limit = q + spans->len;
for ( ; q < limit; q++ )
- q[0] = (spans->coverage+1) >> 1;
+ q[0] = spans->coverage >> 1;
}
}
}
@@ -1364,6 +1856,8 @@ int check_sort( PCell cells, int count )
if (coverage)
{
+ x += ras.min_ex;
+
/* see if we can add this span to the current list */
count = ras.num_gray_spans;
span = ras.gray_spans + count-1;
@@ -1377,7 +1871,7 @@ int check_sort( PCell cells, int count )
if ( ras.span_y != y || count >= FT_MAX_GRAY_SPANS)
{
if (ras.render_span)
- ras.render_span( ras.span_y, count, ras.gray_spans, ras.render_span_closure );
+ ras.render_span( ras.min_ey + ras.span_y, count, ras.gray_spans, ras.render_span_closure );
/* ras.render_span( span->y, ras.gray_spans, count ); */
#ifdef DEBUG_GRAYS
@@ -1452,32 +1946,41 @@ int check_sort( PCell cells, int count )
/* accumulate all start cells */
for (;;)
{
- /* XXX : for now, only deal with vertical intersections */
- switch ((cur->dir)&3)
+#if 0
+ /* we ignore silent cells for now XXXX */
+ if (!(cur->dir & dir_silent))
+#endif
{
- case dir_up:
- varea += ONE_PIXEL - cur->pos;
- if (cur->pos <= 32)
- hpos = ONE_PIXEL;
- cover++;
- numv++;
- break;
-
- case dir_down:
- varea -= ONE_PIXEL - cur->pos;
- if (cur->pos <= 32)
- hpos = 0;
- cover--;
- numv++;
- break;
-
- case dir_left:
- harea += ONE_PIXEL - cur->pos;
- break;
+ switch ((cur->dir)&3)
+ {
+ case dir_up:
+ varea += ONE_PIXEL - cur->pos;
+ if (cur->pos <= 32)
+ hpos = ONE_PIXEL;
+ cover++;
+ numv++;
+ break;
- default:
- harea -= ONE_PIXEL - cur->pos;
- break;
+ case dir_down:
+ varea -= ONE_PIXEL - cur->pos;
+ if (cur->pos <= 32)
+ hpos = 0;
+ cover--;
+ numv++;
+ break;
+#if 0
+ case dir_left:
+ harea += ONE_PIXEL - cur->pos;
+ break;
+
+ default:
+ harea -= ONE_PIXEL - cur->pos;
+ break;
+#else
+ default:
+ ;
+#endif
+ }
}
++cur;
@@ -1489,15 +1992,14 @@ int check_sort( PCell cells, int count )
if (varea < 0) varea += ONE_PIXEL;
if (harea < 0) harea += ONE_PIXEL;
- if (harea)
- area = varea + harea;
- else
+ if (varea == 0)
+ area = 2*harea;
+
+ else if (harea == 0)
area = 2*varea;
-
-#if 1
- if ( varea < ONE_PIXEL && harea == 0 && (icover|cover) == 0 && area < ONE_PIXEL)
- area += ONE_HALF;
-#endif
+
+ else
+ area = (varea+harea+ONE_PIXEL) >> 1;
is_black = ( area >= 2*ONE_PIXEL );
@@ -1604,19 +2106,27 @@ int check_sort( PCell cells, int count )
/* compute vertical intersections */
if (FT_Outline_Decompose( outline, &interface, &ras ))
return 1;
-#if 1
+#if 0
/* compute horizontal intersections */
ras.horizontal = 1;
return FT_Outline_Decompose( outline, &interface, &ras );
+#else
+ return 0;
#endif
}
+
+
+
+
extern
- int grays2_raster_render( TRaster* raster,
- FT_Outline* outline,
- FT_Bitmap* target_map )
+ int grays2_raster_render( PRaster raster,
+ FT_Raster_Params* params )
{
+ FT_Outline* outline = (FT_Outline*)params->source;
+ FT_Bitmap* target_map = params->target;
+
if ( !raster || !raster->cells || !raster->max_cells )
return -1;
@@ -1665,41 +2175,76 @@ int check_sort( PCell cells, int count )
}
+ /**** RASTER OBJECT CREATION : in standalone mode, we simply use *****/
+ /**** a static object .. *****/
+#ifdef _STANDALONE_
+ static
+ int grays2_raster_new( void* memory, FT_Raster *araster )
+ {
+ static TRaster the_raster;
+ *araster = (FT_Raster)&the_raster;
+ memset( &the_raster, sizeof(the_raster), 0 );
+ return 0;
+ }
+ static
+ void grays2_raster_done( FT_Raster raster )
+ {
+ /* nothing */
+ (void)raster;
+ }
+#else
- extern
- int grays2_raster_init( FT_Raster raster,
- const char* pool_base,
- long pool_size )
+#include "ftobjs.h"
+
+ static
+ int grays2_raster_new( FT_Memory memory, FT_Raster* araster )
+ {
+ FT_Error error;
+ PRaster raster;
+
+ *araster = 0;
+ if ( !ALLOC( raster, sizeof(TRaster) ))
+ {
+ raster->memory = memory;
+ *araster = (FT_Raster)raster;
+ }
+
+ return error;
+ }
+
+ static
+ void grays2_raster_done( FT_Raster raster )
{
-/* static const char default_palette[5] = { 0, 1, 2, 3, 4 }; */
+ FT_Memory memory = (FT_Memory)((PRaster)raster)->memory;
+ FREE( raster );
+ }
+
+#endif
- /* check the object address */
- if ( !raster )
- return -1;
- /* check the render pool - we won't go under 4 Kb */
- if ( !pool_base || pool_size < 4096 )
- return -1;
- /* save the pool */
- init_cells( (PRaster)raster, (char*)pool_base, pool_size );
- return 0;
+ static
+ void grays2_raster_reset( FT_Raster raster,
+ const char* pool_base,
+ long pool_size )
+ {
+ if (raster && pool_base && pool_size >= 4096)
+ init_cells( (PRaster)raster, (char*)pool_base, pool_size );
}
-
- FT_Raster_Interface ft_grays2_raster =
+ FT_Raster_Funcs ft_grays2_raster =
{
- sizeof( TRaster ),
ft_glyph_format_outline,
-
- (FT_Raster_Init_Proc) grays2_raster_init,
- (FT_Raster_Set_Mode_Proc) 0,
- (FT_Raster_Render_Proc) grays2_raster_render
+
+ (FT_Raster_New_Func) grays2_raster_new,
+ (FT_Raster_Reset_Func) grays2_raster_reset,
+ (FT_Raster_Set_Mode_Func) 0,
+ (FT_Raster_Render_Func) grays2_raster_render,
+ (FT_Raster_Done_Func) grays2_raster_done
};
-
diff --git a/demos/src/ftgrays2.h b/demos/src/ftgrays2.h
index e127a8e..cba7bbe 100644
--- a/demos/src/ftgrays2.h
+++ b/demos/src/ftgrays2.h
@@ -1,102 +1,9 @@
#ifndef FTGRAYS2_H
#define FTGRAYS2_H
-typedef int TScan;
-typedef long TPos;
-typedef float TDist;
-
-#define FT_MAX_GRAY_SPANS 32
-
-typedef struct FT_GraySpan_
-{
- short x;
- short len;
- unsigned char coverage;
-
-} FT_GraySpan;
-
-typedef int (*FT_GraySpan_Func)( int y,
- int count,
- FT_GraySpan* spans,
- void* user );
-
-typedef enum {
-
- dir_up = 0,
- dir_down = 1,
- dir_right = 2,
- dir_left = 3,
-
- dir_horizontal = 2,
- dir_reverse = 1,
-
- dir_unknown = 4
-
-} TDir;
-
-typedef struct TCell_
-{
- unsigned short x;
- unsigned short y;
- unsigned short pos;
- TDir dir;
-
-} TCell, *PCell;
-
-
-
-typedef struct TRaster_
-{
- PCell cells;
- PCell cursor;
- PCell cell_limit;
- int max_cells;
- int num_cells;
-
- TScan min_ex, max_ex;
- TScan min_ey, max_ey;
- TPos min_x, min_y;
- TPos max_x, max_y;
-
- TScan ex, ey;
- TScan cx, cy;
- TPos x, y;
-
- PCell contour_cell; /* first contour cell */
-
- char joint;
- char horizontal;
- TDir dir;
- PCell last;
-
- FT_Vector starter;
- FT_Vector* start;
-
- int error;
-
- FT_Vector bez_stack[32*3];
- int lev_stack[32];
-
- FT_Outline outline;
- FT_Bitmap target;
-
- FT_GraySpan gray_spans[ FT_MAX_GRAY_SPANS ];
- int num_gray_spans;
-
- FT_GraySpan_Func render_span;
- void* render_span_closure;
- int span_y;
-
-} TRaster, *PRaster;
-
- extern
- int grays2_raster_render( TRaster* raster,
- FT_Outline* outline,
- FT_Bitmap* target_map );
+#include <ftimage.h>
extern
- int grays2_raster_init( FT_Raster raster,
- const char* pool_base,
- long pool_size );
+ FT_Raster_Funcs ft_grays2_raster;
#endif
diff --git a/demos/src/fttimer.c b/demos/src/fttimer.c
index 295b675..3be2615 100644
--- a/demos/src/fttimer.c
+++ b/demos/src/fttimer.c
@@ -78,10 +78,9 @@
int vio_Height, vio_Width;
short visual; /* display glyphs while rendering */
- short gray_render; /* smooth fonts with gray levels */
+ short antialias; /* smooth fonts with gray levels */
short force_low;
- TRaster raster;
#define RASTER_BUFF_SIZE 128000
char raster_buff[ RASTER_BUFF_SIZE ];
@@ -122,7 +121,7 @@
Bit.width = bit.width;
Bit.pitch = bit.pitch;
Bit.buffer = bit.buffer;
- Bit.pixel_mode = gray_render ? ft_pixel_mode_grays : ft_pixel_mode_mono;
+ Bit.pixel_mode = antialias ? ft_pixel_mode_grays : ft_pixel_mode_mono;
Bit.num_grays = bit.grays;
Clear_Buffer();
}
@@ -219,10 +218,7 @@
FT_Error ConvertRaster( int index )
{
outlines[index].flags |= ~ft_outline_single_pass;
- if (use_grays)
- return grays_raster_render( &raster, &outlines[index], &Bit );
- else
- return FT_Outline_Get_Bitmap( library, &outlines[index], &Bit );
+ return FT_Outline_Get_Bitmap( library, &outlines[index], &Bit );
}
@@ -255,7 +251,7 @@
execname = argv[0];
- gray_render = 0;
+ antialias = 0;
visual = 0;
force_low = 0;
@@ -264,7 +260,7 @@
switch ( argv[1][1] )
{
case 'g':
- gray_render = 1;
+ antialias = 1;
break;
case 'a':
@@ -333,8 +329,12 @@
if ( (error = FT_Init_FreeType( &library )) )
Panic( "Error while initializing engine" );
- error = grays_raster_init( (FT_Raster)&raster, (const char*)raster_buff, RASTER_BUFF_SIZE );
- if (error) Panic( "Could not initialize smooth anti-aliasing renderer" );
+ /* set-up smooth anti-aliaser */
+ if (use_grays)
+ {
+ error = FT_Set_Raster( library, &ft_grays_raster );
+ if (error) Panic( "Could not initialize smooth anti-aliasing renderer" );
+ }
/* Load face */
@@ -358,7 +358,7 @@
error = FT_Set_Pixel_Sizes( face, pixel_size, pixel_size );
if ( error ) Panic( "Could not reset instance" );
- bit.mode = gray_render ? gr_pixel_mode_gray : gr_pixel_mode_mono;
+ bit.mode = antialias ? gr_pixel_mode_gray : gr_pixel_mode_mono;
bit.width = 640;
bit.rows = 480;
bit.grays = 128;
diff --git a/demos/src/ftview.c b/demos/src/ftview.c
index f125c8e..cc599a7 100644
--- a/demos/src/ftview.c
+++ b/demos/src/ftview.c
@@ -59,7 +59,7 @@ $\243^\250*\265\371%!\247:/;.,?<>";
int ptsize; /* current point size */
int hinted = 1; /* is glyph hinting active ? */
- int gray_render = 1; /* is anti-aliasing active ? */
+ int antialias = 1; /* is anti-aliasing active ? */
int use_sbits = 1; /* do we use embedded bitmaps ? */
int low_prec = 1; /* force low precision */
int Num; /* current first glyph index */
@@ -76,8 +76,9 @@ $\243^\250*\265\371%!\247:/;.,?<>";
int render_mode = 1;
int use_grays = 0;
- TRaster raster;
-
+ /* the standard raster's interface */
+ FT_Raster_Funcs std_raster;
+
#define RASTER_BUFF_SIZE 32768
char raster_buff[ RASTER_BUFF_SIZE ];
@@ -167,7 +168,7 @@ $\243^\250*\265\371%!\247:/;.,?<>";
if ( glyph->format == ft_glyph_format_outline )
{
- pitch = ( gray_render ? (width+3) & -4 : (width+7) >> 3 );
+ pitch = ( antialias ? (width+3) & -4 : (width+7) >> 3 );
size = pitch*height;
if (size > MAX_BUFFER)
@@ -176,13 +177,13 @@ $\243^\250*\265\371%!\247:/;.,?<>";
bit2.width = width;
bit2.rows = height;
bit2.pitch = pitch;
- bit2.pixel_mode = gray_render ? ft_pixel_mode_grays : ft_pixel_mode_mono;
+ bit2.pixel_mode = antialias ? ft_pixel_mode_grays : ft_pixel_mode_mono;
bit2.buffer = bit_buffer;
bit3.rows = bit2.rows;
bit3.width = bit2.width;
bit3.pitch = bit2.pitch;
- bit3.mode = gray_render ? bit.mode : gr_pixel_mode_mono;
+ bit3.mode = antialias ? bit.mode : gr_pixel_mode_mono;
bit3.buffer = bit_buffer;
bit3.grays = 128;
@@ -192,10 +193,7 @@ $\243^\250*\265\371%!\247:/;.,?<>";
if (low_prec)
glyph->outline.flags &= ~ft_outline_high_precision;
- if (use_grays & gray_render)
- error = grays_raster_render( &raster, &glyph->outline, &bit2 );
- else
- error = FT_Outline_Get_Bitmap( library, &glyph->outline, &bit2 );
+ error = FT_Outline_Get_Bitmap( library, &glyph->outline, &bit2 );
}
else
{
@@ -416,6 +414,17 @@ $\243^\250*\265\371%!\247:/;.,?<>";
grListenSurface( surface, gr_event_key, &dummy_event );
}
+ static void reset_raster( void )
+ {
+ FT_Error error;
+
+ error = 1;
+ if ( use_grays && antialias )
+ error = FT_Set_Raster( library, &ft_grays_raster );
+
+ if (error)
+ (void)FT_Set_Raster( library, &std_raster );
+ }
static int Process_Event( grEvent* event )
@@ -429,10 +438,11 @@ $\243^\250*\265\371%!\247:/;.,?<>";
return 0;
case grKEY('a'):
- gray_render = !gray_render;
- new_header = ( gray_render
+ antialias = !antialias;
+ new_header = ( antialias
? "anti-aliasing is now on"
: "anti-aliasing is now off" );
+ reset_raster();
return 1;
case grKEY('b'):
@@ -451,6 +461,7 @@ $\243^\250*\265\371%!\247:/;.,?<>";
new_header = ( use_grays
? "now using the smooth anti-aliaser"
: "now using the standard anti-aliaser" );
+ reset_raster();
break;
case grKEY('l'):
@@ -598,10 +609,9 @@ $\243^\250*\265\371%!\247:/;.,?<>";
error = FT_Init_FreeType( &library );
if (error) PanicZ( "Could not initialise FreeType library" );
- error = grays_raster_init( (FT_Raster)&raster, (const char*)raster_buff, RASTER_BUFF_SIZE );
- if (error) PanicZ( "Could not initialize anti-aliasing renderer" );
+ /* retrieve the standard raster's interface */
+ (void)FT_Get_Raster( library, ft_glyph_format_outline, &std_raster );
-/* FT_Set_Raster_Palette( library, 17, palette_17 ); */
NewFile:
ptsize = orig_ptsize;
diff --git a/include/freetype.h b/include/freetype.h
index 4897588..3f6ba98 100644
--- a/include/freetype.h
+++ b/include/freetype.h
@@ -736,15 +736,6 @@
/* resolution and point-size independent data found in a font file. */
/* */
/* <Fields> */
- /* driver :: A handle to the face's parent driver */
- /* object. */
- /* */
- /* memory :: A handle to the face's parent memory */
- /* object. Used for the allocation of */
- /* subsequent objects. */
- /* */
- /* stream :: A handle to the face's stream. */
- /* */
/* num_faces :: In the case where the face is located in a */
/* collection (i.e., a resource which embeds */
/* several faces), this is the total number of */
@@ -756,18 +747,6 @@
/* collections (which embed several fonts in a */
/* single resource/file). */
/* */
- /* generic :: A field reserved for client uses. See the */
- /* FT_Generic type description. */
- /* */
- /* glyph :: The face's associated glyph slot(s). This */
- /* object is created automatically with a new */
- /* face object. However, certain kinds of */
- /* applications (mainly tools like converters) */
- /* can need more than one slot to ease their */
- /* task. */
- /* */
- /* sizes_list :: The list of child sizes for this face. */
- /* */
/* face_flags :: A set of bit flags that give important */
/* information about the face; see the */
/* FT_FACE_FLAG_XXX macros for details. */
@@ -778,9 +757,6 @@
/* */
/* num_glyphs :: The total number of glyphs in the face. */
/* */
- /* num_charmaps :: The total number of character maps in the */
- /* face. */
- /* */
/* family_name :: The face's family name. This is an ASCII */
/* string, usually in English, which describes */
/* the typeface's family (like `Times New */
@@ -814,6 +790,19 @@
/* NULL if the field `num_fixed_sizes' is set */
/* to 0. */
/* */
+ /* num_charmaps :: The total number of character maps in the */
+ /* face. */
+ /* */
+ /* charmaps :: A table of pointers to the face's charmaps */
+ /* Used to scan the list of available charmaps */
+ /* this table might change after a call to */
+ /* FT_Attach_File/Stream (e.g. when it used */
+ /* to hook and additional encoding/CMap to */
+ /* the face object). */
+ /* */
+ /* generic :: A field reserved for client uses. See the */
+ /* FT_Generic type description. */
+ /* */
/* bbox :: The font bounding box. Coordinates are */
/* expressed in font units (see units_per_EM). */
/* The box is large enough to contain any */
@@ -880,6 +869,24 @@
/* underline for this face. Only relevant for */
/* scalable formats. */
/* */
+ /* driver :: A handle to the face's parent driver */
+ /* object. */
+ /* */
+ /* memory :: A handle to the face's parent memory */
+ /* object. Used for the allocation of */
+ /* subsequent objects. */
+ /* */
+ /* stream :: A handle to the face's stream. */
+ /* */
+ /* glyph :: The face's associated glyph slot(s). This */
+ /* object is created automatically with a new */
+ /* face object. However, certain kinds of */
+ /* applications (mainly tools like converters) */
+ /* can need more than one slot to ease their */
+ /* task. */
+ /* */
+ /* sizes_list :: The list of child sizes for this face. */
+ /* */
/* max_points :: The maximum number of points used to store */
/* the vectorial outline of any glyph in this */
/* face. If this value cannot be known in */
@@ -894,37 +901,24 @@
/* this should be set to 0. Only relevant for */
/* scalable formats. */
/* */
+ /* transform_matrix :: a 2x2 matrix of 16.16 coefficients used */
+ /* to transform glyph outlines after they're */
+ /* loaded from the font. Only used by the */
+ /* convenience functions. */
+ /* */
+ /* transform_delta :: a translation vector used to transform */
+ /* glyph outlines after they're loaded from */
+ /* the font. Only used by the convenience */
+ /* functions. */
+ /* */
+ /* transform_flags :: some flags used to classify the transform. */
+ /* Only used by the convenience functions. */
+ /* */
typedef struct FT_FaceRec_
{
- FT_Driver driver;
- FT_Memory memory;
- FT_Stream stream;
-
FT_Long num_faces;
FT_Long face_index;
- /* a generic pointer for client use */
- FT_Generic generic;
-
- /* the face's current glyph slot(s) */
- FT_GlyphSlot glyph;
-
- /* the face's current size, may be nil */
- FT_Size size;
-
- /* the face's current charmap */
- FT_CharMap charmap;
-
- /* the face's table of available charmaps */
- FT_Int num_charmaps;
- FT_CharMap* charmaps;
-
- /* the face's current sizes list */
- FT_ListRec sizes_list;
-
- /* a pointer to the face's extensions block, if supported */
- void* extensions;
-
FT_Long face_flags;
FT_Long style_flags;
@@ -936,8 +930,13 @@
FT_Int num_fixed_sizes;
FT_Bitmap_Size* available_sizes;
- /* the following are only relevant for scalable outlines */
+ /* the face's table of available charmaps */
+ FT_Int num_charmaps;
+ FT_CharMap* charmaps;
+
+ FT_Generic generic;
+ /* the following are only relevant for scalable outlines */
FT_BBox bbox;
FT_UShort units_per_EM;
@@ -951,9 +950,28 @@
FT_Short underline_position;
FT_Short underline_thickness;
+ /************************************************************/
+ /* The following fields should be considered private and */
+ /* rarely, if ever, used by client applications.. */
+
+ FT_Driver driver;
+ FT_Memory memory;
+ FT_Stream stream;
+
+ FT_GlyphSlot glyph;
+ FT_Size size;
+ FT_CharMap charmap;
+ FT_ListRec sizes_list;
+
+ void* extensions;
+
FT_UShort max_points;
FT_Short max_contours;
+ FT_Matrix transform_matrix;
+ FT_Vector transform_delta;
+ FT_Int transform_flags;
+
} FT_FaceRec;
@@ -1284,7 +1302,7 @@
FT_Glyph_Metrics metrics;
FT_Glyph_Metrics metrics2;
- FT_Glyph_Tag format;
+ FT_Glyph_Format format;
FT_Bitmap bitmap;
FT_Outline outline;
@@ -1347,6 +1365,28 @@
FT_Error FT_Done_FreeType( FT_Library library );
+ /*************************************************************************/
+ /* */
+ /* <Function> */
+ /* FT_Stream_Type */
+ /* */
+ /* <Description> */
+ /* An enumeration used to list the possible ways to open a new */
+ /* input stream. It is used by the FT_Open_Args structure.. */
+ /* */
+ /* <Fields> */
+ /* ft_stream_memory :: this is a memory-based stream */
+ /* ft_stream_copy :: copy the stream from the "stream" field */
+ /* ft_stream_pathname :: create a new input stream from a C pathname */
+ /* */
+ typedef enum {
+
+ ft_stream_memory = 1,
+ ft_stream_copy = 2,
+ ft_stream_pathname = 3
+
+ } FT_Stream_Type;
+
/*************************************************************************
*
* <Struct>
@@ -1358,6 +1398,8 @@
* function FT_Open_Face & FT_Attach_Stream.
*
* <Fields>
+ * stream_type :: type of input stream
+ *
* memory_base :: first byte of file in memory
* memory_size :: size in bytes of file in memory
*
@@ -1371,28 +1413,30 @@
* the face with each one of the drivers in its list.
*
* <Note>
- * Here's how a new input stream is built from a FT_Open_Args
- * structure:
+ * The stream_type determines which fields are used to create a new
+ * input stream.
*
- * a/ if 'memory_base' and 'memory_size' are non-null, create a
- * memory-based stream from the indicated address and length.
+ * If it is ft_stream_memory, a new memory-based stream will be created
+ * using the memory block specified by "memory_base" and "memory_size"
*
- * b/ Otherwise, if 'pathname' is non NULL, use it to build a
- * new system-specific stream (by calling FT_New_Stream)
+ * If it is ft_stream_pathname, a new stream will be created with the
+ * "pathname" field, calling the system-specific FT_New_Stream function
*
- * c/ Otherwise, if 'stream' is non NULL, use it to access the
- * font file (note that a new FT_Stream object will be created
- * where the contents of 'stream' will be copied).
+ * It is is ft_stream_copy, then the content of "stream" will be copied
+ * to a new input stream object. The object will be closed and destroyed
+ * when the face is destroyed itself.. Note that this means that you
+ * should not close the stream before the library does !!
*
*************************************************************************/
typedef struct FT_Open_Args_
{
- FT_Byte* memory_base;
- FT_Long memory_size;
- FT_String* pathname;
- FT_Stream stream;
- FT_Driver driver;
+ FT_Stream_Type stream_type;
+ FT_Byte* memory_base;
+ FT_Long memory_size;
+ FT_String* pathname;
+ FT_Stream stream;
+ FT_Driver driver;
} FT_Open_Args;
@@ -1568,46 +1612,6 @@
/*************************************************************************/
/* */
/* <Function> */
- /* FT_New_Size */
- /* */
- /* <Description> */
- /* Creates a new size object from a given face object. */
- /* */
- /* <Input> */
- /* face :: A handle to a parent face object. */
- /* */
- /* <Output> */
- /* size :: A handle to a new size object. */
- /* */
- /* <Return> */
- /* Error code. 0 means success. */
- /* */
- EXPORT_DEF
- FT_Error FT_New_Size( FT_Face face,
- FT_Size* size );
-
-
- /*************************************************************************/
- /* */
- /* <Function> */
- /* FT_Done_Size */
- /* */
- /* <Description> */
- /* Discards a given size object. */
- /* */
- /* <Input> */
- /* size :: A handle to a target size object */
- /* */
- /* <Return> */
- /* Error code. 0 means success. */
- /* */
- EXPORT_DEF
- FT_Error FT_Done_Size( FT_Size size );
-
-
- /*************************************************************************/
- /* */
- /* <Function> */
/* FT_Set_Char_Size */
/* */
/* <Description> */
@@ -1660,48 +1664,6 @@
/*************************************************************************/
/* */
/* <Function> */
- /* FT_New_GlyphSlot */
- /* */
- /* <Description> */
- /* It is sometimes useful to have more than one glyph slot for a */
- /* given face object. This function is used to create additional */
- /* slots. All of them are automatically discarded when the face is */
- /* destroyed. */
- /* */
- /* <Input> */
- /* face :: A handle to a parent face object. */
- /* */
- /* <Output> */
- /* slot :: A handle to a new glyph slot object. */
- /* */
- /* <Return> */
- /* Error code. 0 means success. */
- /* */
- EXPORT_DEF
- FT_Error FT_New_GlyphSlot( FT_Face face,
- FT_GlyphSlot* aslot );
-
-
- /*************************************************************************/
- /* */
- /* <Function> */
- /* FT_Done_GlyphSlot */
- /* */
- /* <Description> */
- /* Destroys a given glyph slot. Remember however that all slots are */
- /* automatically destroyed with its parent. Using this function is */
- /* not always mandatory. */
- /* */
- /* <Input> */
- /* slot :: A handle to a target glyph slot. */
- /* */
- EXPORT_DEF
- void FT_Done_GlyphSlot( FT_GlyphSlot slot );
-
-
- /*************************************************************************/
- /* */
- /* <Function> */
/* FT_Load_Glyph */
/* */
/* <Description> */
@@ -1875,7 +1837,11 @@
/* the values of `num_subglyphs' and `subglyphs', as well as set */
/* `face->glyph.format' to ft_glyph_format_composite. */
/* */
- /* XXXXX : IMPORTANT NOTE, THIS FLAG IS NOT YET IMPLEMENTED !! */
+ /* This is for use by the auto-hinter and possibly other tools */
+ /* For nearly all applications, this flags should be left unset */
+ /* when invoking FT_Load_Glyph(). */
+ /* */
+ /* Note that the flag forces the load of unscaled glyphs */
/* */
#define FT_LOAD_NO_RECURSE 1024
@@ -1896,36 +1862,6 @@
/*************************************************************************/
/* */
/* <Function> */
- /* FT_Get_Glyph_Bitmap */
- /* */
- /* <Description> */
- /* Renders a given glyph into a bitmap or pixmap. This function will */
- /* use the registered rasters to render the glyph image. */
- /* */
- /* <Input> */
- /* face :: handle to the face object whose glyph slot contains */
- /* the glyph image */
- /* map :: A pointer to the target bitmap descriptor. */
- /* */
- /* <Return> */
- /* FreeType error code. 0 means success. */
- /* */
- /* <MT-Note> */
- /* YES. Rendering is synchronized, so that concurrent calls to the */
- /* scan-line converter will be serialized. */
- /* */
- /* <Note> */
- /* This function does NOT CREATE the bitmap, it only renders a */
- /* glyph image into it! */
- /* */
- EXPORT_DEF
- FT_Error FT_Get_Glyph_Bitmap( FT_Face face,
- FT_Bitmap* map );
-
-
- /*************************************************************************/
- /* */
- /* <Function> */
/* FT_Get_Kerning */
/* */
/* <Description> */
@@ -2087,6 +2023,75 @@
/*************************************************************************/
/* */
/* <Function> */
+ /* FT_Outline_Get_Bitmap */
+ /* */
+ /* <Description> */
+ /* Renders an outline within a bitmap. The outline's image is simply */
+ /* or-ed to the target bitmap. */
+ /* */
+ /* */
+ /* <Input> */
+ /* library :: A handle to a FreeType library object. */
+ /* outline :: A pointer to the source outline descriptor. */
+ /* map :: A pointer to the target bitmap descriptor. */
+ /* */
+ /* <Return> */
+ /* FreeType error code. 0 means success. */
+ /* */
+ /* <MT-Note> */
+ /* YES. Rendering is synchronized, so that concurrent calls to the */
+ /* scan-line converter will be serialized. */
+ /* */
+ /* <Note> */
+ /* This function does NOT CREATE the bitmap, it only renders an */
+ /* outline image within the one you pass to it! */
+ /* */
+ /* It will use the raster correponding to the default glyph format. */
+ /* */
+ EXPORT_DEF
+ FT_Error FT_Outline_Get_Bitmap( FT_Library library,
+ FT_Outline* outline,
+ FT_Bitmap* map );
+
+ /*************************************************************************/
+ /* */
+ /* <Function> */
+ /* FT_Outline_Render */
+ /* */
+ /* <Description> */
+ /* Renders an outline within a bitmap using the current scan-convert */
+ /* This functions uses a FT_Raster_Params as argument, allowing */
+ /* advanced features like direct composition/translucency, etc.. */
+ /* */
+ /* <Input> */
+ /* library :: A handle to a FreeType library object. */
+ /* outline :: A pointer to the source outline descriptor. */
+ /* params :: A pointer to a FT_Raster_Params used to describe */
+ /* the rendering operation */
+ /* */
+ /* <Return> */
+ /* FreeType error code. 0 means success. */
+ /* */
+ /* <MT-Note> */
+ /* YES. Rendering is synchronized, so that concurrent calls to the */
+ /* scan-line converter will be serialized. */
+ /* */
+ /* <Note> */
+ /* You should know what you're doing and the role of FT_Raster_Params */
+ /* to use this function. */
+ /* */
+ /* the field "params.source" will be set to "outline" before the */
+ /* scan converter is called, which means that the value you give it */
+ /* is actually ignored.. */
+ /* */
+ EXPORT_DEF
+ FT_Error FT_Outline_Render( FT_Library library,
+ FT_Outline* outline,
+ FT_Raster_Params* params );
+
+ /*************************************************************************/
+ /* */
+ /* <Function> */
/* FT_Outline_Decompose */
/* */
/* <Description> */
@@ -2211,15 +2216,12 @@
/* <Output> */
/* cbox :: The outline's control box. */
/* */
- /* <Return> */
- /* FreeType error code. 0 means success. */
- /* */
/* <MT-Note> */
/* Yes. */
/* */
EXPORT_DEF
- FT_Error FT_Outline_Get_CBox( FT_Outline* outline,
- FT_BBox* cbox );
+ void FT_Outline_Get_CBox( FT_Outline* outline,
+ FT_BBox* cbox );
/*************************************************************************/
@@ -2253,23 +2255,79 @@
/* Register a given raster to the library. */
/* */
/* <Input> */
- /* library :: A handle to a target library object. */
- /* */
- /* interface :: pointer to the raster's interface */
+ /* library :: A handle to a target library object. */
+ /* raster_funcs :: pointer to the raster's interface */
/* */
- /* raster :: if this field is nil, this function will allocate */
- /* a new objet. Otherwise, it will simply use the one */
- /* provided here. */
/* <Return> */
/* Error code. 0 means success. */
/* */
+ /* <Note> */
+ /* This function will do the following: */
+ /* */
+ /* - a new raster object is created through raster_func.raster_new */
+ /* if this fails, then the function returns */
+ /* */
+ /* - if a raster is already registered for the glyph format */
+ /* specified in raster_funcs, it will be destroyed */
+ /* */
+ /* - the new raster is registered for the glyph format */
+ /* */
+ EXPORT_DEF
+ FT_Error FT_Set_Raster( FT_Library library,
+ FT_Raster_Funcs* raster_funcs );
+
+
+ /*************************************************************************/
+ /* */
+ /* <Function> */
+ /* FT_Unset_Raster */
+ /* */
+ /* <Description> */
+ /* Removes a given raster from the library. */
+ /* */
+ /* <Input> */
+ /* library :: A handle to a target library object. */
+ /* raster_funcs :: pointer to the raster's interface */
+ /* */
/* <Return> */
/* Error code. 0 means success. */
/* */
+ /* <Note> */
+ /* This function should never be used by a normal client application */
+ /* as FT_Set_Raster unregisters the previous raster for a given */
+ /* glyph format.. */
+ /* */
+ EXPORT_DEF
+ FT_Error FT_Unset_Raster( FT_Library library,
+ FT_Raster_Funcs* raster_funcs );
+
+
+ /*************************************************************************
+ *
+ * <Function>
+ * FT_Get_Raster
+ *
+ * <Description>
+ * Return a pointer to the raster corresponding to a given glyph
+ * format tag.
+ *
+ * <Input>
+ * library :: handle to source library object
+ * glyph_format :: glyph format tag
+ *
+ * <Output>
+ * raster_funcs :: if this field is not 0, returns a pointer to the
+ * raster's interface/descriptor..
+ *
+ * <Return>
+ * a pointer to the corresponding raster object.
+ *
+ *************************************************************************/
+
EXPORT_DEF
- FT_Error FT_Set_Raster( FT_Library library,
- FT_Raster_Interface* interface,
- FT_Raster raster );
+ FT_Raster FT_Get_Raster( FT_Library library,
+ FT_Glyph_Format glyph_format,
+ FT_Raster_Funcs *raster_funcs );
/*************************************************************************/
@@ -2289,11 +2347,162 @@
/* Error code. 0 means success. */
/* */
EXPORT_DEF
- FT_Error FT_Set_Raster_Mode( FT_Library library,
- FT_Glyph_Tag format,
- const char* mode,
- const char* args );
+ FT_Error FT_Set_Raster_Mode( FT_Library library,
+ FT_Glyph_Format format,
+ const char* mode,
+ void* args );
+
+
+ /***************************************************************************/
+ /***************************************************************************/
+ /***************************************************************************/
+ /***** *****/
+ /***** C O N V E N I E N C E F U N C T I O N S *****/
+ /***** *****/
+ /***** *****/
+ /***** The following functions are provided as a convenience *****/
+ /***** to client applications. However, their compilation might *****/
+ /***** be discarded if FT_CONFIG_OPTION_NO_CONVENIENCE_FUNCS *****/
+ /***** is defined in "config/ftoption.h". *****/
+ /***** *****/
+ /***************************************************************************/
+ /***************************************************************************/
+ /***************************************************************************/
+
+ /*************************************************************************/
+ /* */
+ /* <Function> */
+ /* FT_Outline_Copy */
+ /* */
+ /* <Description> */
+ /* Copies an outline into another one. Both objects must have the */
+ /* same sizes (number of points & number of contours) when this */
+ /* function is called. */
+ /* */
+ /* <Input> */
+ /* source :: A handle to the source outline. */
+ /* target :: A handle to the target outline. */
+ /* */
+ /* <Return> */
+ /* FreeType error code. 0 means success. */
+ /* */
+ EXPORT_DEF
+ FT_Error FT_Outline_Copy( FT_Outline* source,
+ FT_Outline* target );
+
+
+
+ /*************************************************************************/
+ /* */
+ /* <Function> */
+ /* FT_Outline_Transform */
+ /* */
+ /* <Description> */
+ /* Applies a simple 2x2 matrix to all of an outline's points. Useful */
+ /* for applying rotations, slanting, flipping, etc. */
+ /* */
+ /* <Input> */
+ /* outline :: A pointer to the target outline descriptor. */
+ /* matrix :: A pointer to the transformation matrix. */
+ /* */
+ /* <MT-Note> */
+ /* Yes. */
+ /* */
+ /* <Note> */
+ /* You can use FT_Outline_Translate() if you need to translate the */
+ /* outline's points. */
+ /* */
+ EXPORT_DEF
+ void FT_Outline_Transform( FT_Outline* outline,
+ FT_Matrix* matrix );
+
+ /*************************************************************************/
+ /* */
+ /* <Function> */
+ /* FT_Outline_Reverse */
+ /* */
+ /* <Description> */
+ /* Reverse the drawing direction of an outline. This is used to */
+ /* ensure consistent fill conventions for mirrored glyphs.. */
+ /* */
+ /* <Input> */
+ /* outline :: A pointer to the target outline descriptor. */
+ /* */
+ /* <Note> */
+ /* This functions toggles the bit flag ft_outline_reverse_fill in */
+ /* the outline's "flags" field.. */
+ /* */
+ /* It shouldn't be used by a normal client application, unless it */
+ /* knows what it's doing.. */
+ /* */
+ EXPORT_DEF
+ void FT_Outline_Reverse( FT_Outline* outline );
+
+
+ /*************************************************************************/
+ /* */
+ /* <Function> */
+ /* FT_Vector_Transform */
+ /* */
+ /* <Description> */
+ /* Transforms a single vector through a 2x2 matrix. */
+ /* */
+ /* <InOut> */
+ /* vector :: The target vector to transform */
+ /* */
+ /* <Input> */
+ /* matrix :: A pointer to the source 2x2 matrix. */
+ /* */
+ /* <MT-Note> */
+ /* Yes. */
+ /* */
+ EXPORT_DEF
+ void FT_Vector_Transform( FT_Vector* vector,
+ FT_Matrix* matrix );
+
+
+ /*************************************************************************/
+ /* */
+ /* <Function> */
+ /* FT_Matrix_Multiply */
+ /* */
+ /* <Description> */
+ /* Performs the matrix operation `b = a*b'. */
+ /* */
+ /* <Input> */
+ /* a :: A pointer to matrix `a'. */
+ /* */
+ /* <InOut> */
+ /* b :: A pointer to matrix `b'. */
+ /* */
+ /* <MT-Note> */
+ /* Yes. */
+ /* */
+ EXPORT_DEF
+ void FT_Matrix_Multiply( FT_Matrix* a,
+ FT_Matrix* b );
+
+ /*************************************************************************/
+ /* */
+ /* <Function> */
+ /* FT_Matrix_Invert */
+ /* */
+ /* <Description> */
+ /* Inverts a 2x2 matrix. Returns an error if it can't be inverted. */
+ /* */
+ /* <InOut> */
+ /* matrix :: A pointer to the target matrix. Remains untouched in */
+ /* case of error. */
+ /* */
+ /* <Return> */
+ /* FreeType error code. 0 means success. */
+ /* */
+ /* <MT-Note> */
+ /* Yes. */
+ /* */
+ EXPORT_DEF
+ FT_Error FT_Matrix_Invert( FT_Matrix* matrix );
#ifdef __cplusplus
}
diff --git a/include/ftglyph.h b/include/ftglyph.h
new file mode 100644
index 0000000..cafc241
--- /dev/null
+++ b/include/ftglyph.h
@@ -0,0 +1,320 @@
+/***************************************************************************/
+/* */
+/* ftglyph.h */
+/* */
+/* FreeType convenience functions to handle glyphs.. */
+/* */
+/* Copyright 1996-1999 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. */
+/* */
+/* This file contains the definition of several convenience functions */
+/* that can be used by client applications to easily retrieve glyph */
+/* bitmaps and outlines from a given face. */
+/* */
+/* These functions should be optional if you're writing a font server */
+/* or text layout engine on top of FreeType. However, they are pretty */
+/* handy for many other simple uses of the library.. */
+/* */
+/***************************************************************************/
+
+#ifndef FTGLYPH_H
+#define FTGLYPH_H
+
+#include <freetype.h>
+
+ typedef enum {
+
+ ft_glyph_type_none = 0,
+ ft_glyph_type_bitmap = 1,
+ ft_glyph_type_outline = 2
+
+ } FT_GlyphType;
+
+ /***********************************************************************
+ *
+ * <Struct>
+ * FT_GlyphRec
+ *
+ * <Description>
+ * The root glyph structure contains a given glyph image's metrics.
+ * Note that the FT_Glyph type is a pointer to FT_GlyphRec
+ *
+ * <Field>
+ * memory :: a handle to the memory allocator that is used to
+ * create/clone/destroy this glyph..
+ *
+ * glyph_type :: the glyph type..
+ *
+ * height :: height of glyph image
+ * width :: width of glyph image
+ *
+ * bearingX :: horizontal bearing, this is the distance from the
+ * the current pen position to the left of the glyph
+ *
+ * bearingY :: vertical bearing, this is the distance from the
+ * current pen position to the top of the glyph
+ *
+ * advance :: this is the horizontal or vertical advance for the
+ * glyph
+ *
+ * <Note>
+ * the distances expressed in the metrics are expressed in 26.6 fixed
+ * float sub-pixels (i.e. 1/64th of pixels).
+ *
+ * the vertical bearing has a positive value when the glyph top is
+ * above the baseline, and negative when it is under..
+ *
+ ***********************************************************************/
+
+ typedef struct FT_GlyphRec_
+ {
+ FT_Memory memory;
+ FT_GlyphType glyph_type;
+ FT_Int height;
+ FT_Int width;
+ FT_Int bearingX;
+ FT_Int bearingY;
+ FT_Int advance;
+
+ } FT_GlyphRec, *FT_Glyph;
+
+
+ /***********************************************************************
+ *
+ * <Struct>
+ * FT_BitmapGlyphRec
+ *
+ * <Description>
+ * A structure used to describe a bitmap glyph image..
+ * Note that the FT_BitmapGlyph type is a pointer to FT_BitmapGlyphRec
+ *
+ * <Field>
+ * metrics :: the corresponding glyph metrics
+ * bitmap :: a descriptor for the bitmap.
+ *
+ * <Note>
+ * the "width" and "height" fields of the metrics are expressed in
+ * 26.6 sub-pixels. However, the width and height in pixels can be
+ * read directly from "bitmap.width" and "bitmap.height"
+ *
+ * this structure is used for both monochrome and anti-aliased
+ * bitmaps (the bitmap descriptor contains field describing the
+ * format of the pixel buffer)
+ *
+ * the corresponding pixel buffer is always owned by the BitmapGlyph
+ * and is thus creatde and destroyed with it..
+ *
+ ***********************************************************************/
+
+ typedef struct FT_BitmapGlyphRec_
+ {
+ FT_GlyphRec metrics;
+ FT_Int left;
+ FT_Int top;
+ FT_Bitmap bitmap;
+
+ } FT_BitmapGlyphRec_, *FT_BitmapGlyph;
+
+
+ /***********************************************************************
+ *
+ * <Struct>
+ * FT_OutlineGlyphRec
+ *
+ * <Description>
+ * A structure used to describe a vectorial outline glyph image..
+ * Note that the FT_OutlineGlyph type is a pointer to FT_OutlineGlyphRec
+ *
+ * <Field>
+ * metrics :: the corresponding glyph metrics
+ * outline :: a descriptor for the outline
+ *
+ * <Note>
+ * the "width" and "height" fields of the metrics are expressed in
+ * 26.6 sub-pixels. However, the width and height in pixels can be
+ * read directly from "bitmap.width" and "bitmap.rows"
+ *
+ * the corresponding outline points tables is always owned by the
+ * object and are destroyed with it..
+ *
+ * an OutlineGlyph can be used to generate a BitmapGlyph with the
+ * function FT_OutlineGlyph_Render()
+ *
+ ***********************************************************************/
+
+ typedef struct FT_OutlineGlyphRec_
+ {
+ FT_GlyphRec metrics;
+ FT_Outline outline;
+
+ } FT_OutlineGlyphRec_, *FT_OutlineGlyph;
+
+
+ /***********************************************************************
+ *
+ * <Function>
+ * FT_Get_Glyph_Bitmap
+ *
+ * <Description>
+ * A function used to directly return a monochrome bitmap glyph image
+ * from a face.
+ *
+ * <Input>
+ * face :: handle to source face object
+ * glyph_index :: glyph index in face
+ * load_flags :: load flags, see FT_LOAD_FLAG_XXXX constants..
+ * grays :: number of gray levels for anti-aliased bitmaps,
+ * set to 0 if you want to render a monochrome bitmap
+ * origin :: a pointer to the origin's position. Set to 0
+ * if the current transform is the identity..
+ *
+ * <Output>
+ * bitglyph :: pointer to the new bitmap glyph
+ *
+ * <Return>
+ * Error code. 0 means success.
+ *
+ * <Note>
+ * If the font contains glyph outlines, these will be automatically
+ * converted to a bitmap according to the value of "grays"
+ *
+ * If "grays" is set to 0, the result is a 1-bit monochrome bitmap
+ * otherwise, it is an 8-bit gray-level bitmap
+ *
+ * The number of gray levels in the result anti-aliased bitmap might
+ * not be "grays", depending on the current scan-converter implementation
+ *
+ * Note that it is not possible to generate 8-bit monochrome bitmaps
+ * with this function. Rather, use FT_Get_Glyph_Outline, then
+ * FT_Glyph_Render_Outline and provide your own span callbacks..
+ *
+ * When the face doesn't contain scalable outlines, this function will
+ * fail if the current transform is not the identity, or if the glyph
+ * origin's phase to the pixel grid is not 0 in both directions !!
+ *
+ ***********************************************************************/
+
+ EXPORT_DEF
+ FT_Error FT_Get_Glyph_Bitmap( FT_Face face,
+ FT_UInt glyph_index,
+ FT_UInt load_flags,
+ FT_Int grays,
+ FT_Vector* origin,
+ FT_BitmapGlyph *abitglyph );
+
+
+ /***********************************************************************
+ *
+ * <Function>
+ * FT_Get_Glyph_Outline
+ *
+ * <Description>
+ * A function used to directly return a bitmap glyph image from a
+ * face. This is faster than calling FT_Load_Glyph+FT_Get_Outline_Bitmap..
+ *
+ * <Input>
+ * face :: handle to source face object
+ * glyph_index :: glyph index in face
+ * load_flags :: load flags, see FT_LOAD_FLAG_XXXX constants..
+ *
+ * <Output>
+ * vecglyph :: pointer to the new outline glyph
+ *
+ * <Return>
+ * Error code. 0 means success.
+ *
+ * <Note>
+ * If the glyph is not an outline in the face, this function will
+ * fail..
+ *
+ * This function will fail if the load flags FT_LOAD_NO_OUTLINE and
+ * FT_LOAD_NO_RECURSE are set..
+ *
+ ***********************************************************************/
+
+ EXPORT_DEF
+ FT_Error FT_Get_Glyph_Outline( FT_Face face,
+ FT_UInt glyph_index,
+ FT_UInt load_flags,
+ FT_OutlineGlyph *vecglyph );
+
+
+ /***********************************************************************
+ *
+ * <Function>
+ * FT_Set_Transform
+ *
+ * <Description>
+ * A function used to set the transform that is applied to glyph images
+ * just after they're loaded in the face's glyph slot, and before they're
+ * returned by either FT_Get_Glyph_Bitmap or FT_Get_Glyph_Outline
+ *
+ * <Input>
+ * face :: handle to source face object
+ * matrix :: pointer to the transform's 2x2 matrix. 0 for identity
+ * delta :: pointer to the transform's translation. 0 for null vector
+ *
+ * <Note>
+ * The transform is only applied to glyph outlines when they are found
+ * in a font face. It is unable to transform embedded glyph bitmaps
+ *
+ ***********************************************************************/
+
+ EXPORT_DEF
+ void FT_Set_Transform( FT_Face face,
+ FT_Matrix* matrix,
+ FT_Vector* delta );
+
+
+ /***********************************************************************
+ *
+ * <Function>
+ * FT_Done_Glyph
+ *
+ * <Description>
+ * Destroys a given glyph..
+ *
+ * <Input>
+ * glyph :: handle to target glyph object
+ *
+ ***********************************************************************/
+
+ EXPORT_DEF
+ void FT_Done_Glyph( FT_Glyph glyph );
+
+
+ /***********************************************************************
+ *
+ * <Function>
+ * FT_Glyph_Get_Box
+ *
+ * <Description>
+ * Returns the glyph image's bounding box in pixels.
+ *
+ * <Input>
+ * glyph :: handle to target glyph object
+ *
+ * <Output>
+ * box :: the glyph bounding box. Coordinates are expressed in
+ * _integer_ pixels, with exclusive max bounds
+ *
+ * <Note>
+ * Coordinates are relative to the glyph origin, using the Y-upwards
+ * convention..
+ *
+ * The width of the box in pixels is box.xMax-box.xMin
+ * The height is box.yMax - box.yMin
+ *
+ ***********************************************************************/
+
+ EXPORT_DEF
+ void FT_Glyph_Get_Box( FT_Glyph glyph,
+ FT_BBox *box );
+
+#endif /* FTGLYPH_H */
diff --git a/include/ftimage.h b/include/ftimage.h
index 527071e..9e8f5d4 100644
--- a/include/ftimage.h
+++ b/include/ftimage.h
@@ -470,8 +470,6 @@
} FT_Outline_Funcs;
-
-
/*************************************************************************/
/* */
/* <Macro> */
@@ -491,7 +489,7 @@
/***********************************************************************
*
* <Enum>
- * FT_Glyph_Tag
+ * FT_Glyph_Format
*
* <Description>
* An enumeration type used to describethe format of a given glyph
@@ -518,7 +516,7 @@
*
***********************************************************************/
- typedef enum FT_Glyph_Tag_
+ typedef enum FT_Glyph_Format_
{
ft_glyph_format_none = 0,
ft_glyph_format_composite = FT_IMAGE_TAG('c','o','m','p'),
@@ -526,8 +524,28 @@
ft_glyph_format_outline = FT_IMAGE_TAG('o','u','t','l'),
ft_glyph_format_plotter = FT_IMAGE_TAG('p','l','o','t')
- } FT_Glyph_Tag;
+ } FT_Glyph_Format;
+
+ /*************************************************************************/
+ /*************************************************************************/
+ /*************************************************************************/
+ /***** *****/
+ /***** R A S T E R D E F I N I T I O N S *****/
+ /***** *****/
+ /*************************************************************************/
+ /*************************************************************************/
+ /*************************************************************************/
+ /**************************************************************************
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ **************************************************************************/
/*************************************************************************/
/* */
@@ -543,126 +561,374 @@
/*************************************************************************/
/* */
- /* <FuncType> */
- /* FT_Raster_Init_Proc */
+ /* <Struct> */
+ /* FT_Span */
/* */
/* <Description> */
- /* Initializes a fresh raster object which should have been allocated */
- /* by client applications. This function is also used to set the */
- /* object's render pool. It can be used repeatedly on a single */
- /* object if one wants to change the pool's address or size. */
+ /* A structure used to model a single span of gray (or black) pixels */
+ /* when rendering a monocrhome or anti-aliased bitmap. */
/* */
- /* Note that the render pool has no state and is only used during a */
- /* call to FT_Raster_Render(). It is thus theorically possible to */
- /* share it between several non-concurrent components of your */
- /* applications when memory is a scarce resource. */
+ /* <Fields> */
+ /* x :: the span's horizontal start position */
+ /* len :: the span's length in pixels */
+ /* coverage :: the span color/coverage, ranging from 0 (background) */
+ /* to 255 (foreground). Only used for anti-aliased */
+ /* rendering.. */
/* */
- /* <Input> */
- /* raster :: a handle to the target raster object. */
- /* pool_base :: the render pool's base address in memory */
- /* pool_size :: the render pool's size in bytes. this must be at */
- /* least 4 kByte. */
- /* <Return> */
- /* An error condition, used as a FT_Error in the FreeType library. */
- /* 0 means success. */
+ /* <Note> */
+ /* This structure is used by the span drawing callback type */
+ /* named FT_Raster_Span_Func, which takes the y coordinate of the */
+ /* span as a paremeter.. */
+ /* */
+ /* The coverage value is always between 0 and 255, even if the */
+ /* number of gray levels have been set through FT_Set_Gray_Levels() */
/* */
- typedef int (*FT_Raster_Init_Proc)( FT_Raster raster,
- const char* pool_base,
- long pool_size );
+ typedef struct FT_Span_
+ {
+ short x;
+ short len;
+ unsigned char coverage;
+
+ } FT_Span;
/*************************************************************************/
/* */
/* <FuncType> */
- /* FT_Raster_Set_Mode_Proc */
+ /* FT_Raster_Span_Func */
/* */
/* <Description> */
- /* Some raster implementations may have several modes of operation. */
- /* This function is used to select one of them, as well as pass some */
- /* arguments. */
+ /* A function used as a call-back by the anti-aliased renderer in */
+ /* order to let client applications draw themselves the gray pixel */
+ /* spans on each scan line. */
/* */
/* <Input> */
- /* raster :: The target raster object. */
+ /* y :: the scanline's y coordinate */
+ /* count :: the number of spans to draw on this scanline */
+ /* spans :: a table of 'count' spans to draw on the scanline */
+ /* user :: user-supplied data that is passed to the callback */
+ /* */
+ /* <Note> */
+ /* This callback allows client applications to directly render the */
+ /* gray spans of the anti-aliased bitmap to any kind of surfaces. */
+ /* */
+ /* This can be used to write anti-aliased outlines directly to a */
+ /* given background bitmap, and even perform translucency.. */
+ /* */
+ /* Note that the "count" field cannot be greater than a fixed value */
+ /* defined by the FT_MAX_GRAY_SPANS configuration macro in ftoption.h */
+ /* */
+ /* By default, this value is set to 32, which means that if there are */
+ /* more than 32 spans on a given scanline, the callback will be called */
+ /* several times with the same "y" parameter in order to draw all */
+ /* callbacks.. */
+ /* */
+ /* Otherwise, the callback is only called once per scan-line, and */
+ /* only for those scanlines that do have "gray" pixels on them.. */
+ /* */
+ typedef void (*FT_Raster_Span_Func)( int y,
+ int count,
+ FT_Span* spans,
+ void* user );
+
+ /*************************************************************************/
/* */
- /* mode :: A pointer used to describe the mode to set. This is */
- /* completely raster-specific, and could be, for example, */
- /* a text string. */
+ /* <FuncType> */
+ /* FT_Raster_BitTest_Func */
/* */
- /* args :: An argument to the set_mode command. This is completely */
- /* specific to the raster and the mode used. */
+ /* <Description> */
+ /* A function used as a call-back by the monochrome scan-converter */
+ /* to test wether a given target pixel is already set to the drawing */
+ /* "color". These tests are crucial to implement drop-out control */
+ /* per-se the TrueType spec.. */
+ /* */
+ /* <Input> */
+ /* y :: the pixel's y coordinate */
+ /* x :: the pixel's x coordinate */
+ /* user :: user-supplied data that is passed to the callback */
/* */
/* <Return> */
- /* An error code, used as a FT_Error by the FreeType library. */
- /* 0 means success. */
+ /* 1 if the pixel is "set", 0 otherwise */
/* */
- typedef int (*FT_Raster_Set_Mode_Proc)( FT_Raster raster,
- const char* mode,
- const char* args );
-
-
- /*************************************************************************
- *
- * <FuncType>
- * FT_Raster_Render_Proc
- *
- * <Description>
- * Renders an outline into a target bitmap/pixmap.
- *
- * <Input>
- * raster :: A handle to a raster object used during rendering.
- *
- * source_image :: a typeless pointer to the source glyph image.
- * (usually a FT_Outline*).
- *
- * target_bitmap :: descriptor to the target bitmap.
- *
- * <Return>
- * Error code, interpreted as a FT_Error by FreeType library.
- * 0 means success.
- *
- *************************************************************************/
-
- typedef int (*FT_Raster_Render_Proc)( FT_Raster raster,
- void* source_image,
- FT_Bitmap* target_bitmap );
+ typedef int (*FT_Raster_BitTest_Func)( int y,
+ int x,
+ void* user );
+
+ /*************************************************************************/
+ /* */
+ /* <FuncType> */
+ /* FT_Raster_BitSet_Func */
+ /* */
+ /* <Description> */
+ /* A function used as a call-back by the monochrome scan-converter */
+ /* used to set an individual target pixel. This is crucial to */
+ /* implement drop-out control per-se the TrueType spec.. */
+ /* */
+ /* <Input> */
+ /* y :: the pixel's y coordinate */
+ /* x :: the pixel's x coordinate */
+ /* user :: user-supplied data that is passed to the callback */
+ /* */
+ /* <Return> */
+ /* 1 if the pixel is "set", 0 otherwise */
+ /* */
+ typedef void (*FT_Raster_BitSet_Func)( int y,
+ int x,
+ void* user );
/**************************************************************************
*
+ * <Enum>
+ * FT_Raster_Flag
+ *
+ * <Description>
+ * An enumeration used to list the bit flags used in the "flags"
+ * field of a FT_Raster_Params function.
+ *
+ * <Fields>
+ * ft_raster_flag_default :: this value is 0
+ *
+ * ft_raster_flag_aa :: resquests the rendering of an anti-aliased
+ * glyph bitmap. If unset, a monchrome bitmap
+ * will be rendered.
+ *
+ * ft_raster_flag_direct :: requests direct rendering over the target
+ * bitmap. Direct rendering uses user-provided
+ * callbacks in order to perform direct
+ * drawing or composition over an existing
+ * bitmap. If this bit is unset, the content
+ * of the target bitmap **must be zeroed** !
+ *
+ **************************************************************************/
+ typedef enum {
+
+ ft_raster_flag_default = 0,
+ ft_raster_flag_aa = 1,
+ ft_raster_flag_direct = 2
+
+ } FT_Raster_Flag;
+
+ /**************************************************************************
+ *
* <Struct>
- * FT_Raster_Interface
+ * FT_Raster_Params
*
* <Description>
- * A structure used to model the default raster interface. A raster
- * is a module in charge of converting a glyph image into a bitmap.
- *
+ * A structure used to hold the arguments used by a raster's render
+ * function.
+ *
* <Fields>
- * size :: the size in bytes of the given raster object. This
- * is used to allocate a new raster when calling
- * `FT_Set_Raster'.
+ * target :: the target bitmap
+ * source :: pointer to the source glyph image (e.g. a FT_Outline)
+ * flags :: rendering flags
+ * gray_spans :: gray span drawing callback
+ * black_spans :: black span drawing callback
+ * bit_test :: bit test callback
+ * bit_set :: bit set callback
+ * user :: user-supplied data that is passed to each drawing
+ * callback..
*
- * format :: the source glyph image format this raster is able to
- * handle.
+ * <Note>
+ * An anti-aliased glyph bitmap is drawn if the ft_raster_flag_aa bit
+ * flag is set in the "flags" field, otherwise a monochrome bitmap will
+ * be generated.
*
- * init :: the raster's initialisation routine
+ * When the ft_raster_flag_direct bit flag is set in "flags", the raster
+ * will call the "gray_spans" callback to drawn gray pixel spans, in the
+ * case of an aa glyph bitmap, or "black_spans", "bit_test" and "bit_set"
+ * in the case of a monochrome bitmap.
*
- * set_mode :: the raster's mode set routine
+ * This allows direct composition over a pre-existing bitmap through
+ * user-provided callbacks to perform the span drawing/composition.
*
- * render :: the raster's rendering routine
+ * Note that the "bit_test" and "bit_set" callbacks are required when
+ * rendering a monochrome bitmap, as they are crucial to implement correct
+ * drop-out control per-se the TrueType specification..
*
**************************************************************************/
- typedef struct FT_Raster_Interface_
+ typedef struct FT_Raster_Params_
{
- long size;
- FT_Glyph_Tag format_tag;
- FT_Raster_Init_Proc init;
- FT_Raster_Set_Mode_Proc set_mode;
- FT_Raster_Render_Proc render;
-
+ FT_Bitmap* target;
+ void* source;
+ int flags;
+ FT_Raster_Span_Func gray_spans;
+ FT_Raster_Span_Func black_spans;
+ FT_Raster_BitTest_Func bit_test;
+ FT_Raster_BitSet_Func bit_set;
+ void* user;
+
+ } FT_Raster_Params;
+
+
+
+ /**************************************************************************
+ * <FuncType>
+ * FT_Raster_New_Func
+ *
+ * <Description>
+ * A function used to create a new raster object.
+ *
+ * <Input>
+ * memory :: handle to memory allocator.
+ *
+ * <Output>
+ * raster :: handle to new raster object
+ *
+ * <Return>
+ * Error code. 0 means success
+ *
+ * <Note>
+ * the "memory" parameter is a typeless pointer in order to avoid
+ * un-wanted dependencies on the rest of the FreeType code.
+ *
+ * in practice, it is a FT_Memory, i.e. a handle to the standard
+ * FreeType memory allocator. However, this field can be completely
+ * ignored by a given raster implementation..
+ *
+ **************************************************************************/
+
+ typedef int (*FT_Raster_New_Func)( void* memory,
+ FT_Raster *raster );
+
+
+ /**************************************************************************
+ * <FuncType>
+ * FT_Raster_Done_Func
+ *
+ * <Description>
+ * A function used to destroy a given raster object.
+ *
+ * <Input>
+ * raster :: handle to new raster object
+ *
+ **************************************************************************/
+
+ typedef void (*FT_Raster_Done_Func)( FT_Raster raster );
+
- } FT_Raster_Interface;
+ /**************************************************************************
+ *
+ * <FuncType>
+ * FT_Raster_Reset_Func
+ *
+ * <Description>
+ * FreeType provides an area of memory called the "render pool",
+ * available to all registered rasters. This pool can be freely
+ * used during a given scan-conversion but is shared by all rasters.
+ * Its content is thus transient.
+ *
+ * This function is called each time the render pool changes, or
+ * just after a new raster object is created.
+ *
+ * <Input>
+ * raster :: handle to new raster object
+ * pool_base :: address in memory of render pool
+ * pool_size :: size in bytes of render pool
+ *
+ * <Note>
+ * Rasters can ignore the render pool and rely on dynamic memory
+ * allocation if they want to (a handle to the memory allocator is
+ * passed to the raster constructor). However, this is not recommended
+ * for efficiency purposes..
+ *
+ **************************************************************************/
+
+ typedef void (*FT_Raster_Reset_Func)( FT_Raster raster,
+ const char* pool_base,
+ long pool_size );
+
+
+ /**************************************************************************
+ *
+ * <FuncType>
+ * FT_Raster_Set_Mode_Func
+ *
+ * <Description>
+ * This function is a generic facility to change modes or attributes
+ * in a given raster. This can be used for debugging purposes, or
+ * simply to allow implementation-specific "features" in a given
+ * raster module.
+ *
+ * <Input>
+ * raster :: handle to new raster object
+ * mode :: an C string naming the mode or property to change
+ * args :: a pointer to the new mode/property to use
+ *
+ **************************************************************************/
+
+ typedef int (*FT_Raster_Set_Mode_Func)( FT_Raster raster,
+ const char* mode,
+ void* args );
+
+ /**************************************************************************
+ *
+ * <FuncType>
+ * FT_Raster_Render_Func
+ *
+ * <Description>
+ * Invokes a given raster to scan-convert a given glyph image into
+ * a target bitmap.
+ *
+ * <Input>
+ * raster :: handle to raster object
+ * params :: pointer to a FT_Raster_Params structure used to store
+ * the rendering parameters.
+ *
+ * <Return>
+ * Error code. 0 means success
+ *
+ * <Note>
+ * The exact format of the source image depends on the raster's
+ * glyph format defined in its FT_Raster_Funcs structure. It can be
+ * an FT_Outline or anything else in order to support a large array
+ * of glyph formats.
+ *
+ * Note also that the render function can fail and return a
+ * FT_Err_Unimplemented_Feature error code when the raster used does
+ * not support direct composition.
+ *
+ * XXX: For now, the standard raster doesn't support direct composition
+ * but this should change for the final release (see the files
+ * demos/src/ftgrays.c and demos/src/ftgrays2.c for examples of
+ * distinct implementations which support direct composition).
+ *
+ **************************************************************************/
+
+ typedef int (*FT_Raster_Render_Func)( FT_Raster raster,
+ FT_Raster_Params* params );
+
+
+ /**************************************************************************
+ *
+ * <Struct>
+ * FT_Raster_Funcs
+ *
+ * <Description>
+ * A structure used to describe a given raster class to the library.
+ *
+ * <Fields>
+ * glyph_format :: the supported glyph format for this raster
+ * raster_new :: the raster constructor
+ * raster_reset :: used to reset the render pool within the raster
+ * raster_render :: renders a glyph into a given bitmap
+ * raster_done :: the raster destructor
+ *
+ **************************************************************************/
+
+
+ typedef struct FT_Raster_Funcs_
+ {
+ FT_Glyph_Format glyph_format;
+ FT_Raster_New_Func raster_new;
+ FT_Raster_Reset_Func raster_reset;
+ FT_Raster_Set_Mode_Func raster_set_mode;
+ FT_Raster_Render_Func raster_render;
+ FT_Raster_Done_Func raster_done;
+
+ } FT_Raster_Funcs;
#endif /* FTIMAGE_H */
diff --git a/include/ftraster.h b/include/ftraster.h
index 1e0ecb3..0ba630b 100644
--- a/include/ftraster.h
+++ b/include/ftraster.h
@@ -38,25 +38,7 @@
#endif
EXPORT_DEF
- int FT_Raster_Init( FT_Raster raster,
- const char* pool_base,
- long pool_size );
-
- EXPORT_DEF
- int FT_Raster_Render( FT_Raster raster,
- FT_Outline* outline,
- FT_Bitmap* target_map );
-
- EXPORT_DEF
- long FT_Raster_ObjSize( void );
-
- /* FT_Raster_SetPalette() is currently unused by FreeType 2 */
-
- EXPORT_DEF
- int FT_Raster_SetPalette( FT_Raster raster,
- int count,
- const char* palette );
-
+ FT_Raster_Funcs ft_raster_funcs;
#ifdef __cplusplus
}
diff --git a/src/base/ftglyph.c b/src/base/ftglyph.c
new file mode 100644
index 0000000..c7ffe8c
--- /dev/null
+++ b/src/base/ftglyph.c
@@ -0,0 +1,500 @@
+/***************************************************************************/
+/* */
+/* ftglyph.c */
+/* */
+/* FreeType convenience functions to handle glyphs.. */
+/* */
+/* Copyright 1996-1999 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. */
+/* */
+/* This file contains the definition of several convenience functions */
+/* that can be used by client applications to easily retrieve glyph */
+/* bitmaps and outlines from a given face. */
+/* */
+/* These functions should be optional if you're writing a font server */
+/* or text layout engine on top of FreeType. However, they are pretty */
+/* handy for many other simple uses of the library.. */
+/* */
+/***************************************************************************/
+
+#include <ftglyph.h>
+#include <ftobjs.h>
+
+ static
+ void ft_prepare_glyph( FT_Glyph glyph,
+ FT_Face face,
+ FT_Bool vertical )
+{
+ FT_Glyph_Metrics* metrics = &face->glyph->metrics;
+
+ glyph->memory = face->memory;
+ glyph->width = metrics->width;
+ glyph->height = metrics->height;
+
+ if (vertical)
+ {
+ glyph->bearingX = metrics->vertBearingX;
+ glyph->bearingY = metrics->vertBearingY;
+ glyph->advance = metrics->vertAdvance;
+ }
+ else
+ {
+ glyph->bearingX = metrics->horiBearingX;
+ glyph->bearingY = metrics->horiBearingY;
+ glyph->advance = metrics->horiAdvance;
+ }
+ }
+
+ /***********************************************************************
+ *
+ * <Function>
+ * FT_Get_Glyph_Bitmap
+ *
+ * <Description>
+ * A function used to directly return a monochrome bitmap glyph image
+ * from a face.
+ *
+ * <Input>
+ * face :: handle to source face object
+ * glyph_index :: glyph index in face
+ * load_flags :: load flags, see FT_LOAD_FLAG_XXXX constants..
+ * grays :: number of gray levels for anti-aliased bitmaps,
+ * set to 0 if you want to render a monochrome bitmap
+ * origin :: a pointer to the origin's position. Set to 0
+ * if the current transform is the identity..
+ *
+ * <Output>
+ * bitglyph :: pointer to the new bitmap glyph
+ *
+ * <Return>
+ * Error code. 0 means success.
+ *
+ * <Note>
+ * If the font contains glyph outlines, these will be automatically
+ * converted to a bitmap according to the value of "grays"
+ *
+ * If "grays" is set to 0, the result is a 1-bit monochrome bitmap
+ * otherwise, it is an 8-bit gray-level bitmap
+ *
+ * The number of gray levels in the result anti-aliased bitmap might
+ * not be "grays", depending on the current scan-converter implementation
+ *
+ * Note that it is not possible to generate 8-bit monochrome bitmaps
+ * with this function. Rather, use FT_Get_Glyph_Outline, then
+ * FT_Glyph_Render_Outline and provide your own span callbacks..
+ *
+ * When the face doesn't contain scalable outlines, this function will
+ * fail if the current transform is not the identity, or if the glyph
+ * origin's phase to the pixel grid is not 0 in both directions !!
+ *
+ ***********************************************************************/
+
+ EXPORT_FUNC
+ FT_Error FT_Get_Glyph_Bitmap( FT_Face face,
+ FT_UInt glyph_index,
+ FT_UInt load_flags,
+ FT_Int grays,
+ FT_Vector* origin,
+ FT_BitmapGlyph *abitglyph )
+ {
+ FT_Error error;
+ FT_Memory memory;
+ FT_BitmapGlyph bitglyph;
+ FT_Glyph glyph;
+ FT_Pos origin_x = 0;
+ FT_Pos origin_y = 0;
+
+ *abitglyph = 0;
+
+ if (origin)
+ {
+ origin_x = origin->x & 63;
+ origin_y = origin->y & 63;
+ }
+
+ /* check arguments if the face's format is not scalable */
+ if ( !(face->face_flags & FT_FACE_FLAG_SCALABLE) && face->transform_flags )
+ {
+ /* we can't transform bitmaps, so return an error */
+ error = FT_Err_Unimplemented_Feature;
+ goto Exit;
+ }
+
+ /* check that NO_SCALE and NO_RECURSE are not set */
+ if (load_flags & (FT_LOAD_NO_SCALE|FT_LOAD_NO_RECURSE))
+ {
+ error = FT_Err_Invalid_Argument;
+ goto Exit;
+ }
+
+ /* disable embedded bitmaps for transformed images */
+ if ( face->face_flags & FT_FACE_FLAG_SCALABLE && face->transform_flags )
+ load_flags |= FT_LOAD_NO_BITMAP;
+
+ error = FT_Load_Glyph( face, glyph_index, load_flags );
+ if (error) goto Exit;
+
+ /* now, handle bitmap and outline glyph images */
+ memory = face->memory;
+ switch ( face->glyph->format )
+ {
+ case ft_glyph_format_bitmap:
+ {
+ FT_Long size;
+ FT_Bitmap* source;
+
+ if ( ALLOC( bitglyph, sizeof(*bitglyph) ) )
+ goto Exit;
+
+ glyph = (FT_Glyph)bitglyph;
+ glyph->glyph_type = ft_glyph_type_bitmap;
+ ft_prepare_glyph( glyph, face, 0 );
+
+ source = &face->glyph->bitmap;
+ size = source->rows * source->pitch;
+ if (size < 0) size = -size;
+
+ bitglyph->bitmap = *source;
+ if ( ALLOC( bitglyph->bitmap.buffer, size ) )
+ goto Fail;
+
+ /* copy the content of the source glyph */
+ MEM_Copy( bitglyph->bitmap.buffer, source->buffer, size );
+ }
+ break;
+
+ case ft_glyph_format_outline:
+ {
+ FT_BBox cbox;
+ FT_Int width, height, pitch;
+ FT_Long size;
+
+ /* transform the outline - note that the original metrics are NOT */
+ /* transformed by this.. only the outline points themselves.. */
+ FT_Outline_Transform( &face->glyph->outline, &face->transform_matrix );
+ FT_Outline_Translate( &face->glyph->outline,
+ face->transform_delta.x + origin_x,
+ face->transform_delta.y + origin_y );
+
+ /* compute the size in pixels of the outline */
+ FT_Outline_Get_CBox( &face->glyph->outline, &cbox );
+ cbox.xMin &= -64;
+ cbox.yMin &= -64;
+ cbox.xMax = (cbox.xMax+63) & -64;
+ cbox.yMax = (cbox.yMax+63) & -64;
+
+ width = (cbox.xMax - cbox.xMin) >> 6;
+ height = (cbox.yMax - cbox.yMin) >> 6;
+
+ /* allocate the pixel buffer for the glyph bitmap */
+ if (grays) pitch = (width+3) & -4; /* some raster implementation need this */
+ else pitch = (width+7) >> 3;
+
+ size = pitch * height;
+ if ( ALLOC( bitglyph, sizeof(*bitglyph) ) )
+ goto Exit;
+
+ glyph = (FT_Glyph)bitglyph;
+ glyph->glyph_type = ft_glyph_type_bitmap;
+ ft_prepare_glyph( glyph, face, 0 );
+
+ if ( ALLOC( bitglyph->bitmap.buffer, size ) )
+ goto Fail;
+
+ bitglyph->bitmap.width = width;
+ bitglyph->bitmap.rows = height;
+ bitglyph->bitmap.pitch = pitch;
+ bitglyph->bitmap.pixel_mode = grays ? ft_pixel_mode_grays
+ : ft_pixel_mode_mono;
+ bitglyph->bitmap.num_grays = (short)grays;
+
+ bitglyph->left = (cbox.xMin >> 6);
+ bitglyph->top = (cbox.yMax >> 6);
+
+ /* render the monochrome outline into the target buffer */
+ FT_Outline_Translate( &face->glyph->outline, -cbox.xMin, -cbox.yMin );
+ error = FT_Outline_Get_Bitmap( face->driver->library,
+ &face->glyph->outline,
+ &bitglyph->bitmap );
+ if (error)
+ {
+ FREE( bitglyph->bitmap.buffer );
+ goto Fail;
+ }
+ }
+ break;
+
+ default:
+ error = FT_Err_Invalid_Glyph_Index;
+ goto Exit;
+ }
+
+ *abitglyph = bitglyph;
+ Exit:
+ return error;
+
+ Fail:
+ FREE( glyph );
+ goto Exit;
+ }
+
+
+ /***********************************************************************
+ *
+ * <Function>
+ * FT_Get_Glyph_Outline
+ *
+ * <Description>
+ * A function used to directly return a bitmap glyph image from a
+ * face. This is faster than calling FT_Load_Glyph+FT_Get_Outline_Bitmap..
+ *
+ * <Input>
+ * face :: handle to source face object
+ * glyph_index :: glyph index in face
+ * load_flags :: load flags, see FT_LOAD_FLAG_XXXX constants..
+ *
+ * <Output>
+ * vecglyph :: pointer to the new outline glyph
+ *
+ * <Return>
+ * Error code. 0 means success.
+ *
+ * <Note>
+ * This function will fail if the load flags FT_LOAD_NO_OUTLINE and
+ * FT_LOAD_NO_RECURSE are set..
+ *
+ ***********************************************************************/
+
+ EXPORT_FUNC
+ FT_Error FT_Get_Glyph_Outline( FT_Face face,
+ FT_UInt glyph_index,
+ FT_UInt load_flags,
+ FT_OutlineGlyph *vecglyph )
+ {
+ FT_Error error;
+ FT_Memory memory;
+ FT_OutlineGlyph glyph;
+
+ *vecglyph = 0;
+
+ /* check that NO_OUTLINE and NO_RECURSE are not set */
+ if (load_flags & (FT_LOAD_NO_OUTLINE|FT_LOAD_NO_RECURSE))
+ {
+ error = FT_Err_Invalid_Argument;
+ goto Exit;
+ }
+
+ /* disable the loading of embedded bitmaps */
+ load_flags |= FT_LOAD_NO_BITMAP;
+
+ error = FT_Load_Glyph( face, glyph_index, load_flags );
+ if (error) goto Exit;
+
+ /* check that we really loaded an outline */
+ if ( face->glyph->format != ft_glyph_format_outline )
+ {
+ error = FT_Err_Invalid_Glyph_Index;
+ goto Exit;
+ }
+
+ /* transform the outline - note that the original metrics are NOT */
+ /* transformed by this.. only the outline points themselves.. */
+ if ( face->transform_flags )
+ {
+ FT_Outline_Transform( &face->glyph->outline, &face->transform_matrix );
+ FT_Outline_Translate( &face->glyph->outline,
+ face->transform_delta.x,
+ face->transform_delta.y );
+ }
+
+ /* now, create a new outline glyph and copy everything there */
+ memory = face->memory;
+ if ( ALLOC( glyph, sizeof(*glyph) ) )
+ goto Exit;
+
+ ft_prepare_glyph( (FT_Glyph)glyph, face, 0 );
+ glyph->metrics.glyph_type = ft_glyph_type_outline;
+
+ error = FT_Outline_New( face->driver->library,
+ face->glyph->outline.n_points,
+ face->glyph->outline.n_contours,
+ &glyph->outline );
+ if (!error)
+ error = FT_Outline_Copy( &face->glyph->outline, &glyph->outline );
+
+ if (error) goto Fail;
+
+ *vecglyph = glyph;
+ Exit:
+ return error;
+
+ Fail:
+ FREE( glyph );
+ goto Exit;
+ }
+
+ /***********************************************************************
+ *
+ * <Function>
+ * FT_Set_Transform
+ *
+ * <Description>
+ * A function used to set the transform that is applied to glyph images
+ * just after they're loaded in the face's glyph slot, and before they're
+ * returned by either FT_Get_Glyph_Bitmap or FT_Get_Glyph_Outline
+ *
+ * <Input>
+ * face :: handle to source face object
+ * matrix :: pointer to the transform's 2x2 matrix. 0 for identity
+ * delta :: pointer to the transform's translation. 0 for null vector
+ *
+ * <Note>
+ * The transform is only applied to glyph outlines when they are found
+ * in a font face. It is unable to transform embedded glyph bitmaps
+ *
+ ***********************************************************************/
+
+ EXPORT_FUNC
+ void FT_Set_Transform( FT_Face face,
+ FT_Matrix* matrix,
+ FT_Vector* delta )
+ {
+ face->transform_flags = 0;
+
+ if (!matrix)
+ {
+ face->transform_matrix.xx = 0x10000L;
+ face->transform_matrix.xy = 0;
+ face->transform_matrix.yx = 0L;
+ face->transform_matrix.yy = 0x10000L;
+ matrix = &face->transform_matrix;
+ }
+ else
+ face->transform_matrix = *matrix;
+
+ /* set transform_flags bit flag 0 if delta isn't the null vector */
+ if ( (matrix->xy | matrix->yx) ||
+ matrix->xx != 0x10000L ||
+ matrix->yy != 0x10000L )
+ face->transform_flags |= 1;
+
+ if (!delta)
+ {
+ face->transform_delta.x = 0;
+ face->transform_delta.y = 0;
+ delta = &face->transform_delta;
+ }
+ else
+ face->transform_delta = *delta;
+
+ /* set transform_flags bit flag 1 if delta isn't the null vector */
+ if ( delta->x | delta->y )
+ face->transform_flags |= 2;
+ }
+
+ /***********************************************************************
+ *
+ * <Function>
+ * FT_Done_Glyph
+ *
+ * <Description>
+ * Destroys a given glyph..
+ *
+ * <Input>
+ * glyph :: handle to target glyph object
+ *
+ ***********************************************************************/
+
+ EXPORT_FUNC
+ void FT_Done_Glyph( FT_Glyph glyph )
+ {
+ if (glyph)
+ {
+ FT_Memory memory = glyph->memory;
+
+ if ( glyph->glyph_type == ft_glyph_type_bitmap )
+ {
+ FT_BitmapGlyph bit = (FT_BitmapGlyph)glyph;
+ FREE( bit->bitmap.buffer );
+ }
+ else if ( glyph->glyph_type == ft_glyph_type_outline )
+ {
+ FT_OutlineGlyph out = (FT_OutlineGlyph)glyph;
+ if (out->outline.flags & ft_outline_owner)
+ {
+ FREE( out->outline.points );
+ FREE( out->outline.contours );
+ FREE( out->outline.tags );
+ }
+ }
+
+ FREE( glyph );
+ }
+ }
+
+
+ /***********************************************************************
+ *
+ * <Function>
+ * FT_Glyph_Get_Box
+ *
+ * <Description>
+ * Returns the glyph image's bounding box in pixels.
+ *
+ * <Input>
+ * glyph :: handle to target glyph object
+ *
+ * <Output>
+ * box :: the glyph bounding box. Coordinates are expressed in
+ * _integer_ pixels, with exclusive max bounds
+ *
+ * <Note>
+ * Coordinates are relative to the glyph origin, using the Y-upwards
+ * convention..
+ *
+ * The width of the box in pixels is box.xMax-box.xMin
+ * The height is box.yMax - box.yMin
+ *
+ ***********************************************************************/
+
+ EXPORT_DEF
+ void FT_Glyph_Get_Box( FT_Glyph glyph,
+ FT_BBox *box )
+ {
+ box->xMin = box->xMax = 0;
+ box->yMin = box->yMax = 0;
+
+ if (glyph) switch (glyph->glyph_type)
+ {
+ case ft_glyph_type_bitmap:
+ {
+ FT_BitmapGlyph bit = (FT_BitmapGlyph)glyph;
+ box->xMin = bit->left;
+ box->xMax = box->xMin + bit->bitmap.width;
+ box->yMax = bit->top;
+ box->yMin = box->yMax - bit->bitmap.rows;
+ }
+ break;
+
+ case ft_glyph_type_outline:
+ {
+ FT_OutlineGlyph out = (FT_OutlineGlyph)glyph;
+
+ FT_Outline_Get_CBox( &out->outline, box );
+ box->xMin >>= 6;
+ box->yMin >>= 6;
+ box->xMax = (box->xMax+63) >> 6;
+ box->yMax = (box->yMax+63) >> 6;
+ }
+ break;
+
+ default:
+ ;
+ }
+ }
diff --git a/src/base/ftobjs.c b/src/base/ftobjs.c
index 58cca87..30f6257 100644
--- a/src/base/ftobjs.c
+++ b/src/base/ftobjs.c
@@ -220,48 +220,58 @@
static
FT_Error ft_new_input_stream( FT_Library library,
FT_Open_Args* args,
- FT_Stream* astream )
+ FT_Stream *astream )
{
FT_Error error;
FT_Memory memory;
FT_Stream stream;
-
- memory = library->memory;
+ *astream = 0;
+ memory = library->memory;
if ( ALLOC( stream, sizeof ( *stream ) ) )
- return error;
+ goto Exit;
stream->memory = memory;
- /* is it a memory stream? */
- if ( args->memory_base && args->memory_size )
- FT_New_Memory_Stream( library,
- args->memory_base,
- args->memory_size,
- stream );
-
- /* do we have an 8-bit pathname? */
- else if ( args->pathname )
- {
- error = FT_New_Stream( args->pathname, stream );
- stream->pathname.pointer = args->pathname;
- }
-
- /* do we have a custom stream? */
- else if ( args->stream )
+ /* now, look at the stream type */
+ switch ( args->stream_type )
{
- /* copy the contents of the argument stream */
- /* into the new stream object */
- *stream = *(args->stream);
- stream->memory = memory;
- }
- else
- error = FT_Err_Invalid_Argument;
+ /***** is it a memory-based stream ? *****************************/
+ case ft_stream_memory:
+ {
+ FT_New_Memory_Stream( library,
+ args->memory_base,
+ args->memory_size,
+ stream );
+ break;
+ }
+
+ /***** is is a pathname stream ? ********************************/
+ case ft_stream_pathname:
+ {
+ error = FT_New_Stream( args->pathname, stream );
+ stream->pathname.pointer = args->pathname;
+ break;
+ }
+ case ft_stream_copy:
+ {
+ if ( args->stream)
+ {
+ *stream = *(args->stream);
+ stream->memory = memory;
+ break;
+ }
+ }
+ default:
+ error = FT_Err_Invalid_Argument;
+ }
+
if ( error )
FREE( stream );
*astream = stream;
+ Exit:
return error;
}
@@ -280,7 +290,6 @@
FT_Stream stream = *astream;
FT_Memory memory = stream->memory;
-
if ( stream->close )
stream->close( stream );
@@ -387,110 +396,171 @@
}
+ /*************************************************************************
+ *
+ * <Function>
+ * FT_Get_Raster
+ *
+ * <Description>
+ * Return a pointer to the raster corresponding to a given glyph
+ * format tag.
+ *
+ * <Input>
+ * library :: handle to source library object
+ * glyph_format :: glyph format tag
+ *
+ * <Output>
+ * raster_funcs :: if this field is not 0, returns the raster's interface
+ *
+ * <Return>
+ * a pointer to the corresponding raster object.
+ *
+ *************************************************************************/
+
+ EXPORT_FUNC
+ FT_Raster FT_Get_Raster( FT_Library library,
+ FT_Glyph_Format glyph_format,
+ FT_Raster_Funcs *raster_funcs )
+ {
+ FT_Int n;
+
+ for ( n = 0; n < FT_MAX_GLYPH_FORMATS; n++ )
+ {
+ FT_Raster_Funcs* funcs = &library->raster_funcs[n];
+ if (funcs->glyph_format == glyph_format)
+ {
+ if (raster_funcs)
+ *raster_funcs = *funcs;
+ return library->rasters[n];
+ }
+ }
+ return 0;
+ }
+
/*************************************************************************/
/* */
/* <Function> */
- /* FT_Get_Glyph_Format */
+ /* FT_Set_Raster */
/* */
/* <Description> */
- /* Gets the glyph format for a given format tag. */
+ /* Register a given raster to the library. */
/* */
/* <Input> */
- /* library :: A handle to the library object. */
- /* format_tag :: A tag identifying the glyph format. */
+ /* library :: A handle to a target library object. */
+ /* raster_funcs :: pointer to the raster's interface */
/* */
/* <Return> */
- /* A pointer to a glyph format. 0 if `format_tag' isn't defined. */
+ /* Error code. 0 means success. */
/* */
- BASE_FUNC
- FT_Glyph_Format* FT_Get_Glyph_Format( FT_Library library,
- FT_Glyph_Tag format_tag )
+ /* <Note> */
+ /* This function will do the following: */
+ /* */
+ /* - a new raster object is created through raster_func.raster_new */
+ /* if this fails, then the function returns */
+ /* */
+ /* - if a raster is already registered for the glyph format */
+ /* specified in raster_funcs, it will be destroyed */
+ /* */
+ /* - the new raster is registered for the glyph format */
+ /* */
+ EXPORT_FUNC
+ FT_Error FT_Set_Raster( FT_Library library,
+ FT_Raster_Funcs* raster_funcs )
{
- FT_Glyph_Format* cur = library->glyph_formats;
- FT_Glyph_Format* limit = cur + FT_MAX_GLYPH_FORMATS;
+ FT_Glyph_Format glyph_format = raster_funcs->glyph_format;
+ FT_Raster_Funcs* funcs;
+ FT_Raster raster;
+ FT_Error error;
+ FT_Int n, index;
+
+ if ( glyph_format == ft_glyph_format_none)
+ return FT_Err_Invalid_Argument;
+
+ /* create a new raster object */
+ error = raster_funcs->raster_new( library->memory, &raster );
+ if (error) goto Exit;
+
+ raster_funcs->raster_reset( raster,
+ library->raster_pool,
+ library->raster_pool_size );
+
+ index = -1;
+ for (n = 0; n < FT_MAX_GLYPH_FORMATS; n++)
+ {
+ FT_Raster_Funcs* funcs = library->raster_funcs + n;
+ /* record the first vacant entry in "index" */
+ if (index < 0 && funcs->glyph_format == ft_glyph_format_none)
+ index = n;
+
+ /* compare this entry's glyph format with the one we need */
+ if (funcs->glyph_format == glyph_format)
+ {
+ /* a raster already exists for this glyph format, we will */
+ /* destroy it before updating its entry in the table */
+ funcs->raster_done( library->rasters[n] );
+ index = n;
+ break;
+ }
+ }
- for ( ; cur < limit; cur ++ )
+ if (index < 0)
{
- if ( cur->format_tag == format_tag )
- return cur;
+ /* the table is full and has no vacant entries */
+ error = FT_Err_Too_Many_Glyph_Formats;
+ goto Fail;
}
- return 0;
- }
+ funcs = library->raster_funcs + index;
+ *funcs = *raster_funcs;
+ library->rasters[index] = raster;
+
+ Exit:
+ return error;
+ Fail:
+ raster_funcs->raster_done( raster );
+ goto Exit;
+ }
/*************************************************************************/
/* */
/* <Function> */
- /* FT_Set_Raster */
+ /* FT_Unset_Raster */
/* */
/* <Description> */
- /* This function changes the raster module used to convert from a */
- /* given memory object. It is thus possible to use libraries with */
- /* distinct memory allocators within the same program. */
+ /* Removes a given raster from the library. */
/* */
/* <Input> */
- /* library :: A handle to the library object. */
- /* interface :: A pointer to the interface of the new raster module. */
- /* */
- /* <Output> */
- /* raster :: A handle to the raster object. */
+ /* library :: A handle to a target library object. */
+ /* raster_funcs :: pointer to the raster's interface */
/* */
/* <Return> */
- /* FreeType error code. 0 means success. */
+ /* Error code. 0 means success. */
/* */
- EXPORT_FUNC
- FT_Error FT_Set_Raster( FT_Library library,
- FT_Raster_Interface* interface,
- FT_Raster raster )
+ EXPORT_DEF
+ FT_Error FT_Unset_Raster( FT_Library library,
+ FT_Raster_Funcs* raster_funcs )
{
- FT_Memory memory = library->memory;
- FT_Error error = FT_Err_Ok;
- FT_Glyph_Format* format;
-
-
- /* allocate the render pool if necessary */
- if ( !library->raster_pool &&
- ALLOC( library->raster_pool, FT_RENDER_POOL_SIZE ) )
- goto Exit;
-
- /* find the glyph formatter for the raster's format */
- format = FT_Get_Glyph_Format( library, interface->format_tag );
- if ( !format )
- {
- error = FT_Err_Invalid_Argument;
+ FT_Glyph_Format glyph_format = raster_funcs->glyph_format;
+ FT_Error error;
+ FT_Int n;
+
+ error = FT_Err_Invalid_Argument;
+ if ( glyph_format == ft_glyph_format_none)
goto Exit;
- }
-
- /* free previous raster object if necessary */
- if ( format->raster_allocated )
- {
- FREE( format->raster );
- format->raster_allocated = 0;
- }
- /* allocate new raster object is necessary */
- if ( !raster )
+ for (n = 0; n < FT_MAX_GLYPH_FORMATS; n++)
{
- if ( ALLOC( raster, interface->size ) )
- goto Exit;
-
- format->raster_allocated = 1;
- }
- format->raster = raster;
- format->raster_interface = interface;
+ FT_Raster_Funcs* funcs = library->raster_funcs + n;
- /* initialize the raster object */
- error = interface->init( raster,
- (char*)library->raster_pool,
- FT_RENDER_POOL_SIZE );
- if ( error )
- {
- if ( format->raster_allocated )
+ if (funcs->glyph_format == glyph_format)
{
- FREE( format->raster );
- format->raster_allocated = 0;
+ funcs->raster_done( library->rasters[n] );
+ library->rasters[n] = 0;
+ library->raster_funcs[n].glyph_format = ft_glyph_format_none;
+ error = FT_Err_Ok;
+ break;
}
}
@@ -502,6 +572,38 @@
/*************************************************************************/
/* */
/* <Function> */
+ /* FT_Set_Raster_Mode */
+ /* */
+ /* <Description> */
+ /* Set a raster-specific mode. */
+ /* */
+ /* <Input> */
+ /* library :: A handle to a target library object. */
+ /* format :: the glyph format used to select the raster */
+ /* mode :: the raster-specific mode descriptor */
+ /* args :: the mode arguments */
+ /* <Return> */
+ /* Error code. 0 means success. */
+ /* */
+ EXPORT_FUNC
+ FT_Error FT_Set_Raster_Mode( FT_Library library,
+ FT_Glyph_Format format,
+ const char* mode,
+ void* args )
+ {
+ FT_Raster_Funcs funcs;
+ FT_Raster raster;
+
+ raster = FT_Get_Raster( library, format, &funcs );
+ if (raster && funcs.raster_set_mode )
+ return funcs.raster_set_mode( raster, mode, args );
+ else
+ return FT_Err_Invalid_Argument;
+ }
+
+ /*************************************************************************/
+ /* */
+ /* <Function> */
/* FT_Set_Debug_Hook */
/* */
/* <Description> */
@@ -532,105 +634,6 @@
/*************************************************************************/
/* */
/* <Function> */
- /* FT_Add_Glyph_Format */
- /* */
- /* <Description> */
- /* Adds a glyph format to the library. */
- /* */
- /* <InOut> */
- /* library :: A handle to the library object. */
- /* */
- /* <Input> */
- /* format :: A pointer to the new glyph format. */
- /* */
- /* <Return> */
- /* FreeType error code. 0 means success. */
- /* */
- BASE_FUNC
- FT_Error FT_Add_Glyph_Format( FT_Library library,
- FT_Glyph_Format* format )
- {
- FT_Glyph_Format* new = 0;
-
-
- {
- FT_Glyph_Format* cur = library->glyph_formats;
- FT_Glyph_Format* limit = cur + FT_MAX_GLYPH_FORMATS;
-
-
- for ( ; cur < limit; cur++ )
- {
- /* return an error if the format is already registered */
- if ( cur->format_tag == format->format_tag )
- return FT_Err_Invalid_Glyph_Format;
-
- if ( cur->format_tag == 0 && new == 0 )
- new = cur;
- }
- }
-
- /* if there is no place to hold the new format, return an error */
- if ( !new )
- return FT_Err_Too_Many_Glyph_Formats;
-
- *new = *format;
-
- /* now, create a raster object if we need to */
- return FT_Set_Raster( library,
- format->raster_interface,
- format->raster );
- }
-
-
- /*************************************************************************/
- /* */
- /* <Function> */
- /* FT_Remove_Glyph_Format */
- /* */
- /* <Description> */
- /* Removes a glyph format from the library. */
- /* */
- /* <InOut> */
- /* library :: A handle to the library object. */
- /* */
- /* <Input> */
- /* format_tag :: A tag identifying the format to be removed. */
- /* */
- /* <Return> */
- /* FreeType error code. 0 means success. */
- /* */
- BASE_FUNC
- FT_Error FT_Remove_Glyph_Format( FT_Library library,
- FT_Glyph_Tag format_tag )
- {
- FT_Memory memory;
- FT_Glyph_Format* cur = library->glyph_formats;
- FT_Glyph_Format* limit = cur + FT_MAX_GLYPH_FORMATS;
-
-
- memory = library->memory;
-
- for ( ; cur < limit; cur++ )
- {
- if ( cur->format_tag == format_tag )
- {
- if ( cur->raster_allocated )
- {
- FREE( cur->raster );
- cur->raster_allocated = 0;
- }
- cur->format_tag = 0;
- return FT_Err_Ok;
- }
- }
-
- return FT_Err_Invalid_Argument;
- }
-
-
- /*************************************************************************/
- /* */
- /* <Function> */
/* FT_New_Library */
/* */
/* <Description> */
@@ -654,31 +657,29 @@
FT_Library library = 0;
FT_Error error;
-
/* first of all, allocate the library object */
if ( ALLOC( library, sizeof ( *library ) ) )
return error;
library->memory = memory;
- /* now register the default raster for the `outline' glyph image format */
- {
- FT_Glyph_Format outline_format =
- {
- ft_glyph_format_outline,
- &ft_default_raster,
- 0,
- 0
- };
-
+ /* allocate the render pool */
+ library->raster_pool_size = FT_RENDER_POOL_SIZE;
+ if ( ALLOC( library->raster_pool, FT_RENDER_POOL_SIZE ) )
+ goto Fail;
- error = FT_Add_Glyph_Format( library, &outline_format );
- }
+ /* now register the default raster for the `outline' glyph image format */
+ /* for now, ignore the error... */
+ error = FT_Set_Raster( library, &ft_default_raster );
+
/* That's ok now */
*alibrary = library;
return FT_Err_Ok;
+ Fail:
+ FREE( library );
+ return error;
}
@@ -726,20 +727,22 @@
}
}
- /* Destroy raster object */
+ /* Destroy raster objects */
FREE( library->raster_pool );
+ library->raster_pool_size = 0;
{
- FT_Glyph_Format* cur = library->glyph_formats;
- FT_Glyph_Format* limit = cur + FT_MAX_GLYPH_FORMATS;
+ FT_Raster_Funcs* cur = library->raster_funcs;
+ FT_Raster_Funcs* limit = cur + FT_MAX_GLYPH_FORMATS;
+ FT_Raster* raster = library->rasters;
-
- for ( ; cur < limit; cur++ )
+ for ( ; cur < limit; cur++, raster++ )
{
- if ( cur->raster_allocated )
+ if ( cur->glyph_format != ft_glyph_format_none )
{
- FREE( cur->raster );
- cur->raster_allocated = 0;
+ cur->raster_done( *raster );
+ *raster = 0;
+ cur->glyph_format = ft_glyph_format_none;
}
}
}
@@ -753,65 +756,6 @@
/*************************************************************************/
/* */
/* <Function> */
- /* FT_Set_Raster_Mode */
- /* */
- /* <Description> */
- /* Sets a raster-specific mode. */
- /* */
- /* <InOut> */
- /* library :: A handle to a target library object. */
- /* */
- /* <Input> */
- /* format :: The glyph format used to select the raster. */
- /* mode :: The raster-specific mode descriptor. */
- /* args :: The mode arguments. */
- /* */
- /* <Return> */
- /* FreeType error code. 0 means success. */
- /* */
- EXPORT_FUNC
- FT_Error FT_Set_Raster_Mode( FT_Library library,
- FT_Glyph_Tag format_tag,
- const char* mode,
- const char* args )
- {
- FT_Memory memory;
- FT_Error error;
- FT_Glyph_Format* format = 0;
-
-
- {
- FT_Glyph_Format* cur = library->glyph_formats;
- FT_Glyph_Format* limit = cur + FT_MAX_GLYPH_FORMATS;
-
-
- for ( ; cur < limit; cur++ )
- {
- if ( cur->format_tag == format_tag )
- {
- format = cur;
- break;
- }
- }
- }
-
- if ( !format )
- return FT_Err_Invalid_Argument;
-
- memory = library->memory;
-
- error = FT_Err_Ok;
- if ( format->raster )
- error = format->raster_interface->set_mode( format->raster,
- mode, args );
-
- return error;
- }
-
-
- /*************************************************************************/
- /* */
- /* <Function> */
/* FT_Add_Driver */
/* */
/* <Description> */
@@ -1028,10 +972,6 @@
}
- static
- const FT_Open_Args ft_default_open_args =
- { 0, 0, 0, 0, 0 };
-
/*************************************************************************/
/* */
@@ -1076,10 +1016,11 @@
FT_Long face_index,
FT_Face* aface )
{
- FT_Open_Args args = ft_default_open_args;
+ FT_Open_Args args;
-
- args.pathname = (char*)pathname;
+ args.stream_type = ft_stream_pathname;
+ args.driver = 0;
+ args.pathname = (char*)pathname;
return FT_Open_Face( library, &args, face_index, aface );
}
@@ -1129,11 +1070,12 @@
FT_Long face_index,
FT_Face* face )
{
- FT_Open_Args args = ft_default_open_args;
-
+ FT_Open_Args args;
+ args.stream_type = ft_stream_memory;
args.memory_base = file_base;
args.memory_size = file_size;
+ args.driver = 0;
return FT_Open_Face( library, &args, face_index, face );
}
@@ -1198,8 +1140,7 @@
/* create input stream */
error = ft_new_input_stream( library, args, &stream );
- if ( error )
- goto Exit;
+ if ( error ) goto Exit;
memory = library->memory;
@@ -1281,6 +1222,15 @@
goto Fail;
}
+ /* initialize transform for convenience functions */
+ face->transform_matrix.xx = 0x10000L;
+ face->transform_matrix.xy = 0;
+ face->transform_matrix.yx = 0;
+ face->transform_matrix.yy = 0x10000L;
+
+ face->transform_delta.x = 0;
+ face->transform_delta.y = 0;
+
*aface = face;
goto Exit;
@@ -1329,9 +1279,10 @@
FT_Error FT_Attach_File( FT_Face face,
const char* filepathname )
{
- FT_Open_Args open = ft_default_open_args;
+ FT_Open_Args open;
- open.pathname = (char*)filepathname;
+ open.stream_type = ft_stream_pathname;
+ open.pathname = (char*)filepathname;
return FT_Attach_Stream( face, &open );
}
@@ -1875,6 +1826,10 @@
return FT_Err_Invalid_Face_Handle;
driver = face->driver;
+
+ /* when the flag NO_RECURSE is set, we disable hinting and scaling */
+ if (load_flags & FT_LOAD_NO_RECURSE)
+ load_flags |= FT_LOAD_NO_SCALE | FT_LOAD_NO_HINTING;
error = driver->interface.load_glyph( face->glyph,
face->size,
@@ -2008,615 +1963,6 @@
return result;
}
- /*************************************************************************/
- /* */
- /* <Function> */
- /* FT_Outline_Decompose */
- /* */
- /* <Description> */
- /* Walks over an outline's structure to decompose it into individual */
- /* segments and Bezier arcs. This function is also able to emit */
- /* `move to' and `close to' operations to indicate the start and end */
- /* of new contours in the outline. */
- /* */
- /* <Input> */
- /* outline :: A pointer to the source target. */
- /* */
- /* interface :: A table of `emitters', i.e,. function pointers called */
- /* during decomposition to indicate path operations. */
- /* */
- /* user :: A typeless pointer which is passed to each emitter */
- /* during the decomposition. It can be used to store */
- /* the state during the decomposition. */
- /* */
- /* <Return> */
- /* Error code. 0 means sucess. */
- /* */
- EXPORT_FUNC
- int FT_Outline_Decompose( FT_Outline* outline,
- FT_Outline_Funcs* interface,
- void* user )
- {
- typedef enum _phases
- {
- phase_point,
- phase_conic,
- phase_cubic,
- phase_cubic2
-
- } TPhase;
-
- FT_Vector v_first;
- FT_Vector v_last;
- FT_Vector v_control;
- FT_Vector v_control2;
- FT_Vector v_start;
-
- FT_Vector* point;
- char* tags;
-
- int n; /* index of contour in outline */
- int first; /* index of first point in contour */
- int index; /* current point's index */
-
- int error;
-
- char tag; /* current point's state */
- TPhase phase;
-
-
- first = 0;
-
- for ( n = 0; n < outline->n_contours; n++ )
- {
- int last; /* index of last point in contour */
-
-
- last = outline->contours[n];
-
- v_first = outline->points[first];
- v_last = outline->points[last];
-
- v_start = v_control = v_first;
-
- tag = FT_CURVE_TAG( outline->tags[first] );
- index = first;
-
- /* A contour cannot start with a cubic control point! */
-
- if ( tag == FT_Curve_Tag_Cubic )
- return FT_Err_Invalid_Outline;
-
-
- /* check first point to determine origin */
-
- if ( tag == FT_Curve_Tag_Conic )
- {
- /* first point is conic control. Yes, this happens. */
- if ( FT_CURVE_TAG( outline->tags[last] ) == FT_Curve_Tag_On )
- {
- /* start at last point if it is on the curve */
- v_start = v_last;
- }
- else
- {
- /* if both first and last points are conic, */
- /* start at their middle and record its position */
- /* for closure */
- v_start.x = ( v_start.x + v_last.x ) / 2;
- v_start.y = ( v_start.y + v_last.y ) / 2;
-
- v_last = v_start;
- }
- phase = phase_conic;
- }
- else
- phase = phase_point;
-
-
- /* Begin a new contour with MOVE_TO */
-
- error = interface->move_to( &v_start, user );
- if ( error )
- return error;
-
- point = outline->points + first;
- tags = outline->tags + first;
-
- /* now process each contour point individually */
-
- while ( index < last )
- {
- index++;
- point++;
- tags++;
-
- tag = FT_CURVE_TAG( tags[0] );
-
- switch ( phase )
- {
- case phase_point: /* the previous point was on the curve */
-
- switch ( tag )
- {
- /* two succesive on points -> emit segment */
- case FT_Curve_Tag_On:
- error = interface->line_to( point, user );
- break;
-
- /* on point + conic control -> remember control point */
- case FT_Curve_Tag_Conic:
- v_control = point[0];
- phase = phase_conic;
- break;
-
- /* on point + cubic control -> remember first control */
- default:
- v_control = point[0];
- phase = phase_cubic;
- break;
- }
- break;
-
- case phase_conic: /* the previous point was a conic control */
-
- switch ( tag )
- {
- /* conic control + on point -> emit conic arc */
- case FT_Curve_Tag_On:
- error = interface->conic_to( &v_control, point, user );
- phase = phase_point;
- break;
-
- /* two successive conics -> emit conic arc `in between' */
- case FT_Curve_Tag_Conic:
- {
- FT_Vector v_middle;
-
-
- v_middle.x = (v_control.x + point->x)/2;
- v_middle.y = (v_control.y + point->y)/2;
-
- error = interface->conic_to( &v_control,
- &v_middle, user );
- v_control = point[0];
- }
- break;
-
- default:
- error = FT_Err_Invalid_Outline;
- }
- break;
-
- case phase_cubic: /* the previous point was a cubic control */
-
- /* this point _must_ be a cubic control too */
- if ( tag != FT_Curve_Tag_Cubic )
- return FT_Err_Invalid_Outline;
-
- v_control2 = point[0];
- phase = phase_cubic2;
- break;
-
-
- case phase_cubic2: /* the two previous points were cubics */
-
- /* this point _must_ be an on point */
- if ( tag != FT_Curve_Tag_On )
- error = FT_Err_Invalid_Outline;
- else
- error = interface->cubic_to( &v_control, &v_control2,
- point, user );
- phase = phase_point;
- break;
- }
-
- /* lazy error testing */
- if ( error )
- return error;
- }
-
- /* end of contour, close curve cleanly */
- error = 0;
-
- tag = FT_CURVE_TAG( outline->tags[first] );
-
- switch ( phase )
- {
- case phase_point:
- if ( tag == FT_Curve_Tag_On )
- error = interface->line_to( &v_first, user );
- break;
-
- case phase_conic:
- error = interface->conic_to( &v_control, &v_start, user );
- break;
-
- case phase_cubic2:
- if ( tag == FT_Curve_Tag_On )
- error = interface->cubic_to( &v_control, &v_control2,
- &v_first, user );
- else
- error = FT_Err_Invalid_Outline;
- break;
-
- default:
- error = FT_Err_Invalid_Outline;
- break;
- }
-
- if ( error )
- return error;
-
- first = last + 1;
- }
-
- return 0;
- }
-
-
- static
- const FT_Outline null_outline = { 0, 0, 0, 0, 0, 0 };
-
-
- /*************************************************************************/
- /* */
- /* <Function> */
- /* FT_Outline_New */
- /* */
- /* <Description> */
- /* Creates a new outline of a given size. */
- /* */
- /* <Input> */
- /* library :: A handle to the library object from where the */
- /* outline is allocated. Note however that the new */
- /* outline will NOT necessarily be FREED when */
- /* destroying the library, by FT_Done_FreeType(). */
- /* */
- /* numPoints :: The maximum number of points within the outline. */
- /* */
- /* numContours :: The maximum number of contours within the outline. */
- /* */
- /* <Output> */
- /* outline :: A handle to the new outline. NULL in case of */
- /* error. */
- /* */
- /* <Return> */
- /* FreeType error code. 0 means success. */
- /* */
- /* <MT-Note> */
- /* No. */
- /* */
- /* <Note> */
- /* The reason why this function takes a `library' parameter is simply */
- /* to use the library's memory allocator. You can copy the source */
- /* code of this function, replacing allocations with `malloc()' if */
- /* you want to control where the objects go. */
- /* */
- BASE_FUNC
- FT_Error FT_Outline_New( FT_Library library,
- FT_UInt numPoints,
- FT_Int numContours,
- FT_Outline* outline )
- {
- FT_Error error;
- FT_Memory memory;
-
-
- if ( !outline )
- return FT_Err_Invalid_Argument;
-
- *outline = null_outline;
- memory = library->memory;
-
- if ( ALLOC_ARRAY( outline->points, numPoints * 2L, FT_Pos ) ||
- ALLOC_ARRAY( outline->tags, numPoints, FT_Byte ) ||
- ALLOC_ARRAY( outline->contours, numContours, FT_UShort ) )
- goto Fail;
-
- outline->n_points = (FT_UShort)numPoints;
- outline->n_contours = (FT_Short)numContours;
- outline->flags |= ft_outline_owner;
-
- return FT_Err_Ok;
-
- Fail:
- outline->flags |= ft_outline_owner;
- FT_Outline_Done( library, outline );
-
- return error;
- }
-
-
- /*************************************************************************/
- /* */
- /* <Function> */
- /* FT_Outline_Done */
- /* */
- /* <Description> */
- /* Destroys an outline created with FT_Outline_New(). */
- /* */
- /* <Input> */
- /* library :: A handle of the library object used to allocate the */
- /* outline. */
- /* */
- /* outline :: A pointer to the outline object to be discarded. */
- /* */
- /* <Return> */
- /* FreeType error code. 0 means success. */
- /* */
- /* <MT-Note> */
- /* No. */
- /* */
- /* <Note> */
- /* If the outline's `owner' field is not set, only the outline */
- /* descriptor will be released. */
- /* */
- /* The reason why this function takes an `outline' parameter is */
- /* simply to use FT_Alloc()/FT_Free(). You can copy the source code */
- /* of this function, replacing allocations with `malloc()' in your */
- /* application if you want something simpler. */
- /* */
- BASE_FUNC
- FT_Error FT_Outline_Done( FT_Library library,
- FT_Outline* outline )
- {
- FT_Memory memory = library->memory;
-
-
- if ( outline )
- {
- if ( outline->flags & ft_outline_owner )
- {
- FREE( outline->points );
- FREE( outline->tags );
- FREE( outline->contours );
- }
- *outline = null_outline;
-
- return FT_Err_Ok;
- }
- else
- return FT_Err_Invalid_Argument;
- }
-
-
- /*************************************************************************/
- /* */
- /* <Function> */
- /* FT_Outline_Get_CBox */
- /* */
- /* <Description> */
- /* Returns an outline's `control box'. The control box encloses all */
- /* the outline's points, including Bezier control points. Though it */
- /* coincides with the exact bounding box for most glyphs, it can be */
- /* slightly larger in some situations (like when rotating an outline */
- /* which contains Bezier outside arcs). */
- /* */
- /* Computing the control box is very fast, while getting the bounding */
- /* box can take much more time as it needs to walk over all segments */
- /* and arcs in the outline. To get the latter, you can use the */
- /* `ftbbox' component which is dedicated to this single task. */
- /* */
- /* <Input> */
- /* outline :: A pointer to the source outline descriptor. */
- /* */
- /* <Output> */
- /* cbox :: The outline's control box. */
- /* */
- /* <Return> */
- /* FreeType error code. 0 means success. */
- /* */
- /* <MT-Note> */
- /* Yes. */
- /* */
- BASE_FUNC
- FT_Error FT_Outline_Get_CBox( FT_Outline* outline,
- FT_BBox* cbox )
- {
- FT_Pos xMin, yMin, xMax, yMax;
-
- if ( outline && cbox )
- {
- if ( outline->n_points == 0 )
- {
- xMin = 0;
- yMin = 0;
- xMax = 0;
- yMax = 0;
- }
- else
- {
- FT_Vector* vec = outline->points;
- FT_Vector* limit = vec + outline->n_points;
-
- xMin = xMax = vec->x;
- yMin = yMax = vec->y;
- vec++;
-
- for ( ; vec < limit; vec++ )
- {
- FT_Pos x, y;
-
- x = vec->x;
- if ( x < xMin ) xMin = x;
- if ( x > xMax ) xMax = x;
-
- y = vec->y;
- if ( y < yMin ) yMin = y;
- if ( y > yMax ) yMax = y;
- }
- }
- cbox->xMin = xMin;
- cbox->xMax = xMax;
- cbox->yMin = yMin;
- cbox->yMax = yMax;
- return FT_Err_Ok;
- }
- else
- return FT_Err_Invalid_Argument;
- }
-
-
-
- /*************************************************************************/
- /* */
- /* <Function> */
- /* FT_Outline_Translate */
- /* */
- /* <Description> */
- /* Applies a simple translation to the points of an outline. */
- /* */
- /* <Input> */
- /* outline :: A pointer to the target outline descriptor. */
- /* xOffset :: The horizontal offset. */
- /* yOffset :: The vertical offset. */
- /* */
- /* <MT-Note> */
- /* Yes. */
- /* */
- BASE_FUNC
- void FT_Outline_Translate( FT_Outline* outline,
- FT_Pos xOffset,
- FT_Pos yOffset )
- {
- FT_UShort n;
- FT_Vector* vec = outline->points;
-
- for ( n = 0; n < outline->n_points; n++ )
- {
- vec->x += xOffset;
- vec->y += yOffset;
- vec++;
- }
- }
-
-
- /*************************************************************************/
- /* */
- /* <Function> */
- /* FT_Done_GlyphZone */
- /* */
- /* <Description> */
- /* Deallocates a glyph zone. */
- /* */
- /* <Input> */
- /* zone :: pointer to the target glyph zone. */
- /* */
- BASE_FUNC
- void FT_Done_GlyphZone( FT_GlyphZone* zone )
- {
- FT_Memory memory = zone->memory;
-
- FREE( zone->contours );
- FREE( zone->tags );
- FREE( zone->cur );
- FREE( zone->org );
-
- zone->max_points = zone->n_points = 0;
- zone->max_contours = zone->n_contours = 0;
- }
-
- /*************************************************************************/
- /* */
- /* <Function> */
- /* FT_New_GlyphZone */
- /* */
- /* <Description> */
- /* Allocates a new glyph zone. */
- /* */
- /* <Input> */
- /* memory :: A handle to the current memory object. */
- /* */
- /* maxPoints :: The capacity of glyph zone in points. */
- /* */
- /* maxContours :: The capacity of glyph zone in contours. */
- /* */
- /* <Output> */
- /* zone :: A pointer to the target glyph zone record. */
- /* */
- /* <Return> */
- /* FreeType error code. 0 means success. */
- /* */
- BASE_FUNC
- FT_Error FT_New_GlyphZone( FT_Memory memory,
- FT_UShort maxPoints,
- FT_Short maxContours,
- FT_GlyphZone* zone )
- {
- FT_Error error;
-
- if (maxPoints > 0)
- maxPoints += 2;
-
- MEM_Set( zone, 0, sizeof(*zone) );
- zone->memory = memory;
-
- if ( ALLOC_ARRAY( zone->org, maxPoints*2, FT_F26Dot6 ) ||
- ALLOC_ARRAY( zone->cur, maxPoints*2, FT_F26Dot6 ) ||
- ALLOC_ARRAY( zone->tags, maxPoints, FT_Byte ) ||
- ALLOC_ARRAY( zone->contours, maxContours, FT_UShort ) )
- {
- FT_Done_GlyphZone(zone);
- }
- return error;
- }
-
- /*************************************************************************/
- /* */
- /* <Function> */
- /* FT_Update_GlyphZone */
- /* */
- /* <Description> */
- /* Checks the size of a zone and reallocates it if necessary. */
- /* */
- /* <Input> */
- /* newPoints :: The new capacity for points. We add two slots for */
- /* phantom points. */
- /* */
- /* newContours :: The new capacity for contours. */
- /* */
- /* <InOut> */
- /* zone :: The address of the target zone. */
- /* */
- /* maxPoints :: The address of the zone's current capacity for */
- /* points. */
- /* */
- /* maxContours :: The address of the zone's current capacity for */
- /* contours. */
- /* */
- BASE_FUNC
- FT_Error FT_Update_GlyphZone( FT_GlyphZone* zone,
- FT_UShort newPoints,
- FT_Short newContours )
- {
- FT_Error error = FT_Err_Ok;
- FT_Memory memory = zone->memory;
-
- newPoints += 2;
- if ( zone->max_points < newPoints )
- {
- /* reallocate the points arrays */
- if ( REALLOC_ARRAY( zone->org, zone->max_points*2, newPoints*2, FT_F26Dot6 ) ||
- REALLOC_ARRAY( zone->cur, zone->max_points*2, newPoints*2, FT_F26Dot6 ) ||
- REALLOC_ARRAY( zone->tags, zone->max_points*2, newPoints, FT_Byte ) )
- goto Exit;
-
- zone->max_points = newPoints;
- }
-
- if ( zone->max_contours < newContours )
- {
- /* reallocate the contours array */
- if ( REALLOC_ARRAY( zone->contours, zone->max_contours, newContours, FT_UShort ) )
- goto Exit;
-
- zone->max_contours = newContours;
- }
- Exit:
- return error;
- }
-
/*************************************************************************/
diff --git a/src/base/ftobjs.h b/src/base/ftobjs.h
index f877963..158e074 100644
--- a/src/base/ftobjs.h
+++ b/src/base/ftobjs.h
@@ -95,95 +95,17 @@
/*************************************************************************/
/*************************************************************************/
- /*************************************************************************/
- /* */
- /* <Function> */
- /* FT_Alloc */
- /* */
- /* <Description> */
- /* Allocates a new block of memory. The returned area is always */
- /* zero-filled, this is a strong convention in many FreeType parts. */
- /* */
- /* <Input> */
- /* memory :: A handle to a given `memory object' where allocation */
- /* occurs. */
- /* */
- /* size :: The size in bytes of the block to allocate. */
- /* */
- /* <Output> */
- /* P :: A pointer to the fresh new block. It should be set to */
- /* NULL if `size' is 0, or in case of error. */
- /* */
- /* <Return> */
- /* FreeType error code. 0 means success. */
- /* */
BASE_DEF
FT_Error FT_Alloc( FT_Memory memory,
FT_Long size,
void** P );
-
- /*************************************************************************/
- /* */
- /* <Function> */
- /* FT_Realloc */
- /* */
- /* <Description> */
- /* Reallocates a block of memory pointed to by `*P' to `Size' bytes */
- /* from the heap, possibly changing `*P'. */
- /* */
- /* <Input> */
- /* memory :: A handle to a given `memory object' where allocation */
- /* occurs. */
- /* */
- /* current :: current block size in bytes */
- /* size :: the new block size in bytes */
- /* */
- /* <InOut> */
- /* P :: A pointer to the fresh new block. It should be set to */
- /* NULL if `size' is 0, or in case of error. */
- /* */
- /* <Return> */
- /* FreeType error code. 0 means success. */
- /* */
- /* <Note> */
- /* All callers of FT_Realloc _must_ provide the current block size */
- /* as well as the new one. */
- /* */
- /* When the memory object's flag FT_memory_FLAG_NO_REALLOC is */
- /* set, this function will try to emulate a realloc through uses */
- /* of FT_Alloc and FT_Free. Otherwise, it will call the memory- */
- /* specific "realloc" implementation. */
- /* */
- /* (Some embedded memorys do not have a working realloc). */
- /* */
BASE_DEF
FT_Error FT_Realloc( FT_Memory memory,
FT_Long current,
FT_Long size,
void** P );
-
- /*************************************************************************/
- /* */
- /* <Function> */
- /* FT_Free */
- /* */
- /* <Description> */
- /* Releases a given block of memory allocated through FT_Alloc(). */
- /* */
- /* <Input> */
- /* memory :: A handle to a given `memory object' where allocation */
- /* occured. */
- /* */
- /* P :: This is the _address_ of a _pointer_ which points to the */
- /* allocated block. It is always set to NULL on exit. */
- /* */
- /* <Note> */
- /* If P or *P are NULL, this function should return successfully. */
- /* This is a strong convention within all of FreeType and its */
- /* drivers. */
- /* */
BASE_DEF
void FT_Free( FT_Memory memory,
void** P );
@@ -246,6 +168,23 @@
+ EXPORT_DEF
+ FT_Error FT_New_Size( FT_Face face,
+ FT_Size* size );
+
+ EXPORT_DEF
+ FT_Error FT_Done_Size( FT_Size size );
+
+ EXPORT_DEF
+ FT_Error FT_New_GlyphSlot( FT_Face face,
+ FT_GlyphSlot* aslot );
+
+ EXPORT_DEF
+ void FT_Done_GlyphSlot( FT_GlyphSlot slot );
+
+
+
+
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
@@ -317,7 +256,17 @@
} FT_DriverRec;
-#ifdef FT_CONFIG_OPTION_ALTERNATE_GLYPH_FORMATS
+ /*************************************************************************/
+ /*************************************************************************/
+ /*************************************************************************/
+ /**** ****/
+ /**** ****/
+ /**** G L Y P H Z O N E S ****/
+ /**** ****/
+ /**** ****/
+ /*************************************************************************/
+ /*************************************************************************/
+ /*************************************************************************/
/************************************************************************
*
@@ -357,6 +306,7 @@
} FT_GlyphZone;
+
BASE_DEF
FT_Error FT_New_GlyphZone( FT_Memory memory,
FT_UShort maxPoints,
@@ -377,132 +327,6 @@
/*************************************************************************/
/**** ****/
/**** ****/
- /**** G L Y P H F O R M A T S ****/
- /**** ****/
- /**** ****/
- /*************************************************************************/
- /*************************************************************************/
- /*************************************************************************/
-
- /*************************************************************************
- *
- * <Struct>
- * FT_Glyph_Format
- *
- * <Description>
- * A structure used to model various properties of a non-standard
- * glyph image format.
- *
- * <Fields>
- * format_tag :: the glyph format tag
- *
- * raster_interface :: the default rasters interface for this glyph
- * format.
- *
- * raster :: the default raster object for this glyph format
- * if set to nil, a new object will be allocated
- * automatically through the raster interface.
- *
- * raster_owned :: a boolean used internally by the library. If
- * set, if indicates that the current raster object
- * was allocated by the library.
- *
- *************************************************************************/
-
- typedef struct FT_Glyph_Format_
- {
- FT_Glyph_Tag format_tag;
- FT_Raster_Interface* raster_interface;
- FT_Raster raster;
- FT_Bool raster_allocated;
-
- } FT_Glyph_Format;
-
-
- /*************************************************************************
- *
- * <Function>
- * FT_Add_Glyph_Format
- *
- * <Description>
- * Register a new glyph format into the library
- *
- * <Input>
- * library :: handle to target library object
- * interface :: pointer to glyph format interface
- *
- * <Return>
- * Error code. 0 means success
- *
- * <Note>
- * This function should normally be called by those font drivers which
- * need to use their own glyph image format.
- *
- *************************************************************************/
-
- EXPORT_DEF
- FT_Error FT_Add_Glyph_Format( FT_Library library,
- FT_Glyph_Format* format );
-
-
- /*************************************************************************
- *
- * <Function>
- * FT_Remove_Glyph_Format
- *
- * <Description>
- * Un-Register a given glyph format from the library
- *
- * <Input>
- * library :: handle to target library object
- * glyph_format :: glyph format tag
- *
- * <Return>
- * Error code. 0 means success
- *
- * <Note>
- * This function should normally be called by those font drivers which
- * need to use their own glyph image format.
- *
- *************************************************************************/
-
- EXPORT_DEF
- FT_Error FT_Remove_Glyph_Format( FT_Library library,
- FT_Glyph_Tag glyph_format );
-
- /*************************************************************************
- *
- * <Function>
- * FT_Get_Glyph_Format
- *
- * <Description>
- * Return a pointer to the glyph format descriptor corresponding to
- * a given format tag.
- *
- * <Input>
- * library :: handle to source library object
- *
- * format_tag :: glyph format tag
- *
- * <Return>
- * a pointer to the corresponding glyph format descriptor, if it was
- * registered in the library. 0 otherwise.
- *
- *************************************************************************/
-
- BASE_DEF
- FT_Glyph_Format* FT_Get_Glyph_Format( FT_Library library,
- FT_Glyph_Tag format_tag );
-
-
-
-#endif /* FT_CONFIG_OPTION_ALTERNATE_GLYPH_FORMATS */
-
- /*************************************************************************/
- /*************************************************************************/
- /*************************************************************************/
- /**** ****/
- /**** ****/
/**** L I B R A R I E S ****/
/**** ****/
/**** ****/
@@ -539,10 +363,6 @@
/* registered font drivers. Note that each driver */
/* contains a list of its opened faces. */
/* */
- /* glyph_formats :: A table used to store glyph format descriptors */
- /* for new image formats that may have been */
- /* registered within the library */
- /* */
/* raster_pool :: The raster object's render pool. This can */
/* ideally be changed dynamically at run-time. */
/* */
@@ -557,59 +377,22 @@
FT_Int num_drivers;
FT_Driver drivers[ FT_MAX_DRIVERS ]; /* driver objects */
- FT_Glyph_Format glyph_formats[FT_MAX_GLYPH_FORMATS];
+ FT_Raster_Funcs raster_funcs[ FT_MAX_GLYPH_FORMATS ];
+ FT_Raster rasters [ FT_MAX_GLYPH_FORMATS ];
- void* raster_pool; /* scan-line conversion render pool */
+ void* raster_pool; /* scan-line conversion render pool */
+ long raster_pool_size; /* size of render pool in bytes */
FT_DebugHook_Func debug_hooks[4];
} FT_LibraryRec;
- /*************************************************************************/
- /* */
- /* <Function> */
- /* FT_New_Library */
- /* */
- /* <Description> */
- /* This function is used to create a new FreeType library instance */
- /* from a given memory object. It is thus possible to use libraries */
- /* with distinct memory allocators within the same program. */
- /* */
- /* <Input> */
- /* memory :: A handle to the original memory object. */
- /* */
- /* <Output> */
- /* library :: A handle to a new library object. */
- /* */
- /* <Return> */
- /* Error code. 0 means success. */
- /* */
- /* <Note> */
- /* This function is normally not called by client applications, */
- /* unless they want to create a specific instance of FreeType which */
- /* uses a specific memory allocator. */
- /* */
EXPORT_DEF
FT_Error FT_New_Library( FT_Memory memory,
FT_Library* library );
- /*************************************************************************/
- /* */
- /* <Function> */
- /* FT_Done_Library */
- /* */
- /* <Description> */
- /* Discards a given library object. This closes all drivers and */
- /* discards all face objects. */
- /* */
- /* <Input> */
- /* library :: A handle to the target library. */
- /* */
- /* <Return> */
- /* Error code. 0 means success. */
- /* */
EXPORT_DEF
FT_Error FT_Done_Library( FT_Library library );
@@ -621,127 +404,26 @@
FT_DebugHook_Func debug_hook );
- /*************************************************************************/
- /* */
- /* <Function> */
- /* FT_Add_Driver */
- /* */
- /* <Description> */
- /* Registers a new driver in a given library object. This function */
- /* takes only a pointer to a driver interface. It uses it to create */
- /* the new driver, then sets up some important fields. */
- /* */
- /* <Input> */
- /* library :: A handle to the target library object. */
- /* */
- /* driver_interface :: A pointer to a driver interface table. */
- /* */
- /* <Return> */
- /* Error code. 0 means success. */
- /* */
- /* <Note> */
- /* This function doesn't check whether the driver is already */
- /* installed! */
- /* */
EXPORT_DEF
FT_Error FT_Add_Driver( FT_Library library,
const FT_DriverInterface* driver_interface );
- /*************************************************************************/
- /* */
- /* <Function> */
- /* FT_Remove_Driver */
- /* */
- /* <Description> */
- /* Unregister a given driver. This closes the driver, which in turn */
- /* destroys all faces, sizes, slots, etc. associated with it. */
- /* */
- /* This function also DESTROYS the driver object. */
- /* */
- /* <Input> */
- /* driver :: A handle to target driver object. */
- /* */
- /* <Return> */
- /* Error code. 0 means success. */
- /* */
EXPORT_DEF
FT_Error FT_Remove_Driver( FT_Driver driver );
- /*************************************************************************/
- /* */
- /* <Function> */
- /* FT_Get_Driver */
- /* */
- /* <Description> */
- /* returns the handle of the driver responsible for a given format */
- /* (or service) according to its `name'. */
- /* */
- /* <Input> */
- /* library :: handle to library object. */
- /* driver_name :: name of driver to look-up. */
- /* */
- /* <Return> */
- /* handle to driver object. 0 otherwise */
- /* */
EXPORT_DEF
FT_Driver FT_Get_Driver( FT_Library library,
char* driver_name );
#ifndef FT_CONFIG_OPTION_NO_DEFAULT_SYSTEM
- /**************************************************************************
- *
- * <Function>
- * FT_New_Stream
- *
- * <Description>
- * Open a new stream from a given standard ASCII file path name
- *
- * <Input>
- * filepathname :: an ASCII string naming the file to be opened
- *
- * <Output>
- * astream :: the opened stream descriptor to be used by the library
- *
- * <Return>
- * Error code. 0 means success
- *
- * <Note>
- * This function must be implemented by the system-specific part
- * of the engine, i.e. `ftsystem.c'.
- *
- * This function should only fill the stream descriptor. Note that
- * the stream's `memory' field should be left to the caller.
- *
- **************************************************************************/
-
extern
FT_Error FT_New_Stream( const char* filepathname,
FT_Stream astream );
- /**************************************************************************
- *
- * <Function>
- * FT_New_Memory
- *
- * <Description>
- * Returns a handle to a new memory object
- *
- * <Return>
- * Handle to the memory object. 0 means failure
- *
- * <Note>
- * This function must be implemented by the system-specific part
- * of the engine, i.e. `ftsystem.c'.
- *
- * It is only used by `ftinit' in order to implement the function
- * FT_Init_FreeType.
- *
- **************************************************************************/
-
extern
FT_Memory FT_New_Memory( void );
@@ -753,7 +435,7 @@
/* */
#ifndef FT_NO_DEFAULT_RASTER
extern
- FT_Raster_Interface ft_default_raster;
+ FT_Raster_Funcs ft_default_raster;
#endif
diff --git a/src/base/ftoutln.c b/src/base/ftoutln.c
index 0253aba..43ec6db 100644
--- a/src/base/ftoutln.c
+++ b/src/base/ftoutln.c
@@ -29,52 +29,616 @@
#include <ftimage.h>
#include <ftoutln.h>
+ static
+ const FT_Outline null_outline = { 0, 0, 0, 0, 0, 0 };
+
/*************************************************************************/
/* */
/* <Function> */
- /* FT_Outline_Copy */
+ /* FT_Outline_Decompose */
/* */
/* <Description> */
- /* Copies an outline into another one. Both objects must have the */
- /* same sizes (number of points & number of contours) when this */
- /* function is called. */
+ /* Walks over an outline's structure to decompose it into individual */
+ /* segments and Bezier arcs. This function is also able to emit */
+ /* `move to' and `close to' operations to indicate the start and end */
+ /* of new contours in the outline. */
/* */
/* <Input> */
- /* source :: A handle to the source outline. */
- /* target :: A handle to the target outline. */
+ /* outline :: A pointer to the source target. */
+ /* */
+ /* interface :: A table of `emitters', i.e,. function pointers called */
+ /* during decomposition to indicate path operations. */
+ /* */
+ /* user :: A typeless pointer which is passed to each emitter */
+ /* during the decomposition. It can be used to store */
+ /* the state during the decomposition. */
+ /* */
+ /* <Return> */
+ /* Error code. 0 means sucess. */
+ /* */
+ EXPORT_FUNC
+ int FT_Outline_Decompose( FT_Outline* outline,
+ FT_Outline_Funcs* interface,
+ void* user )
+ {
+ typedef enum _phases
+ {
+ phase_point,
+ phase_conic,
+ phase_cubic,
+ phase_cubic2
+
+ } TPhase;
+
+ FT_Vector v_first;
+ FT_Vector v_last;
+ FT_Vector v_control;
+ FT_Vector v_start;
+
+ FT_Vector* point;
+ FT_Vector* limit;
+ char* tags;
+
+ int n; /* index of contour in outline */
+ int first; /* index of first point in contour */
+ int error;
+ char tag; /* current point's state */
+
+
+ first = 0;
+
+ for ( n = 0; n < outline->n_contours; n++ )
+ {
+ int last; /* index of last point in contour */
+
+ last = outline->contours[n];
+ limit = outline->points + last;
+
+ v_first = outline->points[first];
+ v_last = outline->points[last];
+
+ v_start = v_control = v_first;
+
+ point = outline->points + first;
+ tags = outline->tags + first;
+ tag = FT_CURVE_TAG( tags[0] );
+
+ /* A contour cannot start with a cubic control point! */
+ if ( tag == FT_Curve_Tag_Cubic )
+ goto Invalid_Outline;
+
+ /* check first point to determine origin */
+ if ( tag == FT_Curve_Tag_Conic )
+ {
+ /* first point is conic control. Yes, this happens. */
+ if ( FT_CURVE_TAG( outline->tags[last] ) == FT_Curve_Tag_On )
+ {
+ /* start at last point if it is on the curve */
+ v_start = v_last;
+ limit--;
+ }
+ else
+ {
+ /* if both first and last points are conic, */
+ /* start at their middle and record its position */
+ /* for closure */
+ v_start.x = ( v_start.x + v_last.x ) / 2;
+ v_start.y = ( v_start.y + v_last.y ) / 2;
+
+ v_last = v_start;
+ }
+ point--;
+ tags--;
+ }
+
+ error = interface->move_to( &v_start, user );
+ if (error) goto Exit;
+
+ while (point < limit)
+ {
+ point++;
+ tags++;
+
+ tag = FT_CURVE_TAG( tags[0] );
+ switch (tag)
+ {
+ case FT_Curve_Tag_On: /* emit a single line_to */
+ {
+ error = interface->line_to( point, user );
+ if (error) goto Exit;
+ continue;
+ }
+
+
+ case FT_Curve_Tag_Conic: /* consume conic arcs */
+ {
+ v_control = point[0];
+
+ Do_Conic:
+ if (point < limit)
+ {
+ FT_Vector v_middle;
+
+ point++;
+ tags++;
+ tag = FT_CURVE_TAG( tags[0] );
+
+ if (tag == FT_Curve_Tag_On)
+ {
+ error = interface->conic_to( &v_control, point, user );
+ if (error) goto Exit;
+ continue;
+ }
+
+ if (tag != FT_Curve_Tag_Conic)
+ goto Invalid_Outline;
+
+ v_middle.x = (v_control.x + point->x)/2;
+ v_middle.y = (v_control.y + point->y)/2;
+
+ error = interface->conic_to( &v_control, &v_middle, user );
+ if (error) goto Exit;
+
+ v_control = point[0];
+ goto Do_Conic;
+ }
+
+ error = interface->conic_to( &v_control, &v_start, user );
+ goto Close;
+ }
+
+ default: /* FT_Curve_Tag_Cubic */
+ {
+ if ( point+1 > limit ||
+ FT_CURVE_TAG( tags[1] ) != FT_Curve_Tag_Cubic )
+ goto Invalid_Outline;
+
+ point += 2;
+ tags += 2;
+
+ if (point <= limit)
+ {
+ error = interface->cubic_to( point-2, point-1, point, user );
+ if (error) goto Exit;
+ continue;
+ }
+
+ error = interface->cubic_to( point-2, point-1, &v_start, user );
+ goto Close;
+ }
+ }
+ }
+
+ /* close the contour with a line segment */
+ error = interface->line_to( &v_start, user );
+
+ Close:
+ if (error) goto Exit;
+ first = last+1;
+ }
+
+ return 0;
+ Exit:
+ return error;
+
+ Invalid_Outline:
+ return -1;
+ }
+
+
+ /*************************************************************************/
+ /* */
+ /* <Function> */
+ /* FT_Outline_New */
+ /* */
+ /* <Description> */
+ /* Creates a new outline of a given size. */
+ /* */
+ /* <Input> */
+ /* library :: A handle to the library object from where the */
+ /* outline is allocated. Note however that the new */
+ /* outline will NOT necessarily be FREED when */
+ /* destroying the library, by FT_Done_FreeType(). */
+ /* */
+ /* numPoints :: The maximum number of points within the outline. */
+ /* */
+ /* numContours :: The maximum number of contours within the outline. */
+ /* */
+ /* <Output> */
+ /* outline :: A handle to the new outline. NULL in case of */
+ /* error. */
/* */
/* <Return> */
/* FreeType error code. 0 means success. */
/* */
+ /* <MT-Note> */
+ /* No. */
+ /* */
+ /* <Note> */
+ /* The reason why this function takes a `library' parameter is simply */
+ /* to use the library's memory allocator. You can copy the source */
+ /* code of this function, replacing allocations with `malloc()' if */
+ /* you want to control where the objects go. */
+ /* */
BASE_FUNC
- FT_Error FT_Outline_Copy( FT_Outline* source,
- FT_Outline* target )
+ FT_Error FT_Outline_New( FT_Library library,
+ FT_UInt numPoints,
+ FT_Int numContours,
+ FT_Outline* outline )
{
- FT_Int is_owner;
-
- if ( !source || !target ||
- source->n_points != target->n_points ||
- source->n_contours != target->n_contours )
+ FT_Error error;
+ FT_Memory memory;
+
+
+ if ( !outline )
return FT_Err_Invalid_Argument;
- MEM_Copy( target->points, source->points,
- source->n_points * 2 * sizeof ( FT_Pos ) );
+ *outline = null_outline;
+ memory = library->memory;
- MEM_Copy( target->tags, source->tags,
- source->n_points * sizeof ( FT_Byte ) );
+ if ( ALLOC_ARRAY( outline->points, numPoints * 2L, FT_Pos ) ||
+ ALLOC_ARRAY( outline->tags, numPoints, FT_Byte ) ||
+ ALLOC_ARRAY( outline->contours, numContours, FT_UShort ) )
+ goto Fail;
- MEM_Copy( target->contours, source->contours,
- source->n_contours * sizeof ( FT_Short ) );
+ outline->n_points = (FT_UShort)numPoints;
+ outline->n_contours = (FT_Short)numContours;
+ outline->flags |= ft_outline_owner;
- /* copy all flags, except the "ft_outline_owner" one */
- is_owner = target->flags & ft_outline_owner;
- target->flags = source->flags;
-
- target->flags &= ~ft_outline_owner;
- target->flags |= is_owner;
return FT_Err_Ok;
+
+ Fail:
+ outline->flags |= ft_outline_owner;
+ FT_Outline_Done( library, outline );
+
+ return error;
+ }
+
+
+ /*************************************************************************/
+ /* */
+ /* <Function> */
+ /* FT_Outline_Done */
+ /* */
+ /* <Description> */
+ /* Destroys an outline created with FT_Outline_New(). */
+ /* */
+ /* <Input> */
+ /* library :: A handle of the library object used to allocate the */
+ /* outline. */
+ /* */
+ /* outline :: A pointer to the outline object to be discarded. */
+ /* */
+ /* <Return> */
+ /* FreeType error code. 0 means success. */
+ /* */
+ /* <MT-Note> */
+ /* No. */
+ /* */
+ /* <Note> */
+ /* If the outline's `owner' field is not set, only the outline */
+ /* descriptor will be released. */
+ /* */
+ /* The reason why this function takes an `outline' parameter is */
+ /* simply to use FT_Alloc()/FT_Free(). You can copy the source code */
+ /* of this function, replacing allocations with `malloc()' in your */
+ /* application if you want something simpler. */
+ /* */
+ BASE_FUNC
+ FT_Error FT_Outline_Done( FT_Library library,
+ FT_Outline* outline )
+ {
+ FT_Memory memory = library->memory;
+
+ if ( outline )
+ {
+ if ( outline->flags & ft_outline_owner )
+ {
+ FREE( outline->points );
+ FREE( outline->tags );
+ FREE( outline->contours );
+ }
+ *outline = null_outline;
+
+ return FT_Err_Ok;
+ }
+ else
+ return FT_Err_Invalid_Argument;
+ }
+
+
+ /*************************************************************************/
+ /* */
+ /* <Function> */
+ /* FT_Outline_Get_CBox */
+ /* */
+ /* <Description> */
+ /* Returns an outline's `control box'. The control box encloses all */
+ /* the outline's points, including Bezier control points. Though it */
+ /* coincides with the exact bounding box for most glyphs, it can be */
+ /* slightly larger in some situations (like when rotating an outline */
+ /* which contains Bezier outside arcs). */
+ /* */
+ /* Computing the control box is very fast, while getting the bounding */
+ /* box can take much more time as it needs to walk over all segments */
+ /* and arcs in the outline. To get the latter, you can use the */
+ /* `ftbbox' component which is dedicated to this single task. */
+ /* */
+ /* <Input> */
+ /* outline :: A pointer to the source outline descriptor. */
+ /* */
+ /* <Output> */
+ /* cbox :: The outline's control box. */
+ /* */
+ /* <MT-Note> */
+ /* Yes. */
+ /* */
+ BASE_FUNC
+ void FT_Outline_Get_CBox( FT_Outline* outline,
+ FT_BBox* cbox )
+ {
+ FT_Pos xMin, yMin, xMax, yMax;
+
+ if ( outline && cbox )
+ {
+ if ( outline->n_points == 0 )
+ {
+ xMin = 0;
+ yMin = 0;
+ xMax = 0;
+ yMax = 0;
+ }
+ else
+ {
+ FT_Vector* vec = outline->points;
+ FT_Vector* limit = vec + outline->n_points;
+
+ xMin = xMax = vec->x;
+ yMin = yMax = vec->y;
+ vec++;
+
+ for ( ; vec < limit; vec++ )
+ {
+ FT_Pos x, y;
+
+ x = vec->x;
+ if ( x < xMin ) xMin = x;
+ if ( x > xMax ) xMax = x;
+
+ y = vec->y;
+ if ( y < yMin ) yMin = y;
+ if ( y > yMax ) yMax = y;
+ }
+ }
+ cbox->xMin = xMin;
+ cbox->xMax = xMax;
+ cbox->yMin = yMin;
+ cbox->yMax = yMax;
+ }
+ }
+
+
+
+ /*************************************************************************/
+ /* */
+ /* <Function> */
+ /* FT_Outline_Translate */
+ /* */
+ /* <Description> */
+ /* Applies a simple translation to the points of an outline. */
+ /* */
+ /* <Input> */
+ /* outline :: A pointer to the target outline descriptor. */
+ /* xOffset :: The horizontal offset. */
+ /* yOffset :: The vertical offset. */
+ /* */
+ /* <MT-Note> */
+ /* Yes. */
+ /* */
+ BASE_FUNC
+ void FT_Outline_Translate( FT_Outline* outline,
+ FT_Pos xOffset,
+ FT_Pos yOffset )
+ {
+ FT_UShort n;
+ FT_Vector* vec = outline->points;
+
+ for ( n = 0; n < outline->n_points; n++ )
+ {
+ vec->x += xOffset;
+ vec->y += yOffset;
+ vec++;
+ }
+ }
+
+ /*************************************************************************/
+ /* */
+ /* <Function> */
+ /* FT_Outline_Reverse */
+ /* */
+ /* <Description> */
+ /* Reverse the drawing direction of an outline. This is used to */
+ /* ensure consistent fill conventions for mirrored glyphs.. */
+ /* */
+ /* <Input> */
+ /* outline :: A pointer to the target outline descriptor. */
+ /* */
+ /* <Note> */
+ /* This functions toggles the bit flag ft_outline_reverse_fill in */
+ /* the outline's "flags" field.. */
+ /* */
+ BASE_FUNC
+ void FT_Outline_Reverse( FT_Outline* outline )
+ {
+ FT_UShort n;
+ FT_Int first, last;
+
+ first = 0;
+ for ( n = 0; n < outline->n_contours; n++ )
+ {
+ last = outline->contours[n];
+
+ /* reverse point table */
+ {
+ FT_Vector* p = outline->points + first;
+ FT_Vector* q = outline->points + last;
+ FT_Vector swap;
+
+ while (p < q)
+ {
+ swap = *p;
+ *p = *q;
+ *q = swap;
+ p++;
+ q--;
+ }
+ }
+
+ /* reverse tags table */
+ {
+ char* p = outline->tags + first;
+ char* q = outline->tags + last;
+ char swap;
+
+ while (p < q)
+ {
+ swap = *p;
+ *p = *q;
+ *q = swap;
+ p++;
+ q--;
+ }
+ }
+
+ first = last+1;
+ }
+ outline->flags ^= ft_outline_reverse_fill;
+ }
+
+ /*************************************************************************/
+ /* */
+ /* <Function> */
+ /* FT_Done_GlyphZone */
+ /* */
+ /* <Description> */
+ /* Deallocates a glyph zone. */
+ /* */
+ /* <Input> */
+ /* zone :: pointer to the target glyph zone. */
+ /* */
+ BASE_FUNC
+ void FT_Done_GlyphZone( FT_GlyphZone* zone )
+ {
+ FT_Memory memory = zone->memory;
+
+ FREE( zone->contours );
+ FREE( zone->tags );
+ FREE( zone->cur );
+ FREE( zone->org );
+
+ zone->max_points = zone->n_points = 0;
+ zone->max_contours = zone->n_contours = 0;
+ }
+
+ /*************************************************************************/
+ /* */
+ /* <Function> */
+ /* FT_New_GlyphZone */
+ /* */
+ /* <Description> */
+ /* Allocates a new glyph zone. */
+ /* */
+ /* <Input> */
+ /* memory :: A handle to the current memory object. */
+ /* */
+ /* maxPoints :: The capacity of glyph zone in points. */
+ /* */
+ /* maxContours :: The capacity of glyph zone in contours. */
+ /* */
+ /* <Output> */
+ /* zone :: A pointer to the target glyph zone record. */
+ /* */
+ /* <Return> */
+ /* FreeType error code. 0 means success. */
+ /* */
+ BASE_FUNC
+ FT_Error FT_New_GlyphZone( FT_Memory memory,
+ FT_UShort maxPoints,
+ FT_Short maxContours,
+ FT_GlyphZone* zone )
+ {
+ FT_Error error;
+
+ if (maxPoints > 0)
+ maxPoints += 2;
+
+ MEM_Set( zone, 0, sizeof(*zone) );
+ zone->memory = memory;
+
+ if ( ALLOC_ARRAY( zone->org, maxPoints*2, FT_F26Dot6 ) ||
+ ALLOC_ARRAY( zone->cur, maxPoints*2, FT_F26Dot6 ) ||
+ ALLOC_ARRAY( zone->tags, maxPoints, FT_Byte ) ||
+ ALLOC_ARRAY( zone->contours, maxContours, FT_UShort ) )
+ {
+ FT_Done_GlyphZone(zone);
+ }
+ return error;
}
+ /*************************************************************************/
+ /* */
+ /* <Function> */
+ /* FT_Update_GlyphZone */
+ /* */
+ /* <Description> */
+ /* Checks the size of a zone and reallocates it if necessary. */
+ /* */
+ /* <Input> */
+ /* newPoints :: The new capacity for points. We add two slots for */
+ /* phantom points. */
+ /* */
+ /* newContours :: The new capacity for contours. */
+ /* */
+ /* <InOut> */
+ /* zone :: The address of the target zone. */
+ /* */
+ /* maxPoints :: The address of the zone's current capacity for */
+ /* points. */
+ /* */
+ /* maxContours :: The address of the zone's current capacity for */
+ /* contours. */
+ /* */
+ BASE_FUNC
+ FT_Error FT_Update_GlyphZone( FT_GlyphZone* zone,
+ FT_UShort newPoints,
+ FT_Short newContours )
+ {
+ FT_Error error = FT_Err_Ok;
+ FT_Memory memory = zone->memory;
+
+ newPoints += 2;
+ if ( zone->max_points < newPoints )
+ {
+ /* reallocate the points arrays */
+ if ( REALLOC_ARRAY( zone->org, zone->max_points*2, newPoints*2, FT_F26Dot6 ) ||
+ REALLOC_ARRAY( zone->cur, zone->max_points*2, newPoints*2, FT_F26Dot6 ) ||
+ REALLOC_ARRAY( zone->tags, zone->max_points*2, newPoints, FT_Byte ) )
+ goto Exit;
+
+ zone->max_points = newPoints;
+ }
+
+ if ( zone->max_contours < newContours )
+ {
+ /* reallocate the contours array */
+ if ( REALLOC_ARRAY( zone->contours, zone->max_contours, newContours, FT_UShort ) )
+ goto Exit;
+
+ zone->max_contours = newContours;
+ }
+ Exit:
+ return error;
+ }
/*************************************************************************/
/* */
@@ -104,27 +668,148 @@
/* */
/* It will use the raster correponding to the default glyph format. */
/* */
- BASE_FUNC
+ EXPORT_FUNC
FT_Error FT_Outline_Get_Bitmap( FT_Library library,
FT_Outline* outline,
FT_Bitmap* map )
{
FT_Error error;
- FT_Glyph_Format* format;
+ FT_Raster raster;
+ FT_Raster_Funcs funcs;
+ FT_Raster_Params params;
error = FT_Err_Invalid_Glyph_Format;
- format = FT_Get_Glyph_Format( library, ft_glyph_format_outline );
- if (!format) goto Exit;
+ raster = FT_Get_Raster( library, ft_glyph_format_outline, &funcs );
+ if (!raster) goto Exit;
+
+ params.target = map;
+ params.source = outline;
+ params.flags = 0;
+ if (map->pixel_mode == ft_pixel_mode_grays)
+ params.flags |= ft_raster_flag_aa;
+
+ error = funcs.raster_render( raster, ¶ms );
+ Exit:
+ return error;
+ }
- error = FT_Err_Invalid_Glyph_Format;
- if (!format->raster) goto Exit;
+ /*************************************************************************/
+ /* */
+ /* <Function> */
+ /* FT_Outline_Render */
+ /* */
+ /* <Description> */
+ /* Renders an outline within a bitmap using the current scan-convert */
+ /* This functions uses a FT_Raster_Params as argument, allowing */
+ /* advanced features like direct composition/translucency, etc.. */
+ /* */
+ /* <Input> */
+ /* library :: A handle to a FreeType library object. */
+ /* outline :: A pointer to the source outline descriptor. */
+ /* params :: A pointer to a FT_Raster_Params used to describe */
+ /* the rendering operation */
+ /* */
+ /* <Return> */
+ /* FreeType error code. 0 means success. */
+ /* */
+ /* <MT-Note> */
+ /* YES. Rendering is synchronized, so that concurrent calls to the */
+ /* scan-line converter will be serialized. */
+ /* */
+ /* <Note> */
+ /* You should know what you're doing and the role of FT_Raster_Params */
+ /* to use this function. */
+ /* */
+ /* the field "params.source" will be set to "outline" before the */
+ /* scan converter is called, which means that the value you give it */
+ /* is actually ignored.. */
+ /* */
+ EXPORT_FUNC
+ FT_Error FT_Outline_Render( FT_Library library,
+ FT_Outline* outline,
+ FT_Raster_Params* params )
+ {
+ FT_Error error;
+ FT_Raster raster;
+ FT_Raster_Funcs funcs;
- error = format->raster_interface->render( format->raster, outline, map );
+ error = FT_Err_Invalid_Glyph_Format;
+ raster = FT_Get_Raster( library, ft_glyph_format_outline, &funcs );
+ if (!raster) goto Exit;
+
+ params->source = (void*)outline;
+ error = funcs.raster_render( raster, params );
Exit:
return error;
}
+
+
+
+ /*************************************************************************/
+ /*************************************************************************/
+ /*************************************************************************/
+ /**** ****/
+ /**** The following functions are not used by the font drivers ****/
+ /**** but they are provided as a convenience for client apps. ****/
+ /**** ****/
+ /**** Note that they will not be compiled if the configuration ****/
+ /**** macro FT_CONFIG_OPTION_NO_CONVENIENCE_FUNCS is defined ****/
+ /**** ****/
+ /*************************************************************************/
+ /*************************************************************************/
+ /*************************************************************************/
+
+#ifndef FT_CONFIG_OPTION_NO_CONVENIENCE_FUNCS
+
+ /*************************************************************************/
+ /* */
+ /* <Function> */
+ /* FT_Outline_Copy */
+ /* */
+ /* <Description> */
+ /* Copies an outline into another one. Both objects must have the */
+ /* same sizes (number of points & number of contours) when this */
+ /* function is called. */
+ /* */
+ /* <Input> */
+ /* source :: A handle to the source outline. */
+ /* target :: A handle to the target outline. */
+ /* */
+ /* <Return> */
+ /* FreeType error code. 0 means success. */
+ /* */
+ BASE_FUNC
+ FT_Error FT_Outline_Copy( FT_Outline* source,
+ FT_Outline* target )
+ {
+ FT_Int is_owner;
+
+ if ( !source || !target ||
+ source->n_points != target->n_points ||
+ source->n_contours != target->n_contours )
+ return FT_Err_Invalid_Argument;
+
+ MEM_Copy( target->points, source->points,
+ source->n_points * 2 * sizeof ( FT_Pos ) );
+
+ MEM_Copy( target->tags, source->tags,
+ source->n_points * sizeof ( FT_Byte ) );
+
+ MEM_Copy( target->contours, source->contours,
+ source->n_contours * sizeof ( FT_Short ) );
+
+ /* copy all flags, except the "ft_outline_owner" one */
+ is_owner = target->flags & ft_outline_owner;
+ target->flags = source->flags;
+
+ target->flags &= ~ft_outline_owner;
+ target->flags |= is_owner;
+ return FT_Err_Ok;
+ }
+
+
/*************************************************************************/
/* */
/* <Function> */
@@ -158,7 +843,6 @@
{
FT_Pos x, y;
-
x = FT_MulFix( vec->x, matrix->xx ) +
FT_MulFix( vec->y, matrix->xy );
@@ -181,8 +865,7 @@
/* Transforms a single vector through a 2x2 matrix. */
/* */
/* <InOut> */
- /* x :: The horizontal vector coordinate. */
- /* y :: The vertical vector coordinate. */
+ /* vector :: The target vector to transform */
/* */
/* <Input> */
/* matrix :: A pointer to the source 2x2 matrix. */
@@ -190,22 +873,20 @@
/* <MT-Note> */
/* Yes. */
/* */
- BASE_FUNC
- void FT_Vector_Transform( FT_Pos* x,
- FT_Pos* y,
+ EXPORT_DEF
+ void FT_Vector_Transform( FT_Vector* vector,
FT_Matrix* matrix )
{
FT_Pos xz, yz;
+ xz = FT_MulFix( vector->x, matrix->xx ) +
+ FT_MulFix( vector->y, matrix->xy );
- xz = FT_MulFix( *x, matrix->xx ) +
- FT_MulFix( *y, matrix->xy );
-
- yz = FT_MulFix( *x, matrix->yx ) +
- FT_MulFix( *y, matrix->yy );
+ yz = FT_MulFix( vector->x, matrix->yx ) +
+ FT_MulFix( vector->y, matrix->yy );
- *x = xz;
- *y = yz;
+ vector->x = xz;
+ vector->y = yz;
}
@@ -286,5 +967,6 @@
return FT_Err_Ok;
}
+#endif
/* END */
diff --git a/src/base/ftoutln.h b/src/base/ftoutln.h
index 07b0b55..438d00b 100644
--- a/src/base/ftoutln.h
+++ b/src/base/ftoutln.h
@@ -3,151 +3,4 @@
#include <ftobjs.h>
- /*************************************************************************/
- /* */
- /* <Function> */
- /* FT_Outline_Copy */
- /* */
- /* <Description> */
- /* Copies an outline into another one. Both objects must have the */
- /* same sizes (number of points & number of contours) when this */
- /* function is called. */
- /* */
- /* <Input> */
- /* source :: A handle to the source outline. */
- /* target :: A handle to the target outline. */
- /* */
- /* <Return> */
- /* FreeType error code. 0 means success. */
- /* */
- EXPORT_DEF
- FT_Error FT_Outline_Copy( FT_Outline* source,
- FT_Outline* target );
-
- /*************************************************************************/
- /* */
- /* <Function> */
- /* FT_Outline_Get_Bitmap */
- /* */
- /* <Description> */
- /* Renders an outline within a bitmap. The outline's image is simply */
- /* or-ed to the target bitmap. */
- /* */
- /* */
- /* <Input> */
- /* library :: A handle to a FreeType library object. */
- /* outline :: A pointer to the source outline descriptor. */
- /* map :: A pointer to the target bitmap descriptor. */
- /* */
- /* <Return> */
- /* FreeType error code. 0 means success. */
- /* */
- /* <MT-Note> */
- /* YES. Rendering is synchronized, so that concurrent calls to the */
- /* scan-line converter will be serialized. */
- /* */
- /* <Note> */
- /* This function does NOT CREATE the bitmap, it only renders an */
- /* outline image within the one you pass to it! */
- /* */
- /* It will use the raster correponding to the default glyph format. */
- /* */
- EXPORT_DEF
- FT_Error FT_Outline_Get_Bitmap( FT_Library library,
- FT_Outline* outline,
- FT_Bitmap* map );
-
-
- /*************************************************************************/
- /* */
- /* <Function> */
- /* FT_Outline_Transform */
- /* */
- /* <Description> */
- /* Applies a simple 2x2 matrix to all of an outline's points. Useful */
- /* for applying rotations, slanting, flipping, etc. */
- /* */
- /* <Input> */
- /* outline :: A pointer to the target outline descriptor. */
- /* matrix :: A pointer to the transformation matrix. */
- /* */
- /* <MT-Note> */
- /* Yes. */
- /* */
- /* <Note> */
- /* You can use FT_Outline_Translate() if you need to translate the */
- /* outline's points. */
- /* */
- EXPORT_DEF
- void FT_Outline_Transform( FT_Outline* outline,
- FT_Matrix* matrix );
-
-
- /*************************************************************************/
- /* */
- /* <Function> */
- /* FT_Vector_Transform */
- /* */
- /* <Description> */
- /* Transforms a single vector through a 2x2 matrix. */
- /* */
- /* <InOut> */
- /* x :: The horizontal vector coordinate. */
- /* y :: The vertical vector coordinate. */
- /* */
- /* <Input> */
- /* matrix :: A pointer to the source 2x2 matrix. */
- /* */
- /* <MT-Note> */
- /* Yes. */
- /* */
- EXPORT_DEF
- void FT_Vector_Transform( FT_Pos* x,
- FT_Pos* y,
- FT_Matrix* matrix );
-
-
- /*************************************************************************/
- /* */
- /* <Function> */
- /* FT_Matrix_Multiply */
- /* */
- /* <Description> */
- /* Performs the matrix operation `b = a*b'. */
- /* */
- /* <Input> */
- /* a :: A pointer to matrix `a'. */
- /* */
- /* <InOut> */
- /* b :: A pointer to matrix `b'. */
- /* */
- /* <MT-Note> */
- /* Yes. */
- /* */
- EXPORT_DEF
- void FT_Matrix_Multiply( FT_Matrix* a,
- FT_Matrix* b );
-
-
- /*************************************************************************/
- /* */
- /* <Function> */
- /* FT_Matrix_Invert */
- /* */
- /* <Description> */
- /* Inverts a 2x2 matrix. Returns an error if it can't be inverted. */
- /* */
- /* <InOut> */
- /* matrix :: A pointer to the target matrix. Remains untouched in */
- /* case of error. */
- /* */
- /* <Return> */
- /* FreeType error code. 0 means success. */
- /* */
- /* <MT-Note> */
- /* Yes. */
- /* */
- EXPORT_DEF
- FT_Error FT_Matrix_Invert( FT_Matrix* matrix );
-
#endif /* FTOUTLN_H */
diff --git a/src/base/ftraster.c b/src/base/ftraster.c
index 8b10678..601a5f4 100644
--- a/src/base/ftraster.c
+++ b/src/base/ftraster.c
@@ -92,7 +92,7 @@
/* Define this configuration macro if you want to support */
/* anti-aliasing. */
/* */
-#define FT_RASTER_OPTION_ANTI_ALIAS
+#undef FT_RASTER_OPTION_ANTI_ALIAS
/*************************************************************************/
@@ -643,6 +643,7 @@
TDirection state; /* rendering state */
FT_Bitmap target; /* description of target bit/pixmap */
+ void* memory;
int trace_bit; /* current offset in target bitmap */
int trace_pix; /* current offset in target pixmap */
@@ -2204,260 +2205,6 @@
#endif /* FT_RASTER_CUBIC_BEZIERS */
-/********************************************************************/
-/* */
-/* The following function is compiled in the raster only when it is */
-/* compile as a stand-alone module.. */
-
-/* It can, otherwise, be found in the FreeType base layer */
-
-#ifdef _STANDALONE_
- /*************************************************************************/
- /* */
- /* <Function> */
- /* FT_Outline_Decompose */
- /* */
- /* <Description> */
- /* Walks over an outline's structure to decompose it into individual */
- /* segments and Bezier arcs. This function is also able to emit */
- /* `move to' and `close to' operations to indicate the start and end */
- /* of new contours in the outline. */
- /* */
- /* <Input> */
- /* outline :: A pointer to the source target. */
- /* */
- /* interface :: A table of `emitters', i.e,. function pointers called */
- /* during decomposition to indicate path operations. */
- /* */
- /* user :: A typeless pointer which is passed to each emitter */
- /* during the decomposition. It can be used to store */
- /* the state during the decomposition. */
- /* */
- /* <Return> */
- /* Error code. 0 means sucess. */
- /* */
- static
- int FT_Outline_Decompose( FT_Outline* outline,
- FT_Outline_Funcs* interface,
- void* user )
- {
- typedef enum _phases
- {
- phase_point,
- phase_conic,
- phase_cubic,
- phase_cubic2
-
- } TPhase;
-
- FT_Vector v_first;
- FT_Vector v_last;
- FT_Vector v_control;
- FT_Vector v_control2;
- FT_Vector v_start;
-
- FT_Vector* point;
- char* flags;
-
- int n; /* index of contour in outline */
- int first; /* index of first point in contour */
- int index; /* current point's index */
-
- int error;
-
- char tag; /* current point's state */
- TPhase phase;
-
-
- first = 0;
-
- for ( n = 0; n < outline->n_contours; n++ )
- {
- int last; /* index of last point in contour */
-
-
- last = outline->contours[n];
-
- v_first = outline->points[first];
- v_last = outline->points[last];
-
- v_start = v_control = v_first;
-
- tag = FT_CURVE_TAG( outline->flags[first] );
- index = first;
-
- /* A contour cannot start with a cubic control point! */
-
- if ( tag == FT_Curve_Tag_Cubic )
- return ErrRaster_Invalid_Outline;
-
-
- /* check first point to determine origin */
-
- if ( tag == FT_Curve_Tag_Conic )
- {
- /* first point is conic control. Yes, this happens. */
- if ( FT_CURVE_TAG( outline->flags[last] ) == FT_Curve_Tag_On )
- {
- /* start at last point if it is on the curve */
- v_start = v_last;
- }
- else
- {
- /* if both first and last points are conic, */
- /* start at their middle and record its position */
- /* for closure */
- v_start.x = ( v_start.x + v_last.x ) / 2;
- v_start.y = ( v_start.y + v_last.y ) / 2;
-
- v_last = v_start;
- }
- phase = phase_conic;
- }
- else
- phase = phase_point;
-
-
- /* Begin a new contour with MOVE_TO */
-
- error = interface->move_to( &v_start, user );
- if ( error )
- return error;
-
- point = outline->points + first;
- flags = outline->flags + first;
-
- /* now process each contour point individually */
-
- while ( index < last )
- {
- index++;
- point++;
- flags++;
-
- tag = FT_CURVE_TAG( flags[0] );
-
- switch ( phase )
- {
- case phase_point: /* the previous point was on the curve */
-
- switch ( tag )
- {
- /* two succesive on points -> emit segment */
- case FT_Curve_Tag_On:
- error = interface->line_to( point, user );
- break;
-
- /* on point + conic control -> remember control point */
- case FT_Curve_Tag_Conic:
- v_control = point[0];
- phase = phase_conic;
- break;
-
- /* on point + cubic control -> remember first control */
- default:
- v_control = point[0];
- phase = phase_cubic;
- break;
- }
- break;
-
- case phase_conic: /* the previous point was a conic control */
-
- switch ( tag )
- {
- /* conic control + on point -> emit conic arc */
- case FT_Curve_Tag_On:
- error = interface->conic_to( &v_control, point, user );
- phase = phase_point;
- break;
-
- /* two successive conics -> emit conic arc `in between' */
- case FT_Curve_Tag_Conic:
- {
- FT_Vector v_middle;
-
-
- v_middle.x = (v_control.x + point->x)/2;
- v_middle.y = (v_control.y + point->y)/2;
-
- error = interface->conic_to( &v_control,
- &v_middle, user );
- v_control = point[0];
- }
- break;
-
- default:
- error = ErrRaster_Invalid_Outline;
- }
- break;
-
- case phase_cubic: /* the previous point was a cubic control */
-
- /* this point _must_ be a cubic control too */
- if ( tag != FT_Curve_Tag_Cubic )
- return ErrRaster_Invalid_Outline;
-
- v_control2 = point[0];
- phase = phase_cubic2;
- break;
-
-
- case phase_cubic2: /* the two previous points were cubics */
-
- /* this point _must_ be an on point */
- if ( tag != FT_Curve_Tag_On )
- error = ErrRaster_Invalid_Outline;
- else
- error = interface->cubic_to( &v_control, &v_control2,
- point, user );
- phase = phase_point;
- break;
- }
-
- /* lazy error testing */
- if ( error )
- return error;
- }
-
- /* end of contour, close curve cleanly */
- error = 0;
-
- tag = FT_CURVE_TAG( outline->flags[first] );
-
- switch ( phase )
- {
- case phase_point:
- if ( tag == FT_Curve_Tag_On )
- error = interface->line_to( &v_first, user );
- break;
-
- case phase_conic:
- error = interface->conic_to( &v_control, &v_start, user );
- break;
-
- case phase_cubic2:
- if ( tag == FT_Curve_Tag_On )
- error = interface->cubic_to( &v_control, &v_control2,
- &v_first, user );
- else
- error = ErrRaster_Invalid_Outline;
- break;
-
- default:
- error = ErrRaster_Invalid_Outline;
- break;
- }
-
- if ( error )
- return error;
-
- first = last + 1;
- }
-
- return SUCCESS;
- }
-#endif
/*************************************************************************/
/* */
@@ -3109,14 +2856,6 @@
x1 += PRECISION_HALF;
x2 += PRECISION_HALF;
-#ifdef FT_RASTER_OPTION_CONTRAST
- if ( x2-x1 < PRECISION )
- {
- x1 = ((x1+x2) >> 1) - PRECISION_HALF;
- x2 = x1 + PRECISION;
- }
-#endif
-
e1 = TRUNC( x1 );
e2 = TRUNC( x2 );
@@ -3324,14 +3063,6 @@
x1 += PRECISION_HALF;
x2 += PRECISION_HALF;
-#ifdef FT_RASTER_OPTION_CONTRAST
- if (x2-x1 < PRECISION)
- {
- x1 = ((x1+x2) >> 1) - PRECISION_HALF;
- x2 = x1 + PRECISION;
- }
-#endif
-
e1 = TRUNC( x1 );
e2 = TRUNC( x2 );
@@ -4081,38 +3812,87 @@ Scan_DropOuts :
#endif /* FT_RASTER_OPTION_ANTI_ALIAS */
- /*************************************************************************/
- /* */
- /* <Function> */
- /* FT_Raster_Render */
- /* */
- /* <Description> */
- /* Renders an outline into a target bitmap. */
- /* */
- /* <Input> */
- /* raster :: A handle to the raster object used during rendering. */
- /* outline :: A pointer to the source outline record/object. */
- /* bitmap :: A pointer to the target bitmap descriptor. */
- /* */
- /* <Return> */
- /* Error code, interpreted as a FT_Error by FreeType. 0 means */
- /* success. */
- /* */
- EXPORT_FUNC
- int FT_Raster_Render( FT_Raster raster,
- FT_Outline* outline,
- FT_Bitmap* target_map )
+
+ /**** RASTER OBJECT CREATION : in standalone mode, we simply use *****/
+ /**** a static object .. *****/
+#ifdef _STANDALONE_
+
+ static
+ int ft_raster_new( void* memory, FT_Raster *araster )
+ {
+ static FT_RasterRec_ the_raster;
+ *araster = &the_raster;
+ memset( &the_raster, sizeof(the_raster), 0 );
+ return 0;
+ }
+
+ static
+ void ft_raster_done( FT_Raster raster )
+ {
+ /* nothing */
+ raster->init = 0;
+ }
+
+#else
+
+#include "ftobjs.h"
+
+ static
+ int ft_raster_new( FT_Memory memory, FT_Raster* araster )
+ {
+ FT_Error error;
+ FT_Raster raster;
+
+ *araster = 0;
+ if ( !ALLOC( raster, sizeof(*raster) ))
+ {
+ raster->memory = memory;
+ *araster = raster;
+ }
+
+ return error;
+ }
+
+ static
+ void ft_raster_done( FT_Raster raster )
+ {
+ FT_Memory memory = (FT_Memory)raster->memory;
+ FREE( raster );
+ }
+
+#endif
+
+
+ static void ft_raster_reset( FT_Raster raster,
+ const char* pool_base,
+ long pool_size )
+ {
+ if ( raster && pool_base && pool_size >= 4096 )
+ {
+ /* save the pool */
+ raster->pool = (PPos)pool_base;
+ raster->pool_size = raster->pool + pool_size / sizeof ( TPos );
+ }
+ }
+
+
+ static
+ int ft_raster_render( FT_Raster raster,
+ FT_Raster_Params* params )
{
+ FT_Outline* outline = (FT_Outline*)params->source;
+ FT_Bitmap* target_map = params->target;
+
if ( !raster || !raster->pool || !raster->pool_size )
return ErrRaster_Uninitialized_Object;
+ if ( !outline || !outline->contours || !outline->points )
+ return ErrRaster_Invalid_Outline;
+
/* return immediately if the outline is empty */
if ( outline->n_points == 0 || outline->n_contours <= 0 )
return ErrRaster_Ok;
- if ( !outline || !outline->contours || !outline->points )
- return ErrRaster_Invalid_Outline;
-
if ( outline->n_points != outline->contours[outline->n_contours - 1] + 1 )
return ErrRaster_Invalid_Outline;
@@ -4125,107 +3905,29 @@ Scan_DropOuts :
/* Note that we always use drop-out mode 2, because it seems that */
/* it's the only way to do to get results consistent with Windows */
/* rendering.. */
-#if 0
- ras.dropout_mode = outline->dropout_mode;
-#else
ras.dropout_mode = 2;
-#endif
+
ras.second_pass = (outline->flags & ft_outline_single_pass) == 0;
SET_High_Precision( (char)((outline->flags & ft_outline_high_precision)!= 0) );
- switch ( target_map->pixel_mode )
- {
- case ft_pixel_mode_mono: return Raster_Render1( raster );
- case ft_pixel_mode_grays: return Raster_Render8( raster );
- default: return ErrRaster_Unimplemented;
- }
- }
-
-
-
+ /* this version of the raster does not support direct rendering, sorry */
+ if ( params->flags & ft_raster_flag_direct )
+ return ErrRaster_Unimplemented;
- /*************************************************************************/
- /* */
- /* <Function> */
- /* FT_Raster_ObjSize */
- /* */
- /* <Description> */
- /* This function returns the size of a raster object in bytes. */
- /* Client applications are thus able to allocate objects in their own */
- /* heap/memory space, without revealing the internal structures of */
- /* the scan-line converter. */
- /* */
- /* <Return> */
- /* The size in bytes of a single raster object. */
- /* */
- EXPORT_FUNC
- long FT_Raster_ObjSize( void )
- {
- return (long)sizeof( struct FT_RasterRec_ );
+ return ( params->flags & ft_raster_flag_aa
+ ? Raster_Render8( raster )
+ : Raster_Render1( raster ) );
}
- /*************************************************************************/
- /* */
- /* <Function> */
- /* FT_Raster_Init */
- /* */
- /* <Description> */
- /* Initializes a fresh raster object which should have been allocated */
- /* by client applications. This function is also used to set the */
- /* object's render pool. It can be used repeatedly on a single */
- /* object if one wants to change the pool's address or size. */
- /* */
- /* Note that the render pool has no state and is only used during a */
- /* call to FT_Raster_Render(). It is thus theorically possible to */
- /* share it between several non-concurrent components of your */
- /* applications when memory is a scarce resource. */
- /* */
- /* <Input> */
- /* pool_size :: The render pool's size in bytes. This must be at */
- /* least 4 kByte. */
- /* */
- /* <InOut> */
- /* raster :: A handle to the target raster object. */
- /* */
- /* pool_base :: The render pool's base address in memory. */
- /* */
- /* <Return> */
- /* An error condition, used as a FT_Error in the FreeType library. */
- /* 0 means success. */
- /* */
- EXPORT_FUNC
- int FT_Raster_Init( FT_Raster raster,
- const char* pool_base,
- long pool_size )
+ FT_Raster_Funcs ft_default_raster =
{
-/* static const char default_palette[5] = { 0, 1, 2, 3, 4 }; */
-
- /* check the object address */
- if ( !raster )
- return ErrRaster_Uninitialized_Object;
-
- /* check the render pool - we won't go under 4 Kb */
- if ( !pool_base || pool_size < 4096 )
- return ErrRaster_Invalid_Pool;
-
- /* save the pool */
- raster->pool = (PPos)pool_base;
- raster->pool_size = raster->pool + pool_size / sizeof ( TPos );
-
- return ErrRaster_Ok;
- }
-
-
-
- FT_Raster_Interface ft_default_raster =
- {
- sizeof( struct FT_RasterRec_ ),
ft_glyph_format_outline,
-
- (FT_Raster_Init_Proc) FT_Raster_Init,
- (FT_Raster_Set_Mode_Proc) 0,
- (FT_Raster_Render_Proc) FT_Raster_Render
+ (FT_Raster_New_Func) ft_raster_new,
+ (FT_Raster_Reset_Func) ft_raster_reset,
+ (FT_Raster_Set_Mode_Func) 0,
+ (FT_Raster_Render_Func) ft_raster_render,
+ (FT_Raster_Done_Func) ft_raster_done
};
diff --git a/src/base/rules.mk b/src/base/rules.mk
index 0ad0479..30eb1ec 100644
--- a/src/base/rules.mk
+++ b/src/base/rules.mk
@@ -33,7 +33,9 @@ BASE_SRC := $(BASE_)ftcalc.c \
$(BASE_)ftextend.c \
$(BASE_)ftlist.c \
$(BASE_)ftobjs.c \
- $(BASE_)ftstream.c
+ $(BASE_)ftstream.c \
+ $(BASE_)ftoutln.c
+
# Base layer headers
#
@@ -53,7 +55,7 @@ BASE_H := $(BASE_)ftcalc.h \
# symbols is used by the application.
#
BASE_EXT_SRC := $(BASE_)ftraster.c \
- $(BASE_)ftoutln.c
+ $(BASE_)ftglyph.c
# Base layer extensions headers
#