Commit 14183ea0f8b9c021400d748d7311ec2a907e9f8d

David Turner 2001-12-05T15:59:33

First of all, a big thanks to Werner and Antoine for their latest work !! * src/pshinter/pshalgo2.c (psh2_hint_table_init), src/pshinter/pshalgo1.c (psh1_hint_table_init): removed compiler warnings * include/freetype/cache/*, src/cache/*: yet another massive rewrite of the caching sub-system, in order to both increase performance and allow simpler cache sub-classing. As an example, the code for the image and sbit caches is now much simpler I still need to update the documentation in www/freetype2/docs/cache.html to reflect the new design though..

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
diff --git a/ChangeLog b/ChangeLog
index 8721293..ba173b5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,20 @@
+2001-12-05  David Turner  <david@freetype.org>
+
+    First of all, a big thanks to Werner and Antoine for their latest work !!
+    
+    * src/pshinter/pshalgo2.c (psh2_hint_table_init),
+      src/pshinter/pshalgo1.c (psh1_hint_table_init): removed compiler
+      warnings
+
+    * include/freetype/cache/*, src/cache/*: yet another massive rewrite of
+    the caching sub-system, in order to both increase performance and allow
+    simpler cache sub-classing. As an example, the code for the image and
+    sbit caches is now much simpler
+
+    I still need to update the documentation in www/freetype2/docs/cache.html
+    to reflect the new design though..
+
+
 2001-12-05  David Krause  <freetype@davidkrause.com>
 
 	* docs/license.txt: s/X Windows/X Window System/.
diff --git a/include/freetype/cache/ftccache.h b/include/freetype/cache/ftccache.h
new file mode 100644
index 0000000..b6eee1f
--- /dev/null
+++ b/include/freetype/cache/ftccache.h
@@ -0,0 +1,251 @@
+#ifndef __FT_CACHE_CACHE_H__
+#define __FT_CACHE_CACHE_H__
+
+FT_BEGIN_HEADER
+
+  /* handle to cache object */
+  typedef struct FTC_CacheRec_*  FTC_Cache;
+
+
+  /* handle to cache class */
+  typedef const struct FTC_Cache_ClassRec_*  FTC_Cache_Class;
+
+
+ /* handle to cache node family */
+  typedef struct FTC_FamilyRec_*    FTC_Family;
+
+
+ /* handle to cache root query */
+  typedef struct FTC_QueryRec_*  FTC_Query;
+  
+
+  /*************************************************************************/
+  /*************************************************************************/
+  /*****                                                               *****/
+  /*****                   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 held by  */
+  /* the cache.  It can be an individual glyph image, a set of bitmaps     */
+  /* glyphs for a given size, some metrics, etc.                           */
+  /*                                                                       */
+
+
+  /* structure size should be 20 bytes on 32-bits machines */  
+  typedef struct  FTC_NodeRec_
+  {
+    FTC_Node   mru_next;     /* circular mru list pointer           */
+    FTC_Node   mru_prev;     /* circular mru list pointer           */
+    FTC_Node   link;         /* used for hashing..                  */
+    FT_UInt32  hash;         /* used for hashing too..              */
+    FT_UShort  fam_index;    /* index of family the node belongs to */
+    FT_Short   ref_count;    /* reference count for this node..     */
+  
+  } FTC_NodeRec;
+
+#define  FTC_NODE(x)    ((FTC_Node)(x))
+#define  FTC_NODE_P(x)  ((FTC_Node*)(x))
+
+ /* can be used as a FTC_Node_DoneFunc */
+  FT_EXPORT(void)
+  ftc_node_done( FTC_Node   node,
+                 FTC_Cache  cache );
+
+
+ /* reserved for manager's use */
+  FT_EXPORT(void)
+  ftc_node_destroy( FTC_Node     node,
+                    FTC_Manager  manager );
+
+
+  /*************************************************************************/
+  /*************************************************************************/
+  /*****                                                               *****/
+  /*****                   CACHE QUERY DEFINITIONS                     *****/
+  /*****                                                               *****/
+  /*************************************************************************/
+  /*************************************************************************/
+
+ /* structure modelling a cache node query. the following fields must    */
+ /* all be set by the @FTC_Family_CompareFunc method of a cache's family */
+ /* list                                                                 */
+ /*                                                                      */
+  typedef struct FTC_QueryRec_
+  {
+    FTC_Family  family;
+    FT_UFast    hash;
+
+  } FTC_QueryRec;
+
+
+#define  FTC_QUERY(x)    ((FTC_Query)(x))
+#define  FTC_QUERY_P(x)  ((FTC_Query*)(x))
+
+
+
+
+  /*************************************************************************/
+  /*************************************************************************/
+  /*****                                                               *****/
+  /*****                   CACHE FAMILY DEFINITIONS                    *****/
+  /*****                                                               *****/
+  /*************************************************************************/
+  /*************************************************************************/
+
+  typedef struct FTC_FamilyRec_
+  {
+    FT_LruNodeRec  lru;
+    FTC_Cache      cache;
+    FT_UInt        num_nodes;
+    FT_UInt        fam_index;
+    
+  } FTC_FamilyRec;
+
+#define  FTC_FAMILY(x)    ((FTC_Family)(x))
+#define  FTC_FAMILY_P(x)  ((FTC_Family*)(x))
+
+
+ /* must be called by any FTC_Node_InitFunc routine */
+  FT_EXPORT(FT_Error)
+  ftc_family_init( FTC_Family  family,
+                   FTC_Query   query,
+                   FTC_Cache   cache );
+
+
+ /* can be used as a FTC_Family_DoneFunc, otherwise, must be called */
+ /* by any family finalizer function..                              */
+  FT_EXPORT(void)
+  ftc_family_done( FTC_Family  family );
+
+
+  /*************************************************************************/
+  /*************************************************************************/
+  /*****                                                               *****/
+  /*****                       CACHE DEFINITIONS                       *****/
+  /*****                                                               *****/
+  /*************************************************************************/
+  /*************************************************************************/
+
+ /* each cache really implements a dynamic hash table to manage its nodes */
+  typedef struct  FTC_CacheRec_
+  {
+    FTC_Manager          manager;
+    FT_Memory            memory;
+    FTC_Cache_Class      clazz;
+
+    FT_UInt              cache_index;  /* in manager's table         */
+    FT_Pointer           cache_data;   /* used by cache node methods */
+
+    FT_UFast             nodes;
+    FT_UFast             size;
+    FTC_Node*            buckets;
+
+    FT_LruList_ClassRec  family_class;
+    FT_LruList           families;
+
+  } FTC_CacheRec;
+
+
+#define  FTC_CACHE(x)    ((FTC_Cache)(x))
+#define  FTC_CACHE_P(x)  ((FTC_Cache*)(x))
+
+
+  /* initialize a given cache */
+  typedef FT_Error  (*FTC_Cache_InitFunc)( FTC_Cache  cache );
+
+  /* clear a cache */
+  typedef void      (*FTC_Cache_ClearFunc)( FTC_Cache  cache );
+  
+ /* finalize a given cache */
+  typedef void      (*FTC_Cache_DoneFunc)( FTC_Cache   cache );
+
+
+  typedef FT_Error  (*FTC_Family_InitFunc)( FTC_Family  family,
+                                            FTC_Query   query,
+                                            FTC_Cache   cache );
+
+  typedef FT_Int    (*FTC_Family_CompareFunc)( FTC_Family  family,
+                                               FTC_Query   query );
+
+  typedef void      (*FTC_Family_DoneFunc)( FTC_Family  family,
+                                            FTC_Cache   cache );
+                                            
+ /* initialize a new cache node */
+  typedef FT_Error  (*FTC_Node_InitFunc)( FTC_Node    node,
+                                          FT_Pointer  type,
+                                          FTC_Cache   cache );
+
+  /* compute the weight of a given cache node */
+  typedef FT_ULong  (*FTC_Node_WeightFunc)( FTC_Node   node,
+                                            FTC_Cache  cache );
+
+  /* compare a node to a given key pair */
+  typedef FT_Bool   (*FTC_Node_CompareFunc)( FTC_Node    node,
+                                             FT_Pointer  key,
+                                             FTC_Cache   cache );
+
+  /* finalize a given cache node */
+  typedef void      (*FTC_Node_DoneFunc)( FTC_Node   node,
+                                          FTC_Cache  cache );
+
+
+  typedef struct  FTC_Cache_ClassRec_
+  {
+    FT_UInt                 cache_size;
+    FTC_Cache_InitFunc      cache_init;
+    FTC_Cache_ClearFunc     cache_clear;
+    FTC_Cache_DoneFunc      cache_done;
+
+    FT_UInt                 family_size;
+    FTC_Family_InitFunc     family_init;
+    FTC_Family_CompareFunc  family_compare;
+    FTC_Family_DoneFunc     family_done;
+    
+    FT_UInt                 node_size;
+    FTC_Node_InitFunc       node_init;
+    FTC_Node_WeightFunc     node_weight;
+    FTC_Node_CompareFunc    node_compare;
+    FTC_Node_DoneFunc       node_done;
+  
+  } FTC_Cache_ClassRec;
+
+  /* */
+
+  /* can be used directly as FTC_Cache_DoneFunc(), or called by custom */
+  /* cache finalizers                                                  */
+  FT_EXPORT( void )
+  ftc_cache_done( FTC_Cache  cache );
+
+
+  /* can be used directly as FTC_Cache_ClearFunc(), or called by custom */
+  /* cache clear routines..                                             */
+  FT_EXPORT( void )
+  ftc_cache_clear( FTC_Cache  cache );
+
+
+  /* initalize the hash table within the cache */
+  FT_EXPORT( FT_Error )
+  ftc_cache_init( FTC_Cache  cache );
+
+
+ /* can be called when the key's hash value has been computed */
+  FT_EXPORT(FT_Error)
+  ftc_cache_lookup( FTC_Cache    cache,
+                    FTC_Query    query,
+                    FTC_Node    *anode );
+
+
+
+ /* */
+
+FT_END_HEADER
+
+#endif /* __FT_CACHE_CACHE_H__ */
diff --git a/include/freetype/cache/ftcchunk.h b/include/freetype/cache/ftcchunk.h
deleted file mode 100644
index 8bc02a4..0000000
--- a/include/freetype/cache/ftcchunk.h
+++ /dev/null
@@ -1,168 +0,0 @@
-/***************************************************************************/
-/*                                                                         */
-/*  ftcchunk.h                                                             */
-/*                                                                         */
-/*    FreeType chunk cache (specification).                                */
-/*                                                                         */
-/*  Copyright 2000-2001 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.                                        */
-/*                                                                         */
-/***************************************************************************/
-
-
-  /*************************************************************************/
-  /*                                                                       */
-  /* Important: The functions defined in this file are only used to        */
-  /*            implement an abstract chunk cache class.  You need to      */
-  /*            provide additional logic to implement a complete cache.    */
-  /*            For example, see `ftcmetrx.h' and `ftcmetrx.c' which       */
-  /*            implement a glyph metrics cache based on this code.        */
-  /*                                                                       */
-  /*************************************************************************/
-
-
-  /*************************************************************************/
-  /*************************************************************************/
-  /*************************************************************************/
-  /*************************************************************************/
-  /*************************************************************************/
-  /*********                                                       *********/
-  /*********             WARNING, THIS IS BETA CODE.               *********/
-  /*********                                                       *********/
-  /*************************************************************************/
-  /*************************************************************************/
-  /*************************************************************************/
-  /*************************************************************************/
-  /*************************************************************************/
-
-
-#ifndef __FTCCHUNK_H__
-#define __FTCCHUNK_H__
-
-
-#include <ft2build.h>
-#include FT_CACHE_H
-#include FT_CACHE_MANAGER_H
-
-
-FT_BEGIN_HEADER
-
-
-  /* maximum number of chunk sets in a given chunk cache */
-#define FTC_MAX_CHUNK_SETS  16
-
-
-  typedef struct FTC_ChunkNodeRec_*   FTC_ChunkNode;
-  typedef struct FTC_ChunkSetRec_*    FTC_ChunkSet;
-  typedef struct FTC_ChunkCacheRec_*  FTC_ChunkCache;
-
-  typedef struct  FTC_ChunkNodeRec_
-  {
-    FTC_NodeRec   node;
-    FTC_ChunkSet  cset;
-    FT_UShort     item_count;
-    FT_UShort     item_start;
-    FT_Byte*      items;
-
-  } FTC_ChunkNodeRec;
-
-#define FTC_CHUNK_NODE( x )  ((FTC_ChunkNode)( x ))
-
-  /* a chunk set is used to categorize chunks of a given type */
-  typedef struct  FTC_ChunkSetRec_
-  {
-    FT_LruNodeRec   lru;
-    FT_UFast        hash;
-    FTC_ChunkCache  ccache;
-    FT_Fast         num_chunks;
-    FT_UInt         item_total;   /* total number of glyphs in set   */
-    FT_UInt         item_size;    /* size of each glyph item in set  */
-    FT_UInt         item_count;   /* number of glyph items per chunk */
-  
-  } FTC_ChunkSetRec;
-
-#define FTC_CHUNK_SET( x )  ((FTC_ChunkSet)( x ))
-
-#define FTC_CHUNK_SET_MEMORY( x )  (( x )->ccache->cache.memory)
-
-  /* the abstract chunk cache class */
-  typedef struct  FTC_ChunkCacheRec_
-  {
-    FTC_CacheRec  cache;
-    FT_LruList    cset_lru;  /* LRU list of chunk sets */
-  
-  } FTC_ChunkCacheRec;
-
-#define FTC_CHUNK_CACHE( x )  ((FTC_ChunkCache)( x ))
-
-
-  typedef struct  FTC_ChunkQueryRec_
-  {
-    /* input */
-    FT_UInt       gindex;      /* glyph index */
-
-    /* output */
-    FTC_ChunkSet  cset;
-  
-  } FTC_ChunkQueryRec, *FTC_ChunkQuery;
-
-
-  /*************************************************************************/
-  /*                                                                       */
-  /* These functions are exported so that they can be called from          */
-  /* user-provided cache classes; otherwise, they are really part of the   */
-  /* cache sub-system internals.                                           */
-  /*                                                                       */
-
-  FT_EXPORT( FT_Error )
-  ftc_chunk_node_init( FTC_ChunkNode  node,
-                       FTC_ChunkSet   cset,
-                       FT_UInt        index,
-                       FT_Bool        alloc );
-
-  /* chunk set objects */
-
-  FT_EXPORT( void )
-  ftc_chunk_node_done( FTC_ChunkNode  node );
-
-
-  FT_EXPORT( FT_Error )
-  ftc_chunk_set_init( FTC_ChunkSet    cset,
-                      FT_UInt         item_size,
-                      FT_UInt         item_count,
-                      FT_UInt         item_total,
-                      FTC_ChunkCache  cache );
-
-  FT_EXPORT( void )
-  ftc_chunk_set_done( FTC_ChunkSet  cset );
-
-
-  /* chunk cache objects */
-
-  FT_EXPORT( FT_Error )
-  ftc_chunk_cache_init( FTC_ChunkCache    cache,
-                        FT_LruList_Class  cset_class );
-
-  FT_EXPORT( void )
-  ftc_chunk_cache_done( FTC_ChunkCache  cache );
-
-
-  FT_EXPORT( FT_Error )
-  ftc_chunk_cache_lookup( FTC_ChunkCache  cache,
-                          FTC_ChunkQuery  query,
-                          FTC_ChunkNode  *anode );
-
- /* */
-
-FT_END_HEADER
-
-#endif /* __FTCCHUNK_H__ */
-
-
-/* END */
diff --git a/include/freetype/cache/ftcglyph.h b/include/freetype/cache/ftcglyph.h
index bc11c7c..bf9108b 100644
--- a/include/freetype/cache/ftcglyph.h
+++ b/include/freetype/cache/ftcglyph.h
@@ -64,84 +64,90 @@
 FT_BEGIN_HEADER
 
 
-  /* each glyph set is caracterized by a "glyph set type" which must be */
-  /* defined by sub-classes                                             */
-  typedef struct FTC_GlyphSetRec_*  FTC_GlyphSet;
+ /* each glyph set is caracterized by a "glyph set type" which must be */
+ /* defined by sub-classes..                                           */
+  typedef struct FTC_GlyphFamilyRec_*     FTC_GlyphFamily;
 
