formatting small fixes
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
diff --git a/include/freetype/cache/ftcglyph.h b/include/freetype/cache/ftcglyph.h
index 0bda99d..0a18823 100644
--- a/include/freetype/cache/ftcglyph.h
+++ b/include/freetype/cache/ftcglyph.h
@@ -2,7 +2,7 @@
/* */
/* ftcglyph.h */
/* */
-/* FreeType glyph image (FT_Glyph) cache.. */
+/* FreeType glyph image (FT_Glyph) cache (specification). */
/* */
/* Copyright 2000 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
@@ -13,53 +13,59 @@
/* this file you indicate that you have read the license and */
/* understand and accept it fully. */
/* */
-/* */
-/* Important: the functions defined in this file are only used */
-/* to implement an abstract glyph cache class. You */
-/* need to provide additional logic to implement */
-/* a complete cache. For example, see "ftcimage.h" */
-/* and "ftcimage.c" which implement a FT_Glyph cache */
-/* based on this code.. */
-/* */
/***************************************************************************/
- /**************************************************************************/
- /**************************************************************************/
- /**************************************************************************/
- /**************************************************************************/
- /**************************************************************************/
- /********* **********/
- /********* **********/
- /********* WARNING, THIS IS ALPHA CODE, THIS API **********/
- /********* IS DUE TO CHANGE UNTIL STRICTLY NOTIFIED BY THE **********/
- /********* FREETYPE DEVELOPMENT TEAM **********/
- /********* **********/
- /**************************************************************************/
- /**************************************************************************/
- /**************************************************************************/
- /**************************************************************************/
- /**************************************************************************/
+
+ /*************************************************************************/
+ /* */
+ /* Important: The functions defined in this file are only used to */
+ /* implement an abstract glyph cache class. You need to */
+ /* provide additional logic to implement a complete cache. */
+ /* For example, see `ftcimage.h' and `ftcimage.c' which */
+ /* implement a FT_Glyph cache based on this code. */
+ /* */
+ /*************************************************************************/
+
+
+ /*************************************************************************/
+ /*************************************************************************/
+ /*************************************************************************/
+ /*************************************************************************/
+ /*************************************************************************/
+ /********* *********/
+ /********* WARNING, THIS IS ALPHA CODE, THIS API *********/
+ /********* IS DUE TO CHANGE UNTIL STRICTLY NOTIFIED BY THE *********/
+ /********* FREETYPE DEVELOPMENT TEAM *********/
+ /********* *********/
+ /*************************************************************************/
+ /*************************************************************************/
+ /*************************************************************************/
+ /*************************************************************************/
+ /*************************************************************************/
#ifndef FTCGLYPH_H
#define FTCGLYPH_H
+
#include <freetype/cache/ftcmanag.h>
#include <freetype/ftglyph.h>
#include <stddef.h>
+
#ifdef __cplusplus
extern "C" {
#endif
-/* maximum number of queues per image cache, must be < 256 */
+
+ /* maximum number of queues per image cache; must be < 256 */
#define FTC_MAX_GLYPH_QUEUES 16
#define FTC_QUEUE_HASH_SIZE_DEFAULT 64
- typedef struct FTC_Glyph_QueueRec_* FTC_Glyph_Queue;
- typedef struct FTC_GlyphNodeRec_* FTC_GlyphNode;
- typedef struct FTC_Glyph_CacheRec_* FTC_Glyph_Cache;
+ typedef struct FTC_Glyph_QueueRec_* FTC_Glyph_Queue;
+ typedef struct FTC_GlyphNodeRec_* FTC_GlyphNode;
+ typedef struct FTC_Glyph_CacheRec_* FTC_Glyph_Cache;
typedef struct FTC_GlyphNodeRec_
{
@@ -74,8 +80,13 @@
} FTC_GlyphNodeRec;
-#define FTC_GLYPHNODE_GET_GLYPH(n) ((FT_Glyph)((n)->link.data))
-#define FTC_GLYPHNODE_SET_GLYPH(n,g) do { (n)->link.data = (g); } while (0)
+#define FTC_GLYPHNODE_GET_GLYPH( n ) \
+ ( (FT_Glyph)((n)->link.data) )
+#define FTC_GLYPHNODE_SET_GLYPH( n, g ) \
+ do \
+ { \
+ (n)->link.data = (g); \
+ } while ( 0 )
/* this macro is used to extract a handle to the bucket's lru list */
/* corresponding to a given image node */
@@ -83,37 +94,40 @@
( (FT_ListNode)&(n)->link )
/* this macro is used to extract a handle to a given image node from */
- /* the corresponding LRU glyph list node. That's a bit hackish.. */
-#define FTC_LISTNODE_TO_GLYPHNODE( p ) \
- ( (FTC_GlyphNode)( (char*)(p) - \
+ /* the corresponding LRU glyph list node. That's a bit hackish... */
+#define FTC_LISTNODE_TO_GLYPHNODE( p ) \
+ ( (FTC_GlyphNode)( (char*)(p) - \
offsetof( FTC_GlyphNodeRec,link ) ) )
-#define FTC_GLYPHNODE_TO_LRUNODE(n) ((FT_ListNode)(n))
-#define FTC_LRUNODE_TO_GLYPHNODE(n) ((FTC_GlyphNode)(n))
+#define FTC_GLYPHNODE_TO_LRUNODE( n ) ( (FT_ListNode)(n) )
+#define FTC_LRUNODE_TO_GLYPHNODE( n ) ( (FTC_GlyphNode)(n) )
- /* glyph queue methods *****************************************************/
+ /*************************************************************************/
+ /* */
+ /* Glyph queue methods. */
+ /* */
- typedef FT_Error (*FTC_Glyph_Queue_InitFunc) ( FTC_Glyph_Queue queue,
- FT_Pointer type );
+ typedef FT_Error (*FTC_Glyph_Queue_InitFunc)( FTC_Glyph_Queue queue,
+ FT_Pointer type );
- typedef void (*FTC_Glyph_Queue_DoneFunc) ( FTC_Glyph_Queue queue );
+ typedef void (*FTC_Glyph_Queue_DoneFunc)( FTC_Glyph_Queue queue );
- typedef FT_Bool (*FTC_Glyph_Queue_CompareFunc)( FTC_Glyph_Queue queue,
- FT_Pointer type );
+ typedef FT_Bool (*FTC_Glyph_Queue_CompareFunc)( FTC_Glyph_Queue queue,
+ FT_Pointer type );
typedef FT_Error (*FTC_Glyph_Queue_NewNodeFunc)( FTC_Glyph_Queue queue,
FT_UInt gindex,
- FTC_GlyphNode *anode );
+ FTC_GlyphNode* anode );
typedef void (*FTC_Glyph_Queue_DestroyNodeFunc)( FTC_GlyphNode node,
FTC_Glyph_Queue queue );
-
typedef FT_ULong (*FTC_Glyph_Queue_SizeNodeFunc)( FTC_GlyphNode node,
FTC_Glyph_Queue queue );
- typedef struct FTC_Glyph_Queue_Class_
+
+ typedef struct FTC_Glyph_Queue_Class_
{
FT_UInt queue_byte_size;
@@ -142,8 +156,8 @@
} FTC_Glyph_QueueRec;
- /* the abstract glyph cache class */
- typedef struct FTC_Glyph_Cache_Class_
+ /* the abstract glyph cache class */
+ typedef struct FTC_Glyph_Cache_Class_
{
FTC_Cache_Class root;
FTC_Glyph_Queue_Class* queue_class;
@@ -151,54 +165,52 @@
} FTC_Glyph_Cache_Class;
- /* the abstract glyph cache object */
+ /* the abstract glyph cache object */
typedef struct FTC_Glyph_CacheRec_
{
- FTC_CacheRec root;
- FT_Lru queues_lru; /* static queues lru list */
- FTC_Glyph_Queue last_queue; /* small cache */
+ FTC_CacheRec root;
+ FT_Lru queues_lru; /* static queues lru list */
+ FTC_Glyph_Queue last_queue; /* small cache */
} FTC_Glyph_CacheRec;
- /* these function are exported so that they can be called from */
- /* user-provided cache classes.. otherwise, they're really */
- /* part of the cache sub-system internals.. */
- /* */
-
- FT_EXPORT_FUNC(void) FTC_GlyphNode_Init( FTC_GlyphNode node,
- FTC_Glyph_Queue queue,
- FT_UInt gindex );
+ /*************************************************************************/
+ /* */
+ /* These functions are exported so that they can be called from */
+ /* user-provided cache classes; otherwise, they are really parts of the */
+ /* cache sub-system internals. */
+ /* */
-#define FTC_GlyphNode_Ref(n) \
- FTC_CACHENODE_TO_DATA_P(&(n)->root)->ref_count++
+ FT_EXPORT_FUNC( void ) FTC_GlyphNode_Init( FTC_GlyphNode node,
+ FTC_Glyph_Queue queue,
+ FT_UInt gindex );
-#define FTC_GlyphNode_Unref(n) \
- FTC_CACHENODE_TO_DATA_P(&(n)->root)->ref_count--
+#define FTC_GlyphNode_Ref( n ) \
+ FTC_CACHENODE_TO_DATA_P( &(n)->root )->ref_count++
+#define FTC_GlyphNode_Unref( n ) \
+ FTC_CACHENODE_TO_DATA_P( &(n)->root )->ref_count--
- FT_EXPORT_DEF(void) FTC_Destroy_Glyph_Node( FTC_GlyphNode node,
- FTC_Glyph_Cache cache );
+ FT_EXPORT_DEF( void ) FTC_Destroy_Glyph_Node( FTC_GlyphNode node,
+ FTC_Glyph_Cache cache );
- FT_EXPORT_DEF(FT_Error) FTC_Glyph_Cache_Init( FTC_Glyph_Cache cache );
- FT_EXPORT_DEF(void) FTC_Glyph_Cache_Done( FTC_Glyph_Cache cache );
+ FT_EXPORT_DEF( FT_Error ) FTC_Glyph_Cache_Init( FTC_Glyph_Cache cache );
- FT_EXPORT_DEF(FT_Error) FTC_Glyph_Queue_New(
- FTC_Glyph_Cache cache,
- FT_Pointer type,
- FTC_Glyph_Queue *aqueue );
+ FT_EXPORT_DEF( void ) FTC_Glyph_Cache_Done( FTC_Glyph_Cache cache );
- FT_EXPORT_DEF(FT_Error) FTC_Glyph_Queue_Lookup_Node(
- FTC_Glyph_Queue queue,
- FT_UInt glyph_index,
- FTC_GlyphNode* anode );
+ FT_EXPORT_DEF( FT_Error ) FTC_Glyph_Queue_New( FTC_Glyph_Cache cache,
+ FT_Pointer type,
+ FTC_Glyph_Queue* aqueue );
- FT_EXPORT_DEF(FT_Error) FTC_Glyph_Cache_Init( FTC_Glyph_Cache cache );
+ FT_EXPORT_DEF( FT_Error ) FTC_Glyph_Queue_Lookup_Node(
+ FTC_Glyph_Queue queue,
+ FT_UInt glyph_index,
+ FTC_GlyphNode* anode );
- FT_EXPORT_DEF(void) FTC_Glyph_Cache_Done( FTC_Glyph_Cache cache );
#ifdef __cplusplus
}
diff --git a/include/freetype/cache/ftcmanag.h b/include/freetype/cache/ftcmanag.h
index 10678d5..0956a4d 100644
--- a/include/freetype/cache/ftcmanag.h
+++ b/include/freetype/cache/ftcmanag.h
@@ -13,48 +13,52 @@
/* this file you indicate that you have read the license and */
/* understand and accept it fully. */
/* */
-/* */
-/* A cache manager is in charge of the following: */
-/* */
-/* - maintain a mapping between generic FTC_FaceIDs and live */
-/* FT_Face objects. The mapping itself is performed through a */
-/* user-provided callback. However, the manager maintains a small */
-/* cache of FT_Face & FT_Size objects in order to speed things */
-/* considerably.. */
-/* */
-/* - manage one or more cache object. Each cache is in charge of */
-/* holding a varying number of "cache nodes". Each cache node */
-/* represents a minimal amount of individually-accessible cached */
-/* data. For example, a cache node can be a FT_Glyph image containing */
-/* a vector outline, or some glyph metrics, or anything else.. */
-/* */
-/* each cache node has a certain size in bytes that is added to the */
-/* total amount of "cache memory" within the manager. */
-/* */
-/* all cache nodes are located in a global LRU list, where the */
-/* oldest node is at the tail of the list */
-/* */
-/* each node belongs to a single cache, and includes a reference */
-/* count to avoid destroying it (due to caching) */
-/* */
/***************************************************************************/
- /**************************************************************************/
- /**************************************************************************/
- /**************************************************************************/
- /**************************************************************************/
- /**************************************************************************/
- /********* **********/
- /********* **********/
- /********* WARNING, THIS IS ALPHA CODE, THIS API **********/
- /********* IS DUE TO CHANGE UNTIL STRICTLY NOTIFIED BY THE **********/
- /********* FREETYPE DEVELOPMENT TEAM **********/
- /********* **********/
- /**************************************************************************/
- /**************************************************************************/
- /**************************************************************************/
- /**************************************************************************/
- /**************************************************************************/
+
+ /*************************************************************************/
+ /* */
+ /* A cache manager is in charge of the following: */
+ /* */
+ /* - Maintain a mapping between generic FTC_FaceIDs and live FT_Face */
+ /* objects. The mapping itself is performed through a user-provided */
+ /* callback. However, the manager maintains a small cache of FT_Face */
+ /* & FT_Size objects in order to speed things considerably. */
+ /* */
+ /* - Manage one or more cache objects. Each cache is in charge of */
+ /* holding a varying number of `cache nodes'. Each cache node */
+ /* represents a minimal amount of individually-accessible cached */
+ /* data. For example, a cache node can be an FT_Glyph image */
+ /* containing a vector outline, or some glyph metrics, or anything */
+ /* else. */
+ /* */
+ /* Each cache node has a certain size in bytes that is added to the */
+ /* total amount of `cache memory' within the manager. */
+ /* */
+ /* All cache nodes are located in a global LRU list, where the oldest */
+ /* node is at the tail of the list. */
+ /* */
+ /* Each node belongs to a single cache, and includes a reference */
+ /* count to avoid destroying it (due to caching). */
+ /* */
+ /*************************************************************************/
+
+
+ /*************************************************************************/
+ /*************************************************************************/
+ /*************************************************************************/
+ /*************************************************************************/
+ /*************************************************************************/
+ /********* *********/
+ /********* WARNING, THIS IS ALPHA CODE, THIS API *********/
+ /********* IS DUE TO CHANGE UNTIL STRICTLY NOTIFIED BY THE *********/
+ /********* FREETYPE DEVELOPMENT TEAM *********/
+ /********* *********/
+ /*************************************************************************/
+ /*************************************************************************/
+ /*************************************************************************/
+ /*************************************************************************/
+ /*************************************************************************/
#ifndef FTCMANAG_H
@@ -68,13 +72,14 @@
extern "C" {
#endif
-/* default values */
-#define FTC_MAX_FACES_DEFAULT 4
-#define FTC_MAX_SIZES_DEFAULT 8
-#define FTC_MAX_BYTES_DEFAULT 300000 /* 300 Kb by default !! */
-/* maximum number of caches registered in a single manager */
-#define FTC_MAX_CACHES 16
+ /* default values */
+#define FTC_MAX_FACES_DEFAULT 4
+#define FTC_MAX_SIZES_DEFAULT 8
+#define FTC_MAX_BYTES_DEFAULT 300000 /* 300kByte by default! */
+
+ /* maximum number of caches registered in a single manager */
+#define FTC_MAX_CACHES 16
typedef struct FTC_ManagerRec_
@@ -86,114 +91,112 @@
FT_ULong max_bytes;
FT_ULong num_bytes;
FT_ListRec global_lru;
- FTC_Cache caches[ FTC_MAX_CACHES ];
-
+ FTC_Cache caches[FTC_MAX_CACHES];
+
FT_Pointer request_data;
FTC_Face_Requester request_face;
-
+
} FTC_ManagerRec;
- /*********************************************************************/
- /*********************************************************************/
- /***** *****/
- /***** CACHE NODE DEFINITIONS *****/
- /***** *****/
- /*********************************************************************/
- /*********************************************************************/
-
-
-
- /* each cache controls one or more cache nodes. Each node */
- /* is part of the global_lru list of the manager. Its "data" */
- /* field however is used as a reference count for now.. */
- /* */
- /* a node can anything, depending on the type of information */
- /* held by the cache. It can be an individual glyph image, */
- /* a set of bitmaps glyphs for a given size, some metrics, */
- /* etc.. */
- /* */
-
+ /*************************************************************************/
+ /*************************************************************************/
+ /***** *****/
+ /***** CACHE NODE DEFINITIONS *****/
+ /***** *****/
+ /*************************************************************************/
+ /*************************************************************************/
+
+
+ /*************************************************************************/
+ /* */
+ /* Each cache controls one or more cache nodes. Each node is part of */
+ /* the global_lru list of the manager. Its `data' field however is used */
+ /* as a reference count for now. */
+ /* */
+ /* A node can be anything, depending on the type of information hold by */
+ /* the cache. It can be an individual glyph image, a set of bitmaps */
+ /* glyphs for a given size, some metrics, etc. */
+ /* */
+
typedef FT_ListNodeRec FTC_CacheNodeRec;
typedef FTC_CacheNodeRec* FTC_CacheNode;
- /* the fields "cachenode.data" is typecasted to this type */
- typedef struct FTC_CacheNode_Data_
+ /* the fields `cachenode.data' is typecast to this type */
+ typedef struct FTC_CacheNode_Data_
{
- FT_UShort cache_index;
- FT_Short ref_count;
-
+ FT_UShort cache_index;
+ FT_Short ref_count;
+
} FTC_CacheNode_Data;
-
-/* returns a pointer to the FTC_CacheNode_Data contained in a */
-/* CacheNode's "data" field.. */
-#define FTC_CACHENODE_TO_DATA_P(n) \
- ((FTC_CacheNode_Data*)&(n)->data)
-
-#define FTC_LIST_TO_CACHENODE(n) ((FTC_CacheNode)(n))
-
- /* returns the size in bytes of a given cache node */
- typedef FT_ULong (*FTC_CacheNode_SizeFunc)( FTC_CacheNode node,
- FT_Pointer user );
-
- /* finalise a given cache node */
- typedef void (*FTC_CacheNode_DestroyFunc)( FTC_CacheNode node,
- FT_Pointer user );
-
- /* this structure is used to provide functions to the cache manager */
- /* It will use them to size and destroy cache nodes.. Note that there */
- /* is no "init_node" there because cache objects are entirely */
- /* responsible for the creation of new cache nodes */
+
+ /* return a pointer to the FTC_CacheNode_Data contained in a */
+ /* CacheNode's `data' field */
+#define FTC_CACHENODE_TO_DATA_P( n ) \
+ ( (FTC_CacheNode_Data*)&(n)->data )
+
+#define FTC_LIST_TO_CACHENODE( n ) ( (FTC_CacheNode)(n) )
+
+ /* return the size in bytes of a given cache node */
+ typedef FT_ULong (*FTC_CacheNode_SizeFunc)( FTC_CacheNode node,
+ FT_Pointer user );
+
+ /* finalize a given cache node */
+ typedef void (*FTC_CacheNode_DestroyFunc)( FTC_CacheNode node,
+ FT_Pointer user );
+
+ /* This structure is used to provide functions to the cache manager. */
+ /* It will use them to size and destroy cache nodes. Note that there */
+ /* is no `init_node' because cache objects are entirely responsible */
+ /* for the creation of new cache nodes. */
/* */
- typedef struct FTC_CacheNode_Class_
+ typedef struct FTC_CacheNode_Class_
{
- FTC_CacheNode_SizeFunc size_node;
- FTC_CacheNode_DestroyFunc destroy_node;
-
+ FTC_CacheNode_SizeFunc size_node;
+ FTC_CacheNode_DestroyFunc destroy_node;
+
} FTC_CacheNode_Class;
-
-
- /*********************************************************************/
- /*********************************************************************/
- /***** *****/
- /***** CACHE DEFINITIONS *****/
- /***** *****/
- /*********************************************************************/
- /*********************************************************************/
-
-
- typedef FT_Error (*FTC_Cache_InitFunc)( FTC_Cache cache );
-
- typedef void (*FTC_Cache_DoneFunc)( FTC_Cache cache );
-
-
- struct FTC_Cache_Class_
- {
- FT_UInt cache_byte_size;
- FTC_Cache_InitFunc init_cache;
- FTC_Cache_DoneFunc done_cache;
- };
+ /*************************************************************************/
+ /*************************************************************************/
+ /***** *****/
+ /***** CACHE DEFINITIONS *****/
+ /***** *****/
+ /*************************************************************************/
+ /*************************************************************************/
+
+
+ typedef FT_Error (*FTC_Cache_InitFunc)( FTC_Cache cache );
+
+ typedef void (*FTC_Cache_DoneFunc)( FTC_Cache cache );
+
+
+ struct FTC_Cache_Class_
+ {
+ FT_UInt cache_byte_size;
+ FTC_Cache_InitFunc init_cache;
+ FTC_Cache_DoneFunc done_cache;
+ };
typedef struct FTC_CacheRec_
{
- FTC_Manager manager;
- FT_Memory memory;
- FTC_Cache_Class* clazz;
- FTC_CacheNode_Class* node_clazz;
-
- FT_UInt cache_index; /* in manager's table */
- FT_Pointer cache_user; /* passed to cache node methods*/
-
+ FTC_Manager manager;
+ FT_Memory memory;
+ FTC_Cache_Class* clazz;
+ FTC_CacheNode_Class* node_clazz;
+
+ FT_UInt cache_index; /* in manager's table */
+ FT_Pointer cache_user; /* passed to cache node methods */
+
} FTC_CacheRec;
- /* "compress" the manager's data, i.e. get rids of old cache nodes */
+ /* `Compress' the manager's data, i.e., get rid of old cache nodes */
/* that are not referenced anymore in order to limit the total */
- /* memory used by the cache.. */
- FT_EXPORT_DEF(void) FTC_Manager_Compress( FTC_Manager manager );
+ /* memory used by the cache. */
+ FT_EXPORT_DEF( void ) FTC_Manager_Compress( FTC_Manager manager );
#ifdef __cplusplus
diff --git a/include/freetype/cache/ftlru.h b/include/freetype/cache/ftlru.h
index 8e7df53..856caef 100644
--- a/include/freetype/cache/ftlru.h
+++ b/include/freetype/cache/ftlru.h
@@ -13,45 +13,48 @@
/* this file you indicate that you have read the license and */
/* understand and accept it fully. */
/* */
-/* */
-/* A LRU is a list that cannot hold more than a certain number of */
-/* elements ("max_elements"). All elements on the list are sorted */
-/* in lest-recently-used order, i.e. the "oldest" element is at */
-/* the tail of the list */
-/* */
-/* When doing a lookup (either through "Lookup" or "Lookup_Node"), */
-/* the list is searched for an element with the corresponding key */
-/* if it is found, the element is moved to the head of the list */
-/* and is returned.. */
-/* */
-/* If no corresponding element is found, the lookup routine will */
-/* try to obtain a new element with the relevant key. If the list */
-/* is already full, the oldest element from the list is discarded */
-/* and replaced by a new one; a new element is added to the list */
-/* otherwise.. */
-/* */
-/* Note that it is possible to pre-allocate the element list nodes. */
-/* That's handy when "max_elements" is sufficiently small, as it */
-/* saves allocations/releases during the lookup process */
-/* */
/***************************************************************************/
- /**************************************************************************/
- /**************************************************************************/
- /**************************************************************************/
- /**************************************************************************/
- /**************************************************************************/
- /********* **********/
- /********* **********/
- /********* WARNING, THIS IS ALPHA CODE, THIS API **********/
- /********* IS DUE TO CHANGE UNTIL STRICTLY NOTIFIED BY THE **********/
- /********* FREETYPE DEVELOPMENT TEAM **********/
- /********* **********/
- /**************************************************************************/
- /**************************************************************************/
- /**************************************************************************/
- /**************************************************************************/
- /**************************************************************************/
+
+ /*************************************************************************/
+ /* */
+ /* An LRU is a list that cannot hold more than a certain number of */
+ /* elements (`max_elements'). All elements on the list are sorted in */
+ /* lest-recently-used order, i.e., the `oldest' element is at the tail */
+ /* of the list. */
+ /* */
+ /* When doing a lookup (either through `Lookup()' or `Lookup_Node()'), */
+ /* the list is searched for an element with the corresponding key. If */
+ /* it is found, the element is moved to the head of the list and is */
+ /* returned. */
+ /* */
+ /* If no corresponding element is found, the lookup routine will try to */
+ /* obtain a new element with the relevant key. If the list is already */
+ /* full, the oldest element from the list is discarded and replaced by a */
+ /* new one; a new element is added to the list otherwise. */
+ /* */
+ /* Note that it is possible to pre-allocate the element list nodes. */
+ /* This is handy if `max_elements' is sufficiently small, as it saves */
+ /* allocations/releases during the lookup process. */
+ /* */
+ /*************************************************************************/
+
+
+ /*************************************************************************/
+ /*************************************************************************/
+ /*************************************************************************/
+ /*************************************************************************/
+ /*************************************************************************/
+ /********* *********/
+ /********* WARNING, THIS IS ALPHA CODE, THIS API *********/
+ /********* IS DUE TO CHANGE UNTIL STRICTLY NOTIFIED BY THE *********/
+ /********* FREETYPE DEVELOPMENT TEAM *********/
+ /********* *********/
+ /*************************************************************************/
+ /*************************************************************************/
+ /*************************************************************************/
+ /*************************************************************************/
+ /*************************************************************************/
#ifndef FTLRU_H
@@ -64,11 +67,12 @@
extern "C" {
#endif
- /* generic key type */
+
+ /* generic key type */
typedef FT_Pointer FT_LruKey;
- /* a lru node - node.root.data points to the element */
+ /* an lru node -- node.root.data points to the element */
typedef struct FT_LruNodeRec_
{
FT_ListNodeRec root;
@@ -76,43 +80,44 @@
} FT_LruNodeRec, *FT_LruNode;
- /* forward declaration */
+ /* forward declaration */
typedef struct FT_LruRec_* FT_Lru;
- /* LRU clazz */
+ /* LRU clazz */
typedef struct FT_Lru_Class_
{
- FT_UInt lru_size; /* object size in bytes */
+ FT_UInt lru_size; /* object size in bytes */
- /* this method is used to initialise a new list element node */
+ /* this method is used to initialize a new list element node */
FT_Error (*init_element)( FT_Lru lru,
FT_LruNode node );
- /* this method is used to finalise a given list element node */
- void (*done_element)( FT_Lru lru,
- FT_LruNode node );
+ /* this method is used to finalize a given list element node */
+ void (*done_element)( FT_Lru lru,
+ FT_LruNode node );
- /* when defined, this method is called when the list if full */
- /* during the lookup process.. it is used to change the content */
- /* of a list element node, instead of calling "done_element" */
- /* then "init_element". Put it to 0 for default behaviour */
+ /* If defined, this method is called when the list if full */
+ /* during the lookup process -- it is used to change the contents */
+ /* of a list element node, instead of calling `done_element()', */
+ /* then `init_element'. Set it to 0 for default behaviour. */
FT_Error (*flush_element)( FT_Lru lru,
FT_LruNode node,
FT_LruKey new_key );
- /* when defined, this method is used to compare a list element node */
- /* with a given key during a lookup. When set to 0, the "key" */
- /* fields will be directly compared instead.. */
- FT_Bool (*compare_element)( FT_LruNode node,
- FT_LruKey key );
+ /* If defined, this method is used to compare a list element node */
+ /* with a given key during a lookup. If set to 0, the `key' */
+ /* fields will be directly compared instead. */
+ FT_Bool (*compare_element)( FT_LruNode node,
+ FT_LruKey key );
} FT_Lru_Class;
- /* a selector is used to indicate wether a given list element node */
- /* is part of a selection for FT_Lru_Remove_Selection. The function */
- /* must returns true (i.e. non 0) to indicate that the node is part */
- /* of it.. */
+
+ /* A selector is used to indicate whether a given list element node */
+ /* is part of a selection for FT_Lru_Remove_Selection(). The function */
+ /* must return true (i.e., non-null) to indicate that the node is part */
+ /* of it. */
typedef FT_Bool (*FT_Lru_Selector)( FT_Lru lru,
FT_LruNode node,
FT_Pointer data );
@@ -120,16 +125,16 @@
typedef struct FT_LruRec_
{
- FT_Lru_Class* clazz;
- FT_UInt max_elements;
- FT_UInt num_elements;
- FT_ListRec elements;
- FT_Memory memory;
- FT_Pointer user_data;
+ FT_Lru_Class* clazz;
+ FT_UInt max_elements;
+ FT_UInt num_elements;
+ FT_ListRec elements;
+ FT_Memory memory;
+ FT_Pointer user_data;
/* the following fields are only meaningful for static lru containers */
- FT_ListRec free_nodes;
- FT_LruNode nodes;
+ FT_ListRec free_nodes;
+ FT_LruNode nodes;
} FT_LruRec;
@@ -141,9 +146,9 @@
FT_Bool pre_alloc,
FT_Lru* alru );
- FT_EXPORT_DEF( void ) FT_Lru_Reset( FT_Lru lru );
+ FT_EXPORT_DEF( void ) FT_Lru_Reset( FT_Lru lru );
- FT_EXPORT_DEF( void ) FT_Lru_Done( FT_Lru lru );
+ FT_EXPORT_DEF( void ) FT_Lru_Done( FT_Lru lru );
FT_EXPORT_DEF( FT_Error ) FT_Lru_Lookup_Node( FT_Lru lru,
FT_LruKey key,
@@ -153,12 +158,12 @@
FT_LruKey key,
FT_Pointer* aobject );
- FT_EXPORT_DEF( void ) FT_Lru_Remove_Node( FT_Lru lru,
- FT_LruNode node );
+ FT_EXPORT_DEF( void ) FT_Lru_Remove_Node( FT_Lru lru,
+ FT_LruNode node );
- FT_EXPORT_DEF( void ) FT_Lru_Remove_Selection( FT_Lru lru,
- FT_Lru_Selector selector,
- FT_Pointer data );
+ FT_EXPORT_DEF( void ) FT_Lru_Remove_Selection( FT_Lru lru,
+ FT_Lru_Selector selector,
+ FT_Pointer data );
#ifdef __cplusplus
diff --git a/include/freetype/ftcache.h b/include/freetype/ftcache.h
index 4baa058..97df187 100644
--- a/include/freetype/ftcache.h
+++ b/include/freetype/ftcache.h
@@ -16,26 +16,27 @@
/***************************************************************************/
- /**************************************************************************/
- /**************************************************************************/
- /**************************************************************************/
- /**************************************************************************/
- /**************************************************************************/
- /********* **********/
- /********* **********/
- /********* WARNING, THIS IS ALPHA CODE, THIS API **********/
- /********* IS DUE TO CHANGE UNTIL STRICTLY NOTIFIED BY THE **********/
- /********* FREETYPE DEVELOPMENT TEAM **********/
- /********* **********/
- /**************************************************************************/
- /**************************************************************************/
- /**************************************************************************/
- /**************************************************************************/
- /**************************************************************************/
+ /*************************************************************************/
+ /*************************************************************************/
+ /*************************************************************************/
+ /*************************************************************************/
+ /*************************************************************************/
+ /********* *********/
+ /********* WARNING, THIS IS ALPHA CODE, THIS API *********/
+ /********* IS DUE TO CHANGE UNTIL STRICTLY NOTIFIED BY THE *********/
+ /********* FREETYPE DEVELOPMENT TEAM *********/
+ /********* *********/
+ /*************************************************************************/
+ /*************************************************************************/
+ /*************************************************************************/
+ /*************************************************************************/
+ /*************************************************************************/
+
#ifndef FTCACHE_H
#define FTCACHE_H
+
#include <freetype/ftglyph.h>
@@ -91,7 +92,7 @@
/* */
typedef FT_Error (*FTC_Face_Requester)( FTC_FaceID face_id,
FT_Library library,
- FT_Pointer request_data,
+ FT_Pointer request_data,
FT_Face* aface );
@@ -102,8 +103,8 @@
/* */
/* <Description> */
/* A simple structure used to describe a given `font' to the cache */
- /* manager. Note that a "font" is the combination of a given face */
- /* with a given character size.. */
+ /* manager. Note that a `font' is the combination of a given face */
+ /* with a given character size. */
/* */
/* <Fields> */
/* face_id :: The ID of the face to use. */
@@ -117,7 +118,7 @@
FTC_FaceID face_id;
FT_UShort pix_width;
FT_UShort pix_height;
-
+
} FTC_FontRec;
@@ -130,7 +131,7 @@
/* A simple handle to a FTC_FontRec structure. */
/* */
typedef FTC_FontRec* FTC_Font;
-
+
/*************************************************************************/
/*************************************************************************/
@@ -196,7 +197,7 @@
FT_Pointer req_data,
FTC_Manager* amanager );
-
+
/*************************************************************************/
/* */
/* <Function> */
@@ -261,7 +262,7 @@
FT_EXPORT_DEF( FT_Error ) FTC_Manager_Lookup_Face( FTC_Manager manager,
FTC_FaceID face_id,
FT_Face* aface );
-
+
/*************************************************************************/
/* */
@@ -308,19 +309,18 @@
FT_Size* asize );
- /* a cache class is used to describe a unique cache type to the */
- /* manager.. */
+ /* a cache class is used to describe a unique cache type to the manager */
typedef struct FTC_Cache_Class_ FTC_Cache_Class;
typedef struct FTC_CacheRec_* FTC_Cache;
/* this must be used internally for the moment */
FT_EXPORT_DEF( FT_Error ) FTC_Manager_Register_Cache(
- FTC_Manager manager,
- FTC_Cache_Class* clazz,
- FTC_Cache *acache );
+ FTC_Manager manager,
+ FTC_Cache_Class* clazz,
+ FTC_Cache* acache );
+
-
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
@@ -332,6 +332,8 @@
/*************************************************************************/
+#define FTC_IMAGE_FORMAT( x ) ( (x) & 7 )
+
/*************************************************************************/
/* */
/* <Enum> */
@@ -353,30 +355,25 @@
/* <Note> */
/* Other types may be defined in the future. */
/* */
-
-#define FTC_IMAGE_FORMAT(x) ((x) & 7)
-
typedef enum FTC_Image_Type_
{
ftc_image_format_bitmap = 0,
ftc_image_format_outline = 1,
-
+
ftc_image_flag_monochrome = 16,
ftc_image_flag_unhinted = 32,
ftc_image_flag_autohinted = 64,
ftc_image_flag_unscaled = 128,
ftc_image_flag_no_sbits = 256,
-
- ftc_image_mono = ftc_image_format_bitmap |
- ftc_image_flag_monochrome, /* monochrome bitmap */
-
- ftc_image_grays = ftc_image_format_bitmap, /* anti-aliased bitmap */
-
- ftc_image_outline = ftc_image_format_outline /* scaled outline */
-
+
+ ftc_image_mono = ftc_image_format_bitmap |
+ ftc_image_flag_monochrome, /* monochrome bitmap */
+ ftc_image_grays = ftc_image_format_bitmap, /* anti-aliased bitmap */
+ ftc_image_outline = ftc_image_format_outline /* scaled outline */
+
} FTC_Image_Type;
-
+
/*************************************************************************/
/* */
/* <Struct> */
@@ -395,7 +392,7 @@
{
FTC_FontRec font;
FT_UInt image_type;
-
+
} FTC_Image_Desc;
@@ -409,7 +406,7 @@
/* hold many distinct glyph images, while not exceeding a certain */
/* memory threshold. */
/* */
- typedef struct FTC_Image_CacheRec_* FTC_Image_Cache;
+ typedef struct FTC_Image_CacheRec_* FTC_Image_Cache;
/*************************************************************************/
@@ -431,7 +428,7 @@
/* */
FT_EXPORT_DEF( FT_Error ) FTC_Image_Cache_New( FTC_Manager manager,
FTC_Image_Cache* acache );
-
+
/*************************************************************************/
/* */
@@ -462,7 +459,7 @@
/* */
/* Because the glyph image cache limits the total amount of memory */
/* taken by the glyphs it holds, the returned glyph might disappear */
- /* on a later invocation of this function! It's a cache after all ;-) */
+ /* on a later invocation of this function! It's a cache after all... */
/* */
FT_EXPORT_DEF( FT_Error ) FTC_Image_Cache_Lookup(
FTC_Image_Cache cache,
diff --git a/include/freetype/ftsynth.h b/include/freetype/ftsynth.h
index cfe0206..9e7f95d 100644
--- a/include/freetype/ftsynth.h
+++ b/include/freetype/ftsynth.h
@@ -16,22 +16,23 @@
/* */
/***************************************************************************/
- /**************************************************************************/
- /**************************************************************************/
- /**************************************************************************/
- /**************************************************************************/
- /**************************************************************************/
- /********* **********/
- /********* **********/
- /********* WARNING, THIS IS ALPHA CODE, THIS API **********/
- /********* IS DUE TO CHANGE UNTIL STRICTLY NOTIFIED BY THE **********/
- /********* FREETYPE DEVELOPMENT TEAM **********/
- /********* **********/
- /**************************************************************************/
- /**************************************************************************/
- /**************************************************************************/
- /**************************************************************************/
- /**************************************************************************/
+
+ /*************************************************************************/
+ /*************************************************************************/
+ /*************************************************************************/
+ /*************************************************************************/
+ /*************************************************************************/
+ /********* *********/
+ /********* WARNING, THIS IS ALPHA CODE, THIS API *********/
+ /********* IS DUE TO CHANGE UNTIL STRICTLY NOTIFIED BY THE *********/
+ /********* FREETYPE DEVELOPMENT TEAM *********/
+ /********* *********/
+ /*************************************************************************/
+ /*************************************************************************/
+ /*************************************************************************/
+ /*************************************************************************/
+ /*************************************************************************/
+
#ifndef FTSYNTH_H
#define FTSYNTH_H
@@ -44,9 +45,9 @@
#endif
- /* This code is completely experimental - use with care! */
+ /* This code is completely experimental -- use with care! */
/* It will probably be completely rewritten in the future */
- /* or even integrated within the library... */
+ /* or even integrated into the library. */
FT_EXPORT_DEF( FT_Error ) FT_Embolden_Outline( FT_Face original,
FT_Outline* outline,
FT_Pos* advance );
diff --git a/src/base/ftobjs.c b/src/base/ftobjs.c
index d08ed0e..bfa440e 100644
--- a/src/base/ftobjs.c
+++ b/src/base/ftobjs.c
@@ -975,13 +975,13 @@
/* when the flag NO_RECURSE is set, we disable hinting and scaling */
if ( load_flags & FT_LOAD_NO_RECURSE )
{
- /* disable scaling, hinting and transform */
- load_flags |= FT_LOAD_NO_SCALE |
- FT_LOAD_NO_HINTING |
+ /* disable scaling, hinting, and transformation */
+ load_flags |= FT_LOAD_NO_SCALE |
+ FT_LOAD_NO_HINTING |
FT_LOAD_IGNORE_TRANSFORM;
-
+
/* disable bitmap rendering */
- load_flags &= ~FT_LOAD_RENDER;
+ load_flags &= ~FT_LOAD_RENDER;
}
/* do we need to load the glyph through the auto-hinter? */
@@ -1032,7 +1032,7 @@
{
FT_UInt EM = face->units_per_EM;
FT_Size_Metrics* metrics = &face->size->metrics;
-
+
slot->linearHoriAdvance = FT_MulDiv( slot->linearHoriAdvance,
(FT_Long)metrics->x_ppem << 16, EM );
@@ -1161,7 +1161,7 @@
/* discard auto-hinting data */
if ( face->autohint.finalizer )
face->autohint.finalizer( face->autohint.data );
-
+
/* Discard glyph slots for this face */
/* Beware! FT_Done_GlyphSlot() changes the field `face->slot' */
while ( face->glyph )
@@ -2344,12 +2344,12 @@
FT_UInt buffer_max )
{
FT_Error error = FT_Err_Invalid_Argument;
-
+
/* clean up buffer */
if ( buffer && buffer_max > 0 )
((FT_Byte*)buffer)[0] = 0;
-
+
if ( face &&
glyph_index < (FT_UInt)face->num_glyphs &&
FT_HAS_GLYPH_NAMES( face ) )
@@ -2362,7 +2362,7 @@
if ( clazz->get_interface )
{
FT_Glyph_Name_Requester requester;
-
+
requester = (FT_Glyph_Name_Requester)clazz->get_interface(
FT_MODULE( driver ), "glyph_name" );
@@ -2372,7 +2372,7 @@
}
return error;
- }
+ }
/*************************************************************************/
diff --git a/src/cache/ftcglyph.c b/src/cache/ftcglyph.c
index c7d7463..970cc3d 100644
--- a/src/cache/ftcglyph.c
+++ b/src/cache/ftcglyph.c
@@ -2,7 +2,7 @@
/* */
/* ftcglyph.c */
/* */
-/* FreeType Glyph Image (FT_Glyph) cache.. */
+/* FreeType Glyph Image (FT_Glyph) cache (body). */
/* */
/* Copyright 2000 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
@@ -13,124 +13,134 @@
/* this file you indicate that you have read the license and */
/* understand and accept it fully. */
/* */
-/* */
-/* Note: the implementation of glyph queues is rather generic in this */
-/* code. This will allow other glyph node/cache types to be */
-/* easily included in the future.. For now, we only cache */
-/* glyph images.. */
-/* */
/***************************************************************************/
+ /*************************************************************************/
+ /* */
+ /* Note: The implementation of glyph queues is rather generic in this */
+ /* code. This will allow other glyph node/cache types to be */
+ /* easily included in the future. For now, we only cache glyph */
+ /* images. */
+ /* */
+ /*************************************************************************/
+
+
#include <freetype/cache/ftcglyph.h>
#include <freetype/fterrors.h>
#include <freetype/internal/ftobjs.h>
#include <freetype/internal/ftlist.h>
#include <freetype/fterrors.h>
- /*************************************************************************/
- /*************************************************************************/
- /***** *****/
- /***** GLYPH NODES *****/
- /***** *****/
- /*************************************************************************/
- /*************************************************************************/
-
-/* in the future, we might provide a better scheme for managing */
-/* glyph node element. For the moment, we simply use FT_Alloc/FT_Free */
-
- /* creates a new glyph node, setting its cache index and ref count */
- FT_EXPORT_FUNC(void) FTC_GlyphNode_Init( FTC_GlyphNode node,
- FTC_Glyph_Queue queue,
- FT_UInt gindex )
+
+ /*************************************************************************/
+ /*************************************************************************/
+ /***** *****/
+ /***** GLYPH NODES *****/
+ /***** *****/
+ /*************************************************************************/
+ /*************************************************************************/
+
+
+ /* In the future, we might provide a better scheme for managing glyph */
+ /* node elements. For the moment, we simply use FT_Alloc()/FT_Free(). */
+
+
+ /* create a new glyph node, setting its cache index and ref count */
+ FT_EXPORT_FUNC( void ) FTC_GlyphNode_Init( FTC_GlyphNode node,
+ FTC_Glyph_Queue queue,
+ FT_UInt gindex )
{
FTC_Glyph_Cache cache = queue->cache;
FTC_CacheNode_Data* data = FTC_CACHENODE_TO_DATA_P( &node->root );
-
- data->cache_index = (FT_UShort) cache->root.cache_index;
- data->ref_count = (FT_Short) 0;
- node->queue_index = (FT_UShort) queue->queue_index;
- node->glyph_index = (FT_UShort) gindex;
- }
+ data->cache_index = (FT_UShort)cache->root.cache_index;
+ data->ref_count = (FT_Short) 0;
+ node->queue_index = (FT_UShort)queue->queue_index;
+ node->glyph_index = (FT_UShort)gindex;
+ }
+
+ /* Important: This function is called from the cache manager to */
+ /* destroy a given cache node during `cache compression'. The */
+ /* second argument is always `cache.user_data'. Thus be */
+ /* certain that the function FTC_Image_Cache_New() does indeed */
+ /* set its `user_data' field correctly, otherwise bad things */
+ /* will happen! */
- /* Important: this function is called from the cache manager to */
- /* destroy a given cache node during "cache compression". The */
- /* second argument is always "cache.user_data". You thus be */
- /* certain that the function FTC_Image_Cache_New does indeed */
- /* set its "user_data" field correctly, otherwise bad things */
- /* will happen !! */
-
- FT_EXPORT_FUNC(void) FTC_GlyphNode_Destroy( FTC_GlyphNode node,
- FTC_Glyph_Cache cache )
+ FT_EXPORT_FUNC( void ) FTC_GlyphNode_Destroy( FTC_GlyphNode node,
+ FTC_Glyph_Cache cache )
{
- FT_LruNode queue_lru = cache->queues_lru->nodes+node->queue_index;
+ FT_LruNode queue_lru = cache->queues_lru->nodes + node->queue_index;
FTC_Glyph_Queue queue = (FTC_Glyph_Queue)queue_lru->root.data;
FT_UInt hash = node->glyph_index % queue->hash_size;
FT_List bucket = queue->buckets + hash;
-
+
+
/* remove node from its queue's bucket list */
- FT_List_Remove( bucket, FTC_GLYPHNODE_TO_LISTNODE(node) );
-
+ FT_List_Remove( bucket, FTC_GLYPHNODE_TO_LISTNODE( node ) );
+
/* destroy the node */
queue->clazz->destroy_node( node, queue );
}
-
- /* Important: this function is called from the cache manager to */
- /* size a given cache node during "cache compression". The */
- /* second argument is always "cache.user_data". You thus be */
- /* certain that the function FTC_Image_Cache_New does indeed */
- /* set its "user_data" field correctly, otherwise bad things */
- /* will happen !! */
-
- FT_EXPORT_FUNC(FT_ULong) FTC_GlyphNode_Size( FTC_GlyphNode node,
- FTC_Glyph_Cache cache )
+
+ /* Important: This function is called from the cache manager to */
+ /* size a given cache node during `cache compression'. The */
+ /* second argument is always `cache.user_data'. Thus be */
+ /* certain that the function FTC_Image_Cache_New() does indeed */
+ /* set its `user_data' field correctly, otherwise bad things */
+ /* will happen! */
+
+ FT_EXPORT_FUNC( FT_ULong ) FTC_GlyphNode_Size( FTC_GlyphNode node,
+ FTC_Glyph_Cache cache )
{
- FT_LruNode queue_lru = cache->queues_lru->nodes+node->queue_index;
+ FT_LruNode queue_lru = cache->queues_lru->nodes + node->queue_index;
FTC_Glyph_Queue queue = (FTC_Glyph_Queue)queue_lru->root.data;
-
+
+
return queue->clazz->size_node( node, queue );
}
- FT_CPLUSPLUS(const FTC_CacheNode_Class) ftc_glyph_cache_node_class =
+ FT_CPLUSPLUS( const FTC_CacheNode_Class ) ftc_glyph_cache_node_class =
{
- (FTC_CacheNode_SizeFunc) FTC_GlyphNode_Size,
- (FTC_CacheNode_DestroyFunc) FTC_GlyphNode_Destroy
+ (FTC_CacheNode_SizeFunc) FTC_GlyphNode_Size,
+ (FTC_CacheNode_DestroyFunc)FTC_GlyphNode_Destroy
};
- /*************************************************************************/
- /*************************************************************************/
- /***** *****/
- /***** GLYPH QUEUES *****/
- /***** *****/
- /*************************************************************************/
- /*************************************************************************/
-
- FT_EXPORT_FUNC(FT_Error) FTC_Glyph_Queue_New(
- FTC_Glyph_Cache cache,
- FT_Pointer type,
- FTC_Glyph_Queue* aqueue )
+
+ /*************************************************************************/
+ /*************************************************************************/
+ /***** *****/
+ /***** GLYPH QUEUES *****/
+ /***** *****/
+ /*************************************************************************/
+ /*************************************************************************/
+
+
+ FT_EXPORT_FUNC( FT_Error ) FTC_Glyph_Queue_New( FTC_Glyph_Cache cache,
+ FT_Pointer type,
+ FTC_Glyph_Queue* aqueue )
{
FT_Error error;
FT_Memory memory = cache->root.memory;
FTC_Manager manager = cache->root.manager;
FTC_Glyph_Queue queue = 0;
-
- FTC_Glyph_Cache_Class* gcache_class;
- FTC_Glyph_Queue_Class* clazz;
-
+
+ FTC_Glyph_Cache_Class* gcache_class;
+ FTC_Glyph_Queue_Class* clazz;
+
+
gcache_class = (FTC_Glyph_Cache_Class*)cache->root.clazz;
clazz = gcache_class->queue_class;
-
+
*aqueue = 0;
-
+
if ( ALLOC( queue, clazz->queue_byte_size ) )
goto Exit;
-
+
queue->cache = cache;
queue->manager = manager;
queue->memory = memory;
@@ -139,14 +149,13 @@
/* allocate buckets table */
if ( ALLOC_ARRAY( queue->buckets, queue->hash_size, FT_ListRec ) )
- if (error)
goto Exit;
- /* initialize queue by type - if needed */
- if (clazz->init)
+ /* initialize queue by type if needed */
+ if ( clazz->init )
{
error = clazz->init( queue, type );
- if (error)
+ if ( error )
goto Exit;
}
@@ -160,77 +169,79 @@
}
return error;
- }
-
+ }
- FT_EXPORT_FUNC(void) FTC_Glyph_Queue_Done( FTC_Glyph_Queue queue )
+ FT_EXPORT_FUNC( void ) FTC_Glyph_Queue_Done( FTC_Glyph_Queue queue )
{
- FTC_Glyph_Cache cache = queue->cache;
- FTC_Manager manager = cache->root.manager;
- FT_List glyphs_lru = &manager->global_lru;
- FT_List bucket = queue->buckets;
- FT_List bucket_limit = bucket + queue->hash_size;
- FT_Memory memory = cache->root.memory;
-
+ FTC_Glyph_Cache cache = queue->cache;
+ FTC_Manager manager = cache->root.manager;
+ FT_List glyphs_lru = &manager->global_lru;
+ FT_List bucket = queue->buckets;
+ FT_List bucket_limit = bucket + queue->hash_size;
+ FT_Memory memory = cache->root.memory;
+
FTC_Glyph_Queue_Class* clazz = queue->clazz;
- /* for each bucket, free the list of Glyph nodes */
+
+ /* for each bucket, free the list of glyph nodes */
for ( ; bucket < bucket_limit; bucket++ )
{
FT_ListNode node = bucket->head;
FT_ListNode next = 0;
FT_ListNode lrunode;
FTC_GlyphNode inode;
-
+
for ( ; node; node = next )
{
next = node->next;
- inode = FTC_LISTNODE_TO_GLYPHNODE(node);
+ inode = FTC_LISTNODE_TO_GLYPHNODE( node );
lrunode = FTC_GLYPHNODE_TO_LRUNODE( inode );
-
+
manager->num_bytes -= clazz->size_node( inode, queue );
-
+
FT_List_Remove( glyphs_lru, lrunode );
clazz->destroy_node( inode, queue );
}
-
+
bucket->head = bucket->tail = 0;
}
- if (clazz->done)
- clazz->done(queue);
+ if ( clazz->done )
+ clazz->done( queue );
FREE( queue->buckets );
FREE( queue );
}
- FT_EXPORT_FUNC(FT_Error) FTC_Glyph_Queue_Lookup_Node(
- FTC_Glyph_Queue queue,
- FT_UInt glyph_index,
- FTC_GlyphNode* anode )
+ FT_EXPORT_FUNC( FT_Error ) FTC_Glyph_Queue_Lookup_Node(
+ FTC_Glyph_Queue queue,
+ FT_UInt glyph_index,
+ FTC_GlyphNode* anode )
{
- FTC_Glyph_Cache cache = queue->cache;
- FTC_Manager manager = cache->root.manager;
- FT_UInt hash_index = glyph_index % queue->hash_size;
- FT_List bucket = queue->buckets + hash_index;
- FT_ListNode node;
- FT_Error error;
- FTC_GlyphNode inode;
-
+ FTC_Glyph_Cache cache = queue->cache;
+ FTC_Manager manager = cache->root.manager;
+ FT_UInt hash_index = glyph_index % queue->hash_size;
+ FT_List bucket = queue->buckets + hash_index;
+ FT_ListNode node;
+ FT_Error error;
+ FTC_GlyphNode inode;
+
FTC_Glyph_Queue_Class* clazz = queue->clazz;
+
*anode = 0;
for ( node = bucket->head; node; node = node->next )
{
FT_UInt gindex;
-
- inode = FTC_LISTNODE_TO_GLYPHNODE(node);
+
+
+ inode = FTC_LISTNODE_TO_GLYPHNODE( node );
gindex = inode->glyph_index;
-
+
if ( gindex == glyph_index )
{
/* we found it! -- move glyph to start of the lists */
@@ -247,23 +258,23 @@
goto Exit;
/* insert the node at the start of our bucket list */
- FT_List_Insert( bucket, FTC_GLYPHNODE_TO_LISTNODE(inode) );
-
+ FT_List_Insert( bucket, FTC_GLYPHNODE_TO_LISTNODE( inode ) );
+
/* insert the node at the start the global LRU glyph list */
- FT_List_Insert( &manager->global_lru, FTC_GLYPHNODE_TO_LRUNODE(inode) );
-
+ FT_List_Insert( &manager->global_lru, FTC_GLYPHNODE_TO_LRUNODE( inode ) );
+
manager->num_bytes += clazz->size_node( inode, queue );
if (manager->num_bytes > manager->max_bytes)
FTC_Manager_Compress( manager );
-
+
*anode = inode;
Exit:
return error;
}
-
+
/*************************************************************************/
/*************************************************************************/
/***** *****/
@@ -271,14 +282,14 @@
/***** *****/
/*************************************************************************/
/*************************************************************************/
-
+
#define FTC_QUEUE_LRU_GET_CACHE( lru ) \
( (FTC_Glyph_Cache)(lru)->user_data )
-
+
#define FTC_QUEUE_LRU_GET_MANAGER( lru ) \
FTC_QUEUE_LRU_GET_CACHE( lru )->manager
-
+
#define FTC_LRUNODE_QUEUE( node ) \
( (FTC_Glyph_Queue)(node)->root.data )
@@ -291,6 +302,7 @@
FT_Error error;
FTC_Glyph_Queue queue;
+
error = FTC_Glyph_Queue_New( cache,
(FT_Pointer)node->key,
&queue );
@@ -300,18 +312,17 @@
queue->queue_index = node - lru->nodes;
node->root.data = queue;
}
-
+
return error;
}
-
LOCAL_FUNC_X
void ftc_glyph_queue_lru_done( FT_Lru lru,
FT_LruNode node )
{
FTC_Glyph_Queue queue = FTC_LRUNODE_QUEUE( node );
-
+
FT_UNUSED( lru );
@@ -319,16 +330,16 @@
}
-
LOCAL_FUNC_X
FT_Bool ftc_glyph_queue_lru_compare( FT_LruNode node,
FT_LruKey key )
{
FTC_Glyph_Queue queue = FTC_LRUNODE_QUEUE( node );
- return queue->clazz->compare( queue, (FT_Pointer)key );
- }
+ return queue->clazz->compare( queue, (FT_Pointer)key );
+ }
+
FT_CPLUSPLUS( const FT_Lru_Class ) ftc_glyph_queue_lru_class =
{
@@ -340,7 +351,6 @@
};
-
/*************************************************************************/
/*************************************************************************/
/***** *****/
@@ -348,21 +358,23 @@
/***** *****/
/*************************************************************************/
/*************************************************************************/
-
- FT_EXPORT_FUNC(FT_Error) FTC_Glyph_Cache_Init( FTC_Glyph_Cache cache )
+
+ FT_EXPORT_FUNC( FT_Error ) FTC_Glyph_Cache_Init( FTC_Glyph_Cache cache )
{
- FT_Memory memory = cache->root.memory;
- FT_Error error;
+ FT_Memory memory = cache->root.memory;
+ FT_Error error;
+
/* set up root node_class to be used by manager */
- cache->root.node_clazz = (FTC_CacheNode_Class*)&ftc_glyph_cache_node_class;
-
- /* The following is extremely important for ftc_destroy_glyph_image */
- /* to work properly, as the second parameter that is sent to it */
- /* through the cache manager is "user_data" and must be set to */
- /* "cache" here.. */
- /* */
+ cache->root.node_clazz =
+ (FTC_CacheNode_Class*)&ftc_glyph_cache_node_class;
+
+ /* The following is extremely important for ftc_destroy_glyph_image() */
+ /* to work properly, as the second parameter that is sent to it */
+ /* through the cache manager is `user_data' and must be set to */
+ /* `cache' here. */
+ /* */
cache->root.cache_user = cache;
error = FT_Lru_New( &ftc_glyph_queue_lru_class,
@@ -375,12 +387,11 @@
}
- FT_EXPORT_FUNC(void) FTC_Glyph_Cache_Done( FTC_Glyph_Cache cache )
+ FT_EXPORT_FUNC( void ) FTC_Glyph_Cache_Done( FTC_Glyph_Cache cache )
{
- /* discard Glyph queues */
+ /* discard glyph queues */
FT_Lru_Done( cache->queues_lru );
}
-
/* END */
diff --git a/src/cache/ftcimage.c b/src/cache/ftcimage.c
index a9e4f9d..19d33b8 100644
--- a/src/cache/ftcimage.c
+++ b/src/cache/ftcimage.c
@@ -1,17 +1,39 @@
+/***************************************************************************/
+/* */
+/* ftcimage.c */
+/* */
+/* FreeType Image cache (body). */
+/* */
+/* Copyright 2000 by */
+/* David Turner, Robert Wilhelm, and Werner Lemberg. */
+/* */
+/* This file is part of the FreeType project, and may only be used, */
+/* modified, and distributed under the terms of the FreeType project */
+/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
+/* this file you indicate that you have read the license and */
+/* understand and accept it fully. */
+/* */
+/***************************************************************************/
+
+
#ifdef FT_FLAT_COMPILE
# include "ftcimage.h"
#else
# include <cache/ftcimage.h>
#endif
- /*************************************************************************/
- /*************************************************************************/
- /***** *****/
- /***** GLYPH IMAGE NODES *****/
- /***** *****/
- /*************************************************************************/
- /*************************************************************************/
-
+#include <string.h>
+
+
+ /*************************************************************************/
+ /*************************************************************************/
+ /***** *****/
+ /***** GLYPH IMAGE NODES *****/
+ /***** *****/
+ /*************************************************************************/
+ /*************************************************************************/
+
+
/* this is a simple glyph image destructor, which is called exclusively */
/* from the CacheQueue object */
LOCAL_FUNC_X
@@ -19,7 +41,8 @@
FTC_Glyph_Queue queue )
{
FT_Memory memory = queue->memory;
-
+
+
FT_Done_Glyph( FTC_GLYPHNODE_GET_GLYPH( node ) );
FREE( node );
}
@@ -28,8 +51,8 @@
LOCAL_FUNC_X
FT_Error ftc_glyph_image_node_new( FTC_Glyph_Queue queue,
FT_UInt glyph_index,
- FTC_GlyphNode *anode )
- {
+ FTC_GlyphNode* anode )
+ {
FT_Memory memory = queue->memory;
FTC_Image_Queue imageq = (FTC_Image_Queue)queue;
FT_Error error;
@@ -37,8 +60,9 @@
FT_Face face;
FT_Size size;
+
/* allocate node */
- if ( ALLOC( node, sizeof(*node) ) )
+ if ( ALLOC( node, sizeof ( *node ) ) )
goto Exit;
/* init its inner fields */
@@ -53,13 +77,14 @@
FT_UInt glyph_index = node->glyph_index;
FT_UInt load_flags = FT_LOAD_DEFAULT;
FT_UInt image_type = imageq->description.image_type;
-
+
+
if ( FTC_IMAGE_FORMAT( image_type ) == ftc_image_format_bitmap )
- {
- load_flags |= FT_LOAD_RENDER;
+ {
+ load_flags |= FT_LOAD_RENDER;
if ( image_type & ftc_image_flag_monochrome )
load_flags |= FT_LOAD_MONOCHROME;
-
+
/* disable embedded bitmaps loading if necessary */
if ( image_type & ftc_image_flag_no_sbits )
load_flags |= FT_LOAD_NO_BITMAP;
@@ -68,14 +93,14 @@
{
/* disable embedded bitmaps loading */
load_flags |= FT_LOAD_NO_BITMAP;
-
+
if ( image_type & ftc_image_flag_unscaled )
load_flags |= FT_LOAD_NO_SCALE;
}
-
+
if ( image_type & ftc_image_flag_unhinted )
load_flags |= FT_LOAD_NO_HINTING;
-
+
if ( image_type & ftc_image_flag_autohinted )
load_flags |= FT_LOAD_FORCE_AUTOHINT;
@@ -84,11 +109,11 @@
{
if ( face->glyph->format == ft_glyph_format_bitmap ||
face->glyph->format == ft_glyph_format_outline )
- {
+ {
/* ok, copy it */
FT_Glyph glyph;
-
-
+
+
error = FT_Get_Glyph( face->glyph, &glyph );
if ( !error )
FTC_GLYPHNODE_SET_GLYPH( node, glyph );
@@ -97,64 +122,68 @@
error = FT_Err_Invalid_Argument;
}
}
+
Exit:
- if (error && node)
- FREE(node);
+ if ( error && node )
+ FREE( node );
*anode = node;
return error;
}
- /* this function is important, because it is both part of */
- /* a FTC_Glyph_Queue_Class and a FTC_CacheNode_Class */
- /* */
+ /* this function is important because it is both part of */
+ /* a FTC_Glyph_Queue_Class and a FTC_CacheNode_Class */
+ /* */
LOCAL_FUNC_X
- FT_ULong ftc_glyph_image_node_size( FTC_GlyphNode node )
+ FT_ULong ftc_glyph_image_node_size( FTC_GlyphNode node )
{
- FT_ULong size = 0;
- FT_Glyph glyph = FTC_GLYPHNODE_GET_GLYPH(node);
-
- switch (glyph->format)
+ FT_ULong size = 0;
+ FT_Glyph glyph = FTC_GLYPHNODE_GET_GLYPH( node );
+
+
+ switch ( glyph->format )
{
- case ft_glyph_format_bitmap:
- {
- FT_BitmapGlyph bitg;
-
- bitg = (FT_BitmapGlyph)glyph;
- size = bitg->bitmap.rows * labs(bitg->bitmap.pitch) +
- sizeof(*bitg);
- }
- break;
-
- case ft_glyph_format_outline:
- {
- FT_OutlineGlyph outg;
-
- outg = (FT_OutlineGlyph)glyph;
- size = outg->outline.n_points *
- ( sizeof( FT_Vector ) + sizeof( FT_Byte ) ) +
- outg->outline.n_contours *
- sizeof( FT_Short ) +
- sizeof(*outg);
- }
- break;
-
- default:
- ;
+ case ft_glyph_format_bitmap:
+ {
+ FT_BitmapGlyph bitg;
+
+
+ bitg = (FT_BitmapGlyph)glyph;
+ size = bitg->bitmap.rows * labs( bitg->bitmap.pitch ) +
+ sizeof ( *bitg );
+ }
+ break;
+
+ case ft_glyph_format_outline:
+ {
+ FT_OutlineGlyph outg;
+
+
+ outg = (FT_OutlineGlyph)glyph;
+ size = outg->outline.n_points *
+ ( sizeof( FT_Vector ) + sizeof ( FT_Byte ) ) +
+ outg->outline.n_contours * sizeof ( FT_Short ) +
+ sizeof ( *outg );
+ }
+ break;
+
+ default:
+ ;
}
- size += sizeof(*node);
+
+ size += sizeof ( *node );
return size;
}
- /*************************************************************************/
- /*************************************************************************/
- /***** *****/
- /***** GLYPH IMAGE QUEUES *****/
- /***** *****/
- /*************************************************************************/
- /*************************************************************************/
+ /*************************************************************************/
+ /*************************************************************************/
+ /***** *****/
+ /***** GLYPH IMAGE QUEUES *****/
+ /***** *****/
+ /*************************************************************************/
+ /*************************************************************************/
LOCAL_FUNC_X
@@ -167,45 +196,44 @@
LOCAL_FUNC_X
- FT_Bool ftc_image_queue_compare( FTC_Image_Queue queue,
- FTC_Image_Desc* type )
+ FT_Bool ftc_image_queue_compare( FTC_Image_Queue queue,
+ FTC_Image_Desc* type )
{
- return !memcmp( &queue->description, type, sizeof(*type) );
+ return !memcmp( &queue->description, type, sizeof ( *type ) );
}
-
- FT_CPLUSPLUS(const FTC_Glyph_Queue_Class) ftc_glyph_image_queue_class =
+
+ FT_CPLUSPLUS( const FTC_Glyph_Queue_Class ) ftc_glyph_image_queue_class =
{
sizeof( FTC_Image_QueueRec ),
-
- (FTC_Glyph_Queue_InitFunc) ftc_image_queue_init,
- (FTC_Glyph_Queue_DoneFunc) 0,
- (FTC_Glyph_Queue_CompareFunc) ftc_image_queue_compare,
-
- (FTC_Glyph_Queue_NewNodeFunc) ftc_glyph_image_node_new,
- (FTC_Glyph_Queue_SizeNodeFunc) ftc_glyph_image_node_size,
- (FTC_Glyph_Queue_DestroyNodeFunc) ftc_glyph_image_node_destroy
- };
+ (FTC_Glyph_Queue_InitFunc) ftc_image_queue_init,
+ (FTC_Glyph_Queue_DoneFunc) 0,
+ (FTC_Glyph_Queue_CompareFunc) ftc_image_queue_compare,
+
+ (FTC_Glyph_Queue_NewNodeFunc) ftc_glyph_image_node_new,
+ (FTC_Glyph_Queue_SizeNodeFunc) ftc_glyph_image_node_size,
+ (FTC_Glyph_Queue_DestroyNodeFunc)ftc_glyph_image_node_destroy
+ };
- /*************************************************************************/
- /*************************************************************************/
- /***** *****/
- /***** GLYPH IMAGE CACHE *****/
- /***** *****/
- /*************************************************************************/
- /*************************************************************************/
+ /*************************************************************************/
+ /*************************************************************************/
+ /***** *****/
+ /***** GLYPH IMAGE CACHE *****/
+ /***** *****/
+ /*************************************************************************/
+ /*************************************************************************/
- FT_CPLUSPLUS(const FTC_Glyph_Cache_Class) ftc_glyph_image_cache_class =
+ FT_CPLUSPLUS( const FTC_Glyph_Cache_Class ) ftc_glyph_image_cache_class =
{
{
sizeof( FTC_Glyph_CacheRec ),
- (FTC_Cache_InitFunc) FTC_Glyph_Cache_Init,
- (FTC_Cache_DoneFunc) FTC_Glyph_Cache_Done
+ (FTC_Cache_InitFunc)FTC_Glyph_Cache_Init,
+ (FTC_Cache_DoneFunc)FTC_Glyph_Cache_Done
},
- (FTC_Glyph_Queue_Class*) &ftc_glyph_image_queue_class
+ (FTC_Glyph_Queue_Class*)&ftc_glyph_image_queue_class
};
@@ -217,7 +245,7 @@
(FTC_Cache_Class*)&ftc_glyph_image_cache_class,
(FTC_Cache*)acache );
}
-
+
FT_EXPORT_DEF( FT_Error ) FTC_Image_Cache_Lookup(
FTC_Image_Cache cache,
@@ -232,15 +260,16 @@
FTC_Image_Queue img_queue;
+
/* check for valid `desc' delayed to FT_Lru_Lookup() */
if ( !cache || !aglyph )
return FT_Err_Invalid_Argument;
- *aglyph = 0;
+ *aglyph = 0;
queue = cache->root.last_queue;
img_queue = (FTC_Image_Queue)queue;
- if ( !queue || memcmp( &img_queue->description, desc, sizeof(*desc) ) )
+ if ( !queue || memcmp( &img_queue->description, desc, sizeof ( *desc ) ) )
{
error = FT_Lru_Lookup( cache->root.queues_lru,
(FT_LruKey)desc,
@@ -256,11 +285,11 @@
/* now compress the manager's cache pool if needed */
manager = cache->root.root.manager;
- if (manager->num_bytes > manager->max_bytes)
+ if ( manager->num_bytes > manager->max_bytes )
{
- FTC_GlyphNode_Ref(inode);
+ FTC_GlyphNode_Ref( inode );
FTC_Manager_Compress( manager );
- FTC_GlyphNode_Unref(inode);
+ FTC_GlyphNode_Unref( inode );
}
*aglyph = FTC_GLYPHNODE_GET_GLYPH( inode );
@@ -270,3 +299,4 @@
}
+/* END */
diff --git a/src/cache/ftcimage.h b/src/cache/ftcimage.h
index cf29d2a..80de115 100644
--- a/src/cache/ftcimage.h
+++ b/src/cache/ftcimage.h
@@ -1,21 +1,55 @@
+/***************************************************************************/
+/* */
+/* ftcimage.c */
+/* */
+/* FreeType Image cache (body). */
+/* */
+/* Copyright 2000 by */
+/* David Turner, Robert Wilhelm, and Werner Lemberg. */
+/* */
+/* This file is part of the FreeType project, and may only be used, */
+/* modified, and distributed under the terms of the FreeType project */
+/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
+/* this file you indicate that you have read the license and */
+/* understand and accept it fully. */
+/* */
+/***************************************************************************/
+
+
#ifndef FTCIMAGE_H
#define FTCIMAGE_H
+
#include <freetype/cache/ftcglyph.h>
- /* the glyph image queue type */
- typedef struct FTC_Image_QueueRec_
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+
+ /* the glyph image queue type */
+ typedef struct FTC_Image_QueueRec_
{
FTC_Glyph_QueueRec root;
FTC_Image_Desc description;
} FTC_Image_QueueRec, *FTC_Image_Queue;
- typedef struct FTC_Image_CacheRec_
+
+ typedef struct FTC_Image_CacheRec_
{
FTC_Glyph_CacheRec root;
} FTC_Image_CacheRec;
+
+#ifdef __cplusplus
+ }
+#endif
+
+
#endif /* FTCIMAGE_H */
+
+/* END */
diff --git a/src/cache/ftcmanag.c b/src/cache/ftcmanag.c
index 64157e1..fe4664a 100644
--- a/src/cache/ftcmanag.c
+++ b/src/cache/ftcmanag.c
@@ -21,8 +21,9 @@
#include <freetype/internal/ftdebug.h>
#include <freetype/ftlist.h>
-#undef FT_COMPONENT
-#define FT_COMPONENT trace_cache
+
+#undef FT_COMPONENT
+#define FT_COMPONENT trace_cache
#define FTC_LRU_GET_MANAGER( lru ) (FTC_Manager)lru->user_data
@@ -36,14 +37,14 @@
/*************************************************************************/
- LOCAL_FUNC_X
+ LOCAL_FUNC_X
FT_Error ftc_manager_init_face( FT_Lru lru,
FT_LruNode node )
{
FTC_Manager manager = FTC_LRU_GET_MANAGER( lru );
FT_Error error;
FT_Face face;
-
+
error = manager->request_face( (FTC_FaceID)node->key,
manager->library,
@@ -60,7 +61,7 @@
}
- /* helper function for ftc_manager_done_face */
+ /* helper function for ftc_manager_done_face() */
LOCAL_FUNC_X
FT_Bool ftc_manager_size_selector( FT_Lru lru,
FT_LruNode node,
@@ -78,7 +79,7 @@
{
FTC_Manager manager = FTC_LRU_GET_MANAGER( lru );
FT_Face face = (FT_Face)node->root.data;
-
+
/* we must begin by removing all sizes for the target face */
/* from the manager's list */
@@ -86,7 +87,7 @@
ftc_manager_size_selector,
face );
- /* all right, we can discard the face now */
+ /* all right, we can discard the face now */
FT_Done_Face( face );
node->root.data = 0;
}
@@ -97,7 +98,7 @@
FT_Face face;
FT_UShort width;
FT_UShort height;
-
+
} FTC_FontRequest;
@@ -109,10 +110,10 @@
FT_Size size;
FT_Error error;
FT_Face face = font_req->face;
-
+
FT_UNUSED( lru );
-
+
node->root.data = 0;
error = FT_New_Size( face, &size );
if ( !error )
@@ -126,7 +127,7 @@
else
node->root.data = size;
}
- return error;
+ return error;
}
@@ -137,7 +138,7 @@
FT_UNUSED( lru );
FT_Done_Size( (FT_Size)node->root.data );
- }
+ }
LOCAL_FUNC_X
@@ -148,7 +149,7 @@
FTC_FontRequest* req = (FTC_FontRequest*)key;
FT_Size size = (FT_Size)node->root.data;
FT_Error error;
-
+
if ( size->face == req->face )
{
@@ -173,7 +174,7 @@
{
FTC_FontRequest* req = (FTC_FontRequest*)key;
FT_Size size = (FT_Size)node->root.data;
-
+
FT_UNUSED( node );
@@ -182,7 +183,7 @@
size->metrics.y_ppem == req->height );
}
-
+
FT_CPLUSPLUS( const FT_Lru_Class ) ftc_face_lru_class =
{
sizeof ( FT_LruRec ),
@@ -192,7 +193,7 @@
0
};
-
+
FT_CPLUSPLUS( const FT_Lru_Class ) ftc_size_lru_class =
{
sizeof ( FT_LruRec ),
@@ -214,8 +215,8 @@
FT_Error error;
FT_Memory memory;
FTC_Manager manager = 0;
-
-
+
+
if ( !library )
return FT_Err_Invalid_Library_Handle;
@@ -223,16 +224,16 @@
if ( ALLOC( manager, sizeof ( *manager ) ) )
goto Exit;
-
+
if ( max_faces == 0 )
max_faces = FTC_MAX_FACES_DEFAULT;
-
+
if ( max_sizes == 0 )
max_sizes = FTC_MAX_SIZES_DEFAULT;
-
+
if ( max_bytes == 0 )
max_bytes = FTC_MAX_BYTES_DEFAULT;
-
+
error = FT_Lru_New( &ftc_face_lru_class,
max_faces,
manager,
@@ -241,22 +242,22 @@
(FT_Lru*)&manager->faces_lru );
if ( error )
goto Exit;
-
+
error = FT_Lru_New( &ftc_size_lru_class,
max_sizes,
manager,
memory,
1, /* pre_alloc = TRUE */
- (FT_Lru*)&manager->sizes_lru );
+ (FT_Lru*)&manager->sizes_lru );
if ( error )
goto Exit;
-
+
manager->library = library;
manager->max_bytes = max_bytes;
manager->request_face = requester;
manager->request_data = req_data;
*amanager = manager;
-
+
Exit:
if ( error && manager )
{
@@ -264,16 +265,16 @@
FT_Lru_Done( manager->faces_lru );
FREE( manager );
}
-
+
return error;
}
-
+
FT_EXPORT_DEF( void ) FTC_Manager_Done( FTC_Manager manager )
{
FT_Memory memory;
FT_UInt index;
-
+
if ( !manager || !manager->library )
return;
@@ -284,20 +285,20 @@
for (index = 0; index < FTC_MAX_CACHES; index++ )
{
FTC_Cache cache = manager->caches[index];
-
-
- if (cache)
+
+
+ if ( cache )
{
cache->clazz->done_cache( cache );
- FREE(cache);
+ FREE( cache );
manager->caches[index] = 0;
}
}
-
+
/* discard faces and sizes */
FT_Lru_Done( manager->sizes_lru );
FT_Lru_Done( manager->faces_lru );
-
+
FREE( manager );
}
@@ -320,7 +321,7 @@
return FT_Err_Invalid_Cache_Handle;
return FT_Lru_Lookup( manager->faces_lru,
- (FT_LruKey)face_id,
+ (FT_LruKey)face_id,
(FT_Pointer*)aface );
}
@@ -332,34 +333,34 @@
{
FTC_FontRequest req;
FT_Error error;
-
+
/* check for valid `manager' delayed to FTC_Manager_Lookup_Face() */
if ( aface )
*aface = 0;
-
+
if ( asize )
*asize = 0;
- error = FTC_Manager_Lookup_Face( manager, font->face_id, aface );
+ error = FTC_Manager_Lookup_Face( manager, font->face_id, aface );
if ( !error )
{
FT_Size size;
-
+
req.face = *aface;
req.width = font->pix_width;
req.height = font->pix_height;
-
+
error = FT_Lru_Lookup( manager->sizes_lru,
(FT_LruKey)&req,
(FT_Pointer*)&size );
if ( !error )
{
/* select the size as the current one for this face */
- face->size = size;
-
+ (*aface)->size = size;
+
if ( asize )
*asize = size;
}
@@ -369,41 +370,44 @@
}
- /* "compress" the manager's data, i.e. get rids of old cache nodes */
+ /* `Compress' the manager's data, i.e., get rid of old cache nodes */
/* that are not referenced anymore in order to limit the total */
- /* memory used by the cache.. */
- FT_EXPORT_FUNC(void) FTC_Manager_Compress( FTC_Manager manager )
+ /* memory used by the cache. */
+ FT_EXPORT_FUNC( void ) FTC_Manager_Compress( FTC_Manager manager )
{
FT_ListNode node;
-
+
+
node = manager->global_lru.tail;
- while (manager->num_bytes > manager->max_bytes && node)
+ while ( manager->num_bytes > manager->max_bytes && node )
{
- FTC_CacheNode cache_node = FTC_LIST_TO_CACHENODE(node);
- FTC_CacheNode_Data* data = FTC_CACHENODE_TO_DATA_P(cache_node);
+ FTC_CacheNode cache_node = FTC_LIST_TO_CACHENODE( node );
+ FTC_CacheNode_Data* data = FTC_CACHENODE_TO_DATA_P( cache_node );
FTC_Cache cache;
FT_ListNode prev = node->prev;
-
- if (data->ref_count <= 0)
+
+
+ if ( data->ref_count <= 0 )
{
- /* ok, we're going to remove this node */
+ /* ok, we are going to remove this node */
FT_List_Remove( &manager->global_lru, node );
-
+
/* finalize cache node */
cache = manager->caches[data->cache_index];
- if (cache)
+ if ( cache )
{
FTC_CacheNode_Class* clazz = cache->node_clazz;
-
+
+
manager->num_bytes -= clazz->size_node( cache_node,
cache->cache_user );
-
+
clazz->destroy_node( cache_node, cache->cache_user );
}
else
{
- /* this should never happen !! */
- FT_ERROR(( "FTC_Manager_Compress: Cache Manager is corrupted !!\n" ));
+ /* this should never happen! */
+ FT_ERROR(( "FTC_Manager_Compress: Cache Manager is corrupted!\n" ));
}
}
node = prev;
@@ -412,19 +416,20 @@
FT_EXPORT_DEF( FT_Error ) FTC_Manager_Register_Cache(
- FTC_Manager manager,
- FTC_Cache_Class* clazz,
- FTC_Cache *acache )
+ FTC_Manager manager,
+ FTC_Cache_Class* clazz,
+ FTC_Cache* acache )
{
- FT_Error error = FT_Err_Invalid_Argument;
-
-
+ FT_Error error = FT_Err_Invalid_Argument;
+
+
if ( manager && clazz && acache )
{
FT_Memory memory = manager->library->memory;
FTC_Cache cache;
FT_UInt index = 0;
+
/* by default, return 0 */
*acache = 0;
@@ -434,33 +439,35 @@
if ( manager->caches[index] == 0 )
break;
}
-
+
/* return an error if there are too many registered caches */
- if (index >= FTC_MAX_CACHES)
+ if ( index >= FTC_MAX_CACHES )
{
error = FT_Err_Too_Many_Caches;
FT_ERROR(( "FTC_Manager_Register_Cache:" ));
- FT_ERROR(( " too many registered caches..\n" ));
+ FT_ERROR(( " too many registered caches\n" ));
goto Exit;
}
-
+
if ( !ALLOC( cache, clazz->cache_byte_size ) )
{
cache->manager = manager;
cache->memory = memory;
cache->clazz = clazz;
- if (clazz->init_cache)
+ if ( clazz->init_cache )
error = clazz->init_cache( cache );
-
- if (error)
- FREE(cache);
+
+ if ( error )
+ FREE( cache );
else
- manager->caches[index] = *acache = cache;
+ manager->caches[index] = *acache = cache;
}
}
+
Exit:
return error;
}
+
/* END */