-  /* handle to a glyph cache node */
-  typedef struct FTC_GlyphNodeRec_*  FTC_GlyphNode;
+ /* handle to a glyph cache node */
+  typedef struct FTC_GlyphNodeRec_*       FTC_GlyphNode;
 
-  /* a glyph cache; its nodes are all glyph-specific */
-  typedef struct FTC_GlyphCacheRec_*  FTC_GlyphCache;
 
-  /* glyph sets class handle */
-  typedef const struct FTC_GlyphSet_ClassRec_*  FTC_GlyphSet_Class;
-
-
-  /* Size should be 24 bytes on 32-bit machines.                      */
-  /* Note that the node's hash is ((gset->hash << 16) | glyph_index); */
-  /* this _must_ be set properly by the glyph node initializer.       */
-  /*                                                                  */
+ /* size should be 24 + chunk size on 32-bit machines               */
+ /* note that the node's hash is ((gfam->hash << 16) | glyph_index) */
+ /* this _must_ be set properly by the glyph node initializer..     */
+ /*                                                                 */
   typedef struct  FTC_GlyphNodeRec_
   {
     FTC_NodeRec   node;
-    FTC_GlyphSet  gset;
+    FT_UShort     item_count;
+    FT_UShort     item_start;
 
   } FTC_GlyphNodeRec;
 
-#define FTC_GLYPH_NODE( x )    ((FTC_GlyphNode)( x ))
-#define FTC_GLYPH_NODE_P( x )  ((FTC_GlyphNode*)( x ))
+#define  FTC_GLYPH_NODE(x)    ((FTC_GlyphNode)(x))
+#define  FTC_GLYPH_NODE_P(x)  ((FTC_GlyphNode*)(x))
 
 
-  /* The glyph set structure.  Each glyph set is used to model a set of    */
-  /* glyphs of the same "type".  The type itself is defined in             */
-  /* sub-classes.                                                          */
-  /*                                                                       */
-  /* For example, the "image cache" uses face_id + character_pixel_sizes + */
-  /* image_format to characterize glyph sets.                              */
-  /*                                                                       */
-  /* A pure "master outlines" cache would only use face_id, etc.           */
-  /*                                                                       */
-  typedef struct  FTC_GlyphSetRec_
+
+  typedef struct  FTC_GlyphQueryRec_
   {
-    FT_LruNodeRec   lru;         /* glyph sets are LRU nodes within */
-    FTC_GlyphCache  gcache;      /* parent cache                    */
-    FT_UFast        hash;        /* must be set by initializer!     */
-    FT_Fast         num_glyphs;  /* destroyed when 0                */
+    FTC_QueryRec  query;
+    FT_UInt       gindex;
 
-  } FTC_GlyphSetRec;
+  } FTC_GlyphQueryRec, *FTC_GlyphQuery;
 
-#define FTC_GLYPH_SET( x )    ((FTC_GlyphSet)( x ))
-#define FTC_GLYPH_SET_P( x )  ((FTC_GlyphSet*)( x ))
+#define FTC_GLYPH_QUERY(x)  ((FTC_GlyphQuery)(x))
 
-#define FTC_GLYPH_SET_MEMORY( x )  (( x )->gcache->cache.memory)
 
 
-  /* retrieve glyph index of glyph node */
-#define FTC_GLYPH_NODE_GINDEX( x ) \
-          ((FT_UInt)(FTC_GLYPH_NODE( x )->node.hash & 0xFFFF))
 
-  /* the abstract glyph cache object */
-  typedef struct  FTC_GlyphCacheRec_
+ /* a glyph set is used to categorize glyphs of a given type */
+  typedef struct FTC_GlyphFamilyRec_
   {
-    FTC_CacheRec  cache;
-    FT_LruList    gset_lru;   /* LRU list of glyph sets */
+    FTC_FamilyRec  family;
+    FT_UInt32      hash;
+    FT_UInt        item_total;   /* total number of glyphs in family */
+    FT_UInt        item_count;   /* number of glyph items per node   */
 
-  } FTC_GlyphCacheRec;
+  } FTC_GlyphFamilyRec;
 
-#define FTC_GLYPH_CACHE( x )    ((FTC_GlyphCache)( x ))
-#define FTC_GLYPH_CACHE_P( x )  ((FTC_GlyphCache*)( x ))
 
+#define  FTC_GLYPH_FAMILY(x)     ((FTC_GlyphFamily)(x))
+#define  FTC_GLYPH_FAMILY_P(x)   ((FTC_GlyphFamily*)(x))
 
-  typedef struct  FTC_GlyphQueryRec_
-  {
-    /* input */
-    FT_UInt       gindex;
-   
-    /* output */
-    FTC_GlyphSet  gset;
+#define  FTC_GLYPH_FAMILY_MEMORY(x)  FTC_FAMILY(x)->cache->memory
 
-  } FTC_GlyphQueryRec, *FTC_GlyphQuery;
+/* each glyph node contains a 'chunk' of glyph items */
+/* translate a glyph index into a chunk index        */
+#define  FTC_GLYPH_FAMILY_CHUNK(gfam,gindex)   \
+      ( (gindex) / FTC_GLYPH_FAMILY(gfam)->item_count )
+
+/* find a glyph index's chunk, and return its start index */
+/*                                                        */
+#define  FTC_GLYPH_FAMILY_START(gfam,gindex)    \
+      ( FTC_GLYPH_FAMILY_CHUNK(gfam,gindex) * FTC_GLYPH_FAMILY(gfam)->item_count )
+
+/* compute a glyph request's hash value */
+/*                                      */
+#define  FTC_GLYPH_FAMILY_HASH(gfam,gindex)                           \
+      ((FT_UFast)( (FTC_GLYPH_FAMILY(gfam)->hash << 16) |             \
+                   (FTC_GLYPH_FAMILY_CHUNK(gfam,gindex) & 0xFFFF) ))
+
+/* must be called in a FTC_Family_CompareFunc to update the query */
+/* whenever a glyph set is matched in the lookup.. or when it     */
+/* is created                                                     */
+/*                                                                */
+#define  FTC_GLYPH_FAMILY_FOUND(gfam,gquery)                                  \
+           do {                                                               \
+             FTC_QUERY(gquery)->family = FTC_FAMILY(gfam);                    \
+             FTC_QUERY(gquery)->hash   =                                      \
+                FTC_GLYPH_FAMILY_HASH(gfam,FTC_GLYPH_QUERY(gquery)->gindex);  \
+           } while (0)
+
+
+/* retrieve glyph index of glyph node */
+#define  FTC_GLYPH_NODE_GINDEX(x)  \
+             ((FT_UInt)(FTC_GLYPH_NODE(x)->node.hash & 0xFFFF))
 
 
   /*************************************************************************/
@@ -153,44 +159,42 @@ FT_BEGIN_HEADER
 
   /* must be called by derived FTC_Node_InitFunc routines */
   FT_EXPORT( void )
-  ftc_glyph_node_init( FTC_GlyphNode  node,
-                       FT_UInt        gindex,  /* glyph index for node */
-                       FTC_GlyphSet   gset );
+  ftc_glyph_node_init( FTC_GlyphNode     node,
+                       FT_UInt           gindex,  /* glyph index for node */
+                       FTC_GlyphFamily   gfam );
+
+  /* returns TRUE iff the query's glyph index correspond to the node  */
+  /* this assume that the "family" and "hash" fields of the query are */
+  /* already correctly set..                                          */
+  /*                                                                  */
+  FT_EXPORT( FT_Bool )
+  ftc_glyph_node_compare( FTC_GlyphNode    gnode,
+                          FTC_GlyphQuery   gquery );
+
 
   /* must be called by derived FTC_Node_DoneFunc routines */
   FT_EXPORT( void )
-  ftc_glyph_node_done( FTC_GlyphNode  node );
+  ftc_glyph_node_done( FTC_GlyphNode  node,
+                       FTC_Cache      cache );
 
 
-  /* can be used as an FTC_LruNode_InitFunc or called by sub-classes */
+ /* must be called by derived FTC_Family_InitFunc, calls "ftc_family_init" */
   FT_EXPORT( FT_Error )
-  ftc_glyph_set_init( FTC_GlyphSet  gset,
-                      FT_LruList    list );
-
-  /* can be used as an FTC_LruNode_DoneFunc or called by sub-classes */
-  FT_EXPORT( void )
-  ftc_glyph_set_done( FTC_GlyphSet  gset );
+  ftc_glyph_family_init( FTC_GlyphFamily  gfam,
+                         FT_UInt32        hash,
+                         FT_UInt          item_count,
+                         FT_UInt          item_total,
+                         FTC_GlyphQuery   gquery,
+                         FTC_Cache        cache );
 
 
-  /* can be used as an FTC_Cache_DoneFunc or called by sub-classes */
   FT_EXPORT( void )
-  ftc_glyph_cache_done( FTC_GlyphCache  cache );
+  ftc_glyph_family_done( FTC_GlyphFamily  gfam );
 
-  /* must be called in an FTC_Cache_InitFunc! */
-  FT_EXPORT( FT_Error )
-  ftc_glyph_cache_init( FTC_GlyphCache    cache,
-                        FT_LruList_Class  gset_class );
-
-  /* can be called directly or from sub-classes */
-  FT_EXPORT( FT_Error )
-  ftc_glyph_cache_lookup( FTC_GlyphCache  cache,
-                          FTC_GlyphQuery  query,
-                          FTC_GlyphNode  *anode );
 
 
+ /* */
+ 
 FT_END_HEADER
 
-#endif /* __FTCGLYPH_H__ */
-
-
-/* END */
+#endif /* __FTC_GLYPH_H__ */
diff --git a/include/freetype/cache/ftcimage.h b/include/freetype/cache/ftcimage.h
index 55e3e6c..e27b398 100644
--- a/include/freetype/cache/ftcimage.h
+++ b/include/freetype/cache/ftcimage.h
@@ -70,6 +70,7 @@ FT_BEGIN_HEADER
                                    ftc_image_flag_monochrome
   /* anti-aliased bitmap */
 #define ftc_image_grays            ftc_image_format_bitmap
+
   /* scaled outline */
 #define ftc_image_outline          ftc_image_format_outline
 
@@ -77,9 +78,130 @@ FT_BEGIN_HEADER
   /*************************************************************************/
   /*                                                                       */
   /* <Struct>                                                              */
+  /*    FTC_ImageDesc                                                      */
+  /*                                                                       */
+  /* <Description>                                                         */
+  /*    A simple structure used to describe a given glyph image category.  */
+  /*    note that this is different from @FTC_Image_Desc                   */
+  /*                                                                       */
+  /* <Fields>                                                              */
+  /*    size    :: An FTC_SizeRec used to describe the glyph's face &      */
+  /*               size.                                                   */
+  /*                                                                       */
+  /*    type    :: The glyph image's type. note that it's a 32-bit uint    */
+  /*                                                                       */
+  /* <Note>                                                                */
+  /*   this type deprecates @FTC_Image_Desc                                */
+  /*                                                                       */
+  typedef struct  FTC_ImageDesc_
+  {
+    FTC_FontRec  font;
+    FT_UInt32    type;
+
+  } FTC_ImageDesc;
+
+ /* */
+#define  FTC_IMAGE_DESC_COMPARE( d1, d2 )                        \
+             ( FTC_FONT_COMPARE( &(d1)->font, &(d2)->font ) &&   \
+               (d1)->type == (d2)->type         )
+
+#define  FTC_IMAGE_DESC_HASH(d)                         \
+             (FT_UFast)( FTC_FONT_HASH(&(d)->font) ^    \
+                         ((d)->type << 4)    )
+
+  /*************************************************************************/
+  /*                                                                       */
+  /* <Type>                                                                */
+  /*    FTC_ImageCache                                                     */
+  /*                                                                       */
+  /* <Description>                                                         */
+  /*    A handle to an glyph image cache object.  They are designed to     */
+  /*    hold many distinct glyph images, while not exceeding a certain     */
+  /*    memory threshold.                                                  */
+  /*                                                                       */
+  typedef struct FTC_ImageCacheRec_*  FTC_ImageCache;
+
+
+  /*************************************************************************/
+  /*                                                                       */
+  /* <Function>                                                            */
+  /*    FTC_ImageCache_New                                                 */
+  /*                                                                       */
+  /* <Description>                                                         */
+  /*    Creates a new glyph image cache.                                   */
+  /*                                                                       */
+  /* <Input>                                                               */
+  /*    manager :: The parent manager for the image cache.                 */
+  /*                                                                       */
+  /* <Output>                                                              */
+  /*    acache  :: A handle to the new glyph image cache object.           */
+  /*                                                                       */
+  /* <Return>                                                              */
+  /*    FreeType error code.  0 means success.                             */
+  /*                                                                       */
+  FT_EXPORT( FT_Error )
+  FTC_ImageCache_New( FTC_Manager      manager,
+                      FTC_ImageCache  *acache );
+
+
+  /*************************************************************************/
+  /*                                                                       */
+  /* <Function>                                                            */
+  /*    FTC_ImageCache_Lookup                                              */
+  /*                                                                       */
+  /* <Description>                                                         */
+  /*    Retrieves a given glyph image from a glyph image cache             */
+  /*    and 'acquire' it. This prevents the glyph image from being         */
+  /*    flushed out of the cache, until @FTC_Image_Cache_Release is        */
+  /*    called                                                             */
+  /*                                                                       */
+  /* <Input>                                                               */
+  /*    cache  :: A handle to the source glyph image cache.                */
+  /*                                                                       */
+  /*    desc   :: A pointer to a glyph image descriptor.                   */
+  /*                                                                       */
+  /*    gindex :: The glyph index to retrieve.                             */
+  /*                                                                       */
+  /* <Output>                                                              */
+  /*    aglyph :: The corresponding FT_Glyph object.  0 in case of         */
+  /*              failure.                                                 */
+  /*                                                                       */
+  /*    anode  :: an opaque cache node pointer that will be used           */
+  /*              to release the glyph once it becomes unuseful.           */
+  /*              can be NULL, in which case this function will            */
+  /*              have the same effect than @FTC_Image_Cache_Lookup        */
+  /*                                                                       */
+  /* <Return>                                                              */
+  /*    FreeType error code.  0 means success.                             */
+  /*                                                                       */
+  /* <Note>                                                                */
+  /*    The returned glyph is owned and managed by the glyph image cache.  */
+  /*    Never try to transform or discard it manually!  You can however    */
+  /*    create a copy with FT_Glyph_Copy() and modify the new one.         */
+  /*                                                                       */
+  /*    if 'anode' is NULL                                                 */
+  /*                                                                       */
+  /*    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... */
+  /*                                                                       */
+  FT_EXPORT( FT_Error )
+  FTC_ImageCache_Lookup( FTC_ImageCache  cache,
+                         FTC_ImageDesc*  desc,
+                         FT_UInt          gindex,
+                         FT_Glyph        *aglyph,
+                         FTC_Node        *anode );
+
+  /* */
+
+
+  /*************************************************************************/
+  /*                                                                       */
+  /* <Struct>                                                              */
   /*    FTC_Image_Desc                                                     */
   /*                                                                       */
   /* <Description>                                                         */
+  /*    THIS TYPE IS DEPRECATED. USE @FTC_ImageDesc instead..              */
   /*    A simple structure used to describe a given glyph image category.  */
   /*                                                                       */
   /* <Fields>                                                              */
@@ -88,6 +210,9 @@ FT_BEGIN_HEADER
   /*                                                                       */
   /*    image_type :: The glyph image's type.                              */
   /*                                                                       */
+  /* <Note>                                                                */
+  /*                                                                       */
+  /*                                                                       */
   typedef struct  FTC_Image_Desc_
   {
     FTC_FontRec  font;
@@ -96,27 +221,16 @@ FT_BEGIN_HEADER
   } FTC_Image_Desc;
 
 
- /* */
-#define FTC_IMAGE_DESC_COMPARE( d1, d2 )                    \
-          ( FTC_FONT_COMPARE( &(d1)->font, &(d2)->font ) && \
-            (d1)->image_type == (d2)->image_type         )
-
-#define FTC_IMAGE_DESC_HASH( d )                  \
-          (FT_UFast)( FTC_FONT_HASH(&(d)->font) ^ \
-                      ((d)->image_type << 4)    )
-
-
   /*************************************************************************/
   /*                                                                       */
   /* <Type>                                                                */
   /*    FTC_Image_Cache                                                    */
   /*                                                                       */
   /* <Description>                                                         */
-  /*    A handle to an glyph image cache object.  They are designed to     */
-  /*    hold many distinct glyph images, while not exceeding a certain     */
-  /*    memory threshold.                                                  */
+  /*    THIS TYPE IS DEPRECATED, USE @FTC_ImageCache instead               */
   /*                                                                       */
-  typedef struct FTC_Image_CacheRec_*  FTC_Image_Cache;
+  typedef FTC_ImageCache  FTC_Image_Cache;
+
 
 
   /*************************************************************************/
@@ -125,6 +239,7 @@ FT_BEGIN_HEADER
   /*    FTC_Image_Cache_New                                                */
   /*                                                                       */
   /* <Description>                                                         */
+  /*    THIS FUNCTION IS DEPRECATED, USE @FTC_ImageCache_New instead       */
   /*    Creates a new glyph image cache.                                   */
   /*                                                                       */
   /* <Input>                                                               */
@@ -147,7 +262,7 @@ FT_BEGIN_HEADER
   /*    FTC_Image_Cache_Lookup                                             */
   /*                                                                       */
   /* <Description>                                                         */
-  /*    Retrieves a given glyph image from a glyph image cache.            */
+  /*    THIS FUNCTION IS DEPRECATED. USE @FTC_ImageCache_Lookup instead    */
   /*                                                                       */
   /* <Input>                                                               */
   /*    cache  :: A handle to the source glyph image cache.                */
@@ -172,15 +287,16 @@ FT_BEGIN_HEADER
   /*    taken by the glyphs it holds, the returned glyph might disappear   */
   /*    on a later invocation of this function!  It's a cache after all... */
   /*                                                                       */
+  /*    use @FTC_ImageCache_Lookup to "lock" the glyph as long as you      */
+  /*    need it..                                                          */
+  /*                                                                       */
   FT_EXPORT( FT_Error )
   FTC_Image_Cache_Lookup( FTC_Image_Cache  cache,
                           FTC_Image_Desc*  desc,
                           FT_UInt          gindex,
                           FT_Glyph        *aglyph );
 
-
-  /* */
-
+ /* */
 
 FT_END_HEADER
 
diff --git a/include/freetype/cache/ftcmanag.h b/include/freetype/cache/ftcmanag.h
index edc092d..aa32cd0 100644
--- a/include/freetype/cache/ftcmanag.h
+++ b/include/freetype/cache/ftcmanag.h
@@ -66,7 +66,7 @@
 #include <ft2build.h>
 #include FT_CACHE_H
 #include FT_CACHE_INTERNAL_LRU_H
-
+#include FT_CACHE_INTERNAL_CACHE_H
 
 FT_BEGIN_HEADER
 
@@ -81,22 +81,43 @@ FT_BEGIN_HEADER
 
 #define FTC_MAX_FACES_DEFAULT  2
 #define FTC_MAX_SIZES_DEFAULT  4
-#define FTC_MAX_BYTES_DEFAULT  100000L  /* 100kByte by default! */
+#define FTC_MAX_BYTES_DEFAULT  200000L  /* ~200 KB bytes by default */
 
   /* maximum number of caches registered in a single manager */
 #define FTC_MAX_CACHES         16
 
 
-  /* handle to cache object */
-  typedef struct FTC_CacheRec_*  FTC_Cache;
+  typedef struct FTC_FamilyEntryRec_
+  {
+    FTC_Family       family;
+    FTC_Cache        cache;
+    FT_UInt          index;
+    FT_UInt          link;
+
+  } FTC_FamilyEntryRec, *FTC_FamilyEntry;
+
+#define  FTC_FAMILY_ENTRY_NONE  ((FT_UInt)-1)
+
+  typedef struct FTC_FamilyTableRec_
+  {
+    FT_UInt          count;
+    FT_UInt          size;
+    FTC_FamilyEntry  entries;
+    FT_UInt          free;
+  
+  } FTC_FamilyTableRec, *FTC_FamilyTable;
 
-  /* handle to cache class */
-  typedef const struct FTC_Cache_ClassRec_*  FTC_Cache_Class;
 
-  /* handle to cache node */
-  typedef struct FTC_NodeRec_*  FTC_Node;
+  FT_LOCAL FT_Error 
+  ftc_family_table_alloc( FTC_FamilyTable   table,
+                          FT_Memory         memory,
+                          FTC_FamilyEntry  *aentry );
 
 
+  FT_LOCAL void 
+  ftc_family_table_free( FTC_FamilyTable  table,
+                         FT_UInt          index );
+
 
   /*************************************************************************/
   /*                                                                       */
@@ -146,6 +167,8 @@ FT_BEGIN_HEADER
     FT_Pointer          request_data;
     FTC_Face_Requester  request_face;
 
+    FTC_FamilyTableRec   families;
+
   } FTC_ManagerRec;
 
 
@@ -174,116 +197,6 @@ FT_BEGIN_HEADER
   FTC_Manager_Compress( FTC_Manager  manager );
 
 
-  /*************************************************************************/
-  /*************************************************************************/
-  /*****                                                               *****/
-  /*****                   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 held by  */
-  /* the cache.  It can be an individual glyph image, a set of bitmaps     */
-  /* glyphs for a given size, some metrics, etc.                           */
-  /*                                                                       */
-
-
-  /* structure size should be 20 bytes on 32-bits machines */  
-  typedef struct  FTC_NodeRec_
-  {
-    FTC_Node   mru_next;     /* circular mru list pointer          */
-    FTC_Node   mru_prev;     /* circular mru list pointer          */
-    FTC_Node   link;         /* used for hashing                   */
-    FT_UInt32  hash;         /* used for hashing too               */
-    FT_UShort  cache_index;  /* index of cache the node belongs to */
-    FT_Short   ref_count;    /* reference count for this node      */
-  
-  } FTC_NodeRec;
-
-#define FTC_NODE( x )    ((FTC_Node)( x ))
-#define FTC_NODE_P( x )  ((FTC_Node*)( x ))
-
-
-  /* each cache really implements a dynamic hash table to manage its nodes */
-  typedef struct  FTC_CacheRec_
-  {
-    FTC_Manager      manager;
-    FT_Memory        memory;
-    FTC_Cache_Class  clazz;
-
-    FT_UInt          cache_index;  /* in manager's table         */
-    FT_Pointer       cache_data;   /* used by cache node methods */
-
-    FT_UFast         nodes;
-    FT_UFast         size;
-    FTC_Node*        buckets;
-
-  } FTC_CacheRec;
-
-
-#define FTC_CACHE( x )    ((FTC_Cache)( x ))
-#define FTC_CACHE_P( x )  ((FTC_Cache*)( x ))
-
-
-  /* initialize a given cache */
-  typedef FT_Error
-  (*FTC_Cache_InitFunc)( FTC_Cache  cache );
-  
-  /* finalize a given cache */
-  typedef void
-  (*FTC_Cache_DoneFunc)( FTC_Cache  cache );
-
-  /* initialize a new cache node */
-  typedef FT_Error
-  (*FTC_Node_InitFunc)( FTC_Node    node,
-                        FT_Pointer  type,
-                        FTC_Cache   cache );
-
-  /* compute the weight of a given cache node */
-  typedef FT_ULong
-  (*FTC_Node_WeightFunc)( FTC_Node   node,
-                          FTC_Cache  cache );
-
-  /* compare a node to a given key pair */
-  typedef FT_Bool
-  (*FTC_Node_CompareFunc)( FTC_Node    node,
-                           FT_Pointer  key,
-                           FTC_Cache   cache );
-
-  /* finalize a given cache node */
-  typedef void
-  (*FTC_Node_DoneFunc)( FTC_Node   node,
-                        FTC_Cache  cache );
-
-
-  typedef struct  FTC_Cache_ClassRec_
-  {
-    FT_UInt               cache_size;
-    FTC_Cache_InitFunc    cache_init;
-    FTC_Cache_DoneFunc    cache_done;
-    
-    FT_UInt               node_size;
-    FTC_Node_InitFunc     node_init;
-    FTC_Node_WeightFunc   node_weight;
-    FTC_Node_CompareFunc  node_compare;
-    FTC_Node_DoneFunc     node_done;
-  
-  } FTC_Cache_ClassRec;
-
-  /* */
-
-#define FTC_CACHE_RESIZE_TEST( c )       \
-          ( (c)->nodes*3 < (c)->size  || \
-            (c)->size*3  < (c)->nodes )      
-
-
   /* this must be used internally for the moment */
   FT_EXPORT( FT_Error )
   FTC_Manager_Register_Cache( FTC_Manager      manager,
@@ -291,37 +204,16 @@ FT_BEGIN_HEADER
                               FTC_Cache       *acache );
 
 
-  /* can be used directly as FTC_Cache_DoneFunc(), or called by custom */
-  /* cache finalizers                                                  */
-  FT_EXPORT( void )
-  ftc_cache_done( FTC_Cache  cache );
+ /* can be called to increment a node's reference count */
+  FT_EXPORT(void)
+  FTC_Node_Ref( FTC_Node     node,
+                FTC_Manager  manager );
 
-  /* initalize the hash table within the cache */
-  FT_EXPORT( FT_Error )
-  ftc_cache_init( FTC_Cache  cache );
-
-  /* can be used when FTC_CACHE_RESIZE_TEST returns TRUE after a node */
-  /* insertion                                                        */
-  FT_EXPORT( void )
-  ftc_cache_resize( FTC_Cache  cache );
 
-
-  /* can be called when the key's hash value has been computed */
-  FT_EXPORT( FT_Error )
-  ftc_cache_lookup_node( FTC_Cache   cache,
-                         FT_UFast    key_hash,
-                         FT_Pointer  key,
-                         FTC_Node   *anode );
-
-  /* can be called to increment a node's reference count */
-  FT_EXPORT( void )
-  ftc_node_ref( FTC_Node   node,
-                FTC_Cache  cache );
-
-  /* can be called to decrement a node's reference count */
-  FT_EXPORT( void )
-  ftc_node_unref( FTC_Node   node,
-                  FTC_Cache  cache );
+ /* can be called to decrement a node's reference count */
+  FT_EXPORT(void)
+  FTC_Node_Unref( FTC_Node     node,
+                  FTC_Manager  manager );
 
  /* */
 
diff --git a/include/freetype/cache/ftcsbits.h b/include/freetype/cache/ftcsbits.h
index 1a30846..d051b7c 100644
--- a/include/freetype/cache/ftcsbits.h
+++ b/include/freetype/cache/ftcsbits.h
@@ -50,20 +50,6 @@ FT_BEGIN_HEADER
 
   /*************************************************************************/
   /*                                                                       */
-  /* <Type>                                                                */
-  /*    FTC_SBit_Cache                                                     */
-  /*                                                                       */
-  /* <Description>                                                         */
-  /*    A handle to a small bitmap cache.  These are special cache objects */
-  /*    used to store small glyph bitmaps (and anti-aliased pixmaps) in a  */
-  /*    much more efficient way than the traditional glyph image cache     */
-  /*    implemented by FTC_Image_Cache.                                    */
-  /*                                                                       */
-  typedef struct FTC_SBit_CacheRec_*  FTC_SBit_Cache;
-
-
-  /*************************************************************************/
-  /*                                                                       */
   /* <Struct>                                                              */
   /*    FTC_SBitRec                                                        */
   /*                                                                       */
@@ -112,6 +98,100 @@ FT_BEGIN_HEADER
   } FTC_SBitRec;
 
 
+
+  /*************************************************************************/
+  /*                                                                       */
+  /* <Type>                                                                */
+  /*    FTC_SBit_Cache                                                     */
+  /*                                                                       */
+  /* <Description>                                                         */
+  /*    A handle to a small bitmap cache.  These are special cache objects */
+  /*    used to store small glyph bitmaps (and anti-aliased pixmaps) in a  */
+  /*    much more efficient way than the traditional glyph image cache     */
+  /*    implemented by FTC_Image_Cache.                                    */
+  /*                                                                       */
+  typedef struct FTC_SBitCacheRec_*   FTC_SBitCache;
+  
+  /*************************************************************************/
+  /*                                                                       */
+  /* <Type>                                                                */
+  /*    FTC_SBit_Cache                                                     */
+  /*                                                                       */
+  /* <Description>                                                         */
+  /*    deprecated. please use @FTC_SBitCache instead                      */
+  /*                                                                       */
+  typedef FTC_SBitCache   FTC_SBit_Cache;
+
+
+
+
+  /*************************************************************************/
+  /*                                                                       */
+  /* <Function>                                                            */
+  /*    FTC_SBitCache_New                                                  */
+  /*                                                                       */
+  /* <Description>                                                         */
+  /*    Creates a new cache to store small glyph bitmaps.                  */
+  /*                                                                       */
+  /* <Input>                                                               */
+  /*    manager :: A handle to the source cache manager.                   */
+  /*                                                                       */
+  /* <Output>                                                              */
+  /*    acache  :: A handle to the new sbit cache.  NULL in case of error. */
+  /*                                                                       */
+  /* <Return>                                                              */
+  /*    FreeType error code.  0 means success.                             */
+  /*                                                                       */
+  FT_EXPORT( FT_Error )
+  FTC_SBitCache_New( FTC_Manager     manager,
+                     FTC_SBitCache  *acache );
+
+
+  /*************************************************************************/
+  /*                                                                       */
+  /* <Function>                                                            */
+  /*    FTC_SBitCache_Lookup                                               */
+  /*                                                                       */
+  /* <Description>                                                         */
+  /*    Looks up a given small glyph bitmap in a given sbit cache and      */
+  /*    "lock" it to prevent its flushing from the cache until needed      */
+  /*                                                                       */
+  /* <Input>                                                               */
+  /*    cache  :: A handle to the source sbit cache.                       */
+  /*    desc   :: A pointer to the glyph image descriptor.                 */
+  /*    gindex :: The glyph index.                                         */
+  /*                                                                       */
+  /* <Output>                                                              */
+  /*    sbit   :: A handle to a small bitmap descriptor.                   */
+  /*                                                                       */
+  /*    anode  :: an opaque cache node pointer that will be used           */
+  /*              to release the sbit once it becomes unuseful.            */
+  /*              can be NULL, in which case this function will            */
+  /*              have the same effect than @FTC_SBit_Cache_Lookup         */
+  /*                                                                       */
+  /* <Return>                                                              */
+  /*    FreeType error code.  0 means success.                             */
+  /*                                                                       */
+  /* <Note>                                                                */
+  /*    The small bitmap descriptor and its bit buffer are owned by the    */
+  /*    cache and should never be freed by the application.  They might    */
+  /*    as well disappear from memory on the next cache lookup, so don't   */
+  /*    treat them as persistent data.                                     */
+  /*                                                                       */
+  /*    The descriptor's `buffer' field is set to 0 to indicate a missing  */
+  /*    glyph bitmap.                                                      */
+  /*                                                                       */
+  FT_EXPORT( FT_Error )
+  FTC_SBitCache_Lookup( FTC_SBitCache    cache,
+                        FTC_ImageDesc*   desc,
+                        FT_UInt          gindex,
+                        FTC_SBit        *sbit,
+                        FTC_Node        *anode );
+
+
+  /* */
+
+
   /*************************************************************************/
   /*                                                                       */
   /* <Function>                                                            */
@@ -169,9 +249,6 @@ FT_BEGIN_HEADER
                          FTC_SBit        *sbit );
 
 
-  /* */
-
-
 FT_END_HEADER
 
 #endif /* __FTCSBITS_H__ */
diff --git a/include/freetype/cache/ftlru.h b/include/freetype/cache/ftlru.h
index d390814..9d51e57 100644
--- a/include/freetype/cache/ftlru.h
+++ b/include/freetype/cache/ftlru.h
@@ -58,14 +58,11 @@
 #ifndef __FTLRU_H__
 #define __FTLRU_H__
 
-
 #include <ft2build.h>
 #include FT_FREETYPE_H
 
-
 FT_BEGIN_HEADER
 
-
   /* generic list key type */
   typedef FT_Pointer  FT_LruKey;
 
@@ -75,9 +72,8 @@ FT_BEGIN_HEADER
   /* list class handle */
   typedef const struct FT_LruList_ClassRec_*  FT_LruList_Class;
 
-  /* a list node handle */
-  typedef struct FT_LruNodeRec_*  FT_LruNode;
-  
+  /* an list node handle */
+  typedef struct  FT_LruNodeRec_*   FT_LruNode;
 
   /* the list node structure */
   typedef struct  FT_LruNodeRec_
@@ -96,25 +92,25 @@ FT_BEGIN_HEADER
     FT_LruNode         nodes;
     FT_UInt            max_nodes;
     FT_UInt            num_nodes;
-    FT_Pointer         user_data;
+    FT_Pointer         data;
 
   } FT_LruListRec;
 
 
   /* initialize a list list */
   typedef FT_Error  (*FT_LruList_InitFunc)( FT_LruList  list );
-  
-  /* finalize a list list */
+
+ /* finalize a list list */
   typedef void      (*FT_LruList_DoneFunc)( FT_LruList  list );
 
   /* this method is used to initialize a new list element node */
   typedef FT_Error  (*FT_LruNode_InitFunc)( FT_LruNode  node,
                                             FT_LruKey   key,
-                                            FT_LruList  list );
+                                            FT_Pointer  data );
 
   /* this method is used to finalize a given list element node */
   typedef void      (*FT_LruNode_DoneFunc)( FT_LruNode  node,
-                                            FT_LruList  list );
+                                            FT_Pointer  data );
 
   /* If defined, this method is called when the list if full        */
   /* during the lookup process -- it is used to change the contents */
@@ -122,14 +118,14 @@ FT_BEGIN_HEADER
   /* then `init_element()'.  Set it to 0 for default behaviour.     */
   typedef FT_Error  (*FT_LruNode_FlushFunc)( FT_LruNode  node,
                                              FT_LruKey   new_key,
-                                             FT_LruList  list );
+                                             FT_Pointer  data );
 
   /* 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.                      */
   typedef FT_Bool   (*FT_LruNode_CompareFunc)( FT_LruNode  node,
                                                FT_LruKey   key,
-                                               FT_LruList  list );
+                                               FT_Pointer  data );
 
   /* A selector is used to indicate whether a given list element node */
   /* is part of a selection for FT_LruList_Remove_Selection().  The   */
@@ -137,7 +133,7 @@ FT_BEGIN_HEADER
   /* node is part of it.                                              */
   typedef FT_Bool    (*FT_LruNode_SelectFunc)( FT_LruNode  node,
                                                FT_Pointer  data,
-                                               FT_LruList  list );
+                                               FT_Pointer  list_data );
 
   /* LRU class */
   typedef struct  FT_LruList_ClassRec_
@@ -145,7 +141,7 @@ FT_BEGIN_HEADER
     FT_UInt                 list_size;
     FT_LruList_InitFunc     list_init;      /* optional */
     FT_LruList_DoneFunc     list_done;      /* optional */
-  
+
     FT_UInt                 node_size;
     FT_LruNode_InitFunc     node_init;     /* MANDATORY */
     FT_LruNode_DoneFunc     node_done;     /* optional  */
@@ -190,7 +186,7 @@ FT_BEGIN_HEADER
                                FT_Pointer             select_data );
 
  /* */
- 
+
 FT_END_HEADER
 
 #endif /* __FTLRU_H__ */
diff --git a/include/freetype/config/ftheader.h b/include/freetype/config/ftheader.h
index b4ec98b..bd64ce4 100644
--- a/include/freetype/config/ftheader.h
+++ b/include/freetype/config/ftheader.h
@@ -467,7 +467,7 @@
 
 #define FT_CACHE_INTERNAL_LRU_H    <freetype/cache/ftlru.h>
 #define FT_CACHE_INTERNAL_GLYPH_H  <freetype/cache/ftcglyph.h>
-#define FT_CACHE_INTERNAL_CHUNK_H  <freetype/cache/ftcchunk.h>
+#define FT_CACHE_INTERNAL_CACHE_H  <freetype/cache/ftccache.h>
 
   /* now include internal headers definitions from <freetype/internal/...> */
 
diff --git a/include/freetype/ftcache.h b/include/freetype/ftcache.h
index d28b21d..b059102 100644
--- a/include/freetype/ftcache.h
+++ b/include/freetype/ftcache.h
@@ -57,6 +57,37 @@ FT_BEGIN_HEADER
   /*   This section describes the FreeType 2 cache sub-system which is     */
   /*   stile in beta.                                                      */
   /*                                                                       */
+  /* <Order>                                                               */
+  /*   FTC_Manager                                                         */
+  /*   FTC_FaceID                                                          */
+  /*   FTC_Face_Requester                                                  */
+  /*                                                                       */
+  /*   FTC_Manager_New                                                     */
+  /*   FTC_Manager_Lookup_Face                                             */
+  /*   FTC_Manager_Lookup_Size                                             */
+  /*                                                                       */
+  /*   FTC_Node                                                            */
+  /*   FTC_Node_Unref                                                      */
+  /*                                                                       */
+  /*   FTC_Font                                                            */
+  /*   FTC_ImageDesc                                                       */
+  /*   FTC_ImageCache                                                      */
+  /*   FTC_ImageCache_New                                                  */
+  /*   FTC_ImageCache_Lookup                                               */
+  /*                                                                       */
+  /*   FTC_SBit                                                            */
+  /*   FTC_SBitCache                                                       */
+  /*   FTC_SBitCache_New                                                   */
+  /*   FTC_SBitCache_Lookup                                                */
+  /*                                                                       */
+  /*                                                                       */
+  /*   FTC_Image_Desc                                                      */
+  /*   FTC_Image_Cache                                                     */
+  /*   FTC_Image_Cache_Lookup                                              */
+  /*                                                                       */
+  /*   FTC_SBit_Cache                                                      */
+  /*   FTC_Sbit_Cache_Lookup                                               */
+  /*                                                                       */
   /*************************************************************************/
 
 
@@ -157,7 +188,6 @@ FT_BEGIN_HEADER
                        ((f)->pix_width << 8)          ^ \
                        ((f)->pix_height)              )
 
-
   /*************************************************************************/
   /*                                                                       */
   /* <Type>                                                                */
@@ -194,6 +224,26 @@ FT_BEGIN_HEADER
 
   /*************************************************************************/
   /*                                                                       */
+  /* <Type>                                                                */
+  /*    FTC_Node                                                           */
+  /*                                                                       */
+  /* <Description>                                                         */
+  /*    an opaque handle to a cache node object. Each cache node is        */
+  /*    reference-counted. A node with a count of 0 might be flushed       */
+  /*    out of a full cache whenever a lookup request is performed         */
+  /*                                                                       */
+  /*    when you lookup nodes, you have the ability to "acquire" them,     */
+  /*    i.e. increment their reference count. This will prevent the node   */
+  /*    from being flushed out of the cache until you explicitely          */
+  /*    "release" it (see @FTC_Node_Release)                               */
+  /*                                                                       */
+  /*    see @FTC_BitsetCache_Lookup and @FTC_ImageCache_Lookup             */
+  /*                                                                       */
+  typedef struct FTC_NodeRec_*     FTC_Node;
+
+
+  /*************************************************************************/
+  /*                                                                       */
   /* <Function>                                                            */
   /*    FTC_Manager_New                                                    */
   /*                                                                       */
@@ -349,6 +399,24 @@ FT_BEGIN_HEADER
                            FT_Face     *aface,
                            FT_Size     *asize );
 
+  /*************************************************************************/
+  /*                                                                       */
+  /* <Function>                                                            */
+  /*    FTC_Node_Unref                                                     */
+  /*                                                                       */
+  /* <Description>                                                         */
+  /*    decrement a cache node's internal reference count. when the count  */
+  /*    reaches 0, it is not destroyed but becomes eligible for subsequent */
+  /*    cache flushes..                                                    */
+  /*                                                                       */
+  /* <Input>                                                               */
+  /*    node    :: cache node handle                                       */
+  /*    manager :: cache manager handle                                    */
+  /*                                                                       */
+  FT_EXPORT( void )
+  FTC_Node_Unref( FTC_Node     node,
+                  FTC_Manager  manager );
+
   /* */
 
 
diff --git a/src/autohint/ahhint.c b/src/autohint/ahhint.c
index b6b2c78..eb9e13b 100644
--- a/src/autohint/ahhint.c
+++ b/src/autohint/ahhint.c
@@ -384,8 +384,8 @@
     ah_debug_disable_horz = no_horz_edges;
     ah_debug_disable_vert = no_vert_edges;
 #else
-    UNUSED( no_horz_edges );
-    UNUSED( no_vert_edges );
+    FT_UNUSED(no_horz_edges);
+    FT_UNUSED(no_vert_edges);    
 #endif
     /* AH_Interpolate_Blue_Edges( hinter ); -- doesn't seem to help      */
     /* reduce the problem of the disappearing eye in the `e' of Times... */
diff --git a/src/base/ftdbgmem.c b/src/base/ftdbgmem.c
index 7f50bd6..8939b13 100644
--- a/src/base/ftdbgmem.c
+++ b/src/base/ftdbgmem.c
@@ -662,8 +662,8 @@
 
 
 #else  /* !FT_DEBUG_MEMORY */
-
- /* ANSI C doesn't like empty source files */
+ 
+ /* ansi C doesn't like empty source files */
   extern const FT_Byte  _debug_mem_dummy = 0;
 
 #endif /* !FT_DEBUG_MEMORY */
diff --git a/src/cache/Jamfile b/src/cache/Jamfile
index 1cbdc77..a4905b1 100644
--- a/src/cache/Jamfile
+++ b/src/cache/Jamfile
@@ -16,7 +16,7 @@ HDRMACRO  [ FT2_SubDir  include ftcache.h ] ;
 
   if $(FT2_MULTI)
   {
-    _sources = ftlru ftcmanag ftcglyph ftcchunk ftcsbits ftcimage ;
+    _sources = ftlru ftcmanag ftccache ftcglyph ftcsbits ftcimage ;
   }
   else
   {
diff --git a/src/cache/ftcache.c b/src/cache/ftcache.c
index 63f7f8e..a80348d 100644
--- a/src/cache/ftcache.c
+++ b/src/cache/ftcache.c
@@ -21,8 +21,8 @@
 #include <ft2build.h>
 #include "ftlru.c"
 #include "ftcmanag.c"
+#include "ftccache.c"
 #include "ftcglyph.c"
-#include "ftcchunk.c"
 #include "ftcimage.c"
 #include "ftcsbits.c"
 
diff --git a/src/cache/ftcglyph.c b/src/cache/ftcglyph.c
index c2effdd..8be466f 100644
--- a/src/cache/ftcglyph.c
+++ b/src/cache/ftcglyph.c
@@ -27,143 +27,96 @@
 #include "ftcerror.h"
 
 
-  /*************************************************************************/
-  /*************************************************************************/
-  /*****                                                               *****/
-  /*****                      GLYPH NODES                              *****/
-  /*****                                                               *****/
-  /*************************************************************************/
-  /*************************************************************************/
 
 
-#define FTC_GSET_HASH( gset, gindex )                                      \
-          ( (FT_UFast)( ( (gset)->hash << 16 ) | ( (gindex) & 0xFFFF ) ) )
-
-
-  /* create a new glyph node, setting its cache index and ref count */
+  /* create a new chunk node, setting its cache index and ref count */
   FT_EXPORT_DEF( void )
-  ftc_glyph_node_init( FTC_GlyphNode  gnode,
-                       FT_UInt        gindex,
-                       FTC_GlyphSet   gset )
+  ftc_glyph_node_init( FTC_GlyphNode     gnode,
+                       FT_UInt           gindex,
+                       FTC_GlyphFamily   gfam )
   {
-    gnode->gset      = gset;
-    gnode->node.hash = FTC_GSET_HASH( gset, gindex );
-    gset->num_glyphs++;
-  }
+    FT_UInt    len;
+    FT_UInt    start = FTC_GLYPH_FAMILY_START(gfam,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.cache_data'.  Thus be       */
-  /* certain that the function FTC_Glyph_Cache_New() does indeed  */
-  /* set its `cache_data' field correctly, otherwise bad things   */
-  /* will happen!                                                 */
+    gnode->node.fam_index = (FT_UShort) gfam->family.fam_index;
+    gnode->node.hash      = FTC_GLYPH_FAMILY_HASH(gfam,gindex);
+    gnode->item_start     = (FT_UShort) start;
 
-  FT_EXPORT_DEF( void )
-  ftc_glyph_node_done( FTC_GlyphNode  gnode )
-  {
-    FTC_GlyphSet  gset = gnode->gset;
-    
+    len = gfam->item_total - start;
+    if ( len > gfam->item_count )
+      len = gfam->item_count;
 
-    if ( --gset->num_glyphs <= 0 )
-      FT_LruList_Remove( gset->gcache->gset_lru, (FT_LruNode)gset );
+    gnode->item_count = (FT_UShort) len;
+    gfam->family.num_nodes++;
   }
 
 
-  /*************************************************************************/
-  /*************************************************************************/
-  /*****                                                               *****/
-  /*****                      GLYPH SETS                               *****/
-  /*****                                                               *****/
-  /*************************************************************************/
-  /*************************************************************************/
-
-
-  FT_EXPORT_DEF( FT_Error )
-  ftc_glyph_set_init( FTC_GlyphSet  gset,
-                      FT_LruList    lru )
+  FT_EXPORT_DEF( void )
+  ftc_glyph_node_done( FTC_GlyphNode  gnode,
+                       FTC_Cache      cache )
   {
-    FTC_GlyphCache  gcache = lru->user_data;
-    
+    /* finalize the node */
+    gnode->item_count = 0;
+    gnode->item_start = 0;
 
-    gset->gcache     = gcache;
-    gset->num_glyphs = 0;
-    
-    return 0;
-  }                      
+    ftc_node_done( FTC_NODE(gnode), cache );
+  }
 
 
-  FT_EXPORT_DEF( void )
-  ftc_glyph_set_done( FTC_GlyphSet  gset )
+  FT_EXPORT_DEF( FT_Bool )
+  ftc_glyph_node_compare( FTC_GlyphNode    gnode,
+                          FTC_GlyphQuery   gquery )
   {
-    /* for now, nothing to be done here */
-    FT_UNUSED( gset );
+    FT_UInt  fam_index = (FT_UInt) FTC_NODE(gnode)->fam_index;
+    FT_UInt  start     = (FT_UInt) gnode->item_start;
+    FT_UInt  count     = (FT_UInt) gnode->item_count;
+
+    return FT_BOOL( (FT_UInt)(gquery->gindex - start) < count &&
+                     gquery->query.family->fam_index == fam_index );
   }
 
 
   /*************************************************************************/
   /*************************************************************************/
   /*****                                                               *****/
-  /*****                      GLYPH CACHES                             *****/
+  /*****                      CHUNK SETS                               *****/
   /*****                                                               *****/
   /*************************************************************************/
   /*************************************************************************/
 
 
-  FT_EXPORT_DEF( void )
-  ftc_glyph_cache_done( FTC_GlyphCache  gcache )
-  {
-    /* remove all nodes in the cache */
-    ftc_cache_done( &gcache->cache );
-  
-    /* simply delete all remaining glyph sets */
-    if ( gcache->gset_lru )
-    {
-      FT_LruList_Destroy( gcache->gset_lru );
-      gcache->gset_lru = NULL;
-    }
-  }
-
-
   FT_EXPORT_DEF( FT_Error )
-  ftc_glyph_cache_init( FTC_GlyphCache    gcache,
-                        FT_LruList_Class  gset_class )
+  ftc_glyph_family_init( FTC_GlyphFamily  gfam,
+                         FT_UInt32        hash,
+                         FT_UInt          item_count,
+                         FT_UInt          item_total,
+                         FTC_GlyphQuery   gquery,
+                         FTC_Cache        cache )
   {
     FT_Error  error;
 
 
-    error = ftc_cache_init( FTC_CACHE( gcache ) );
-    if ( error )
-      goto Exit;
-        
-    error = FT_LruList_New( gset_class, 0, gcache,
-                            gcache->cache.memory,
-                            &gcache->gset_lru );
-  Exit:
+    error = ftc_family_init( FTC_FAMILY(gfam), FTC_QUERY(gquery), cache );
+    if (!error)
+    {
+      gfam->hash       = hash;
+      gfam->item_total = item_total;
+      gfam->item_count = item_count;
+
+      FTC_GLYPH_FAMILY_FOUND(gfam,gquery);
+    }
+
     return error;
   }
 
 
-  FT_EXPORT_DEF( FT_Error )
-  ftc_glyph_cache_lookup( FTC_GlyphCache  gcache,
-                          FTC_GlyphQuery  query,
-                          FTC_GlyphNode  *anode )
+  FT_EXPORT_DEF( void )
+  ftc_glyph_family_done( FTC_GlyphFamily  gfam )
   {
-    FT_LruNode    node;
-    FT_Error      error;
-    
-
-    error = FT_LruList_Lookup( gcache->gset_lru, query, &node );
-    if ( !error )
-    {
-      FTC_GlyphSet  gset = (FTC_GlyphSet)node;
-      FT_UFast      hash = FTC_GSET_HASH( gset, query->gindex );
-      
-      error = ftc_cache_lookup_node( FTC_CACHE( gcache ), hash, query,
-                                     FTC_NODE_P( anode ) );
-    }
-    return error;
+    ftc_family_done( FTC_FAMILY(gfam) );
   }
 
 
+
 /* END */
diff --git a/src/cache/ftcimage.c b/src/cache/ftcimage.c
index 6a2b4d1..2d5cfcc 100644
--- a/src/cache/ftcimage.c
+++ b/src/cache/ftcimage.c
@@ -41,25 +41,29 @@
 #define FTC_IMAGE_NODE_GINDEX( x )  FTC_GLYPH_NODE_GINDEX( x )
 
 
-  /* the glyph image set type */
-  typedef struct  FTC_ImageSetRec_
+  /* the glyph image query */
+  typedef struct  FTC_ImageQueryRec_
   {
-    FTC_GlyphSetRec  gset;
-    FTC_Image_Desc   description;
+    FTC_GlyphQueryRec  gquery;
+    FTC_ImageDesc      desc;
 
-  } FTC_ImageSetRec, *FTC_ImageSet;
+  } FTC_ImageQueryRec, *FTC_ImageQuery;
 
+#define  FTC_IMAGE_QUERY(x)  ((FTC_ImageQuery)(x))
 
-#define  FTC_IMAGE_SET( x )         ((FTC_ImageSet)( x ))
-#define  FTC_IMAGE_SET_MEMORY( x )  FTC_GLYPH_SET_MEMORY( &(x)->gset )
 
 
-  typedef struct  FTC_ImageQueryRec_
+  /* the glyph image set type */
+  typedef struct  FTC_ImageFamilyRec_
   {
-    FTC_GlyphQueryRec  glyph;
-    FTC_Image_Desc     desc;
+    FTC_GlyphFamilyRec  gfam;
+    FTC_ImageDesc       desc;
 
-  } FTC_ImageQueryRec, *FTC_ImageQuery;
+  } FTC_ImageFamilyRec, *FTC_ImageFamily;
+
+
+#define  FTC_IMAGE_FAMILY( x )         ((FTC_ImageFamily)( x ))
+#define  FTC_IMAGE_FAMILY_MEMORY( x )  FTC_GLYPH_FAMILY_MEMORY( &(x)->gfam )
 
 
   /*************************************************************************/
@@ -73,65 +77,70 @@
 
   /* finalize a given glyph image node */
   FT_CALLBACK_DEF( void )
-  ftc_image_node_done( FTC_ImageNode  inode )
+  ftc_image_node_done( FTC_ImageNode  inode,
+                       FTC_Cache      cache )
   {
     if ( inode->glyph )
     {
       FT_Done_Glyph( inode->glyph );
       inode->glyph = NULL;
     }
+    ftc_glyph_node_done( FTC_GLYPH_NODE(inode), cache );
   }
 
 
+
   /* initialize a new glyph image node */
   FT_CALLBACK_DEF( FT_Error )
   ftc_image_node_init( FTC_ImageNode   inode,
-                       FTC_GlyphQuery  query )
+                       FTC_GlyphQuery  gquery,
+                       FTC_Cache       cache )
   {
-    FTC_ImageSet  iset = FTC_IMAGE_SET( query->gset );
-    FT_Error      error;
-    FT_Face       face;
-    FT_Size       size;
+    FTC_ImageFamily ifam = FTC_IMAGE_FAMILY( gquery->query.family );
+    FT_Error        error;
+    FT_Face         face;
+    FT_Size         size;
 
 
     /* initialize its inner fields */
-    ftc_glyph_node_init( FTC_GLYPH_NODE( inode ),
-                         query->gindex, query->gset );
+    ftc_glyph_node_init( FTC_GLYPH_NODE(inode),
+                         gquery->gindex,
+                         FTC_GLYPH_FAMILY(ifam) );
 
     /* we will now load the glyph image */
-    error = FTC_Manager_Lookup_Size( iset->gset.gcache->cache.manager,
-                                     &iset->description.font,
+    error = FTC_Manager_Lookup_Size( FTC_FAMILY(ifam)->cache->manager,
+                                     &ifam->desc.font,
                                      &face, &size );
     if ( !error )
     {
       FT_UInt  gindex      = FTC_GLYPH_NODE_GINDEX(inode);
       FT_UInt  load_flags  = FT_LOAD_DEFAULT;
-      FT_UInt  image_type  = iset->description.image_type;
+      FT_UInt  type        = ifam->desc.type;
 
 
-      if ( FTC_IMAGE_FORMAT( image_type ) == ftc_image_format_bitmap )
+      if ( FTC_IMAGE_FORMAT( type ) == ftc_image_format_bitmap )
       {
         load_flags |= FT_LOAD_RENDER;
-        if ( image_type & ftc_image_flag_monochrome )
+        if ( type & ftc_image_flag_monochrome )
           load_flags |= FT_LOAD_MONOCHROME;
 
         /* disable embedded bitmaps loading if necessary */
-        if ( image_type & ftc_image_flag_no_sbits )
+        if ( type & ftc_image_flag_no_sbits )
           load_flags |= FT_LOAD_NO_BITMAP;
       }
-      else if ( FTC_IMAGE_FORMAT( image_type ) == ftc_image_format_outline )
+      else if ( FTC_IMAGE_FORMAT( type ) == ftc_image_format_outline )
       {
         /* disable embedded bitmaps loading */
         load_flags |= FT_LOAD_NO_BITMAP;
 
-        if ( image_type & ftc_image_flag_unscaled )
+        if ( type & ftc_image_flag_unscaled )
           load_flags |= FT_LOAD_NO_SCALE;
       }
 
-      if ( image_type & ftc_image_flag_unhinted )
+      if ( type & ftc_image_flag_unhinted )
         load_flags |= FT_LOAD_NO_HINTING;
 
-      if ( image_type & ftc_image_flag_autohinted )
+      if ( type & ftc_image_flag_autohinted )
         load_flags |= FT_LOAD_FORCE_AUTOHINT;
 
       error = FT_Load_Glyph( face, gindex, load_flags );
@@ -157,7 +166,7 @@
     }
 
     /* in case of error */
-    ftc_glyph_node_done( FTC_GLYPH_NODE( inode ) );
+    ftc_glyph_node_done( FTC_GLYPH_NODE(inode), cache );
 
   Exit:
     return error;
@@ -206,19 +215,6 @@
   }
 
 
-  /* this function assumes that the desired node's glyph set has been */
-  /* set by a previous call to ftc_image_set_compare()                */
-  /*                                                                  */
-  FT_CALLBACK_DEF( FT_Bool )
-  ftc_image_node_compare( FTC_ImageNode   inode,
-                          FTC_ImageQuery  iquery )
-  {
-    /* only if same glyph index and image set description */
-    return FT_BOOL( iquery->glyph.gindex == FTC_IMAGE_NODE_GINDEX( inode ) &&
-                    iquery->glyph.gset   == inode->gnode.gset );
-  }
-
-
   /*************************************************************************/
   /*************************************************************************/
   /*****                                                               *****/
@@ -229,53 +225,51 @@
 
 
   FT_CALLBACK_DEF( FT_Error )
-  ftc_image_set_init( FTC_ImageSet     iset,
-                      FTC_ImageQuery   query,
-                      FT_LruList       lru )
+  ftc_image_family_init( FTC_ImageFamily  ifam,
+                         FTC_ImageQuery   iquery,
+                         FTC_Cache        cache )
   {
-    ftc_glyph_set_init( &iset->gset, lru );
-    iset->description = query->desc;
+    FTC_Manager  manager = cache->manager;
+    FT_Error     error;
+    FT_Face      face;
+
 
-    /* now compute hash from description -- this is _very_ important */
-    iset->gset.hash   = FTC_IMAGE_DESC_HASH( &query->desc );
-    query->glyph.gset = FTC_GLYPH_SET( iset );
+    ifam->desc = iquery->desc;
 
-    return 0;
+    /* we need to compute "iquery.item_total" now */
+    error = FTC_Manager_Lookup_Face( manager,
+                                     iquery->desc.font.face_id,
+                                     &face );
+    if ( !error )
+    {
+      error = ftc_glyph_family_init( FTC_GLYPH_FAMILY(ifam),
+                                     FTC_IMAGE_DESC_HASH( &ifam->desc ),
+                                     1,
+                                     face->num_glyphs,
+                                     FTC_GLYPH_QUERY(iquery),
+                                     cache );
+    }
+
+    return error;
   }
 
 
   FT_CALLBACK_DEF( FT_Bool )
-  ftc_image_set_compare( FTC_ImageSet    iset,
-                         FTC_ImageQuery  iquery )
+  ftc_image_family_compare( FTC_ImageFamily  ifam,
+                            FTC_ImageQuery   iquery )
   {
     FT_Bool  result;
 
 
-    /* we must set iquery.glyph.gset for faster glyph node comparisons */
-    result = FT_BOOL( FTC_IMAGE_DESC_COMPARE( &iset->description,
-                                              &iquery->desc ) );
+    /* we must set iquery.glyph.gfam for faster glyph node comparisons */
+    result = FT_BOOL( FTC_IMAGE_DESC_COMPARE( &ifam->desc, &iquery->desc ) );
     if ( result )
-      iquery->glyph.gset = &iset->gset;
+      FTC_GLYPH_FAMILY_FOUND(ifam,iquery);
 
     return result;
   }
 
 
-  FT_CALLBACK_TABLE_DEF
-  const FT_LruList_ClassRec  ftc_image_set_class =
-  {
-    sizeof ( FT_LruListRec ),
-    (FT_LruList_InitFunc)   NULL,
-    (FT_LruList_DoneFunc)   NULL,
-
-    sizeof ( FTC_ImageSetRec ),
-    (FT_LruNode_InitFunc)   ftc_image_set_init,
-    (FT_LruNode_DoneFunc)   ftc_glyph_set_init,
-    (FT_LruNode_FlushFunc)  NULL,
-    (FT_LruNode_CompareFunc)ftc_image_set_compare
-  };
-
-
   /*************************************************************************/
   /*************************************************************************/
   /*****                                                               *****/
@@ -285,34 +279,33 @@
   /*************************************************************************/
 
 
-  FT_CALLBACK_DEF( FT_Error )
-  ftc_image_cache_init( FTC_Image_Cache  cache )
-  {
-    return ftc_glyph_cache_init( (FTC_GlyphCache)cache,
-                                 &ftc_image_set_class );
-  }
-
 
   FT_CALLBACK_TABLE_DEF
   const FTC_Cache_ClassRec  ftc_image_cache_class =
   {
-    sizeof ( FTC_GlyphCacheRec ),
-    (FTC_Cache_InitFunc)  ftc_image_cache_init,
-    (FTC_Cache_DoneFunc)  ftc_glyph_cache_done,
-
-    sizeof ( FTC_ImageNodeRec ),
-    (FTC_Node_InitFunc)   ftc_image_node_init,
-    (FTC_Node_WeightFunc) ftc_image_node_weight,
-    (FTC_Node_CompareFunc)ftc_image_node_compare,
-    (FTC_Node_DoneFunc)   ftc_image_node_done
+    sizeof( FTC_CacheRec ),
+    (FTC_Cache_InitFunc)       ftc_cache_init,
+    (FTC_Cache_ClearFunc)      ftc_cache_clear,
+    (FTC_Cache_DoneFunc)       ftc_cache_done,
+
+    sizeof( FTC_ImageFamilyRec ),
+    (FTC_Family_InitFunc)      ftc_image_family_init,
+    (FTC_Family_CompareFunc)   ftc_image_family_compare,
+    (FTC_Family_DoneFunc)      ftc_glyph_family_done,
+
+    sizeof( FTC_ImageNodeRec ),
+    (FTC_Node_InitFunc)        ftc_image_node_init,
+    (FTC_Node_WeightFunc)      ftc_image_node_weight,
+    (FTC_Node_CompareFunc)     ftc_glyph_node_compare,
+    (FTC_Node_DoneFunc)        ftc_image_node_done
   };
 
 
   /* documentation is in ftcimage.h */
 
   FT_EXPORT_DEF( FT_Error )
-  FTC_Image_Cache_New( FTC_Manager       manager,
-                       FTC_Image_Cache  *acache )
+  FTC_ImageCache_New( FTC_Manager      manager,
+                      FTC_ImageCache  *acache )
   {
     return FTC_Manager_Register_Cache(
              manager,
@@ -324,37 +317,37 @@
   /* documentation is in ftcimage.h */
 
   FT_EXPORT_DEF( FT_Error )
-  FTC_Image_Cache_Acquire( FTC_Image_Cache  cache,
-                           FTC_Image_Desc*  desc,
-                           FT_UInt          gindex,
-                           FT_Glyph        *aglyph,
-                           FTC_Node        *anode )
+  FTC_ImageCache_Lookup( FTC_ImageCache  cache,
+                         FTC_ImageDesc*  desc,
+                         FT_UInt         gindex,
+                         FT_Glyph       *aglyph,
+                         FTC_Node       *anode )
   {
-    FTC_ImageQueryRec  query;
+    FTC_ImageQueryRec  iquery;
     FTC_ImageNode      node;
     FT_Error           error;
 
 
-    /* some argument checks are delayed to ftc_glyph_cache_lookup() */
-    if ( !cache || !desc || !aglyph )
-      return FTC_Err_Invalid_Argument;
+    /* some argument checks are delayed to ftc_glyph_cache_lookup */
+    if ( aglyph )
+      *aglyph = NULL;
 
     *aglyph = NULL;
 
     if ( anode )
       *anode  = NULL;
 
-    query.glyph.gindex = gindex;
-    query.glyph.gset   = NULL;
-    query.desc         = *desc;
-    error = ftc_glyph_cache_lookup( FTC_GLYPH_CACHE( cache ),
-                                    &query.glyph,
-                                    (FTC_GlyphNode*)&node );
+    iquery.gquery.gindex = gindex;
+    iquery.desc          = *desc;
+
+    error = ftc_cache_lookup( FTC_CACHE(cache),
+                              FTC_QUERY(&iquery),
+                              (FTC_Node*) &node );
     if ( !error )
     {
       *aglyph = node->glyph;
 
-      if ( anode )
+      if (anode)
       {
         *anode = (FTC_Node)node;
         FTC_NODE(node)->ref_count++;
@@ -365,11 +358,14 @@
   }
 
 
-  FT_EXPORT_DEF( void )
-  FTC_Image_Cache_Release( FTC_Image_Cache  icache,
-                           FTC_Node         node )
+
+ /* backwards-compatibility functions */
+
+  FT_EXPORT_DEF( FT_Error )
+  FTC_Image_Cache_New( FTC_Manager       manager,
+                       FTC_Image_Cache  *acache )
   {
-    ftc_node_unref( node, FTC_CACHE( icache ) );
+    return FTC_ImageCache_New( manager, (FTC_ImageCache*)acache );
   }
 
 
@@ -379,7 +375,19 @@
                           FT_UInt          gindex,
                           FT_Glyph        *aglyph )
   {
-    return FTC_Image_Cache_Acquire( icache, desc, gindex, aglyph, NULL );
+    FTC_ImageDesc  desc0;
+
+    if ( !desc )
+      return FT_Err_Invalid_Argument;
+
+    desc0.font = desc->font;
+    desc0.type = (FT_UInt32) desc->image_type;
+
+    return FTC_ImageCache_Lookup( (FTC_ImageCache)icache,
+                                   &desc0,
+                                   gindex,
+                                   aglyph,
+                                   NULL );
   }
 
 
diff --git a/src/cache/ftcmanag.c b/src/cache/ftcmanag.c
index 03f2303..8e834d1 100644
--- a/src/cache/ftcmanag.c
+++ b/src/cache/ftcmanag.c
@@ -22,7 +22,6 @@
 #include FT_CACHE_INTERNAL_LRU_H
 #include FT_INTERNAL_OBJECTS_H
 #include FT_INTERNAL_DEBUG_H
-#include FT_LIST_H
 #include FT_SIZES_H
 
 #include "ftcerror.h"
@@ -63,12 +62,11 @@
 
 
   FT_CALLBACK_DEF( FT_Error )
-  ftc_face_node_init( FTC_FaceNode  node,
-                      FTC_FaceID    face_id,
-                      FT_LruList    list )
+  ftc_face_node_init( FTC_FaceNode node,
+                      FTC_FaceID   face_id,
+                      FTC_Manager  manager )
   {
-    FTC_Manager  manager = FTC_LRU_GET_MANAGER( list );
-    FT_Error     error;
+    FT_Error  error;
 
 
     error = manager->request_face( face_id,
@@ -97,10 +95,9 @@
 
   FT_CALLBACK_DEF( void )
   ftc_face_node_done( FTC_FaceNode  node,
-                      FT_LruList    list )
+                      FTC_Manager   manager )
   {
-    FTC_Manager  manager = FTC_LRU_GET_MANAGER( list );
-    FT_Face      face    = node->face;
+    FT_Face  face    = node->face;
 
 
     /* we must begin by removing all sizes for the target face */
@@ -130,6 +127,36 @@
   };
 
 
+  /* documentation is in ftcache.h */
+
+  FT_EXPORT_DEF( FT_Error )
+  FTC_Manager_Lookup_Face( FTC_Manager  manager,
+                           FTC_FaceID   face_id,
+                           FT_Face     *aface )
+  {
+    FT_Error      error;
+    FTC_FaceNode  node;
+
+
+    if ( aface == NULL )
+      return FTC_Err_Bad_Argument;
+
+    *aface = NULL;
+
+    if ( !manager )
+      return FTC_Err_Invalid_Cache_Handle;
+
+    error = FT_LruList_Lookup( manager->faces_list,
+                               (FT_LruKey)face_id,
+                               (FT_LruNode*)&node );
+    if ( !error )
+      *aface = node->face;
+
+    return error;
+  }
+
+
+
   /*************************************************************************/
   /*************************************************************************/
   /*****                                                               *****/
@@ -242,6 +269,169 @@
   };
 
 
+
+  /* documentation is in ftcache.h */
+
+  FT_EXPORT_DEF( FT_Error )
+  FTC_Manager_Lookup_Size( FTC_Manager  manager,
+                           FTC_Font     font,
+                           FT_Face     *aface,
+                           FT_Size     *asize )
+  {
+    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 );
+    if ( !error )
+    {
+      FTC_SizeQueryRec  query;
+      FTC_SizeNode      node;
+
+
+      query.face   = *aface;
+      query.width  = font->pix_width;
+      query.height = font->pix_height;
+
+      error = FT_LruList_Lookup( manager->sizes_list,
+                                 (FT_LruKey)&query,
+                                 (FT_LruNode*)&node );
+      if ( !error )
+      {
+        /* select the size as the current one for this face */
+        FT_Activate_Size( node->size );
+
+        if ( asize )
+          *asize = node->size;
+      }
+    }
+
+    return error;
+  }
+
+
+  /*************************************************************************/
+  /*************************************************************************/
+  /*****                                                               *****/
+  /*****                    SET TABLE MANAGEMENT                       *****/
+  /*****                                                               *****/
+  /*************************************************************************/
+  /*************************************************************************/
+
+  static void
+  ftc_family_table_init( FTC_FamilyTable  table )
+  {
+    table->count   = 0;
+    table->size    = 0;
+    table->entries = NULL;
+    table->free    = FTC_FAMILY_ENTRY_NONE;
+  }
+
+
+  static void
+  ftc_family_table_done( FTC_FamilyTable  table,
+                         FT_Memory        memory )
+  {
+    FREE( table->entries );
+    table->free  = 0;
+    table->count = 0;
+    table->size  = 0;
+  }
+
+
+  FT_LOCAL_DEF FT_Error
+  ftc_family_table_alloc( FTC_FamilyTable   table,
+                          FT_Memory         memory,
+                          FTC_FamilyEntry  *aentry )
+  {
+    FTC_FamilyEntry  entry;
+    FT_Error         error = 0;
+
+   /* re-allocate table size when needed */
+    if ( table->free == FTC_FAMILY_ENTRY_NONE && table->count >= table->size )
+    {
+      FT_UInt  old_size = table->size;
+      FT_UInt  new_size, index;
+
+      if ( old_size == 0 )
+        new_size = 8;
+      else
+      {
+        new_size = old_size*2;
+
+        /* check for (unlikely) overflow */
+        if ( new_size < old_size )
+          new_size = 65534;
+      }
+
+      if ( REALLOC_ARRAY( table->entries, old_size, new_size, FTC_FamilyEntryRec ) )
+        return error;
+
+      table->size = new_size;
+
+      entry       = table->entries + old_size;
+      table->free = old_size;
+
+      for ( index = old_size; index+1 < new_size; index++, entry++ )
+      {
+        entry->link  = index+1;
+        entry->index = index;
+      }
+
+      entry->link  = FTC_FAMILY_ENTRY_NONE;
+      entry->index = index;
+    }
+
+    if ( table->free != FTC_FAMILY_ENTRY_NONE )
+    {
+      entry       = table->entries + table->free;
+      table->free = entry->link;
+    }
+    else if ( table->count < table->size )
+    {
+      entry = table->entries + table->count++;
+    }
+    else
+    {
+      FT_ERROR(( "FreeType.cache.alloc_set: internal bug !!" ));
+      return FT_Err_Invalid_Argument;
+    }
+
+    entry->link = FTC_FAMILY_ENTRY_NONE;
+    table->count++;
+
+    *aentry = entry;
+    return error;
+  }
+
+
+  FT_LOCAL_DEF void
+  ftc_family_table_free( FTC_FamilyTable  table,
+                         FT_UInt          index )
+  {
+    /* simply add it to the linked list of free entries */
+    if ( index < table->count )
+    {
+      FTC_FamilyEntry  entry = table->entries + index;
+
+      if ( entry->link != FTC_FAMILY_ENTRY_NONE )
+        FT_ERROR(( "FreeType.cache.set_free: internal bug !!\n" ));
+      else
+      {
+        entry->link = table->free;
+        table->free = entry->index;
+        table->count--;
+      }
+    }
+  }
+
+
   /*************************************************************************/
   /*************************************************************************/
   /*****                                                               *****/
@@ -307,6 +497,8 @@
     manager->request_face = requester;
     manager->request_data = req_data;
 
+    ftc_family_table_init( &manager->families );
+
     *amanager = manager;
 
   Exit:
@@ -348,7 +540,10 @@
         manager->caches[index] = 0;
       }
     }
-    
+
+    /* discard families table */
+    ftc_family_table_done( &manager->families, memory );
+
     /* discard faces and sizes */
     FT_LruList_Destroy( manager->faces_list );
     manager->faces_list = 0;
@@ -374,251 +569,10 @@
   }
 
 
-  /* documentation is in ftcache.h */
-
-  FT_EXPORT_DEF( FT_Error )
-  FTC_Manager_Lookup_Face( FTC_Manager  manager,
-                           FTC_FaceID   face_id,
-                           FT_Face     *aface )
-  {
-    FT_Error      error;
-    FTC_FaceNode  node;
-
-
-    if ( aface == NULL )
-      return FTC_Err_Bad_Argument;
-
-    *aface = NULL;
-
-    if ( !manager )
-      return FTC_Err_Invalid_Cache_Handle;
-
-    error = FT_LruList_Lookup( manager->faces_list,
-                               (FT_LruKey)face_id,
-                               (FT_LruNode*)&node );
-    if ( !error )
-      *aface = node->face;
-    
-    return error;
-  }
-
-
-  /* documentation is in ftcache.h */
-
-  FT_EXPORT_DEF( FT_Error )
-  FTC_Manager_Lookup_Size( FTC_Manager  manager,
-                           FTC_Font     font,
-                           FT_Face     *aface,
-                           FT_Size     *asize )
-  {
-    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 );
-    if ( !error )
-    {
-      FTC_SizeQueryRec  query;
-      FTC_SizeNode      node;
-
-
-      query.face   = *aface;
-      query.width  = font->pix_width;
-      query.height = font->pix_height;
 
-      error = FT_LruList_Lookup( manager->sizes_list,
-                                 (FT_LruKey)&query,
-                                 (FT_LruNode*)&node );
-      if ( !error )
-      {
-        /* select the size as the current one for this face */
-        FT_Activate_Size( node->size );
-
-        if ( asize )
-          *asize = node->size;
-      }
-    }
-
-    return error;
-  }
-
-
-  /* add a new node to the head of the manager's circular MRU list */
-  static void
-  ftc_node_mru_link( FTC_Node     node,
-                     FTC_Manager  manager )
-  {
-    FTC_Node  first = manager->nodes_list;
-
-
-    if ( first )
-    {
-      node->mru_prev = first->mru_prev;
-      node->mru_next = first;
-
-      first->mru_prev->mru_next = node;
-      first->mru_prev           = node;
-    }
-    else
-    {
-      node->mru_next = node;
-      node->mru_prev = node;
-    }
-
-    manager->nodes_list = node;
-    manager->num_nodes++;
-  }
-
-
-  /* remove a node from the manager's MRU list */
-  static void
-  ftc_node_mru_unlink( FTC_Node     node,
-                       FTC_Manager  manager )
-  {
-    FTC_Node  prev  = node->mru_prev;
-    FTC_Node  next  = node->mru_next;
-    FTC_Node  first = manager->nodes_list;
-
-
-    prev->mru_next = next;
-    next->mru_prev = prev;
-
-    if ( node->mru_next == first )
-    {
-      /* this is the last node in the list; update its head pointer */
-      if ( node == first )
-        manager->nodes_list = NULL;
-      else
-        first->mru_prev = prev;
-    }
-
-    node->mru_next = NULL;
-    node->mru_prev = NULL;
-    manager->num_nodes--;
-  }
-
-
-  /* move a node to the head of the manager's MRU list */
-  static void
-  ftc_node_mru_up( FTC_Node     node,
-                   FTC_Manager  manager )
-  {
-    FTC_Node  first = manager->nodes_list;
-
-
-    if ( node != first )
-    {
-      ftc_node_mru_unlink( node, manager );
-      ftc_node_mru_link( node, manager );
-    }
-  }
-
-
-  /* remove a node from its cache's hash table */
-  static void
-  ftc_node_hash_unlink( FTC_Node   node,
-                        FTC_Cache  cache )
-  {
-    FTC_Node  *pnode = cache->buckets + ( node->hash % cache->size );
-
-
-    for (;;)
-    {
-      if ( *pnode == NULL )
-      {
-        FT_ERROR(( "FreeType.cache.hash_unlink: unknown node!\n" ));
-        return;
-      }
-
-      if ( *pnode == node )
-      {
-        *pnode     = node->link;
-        node->link = NULL;
-
-        cache->nodes--;
-        return;
-      }
-
-      pnode = &(*pnode)->link;
-    }
-  }
-
-
-  /* add a node to the "top" of its cache's hash table */
-  static void
-  ftc_node_hash_link( FTC_Node   node,
-                      FTC_Cache  cache )
-  {
-    FTC_Node  *pnode = cache->buckets + ( node->hash % cache->size );
-
-
-    node->link = *pnode;
-    *pnode     = node;
-
-    cache->nodes++;
-  }
-
-
-  /* remove a node from the cache manager */
-  static void
-  ftc_node_destroy( FTC_Node     node,
-                    FTC_Manager  manager )
-  {
-    FT_Memory        memory  = manager->library->memory;
-    FTC_Cache        cache;
-    FTC_Cache_Class  clazz;
-
-
-#ifdef FT_DEBUG_ERROR
-    /* find node's cache */
-    if ( node->cache_index >= FTC_MAX_CACHES )
-    {
-      FT_ERROR(( "FreeType.cache.node_destroy: invalid node handle\n" ));
-      return;
-    }
-#endif
-
-    cache = manager->caches[node->cache_index];
 
 #ifdef FT_DEBUG_ERROR
-    if ( cache == NULL )
-    {
-      FT_ERROR(( "FreeType.cache.node_destroy: invalid node handle\n" ));
-      return;
-    }
-#endif
-
-    clazz = cache->clazz;
-
-    manager->cur_weight -= clazz->node_weight( node, cache );
-
-    /* remove node from mru list */
-    ftc_node_mru_unlink( node, manager );
-
-    /* remove node from cache's hash table */
-    ftc_node_hash_unlink( node, cache );
-
-    /* now finalize it */
-
-    if ( clazz->node_done )
-      clazz->node_done( node, cache );
-
-    FREE( node );
-
-    /* check, just in case of general corruption :-) */
-    if ( manager->num_nodes <= 0 )
-      FT_ERROR(( "FTC_Manager_Compress: Invalid cache node count! = %d\n",
-                  manager->num_nodes ));
-  }
-
-
-  FT_EXPORT_DEF( void )
+  FT_EXPORT_DEF(void)
   FTC_Manager_Check( FTC_Manager  manager )
   {
     FTC_Node  node, first;
@@ -636,14 +590,23 @@
 
       do
       {
-        FTC_Cache  cache = manager->caches[node->cache_index];
-        
+        FTC_FamilyEntry  entry = manager->families.entries + node->fam_index;
+        FTC_Cache     cache;
+
+        if ( (FT_UInt)node->fam_index >= manager->families.count ||
+             entry->link              != FTC_FAMILY_ENTRY_NONE  )
+          FT_ERROR(( "FTC_Manager_Compress: invalid node (family index = %ld\n",
+                     node->fam_index ));
+        else
+        {
+          cache   = entry->cache;
+          weight += cache->clazz->node_weight( node, cache );
+        }
 
-        weight += cache->clazz->node_weight( node, cache );
-        node    = node->mru_next;
+        node = node->mru_next;
+      }
+      while (node != first);
 
-      } while ( node != first );
-      
       if ( weight != manager->cur_weight )
         FT_ERROR((
           "FTC_Manager_Compress: invalid weight %ld instead of %ld\n",
@@ -654,22 +617,23 @@
     if ( first )
     {
       FT_UFast  count = 0;
-      
+
 
       node = first;
       do
       {
         count++;
         node = node->mru_next;
+      }
+      while (node != first);
 
-      } while ( node != first );
-      
       if ( count != manager->num_nodes )
         FT_ERROR((
           "FTC_Manager_Compress: invalid cache node count %d instead of %d\n",
           manager->num_nodes, count ));
     }
   }
+#endif /* FT_DEBUG_ERROR */
 
 
   /* `Compress' the manager's data, i.e., get rid of old cache nodes */
@@ -689,7 +653,7 @@
 
     first = manager->nodes_list;
 
-#if 0
+#ifdef FT_DEBUG_ERROR
     FTC_Manager_Check( manager );
 
     FT_ERROR(( "compressing, weight = %ld, max = %ld, nodes = %d\n",
@@ -782,296 +746,20 @@
   }
 
 
-  /*************************************************************************/
-  /*************************************************************************/
-  /*****                                                               *****/
-  /*****                    ABSTRACT CACHE CLASS                       *****/
-  /*****                                                               *****/
-  /*************************************************************************/
-  /*************************************************************************/
 
-#define FTC_PRIMES_MIN  7
-#define FTC_PRIMES_MAX  13845163
 
-  static const FT_UInt  ftc_primes[] =
-  {
-    7,
-    11,
-    19,
-    37,
-    73,
-    109,
-    163,
-    251,
-    367,
-    557,
-    823,
-    1237,
-    1861,
-    2777,
-    4177,
-    6247,
-    9371,
-    14057,
-    21089,
-    31627,
-    47431,
-    71143,
-    106721,
-    160073,
-    240101,
-    360163,
-    540217,
-    810343,
-    1215497,
-    1823231,
-    2734867,
-    4102283,
-    6153409,
-    9230113,
-    13845163,
-  };
 
 
-  static FT_UFast
-  ftc_prime_closest( FT_UFast  num )
-  {
-    FT_UInt  i;
-
-
-    for ( i = 0; i < sizeof ( ftc_primes ) / sizeof ( ftc_primes[0] ); i++ )
-      if ( ftc_primes[i] > num )
-        return ftc_primes[i];
-
-    return FTC_PRIMES_MAX;
-  }
-
 
-  FT_EXPORT_DEF( void )
-  ftc_cache_resize( FTC_Cache  cache )
-  {
-    FT_UFast  new_size;
-
-
-    new_size = ftc_prime_closest( cache->nodes );
-    if ( new_size != cache->size )
-    {
-      FT_Memory  memory = cache->memory;
-      FT_Error   error;
-      FTC_Node*  new_buckets ;
-      FT_ULong   i;
-
-
-      if ( ALLOC_ARRAY( new_buckets, new_size, FTC_Node ) )
-        return;
-
-      for ( i = 0; i < cache->size; i++ )
-      {
-        FTC_Node   node, next, *pnode;
-        FT_UFast   hash;
-
-
-        node = cache->buckets[i];
-        while ( node )
-        {
-          next  = node->link;
-          hash  = node->hash % new_size;
-          pnode = new_buckets + hash;
-
-          node->link = pnode[0];
-          pnode[0]   = node;
-
-          node = next;
-        }
-      }
-
-      if ( cache->buckets )
-        FREE( cache->buckets );
-
-      cache->buckets = new_buckets;
-      cache->size    = new_size;
-    }
-  }
-
-
-  FT_EXPORT_DEF( FT_Error )
-  ftc_cache_init( FTC_Cache  cache )
-  {
-    FT_Memory  memory = cache->memory;
-    FT_Error   error;
-    
-
-    cache->nodes = 0;
-    cache->size  = FTC_PRIMES_MIN;
-    
-    if ( ALLOC_ARRAY( cache->buckets, cache->size, FTC_Node ) )
-      goto Exit;
-      
-  Exit:
-    return error;
-  }
-
-
-  FT_EXPORT_DEF( void )
-  ftc_cache_done( FTC_Cache  cache )
+  FT_EXPORT_DEF(void)
+  FTC_Node_Unref( FTC_Node     node,
+                  FTC_Manager  manager )
   {
-    if ( cache )
+    if ( node && (FT_UInt)node->fam_index < manager->families.count &&
+         manager->families.entries[node->fam_index].cache )
     {
-      FT_Memory        memory  = cache->memory;
-      FTC_Cache_Class  clazz   = cache->clazz;
-      FTC_Manager      manager = cache->manager;
-      FT_UFast         i;
-
-
-      for ( i = 0; i < cache->size; i++ )
-      {
-        FTC_Node  *pnode = cache->buckets + i, next, node = *pnode;
-
-        while ( node )
-        {
-          next        = node->link;
-          node->link  = NULL;
-
-          /* remove node from mru list */
-          ftc_node_mru_unlink( node, manager );
-
-          /* now finalize it */
-          manager->cur_weight -= clazz->node_weight( node, cache );
-
-          if ( clazz->node_done )
-            clazz->node_done( node, cache );
-
-          FREE( node );
-          node = next;
-        }
-        cache->buckets[i] = NULL;
-      }
-
-      FREE( cache->buckets );
-
-      cache->nodes = 0;
-      cache->size  = 0;
-    }
-  }
-
-
-  /* Look up a node in "top" of its cache's hash table. */
-  /* If not found, create a new node.                   */
-  /*                                                    */
-  FT_EXPORT_DEF( FT_Error )
-  ftc_cache_lookup_node( FTC_Cache   cache,
-                         FT_UFast    key_hash,
-                         FT_Pointer  key,
-                         FTC_Node   *anode )
-  {
-    FT_Error   error  = 0;
-    FTC_Node   result = NULL;
-    FTC_Node*  bucket = cache->buckets + ( key_hash % cache->size );
-
-
-    if ( *bucket )
-    {
-      FTC_Node*             pnode   = bucket;
-      FTC_Node_CompareFunc  compare = cache->clazz->node_compare;
-
-
-      for (;;)
-      {
-        FTC_Node  node;
-
-
-        node = *pnode;
-        if ( node == NULL )
-          break;
-
-        if ( compare( node, key, cache ) )
-        {
-          /* move to head of bucket list */
-          if ( pnode != bucket )
-          {
-            *pnode     = node->link;
-            node->link = *bucket;
-            *bucket    = node;
-          }
-          
-          /* move to head of MRU list */
-          if ( node != cache->manager->nodes_list )
-            ftc_node_mru_up( node, cache->manager );
-
-          result = node;
-          goto Exit;
-        }
-
-        pnode = &(*pnode)->link;
-      }
-    }
-
-    /* didn't find a node, create a new one */
-    {
-      FTC_Cache_Class  clazz   = cache->clazz;
-      FTC_Manager      manager = cache->manager;
-      FT_Memory        memory  = cache->memory;
-      FTC_Node         node;
-
-
-      if ( ALLOC( node, clazz->node_size ) )
-        goto Exit;
-
-      /* node initializer must set 'hash' field */
-
-      node->cache_index = cache->cache_index;
-      node->ref_count   = 0;
-
-      error = clazz->node_init( node, key, cache );
-      if ( error )
-      {
-        FREE( node );
-        goto Exit;
-      }
-
-      ftc_node_hash_link( node, cache );
-      ftc_node_mru_link( node, cache->manager );
-
-      cache->manager->cur_weight += clazz->node_weight( node, cache );
-
-      /* now try to compress the node pool when necessary */
-      if ( manager->cur_weight >= manager->max_weight )
-      {
-        node->ref_count++;
-        FTC_Manager_Compress( manager );
-        node->ref_count--;
-      }
-
-      /* try to resize the hash table when appropriate */
-      if ( FTC_CACHE_RESIZE_TEST( cache ) )
-        ftc_cache_resize( cache );
-
-      result = node;
-    }
-
-  Exit:
-   *anode = result;
-    return error;
-  }
-
-
-  /* maybe the next two functions will disappear eventually */
-
-  FT_EXPORT_DEF( void )
-  ftc_node_ref( FTC_Node   node,
-                FTC_Cache  cache )
-  {
-    if ( node && cache && (FT_UInt)node->cache_index == cache->cache_index )
-      node->ref_count++;
-  }
-
-
-  FT_EXPORT_DEF( void )
-  ftc_node_unref( FTC_Node   node,
-                  FTC_Cache  cache )
-  {
-    if ( node && cache && (FT_UInt)node->cache_index == cache->cache_index )
       node->ref_count--;
+    }
   }
 
 
diff --git a/src/cache/ftcsbits.c b/src/cache/ftcsbits.c
index 12548d1..e917e2d 100644
--- a/src/cache/ftcsbits.c
+++ b/src/cache/ftcsbits.c
@@ -19,7 +19,7 @@
 #include <ft2build.h>
 #include FT_CACHE_H
 #include FT_CACHE_SMALL_BITMAPS_H
-#include FT_CACHE_INTERNAL_CHUNK_H
+#include FT_CACHE_INTERNAL_GLYPH_H
 #include FT_INTERNAL_OBJECTS_H
 #include FT_INTERNAL_DEBUG_H
 #include FT_ERRORS_H
@@ -32,64 +32,58 @@
 #define FTC_SBIT_ITEMS_PER_NODE  16
 
 
- /* handle to sbit set */
-  typedef struct FTC_SBitSetRec_*  FTC_SBitSet;
+  typedef struct FTC_SBitNodeRec_*    FTC_SBitNode;
 
- /* sbit set structure */
-  typedef struct  FTC_SBitSetRec_
+  typedef struct FTC_SBitNodeRec_
   {
-    FTC_ChunkSetRec  cset;
-    FTC_Image_Desc   desc;
+    FTC_GlyphNodeRec   gnode;
+    FTC_SBitRec        sbits[ FTC_SBIT_ITEMS_PER_NODE ];
 
-  } FTC_SBitSetRec;
+  } FTC_SBitNodeRec;
 
+#define  FTC_SBIT_NODE(x)   ((FTC_SBitNode)(x))
 
-#define FTC_SBIT_SET( x )         ( (FTC_SBitSet)(x) )
-#define FTC_SBIT_SET_MEMORY( x )  FTC_CHUNK_SET_MEMORY( &(x)->cset )
 
 
   typedef struct  FTC_SBitQueryRec_
   {
-    FTC_ChunkQueryRec  chunk;
-    FTC_Image_Desc     desc;
+    FTC_GlyphQueryRec  gquery;
+    FTC_ImageDesc      desc;
 
   } FTC_SBitQueryRec, *FTC_SBitQuery;
 
+#define  FTC_SBIT_QUERY(x)  ((FTC_SBitQuery)(x))
 
-  /*************************************************************************/
-  /*************************************************************************/
-  /*****                                                               *****/
-  /*****                     SBIT CACHE NODES                          *****/
-  /*****                                                               *****/
-  /*************************************************************************/
-  /*************************************************************************/
 
 
-  FT_CALLBACK_DEF( void )
-  ftc_sbit_node_done( FTC_ChunkNode  cnode )
+  typedef struct FTC_SBitFamilyRec_*  FTC_SBitFamily;
+
+ /* sbit family structure */
+  typedef struct  FTC_SBitFamilyRec_
   {
-    FTC_ChunkSet  cset   = cnode->cset;
-    FT_Memory     memory = cset->ccache->cache.memory;
-    FT_UInt       count  = cnode->item_count;
-    FTC_SBit      sbit   = (FTC_SBit) cnode->items;
+    FTC_GlyphFamilyRec  gfam;
+    FTC_ImageDesc       desc;
 
+  } FTC_SBitFamilyRec;
+  
+#define FTC_SBIT_FAMILY( x )         ( (FTC_SBitFamily)(x) )
+#define FTC_SBIT_FAMILY_MEMORY( x )  FTC_GLYPH_FAMILY_MEMORY( &(x)->cset )
 
-    if ( sbit )
-    {
-      for ( ; count > 0; sbit++, count-- )
-        FREE( sbit->buffer );
 
-      FREE( cnode->items );
-    }
 
-    ftc_chunk_node_done( cnode );
-  }
+  /*************************************************************************/
+  /*************************************************************************/
+  /*****                                                               *****/
+  /*****                     SBIT CACHE NODES                          *****/
+  /*****                                                               *****/
+  /*************************************************************************/
+  /*************************************************************************/
 
 
   static FT_Error
-  ftc_sbit_set_bitmap( FTC_SBit    sbit,
-                       FT_Bitmap*  bitmap,
-                       FT_Memory   memory )
+  ftc_sbit_copy_bitmap( FTC_SBit    sbit,
+                        FT_Bitmap*  bitmap,
+                        FT_Memory   memory )
   {
     FT_Error  error;
     FT_Int    pitch = bitmap->pitch;
@@ -108,49 +102,69 @@
   }
 
 
+
+  FT_CALLBACK_DEF( void )
+  ftc_sbit_node_done( FTC_SBitNode  snode,
+                      FTC_Cache     cache )
+  {
+    FTC_SBit   sbit  = snode->sbits;
+    FT_UInt    count = FTC_GLYPH_NODE(snode)->item_count;
+    FT_Memory  memory = cache->memory;
+
+
+    for ( ; count > 0; sbit++, count-- )
+      FREE( sbit->buffer );
+
+    ftc_glyph_node_done( FTC_GLYPH_NODE(snode), cache );
+  }
+
+
   static FT_Error
-  ftc_sbit_node_load( FTC_ChunkNode  cnode,
-                      FT_UInt        gindex,
-                      FT_ULong      *asize )
+  ftc_sbit_node_load( FTC_SBitNode  snode,
+                      FTC_Manager   manager,
+                      FT_UInt       gindex,
+                      FT_ULong     *asize )
   {
     FT_Error       error;
-    FTC_ChunkSet   cset    = cnode->cset;
-    FTC_SBitSet    sbitset = FTC_SBIT_SET(cset);
-    FT_Memory      memory  = FTC_SBIT_SET_MEMORY(sbitset);
+    FTC_GlyphNode  gnode = FTC_GLYPH_NODE(snode);
+    FTC_GlyphFamily   gfam;
+    FTC_SBitFamily    sfam;
+    FT_Memory      memory;
     FT_Face        face;
     FT_Size        size;
-
     FTC_SBit       sbit;
 
-
-    if ( gindex <  (FT_UInt)cnode->item_start                     ||
-         gindex >= (FT_UInt)cnode->item_start + cnode->item_count )
+    if ( gindex <  (FT_UInt)gnode->item_start                     ||
+         gindex >= (FT_UInt)gnode->item_start + gnode->item_count )
     {
       FT_ERROR(( "FreeType.cache.sbit_load: invalid glyph index" ));
       return FTC_Err_Invalid_Argument;
     }
 
-    sbit = (FTC_SBit)cnode->items + ( gindex - cnode->item_start );
+    gfam   = FTC_GLYPH_FAMILY( manager->families.entries[ gnode->node.fam_index ].family );
+    sfam   = FTC_SBIT_FAMILY(gfam);
+    memory = manager->library->memory;
 
-    error = FTC_Manager_Lookup_Size( cset->ccache->cache.manager,
-                                     &sbitset->desc.font,
+    sbit = snode->sbits + (gindex - gnode->item_start);
+
+    error = FTC_Manager_Lookup_Size( manager, &sfam->desc.font,
                                      &face, &size );
     if ( !error )
     {
       FT_UInt   load_flags  = FT_LOAD_DEFAULT;
-      FT_UInt   image_type  = sbitset->desc.image_type;
+      FT_UInt   type  = sfam->desc.type;
 
 
       /* determine load flags, depending on the font description's */
       /* image type                                                */
 
-      if ( FTC_IMAGE_FORMAT( image_type ) == ftc_image_format_bitmap )
+      if ( FTC_IMAGE_FORMAT( type ) == ftc_image_format_bitmap )
       {
-        if ( image_type & ftc_image_flag_monochrome )
+        if ( type & ftc_image_flag_monochrome )
           load_flags |= FT_LOAD_MONOCHROME;
 
         /* disable embedded bitmaps loading if necessary */
-        if ( image_type & ftc_image_flag_no_sbits )
+        if ( type & ftc_image_flag_no_sbits )
           load_flags |= FT_LOAD_NO_BITMAP;
       }
       else
@@ -165,10 +179,10 @@
       /* always render glyphs to bitmaps */
       load_flags |= FT_LOAD_RENDER;
 
-      if ( image_type & ftc_image_flag_unhinted )
+      if ( type & ftc_image_flag_unhinted )
         load_flags |= FT_LOAD_NO_HINTING;
 
-      if ( image_type & ftc_image_flag_autohinted )
+      if ( type & ftc_image_flag_autohinted )
         load_flags |= FT_LOAD_FORCE_AUTOHINT;
 
       /* by default, indicates a `missing' glyph */
@@ -222,13 +236,13 @@
           else
           {
             /* copy the bitmap into a new buffer -- ignore error */
-            error = ftc_sbit_set_bitmap( sbit, bitmap, memory );
+            error = ftc_sbit_copy_bitmap( sbit, bitmap, memory );
           }
 
           /* now, compute size */
           if ( asize )
-            *asize = ABS( sbit->pitch ) * sbit->height;
-          
+            *asize = ABS(sbit->pitch) * sbit->height;
+
         }  /* glyph dimensions ok */
 
       } /* glyph loading successful */
@@ -251,45 +265,39 @@
 
 
   FT_CALLBACK_DEF( FT_Error )
-  ftc_sbit_node_init( FTC_ChunkNode   cnode,
-                      FTC_ChunkQuery  query )
+  ftc_sbit_node_init( FTC_SBitNode    snode,
+                      FTC_GlyphQuery  gquery,
+                      FTC_Cache       cache )
   {
     FT_Error  error;
 
+    ftc_glyph_node_init( FTC_GLYPH_NODE(snode),
+                         gquery->gindex,
+                         FTC_GLYPH_FAMILY(gquery->query.family) );
 
-    error = ftc_chunk_node_init( cnode,
-                                 query->cset,
-                                 query->gindex,
-                                 TRUE );
-    if ( !error )
-    {
-      error = ftc_sbit_node_load( cnode, query->gindex, NULL );
-
-      if ( error )
-        ftc_chunk_node_done( cnode );
-    }
+    error = ftc_sbit_node_load( snode, cache->manager, gquery->gindex, NULL );
+    if ( error )
+      ftc_glyph_node_done( FTC_GLYPH_NODE(snode), cache );
 
     return error;
   }
 
 
-  /* this function is important because it is both part of */
-  /* an FTC_ChunkSet_Class and an FTC_CacheNode_Class      */
-  /*                                                       */
   FT_CALLBACK_DEF( FT_ULong )
-  ftc_sbit_node_weight( FTC_ChunkNode  cnode )
+  ftc_sbit_node_weight( FTC_SBitNode  snode )
   {
-    FT_ULong  size;
-    FT_UInt   count = cnode->item_count;
-    FT_Int    pitch;
-    FTC_SBit  sbit  = (FTC_SBit) cnode->items;
+    FTC_GlyphNode  gnode = FTC_GLYPH_NODE(snode);
+    FT_UInt        count = gnode->item_count;
+    FTC_SBit       sbit  = snode->sbits;
+    FT_Int         pitch;
+    FT_ULong       size;
 
 
     /* the node itself */
-    size = sizeof ( *cnode );
+    size  = sizeof ( *snode );
 
     /* the sbit records */
-    size += cnode->item_count * sizeof ( FTC_SBitRec );
+    size += FTC_GLYPH_NODE(snode)->item_count * sizeof ( FTC_SBitRec );
 
     for ( ; count > 0; count--, sbit++ )
     {
@@ -309,30 +317,26 @@
 
 
   FT_CALLBACK_DEF( FT_Bool )
-  ftc_sbit_node_compare( FTC_ChunkNode  cnode,
-                         FTC_SBitQuery  query,
+  ftc_sbit_node_compare( FTC_SBitNode   snode,
+                         FTC_SBitQuery  squery,
                          FTC_Cache      cache )
   {
-    FTC_ChunkQuery  creq  = &query->chunk;
-    FT_UInt         gindex = query->chunk.gindex;
-    FT_UInt         offset = (FT_UInt)(gindex - cnode->item_start);
+    FTC_GlyphQuery  gquery = FTC_GLYPH_QUERY(squery);
+    FTC_GlyphNode   gnode  = FTC_GLYPH_NODE(snode);
     FT_Bool         result;
 
-
-    result = FT_BOOL( offset < (FT_UInt)cnode->item_count &&
-                      creq->cset == cnode->cset );
+    result = ftc_glyph_node_compare( gnode, gquery );
     if ( result )
     {
       /* check if we need to load the glyph bitmap now */
-      FTC_SBit  sbit = (FTC_SBit)cnode->items + offset;
-      
+      FT_UInt   gindex = gquery->gindex;
+      FTC_SBit  sbit   = snode->sbits + (gindex - gnode->item_start);
 
       if ( sbit->buffer == NULL && sbit->width != 255 )
       {
         FT_ULong  size;
 
-
-        ftc_sbit_node_load( cnode, gindex, &size );
+        ftc_sbit_node_load( snode, cache->manager, gindex, &size );
         cache->manager->cur_weight += size;
       }
     }
@@ -344,41 +348,35 @@
   /*************************************************************************/
   /*************************************************************************/
   /*****                                                               *****/
-  /*****                     SBIT CHUNK SETS                           *****/
+  /*****                     SBITS FAMILIES                            *****/
   /*****                                                               *****/
   /*************************************************************************/
   /*************************************************************************/
 
 
   FT_CALLBACK_DEF( FT_Error )
-  ftc_sbit_set_init( FTC_SBitSet    sset,
-                     FTC_SBitQuery  query,
-                     FT_LruList     lru )
+  ftc_sbit_family_init( FTC_SBitFamily  sfam,
+                        FTC_SBitQuery   squery,
+                        FTC_Cache       cache )
   {
-    FTC_ChunkCache  ccache  = lru->user_data;
-    FTC_Manager     manager = ccache->cache.manager;
-    FT_Error        error;
-    FT_Face         face;
-
+    FTC_Manager  manager = cache->manager;
+    FT_Error     error;
+    FT_Face      face;
 
-    sset->desc = query->desc;
+    sfam->desc = squery->desc;
 
     /* we need to compute "cquery.item_total" now */
     error = FTC_Manager_Lookup_Face( manager,
-                                     query->desc.font.face_id,
+                                     squery->desc.font.face_id,
                                      &face );
     if ( !error )
     {
-      ftc_chunk_set_init( FTC_CHUNK_SET( sset ),
-                          sizeof ( FTC_SBitRec ),
-                          FTC_SBIT_ITEMS_PER_NODE,
-                          face->num_glyphs,
-                          FTC_CHUNK_CACHE( lru->user_data ) );
-
-      /* now compute hash from description -- this is _very_ important */
-      /* for good performance                                          */
-      sset->cset.hash   = FTC_IMAGE_DESC_HASH( &sset->desc );
-      query->chunk.cset = &sset->cset;
+      error = ftc_glyph_family_init( FTC_GLYPH_FAMILY(sfam),
+                                     FTC_IMAGE_DESC_HASH( &sfam->desc ),
+                                     FTC_SBIT_ITEMS_PER_NODE,
+                                     face->num_glyphs,
+                                     FTC_GLYPH_QUERY(squery),
+                                     cache );
     }
 
     return error;
@@ -386,37 +384,23 @@
 
 
   FT_CALLBACK_DEF( FT_Bool )
-  ftc_sbit_set_compare( FTC_SBitSet    sset,
-                        FTC_SBitQuery  query )
+  ftc_sbit_family_compare( FTC_SBitFamily    sfam,
+                        FTC_SBitQuery  squery )
   {
     FT_Bool  result;
 
 
     /* we need to set the "cquery.cset" field or our query for */
-    /* faster glyph comparisons in ftc_sbit_node_compare()     */
-    /*                                                         */
-    result = FT_BOOL( FTC_IMAGE_DESC_COMPARE( &sset->desc, &query->desc ) );
+    /* faster glyph comparisons in ftc_sbit_node_compare..         */
+    /*                                                             */
+    result = FT_BOOL( FTC_IMAGE_DESC_COMPARE( &sfam->desc, &squery->desc ) );
     if ( result )
-      query->chunk.cset = &sset->cset;
+      FTC_GLYPH_FAMILY_FOUND(sfam,squery);
 
     return result;
   }
 
 
-  FT_CALLBACK_TABLE_DEF
-  const FT_LruList_ClassRec  ftc_sbit_set_class =
-  {
-    sizeof ( FT_LruListRec ),
-    (FT_LruList_InitFunc)   NULL,
-    (FT_LruList_DoneFunc)   NULL,
-
-    sizeof ( FTC_SBitSetRec ),
-    (FT_LruNode_InitFunc)   ftc_sbit_set_init,
-    (FT_LruNode_DoneFunc)   ftc_chunk_set_done,
-    (FT_LruNode_FlushFunc)  NULL,
-    (FT_LruNode_CompareFunc)ftc_sbit_set_compare,
-  };
-
 
   /*************************************************************************/
   /*************************************************************************/
@@ -427,34 +411,33 @@
   /*************************************************************************/
 
 
-  FT_CALLBACK_DEF( FT_Error )
-  ftc_sbit_cache_init( FTC_SBit_Cache  scache )
-  {
-    return ftc_chunk_cache_init( FTC_CHUNK_CACHE( scache ),
-                                 &ftc_sbit_set_class );
-  }
-
 
   FT_CALLBACK_TABLE_DEF
   const FTC_Cache_ClassRec  ftc_sbit_cache_class =
   {
-    sizeof ( FTC_ChunkCacheRec ),
-    (FTC_Cache_InitFunc)  ftc_sbit_cache_init,
-    (FTC_Cache_DoneFunc)  ftc_chunk_cache_done,
-
-    sizeof ( FTC_ChunkNodeRec ),
-    (FTC_Node_InitFunc)   ftc_sbit_node_init,
-    (FTC_Node_WeightFunc) ftc_sbit_node_weight,
-    (FTC_Node_CompareFunc)ftc_sbit_node_compare,
-    (FTC_Node_DoneFunc)   ftc_sbit_node_done
+    sizeof( FTC_CacheRec ),
+    (FTC_Cache_InitFunc)  ftc_cache_init,
+    (FTC_Cache_ClearFunc) ftc_cache_clear,
+    (FTC_Cache_DoneFunc)  ftc_cache_done,
+
+    sizeof( FTC_SBitFamilyRec ),
+    (FTC_Family_InitFunc)    ftc_sbit_family_init,
+    (FTC_Family_CompareFunc) ftc_sbit_family_compare,
+    (FTC_Family_DoneFunc)    ftc_glyph_family_done,
+
+    sizeof( FTC_SBitNodeRec ),
+    (FTC_Node_InitFunc)     ftc_sbit_node_init,
+    (FTC_Node_WeightFunc)   ftc_sbit_node_weight,
+    (FTC_Node_CompareFunc)  ftc_sbit_node_compare,
+    (FTC_Node_DoneFunc)     ftc_sbit_node_done
   };
 
 
   /* documentation is in ftcsbits.h */
 
   FT_EXPORT_DEF( FT_Error )
-  FTC_SBit_Cache_New( FTC_Manager      manager,
-                      FTC_SBit_Cache  *acache )
+  FTC_SBitCache_New( FTC_Manager     manager,
+                     FTC_SBitCache  *acache )
   {
     return FTC_Manager_Register_Cache( manager,
                                        &ftc_sbit_cache_class,
@@ -465,34 +448,77 @@
   /* documentation is in ftcsbits.h */
 
   FT_EXPORT_DEF( FT_Error )
-  FTC_SBit_Cache_Lookup( FTC_SBit_Cache   cache,
-                         FTC_Image_Desc*  desc,
-                         FT_UInt          gindex,
-                         FTC_SBit        *ansbit )
+  FTC_SBitCache_Lookup( FTC_SBitCache   cache,
+                        FTC_ImageDesc*  desc,
+                        FT_UInt         gindex,
+                        FTC_SBit       *ansbit,
+                        FTC_Node       *anode )
   {
     FT_Error          error;
-    FTC_ChunkCache    ccache = (FTC_ChunkCache) cache;
-    FTC_ChunkNode     node;
-    FTC_SBitQueryRec  query;
+    FTC_SBitQueryRec  squery;
+    FTC_SBitNode      node;
 
-
-    /* argument checks delayed to FTC_Chunk_Cache_Lookup */
+    /* argument checks delayed to ftc_cache_lookup */
     if ( !ansbit )
       return FTC_Err_Invalid_Argument;
 
     *ansbit = NULL;
 
-    query.chunk.gindex = gindex;
-    query.chunk.cset   = NULL;
-    query.desc         = *desc;
-    
-    error = ftc_chunk_cache_lookup( ccache, &query.chunk, &node );
+    if ( anode )
+      *anode = NULL;
+
+    squery.gquery.gindex = gindex;
+    squery.desc          = *desc;
+
+    error = ftc_cache_lookup( FTC_CACHE(cache),
+                              FTC_QUERY(&squery),
+                              (FTC_Node*) &node );
     if ( !error )
     {
-      *ansbit = (FTC_SBit)node->items + ( gindex - node->item_start );
+      *ansbit = node->sbits + (gindex - FTC_GLYPH_NODE(node)->item_start);
+
+      if ( anode )
+      {
+        *anode = FTC_NODE(node);
+        FTC_NODE(node)->ref_count ++;
+      }
     }
     return error;
   }
 
 
+
+ /* backwards-compatibility functions */
+
+  FT_EXPORT_DEF( FT_Error )
+  FTC_SBit_Cache_New( FTC_Manager      manager,
+                      FTC_SBit_Cache  *acache )
+  {
+    return FTC_SBitCache_New( manager, (FTC_SBitCache*)acache );
+  }
+
+
+  FT_EXPORT_DEF( FT_Error )
+  FTC_SBit_Cache_Lookup( FTC_SBit_Cache   cache,
+                         FTC_Image_Desc*  desc,
+                         FT_UInt          gindex,
+                         FTC_SBit        *ansbit )
+  {
+    FTC_ImageDesc  desc0;
+    
+    if ( !desc )
+      return FT_Err_Invalid_Argument;
+      
+    desc0.font = desc->font;
+    desc0.type = (FT_UInt32) desc->image_type;
+
+    return FTC_SBitCache_Lookup( (FTC_SBitCache)cache,
+                                  &desc0,
+                                  gindex,
+                                  ansbit,
+                                  NULL );
+  }
+
+
+
 /* END */
diff --git a/src/cache/ftlru.c b/src/cache/ftlru.c
index 5c4183b..6d2c897 100644
--- a/src/cache/ftlru.c
+++ b/src/cache/ftlru.c
@@ -46,7 +46,7 @@
       list->clazz      = clazz;
       list->memory     = memory;
       list->max_nodes  = max_nodes;
-      list->user_data  = user_data;
+      list->data  = user_data;
 
       if ( clazz->list_init )
       {
@@ -110,7 +110,7 @@
 
 
       if ( clazz->node_done )
-        clazz->node_done( node, list );
+        clazz->node_done( node, list->data );
 
       FREE( node );
       node = next;
@@ -151,7 +151,7 @@
         if ( node == NULL )
           break;
 
-        if ( clazz->node_compare( node, key, list ) )
+        if ( clazz->node_compare( node, key, list->data ) )
           break;
 
         plast = pnode;
@@ -203,15 +203,15 @@
       {
         if ( clazz->node_flush )
         {
-          error = clazz->node_flush( last, key, list );
+          error = clazz->node_flush( last, key, list->data );
         }
         else
         {
           if ( clazz->node_done )
-            clazz->node_done( last, list );
+            clazz->node_done( last, list->data );
 
           last->key  = key;
-          error = clazz->node_init( last, key, list );
+          error = clazz->node_init( last, key, list->data );
         }
 
         if ( !error )
@@ -228,7 +228,7 @@
         /* in case of error during the flush or done/init cycle, */
         /* we need to discard the node                           */
         if ( clazz->node_done )
-          clazz->node_done( last, list );
+          clazz->node_done( last, list->data );
 
         *plast = NULL;
         list->num_nodes--;
@@ -243,7 +243,7 @@
       goto Exit;
 
     node->key = key;
-    error = clazz->node_init( node, key, list );
+    error = clazz->node_init( node, key, list->data );
     if ( error )
     {
       FREE( node );
@@ -284,7 +284,7 @@
         node->next = NULL;
 
         if ( clazz->node_done )
-          clazz->node_done( node, list );
+          clazz->node_done( node, list->data );
 
         FREE( node );
         list->num_nodes--;
@@ -319,7 +319,7 @@
       if ( node == NULL )
         break;
 
-      if ( select_func( node, select_data, list ) )
+      if ( select_func( node, select_data, list->data ) )
       {
         *pnode     = node->next;
         node->next = NULL;
diff --git a/src/cache/rules.mk b/src/cache/rules.mk
index 1e84af2..0620cdd 100644
--- a/src/cache/rules.mk
+++ b/src/cache/rules.mk
@@ -30,8 +30,8 @@ Cache_COMPILE := $(FT_COMPILE) $I$(CACHE_DIR)
 #
 Cache_DRV_SRC := $(CACHE_DIR_)ftlru.c    \
                  $(CACHE_DIR_)ftcmanag.c \
+                 $(CACHE_DIR_)ftccache.c \
                  $(CACHE_DIR_)ftcglyph.c \
-                 $(CACHE_DIR_)ftcchunk.c \
                  $(CACHE_DIR_)ftcsbits.c \
                  $(CACHE_DIR_)ftcimage.c
 
diff --git a/src/pshinter/pshalgo1.c b/src/pshinter/pshalgo1.c
index d8b3022..010ac57 100644
--- a/src/pshinter/pshalgo1.c
+++ b/src/pshinter/pshalgo1.c
@@ -220,7 +220,7 @@
 
 
       FT_ERROR(( "%s.init: missing/incorrect hint masks!\n" ));
-      count = table->max_hints;
+      Count = table->max_hints;
       for ( Index = 0; Index < Count; Index++ )
         psh1_hint_table_record( table, Index );
     }
diff --git a/src/pshinter/pshalgo2.c b/src/pshinter/pshalgo2.c
index 4bfd355..6b27ec6 100644
--- a/src/pshinter/pshalgo2.c
+++ b/src/pshinter/pshalgo2.c
@@ -217,7 +217,7 @@
 
 
       FT_ERROR(( "%s.init: missing/incorrect hint masks!\n" ));
-      count = table->max_hints;
+      Count = table->max_hints;
       for ( Index = 0; Index < Count; Index++ )
         psh2_hint_table_record( table, Index );
     }
@@ -1495,15 +1495,12 @@
                    FT_Outline*  outline,
                    PSH_Globals  globals )
   {
-    PSH2_Glyph     glyph;
     PSH2_GlyphRec  glyphrec;
+    PSH2_Glyph     glyph = &glyphrec;
     FT_Error       error;
     FT_Memory      memory;
     FT_Int         dimension;
 
-    FT_UNUSED(glyphrec);
-
-
     memory = globals->memory;
 
 #ifdef DEBUG_HINTER
@@ -1517,8 +1514,6 @@
       return error;
 
     ps2_debug_glyph = glyph;
-#else
-    glyph = &glyphrec;
 #endif
 
     error = psh2_glyph_init( glyph, outline, ps_hints, globals );