Commit 4f99c3c4234bcc233eb4057cc33dd5e21f3eda27

David Turner 2000-05-29T20:55:13

fixed divide by zero bug added CFF/OpenType driver source (not working for now)

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
diff --git a/CHANGES b/CHANGES
index e7ffb23..5c1b7ae 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,5 +1,14 @@
 LATEST_CHANGES
 
+  - fixed potential "divide by zero" bugs in ftcalc.c.. my god..
+
+  - added source code for the OpenType/CFF driver (still incomplete though..)
+
+  - modified the SFNT driver slightly to perform more robust header
+    checks in TT_Load_SFNT_Header. This prevents certain font files
+    (e.g. some Type 1 Multiple Masters) from being incorrectly "recognized"
+    as TrueType font files..
+
   - moved a lot of stuff from the TrueType driver to the SFNT module,
     this allows greater code re-use between font drivers (e.g. TrueType,
     OpenType, Compact-TrueType, etc..)
diff --git a/src/base/ftcalc.c b/src/base/ftcalc.c
index ddc6946..90d58e1 100644
--- a/src/base/ftcalc.c
+++ b/src/base/ftcalc.c
@@ -132,13 +132,13 @@
   {
     FT_Int s;
 
-
     s = 1;
     if ( a < 0 ) { a = -a; s = -s; }
     if ( b < 0 ) { b = -b; s = -s; }
     if ( c < 0 ) { c = -c; s = -s; }
 
-    return s * ( ( (FT_Int64)a * b + ( c >> 1 ) ) / c );
+    return s * ( c > 0 ? ( ( (FT_Int64)a * b + ( c >> 1 ) ) / c )
+                       : 0x7FFFFFFF );
   }
 
 
@@ -344,21 +344,22 @@
     s ^= b; b = ABS( b );
     s ^= c; c = ABS( c );
 
-    if ( a <= 46340 && b <= 46340 && c <= 176095L )
+    if ( a <= 46340 && b <= 46340 && c <= 176095L && c > 0)
     {
-      a = ( a*b + (c >> 1) ) / c;
+      a = a*b + (c >> 1) ) / c;
     }
-    else
+    else if (c > 0)
     {
       FT_Int64  temp, temp2;
 
-
       FT_MulTo64( a, b, &temp );
       temp2.hi = (FT_Int32)(c >> 31);
       temp2.lo = (FT_Word32)(c / 2);
       FT_Add64( &temp, &temp2, &temp );
       a = FT_Div64by32( &temp, c );
     }
+    else
+      a = 0x7FFFFFFF;
 
     return ( s < 0 ) ? -a : a;
   }
@@ -614,7 +615,6 @@
     FT_Int32   s;
     FT_Word32  q, r, i, lo;
 
-
     s  = x->hi;
     if ( s < 0 )
     {
@@ -626,7 +626,9 @@
     /* Shortcut */
     if ( x->hi == 0 )
     {
-      q = x->lo / y;
+      if (y > 0) q = x->lo / y;
+            else q = 0x7FFFFFFF;
+
       return ( s < 0 ) ? -(FT_Int32)q : (FT_Int32)q;
     }
 
diff --git a/src/cff/cff.c b/src/cff/cff.c
new file mode 100644
index 0000000..b2581e9
--- /dev/null
+++ b/src/cff/cff.c
@@ -0,0 +1,49 @@
+/***************************************************************************/
+/*                                                                         */
+/*  cff.c                                                                  */
+/*                                                                         */
+/*    FreeType OpenType driver component (body only).                      */
+/*                                                                         */
+/*  Copyright 1996-1999 by                                                 */
+/*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
+/*                                                                         */
+/*  This file is part of the FreeType project, and may only be used        */
+/*  modified and distributed under the terms of the FreeType project       */
+/*  license, LICENSE.TXT.  By continuing to use, modify, or distribute     */
+/*  this file you indicate that you have read the license and              */
+/*  understand and accept it fully.                                        */
+/*                                                                         */
+/***************************************************************************/
+
+
+  /*************************************************************************/
+  /*                                                                       */
+  /*  This file is used to compile the FreeType TrueType font driver.  It  */
+  /*  relies on all components included in the `base' layer (see the file  */
+  /*  `ftbase.c').  The source code is located in `freetype/ttlib' and     */
+  /*  contains:                                                            */
+  /*                                                                       */
+  /*  - a driver interface                                                 */
+  /*  - an object manager                                                  */
+  /*  - a table loader                                                     */
+  /*  - a glyph loader                                                     */
+  /*  - a glyph hinter/bytecode interpreter                                */
+  /*  - a charmap processor                                                */
+  /*  - an extension manager (only used for some tools)                    */
+  /*                                                                       */
+  /*  Note that the engine extensions found in `freetype/ttlib/extend' are */
+  /*  reserved to specific tools and/or font servers; they're not part of  */
+  /*  the `core' TrueType driver, even though they are separately linkable */
+  /*  to it.                                                               */
+  /*                                                                       */
+  /*************************************************************************/
+
+
+#define FT_MAKE_OPTION_SINGLE_OBJECT
+
+#include <t2driver.c>    /* driver interface     */
+#include <t2parse.c>     /* token parser         */
+#include <t2load.c>      /* tables loader        */
+#include <t2objs.c>      /* object management    */
+
+/* END */
diff --git a/src/cff/module.mk b/src/cff/module.mk
new file mode 100644
index 0000000..1e8b925
--- /dev/null
+++ b/src/cff/module.mk
@@ -0,0 +1,7 @@
+make_module_list: add_cff_driver
+
+add_cff_driver:
+	$(OPEN_DRIVER)cff_driver_interface$(CLOSE_DRIVER)
+	$(ECHO_DRIVER)cff       $(ECHO_DRIVER_DESC)OpenType fonts with extension *.otf$(ECHO_DRIVER_DONE)
+
+# EOF
diff --git a/src/cff/rules.mk b/src/cff/rules.mk
new file mode 100644
index 0000000..39e658d
--- /dev/null
+++ b/src/cff/rules.mk
@@ -0,0 +1,112 @@
+#
+# FreeType 2 OpenType/CFF driver configuration rules
+#
+
+
+# Copyright 1996-2000 by
+# David Turner, Robert Wilhelm, and Werner Lemberg.
+#
+# This file is part of the FreeType project, and may only be used modified
+# and distributed under the terms of the FreeType project license,
+# LICENSE.TXT.  By continuing to use, modify, or distribute this file you
+# indicate that you have read the license and understand and accept it
+# fully.
+
+
+# Include the rules defined for the SFNT driver, which is heavily used
+# by the TrueType one.
+#
+include $(SRC_)sfnt/rules.mk
+
+
+# OpenType driver directory
+#
+T2_DIR  := $(SRC_)cff
+T2_DIR_ := $(T2_DIR)$(SEP)
+
+
+# location of all extensions to the driver, if any
+#
+T2_EXT_DIR  := $(T2_DIR_)extend
+T2_EXT_DIR_ := $(T2_EXT_DIR)$(SEP)
+
+# additional include flags used when compiling the driver
+#
+T2_INCLUDE := $(SFNT_INCLUDE) $(T2_DIR) $(T2_EXT_DIR)
+
+
+# compilation flags for the driver
+#
+T2_CFLAGS  := $(T2_INCLUDE:%=$I%)
+T2_COMPILE := $(FT_COMPILE) $(T2_CFLAGS)
+
+
+# driver sources (i.e., C files)
+#
+T2_DRV_SRC := $(T2_DIR_)t2objs.c   \
+              $(T2_DIR_)t2load.c   \
+              $(T2_DIR_)t2gload.c  \
+              $(T2_DIR_)t2parse.c  \
+              $(T2_DIR_)t2driver.c
+
+# driver headers
+#
+T2_DRV_H := $(SFNT_H)             \
+            $(T2_DRV_SRC:%.c=%.h)
+
+
+# default extensions headers
+#
+T2_EXT_H := $(T2_EXT_SRC:.c=.h)
+
+
+# driver object(s)
+#
+#   T2_DRV_OBJ_M is used during `debug' builds
+#   T2_DRV_OBJ_S is used during `release' builds
+#
+T2_DRV_OBJ_M := $(T2_DRV_SRC:$(T2_DIR_)%.c=$(OBJ_)%.$O)
+T2_DRV_OBJ_S := $(OBJ_)cff.$O
+
+
+# default extensions objects
+#
+T2_EXT_OBJ := $(T2_EXT_SRC:$(T2_EXT_DIR_)%.c=$(OBJ_)%.$O)
+
+
+# driver source file(s)
+#
+T2_DRV_SRC_M := $(T2_DRV_SRC) $(SFNT_SRC)
+T2_DRV_SRC_S := $(T2_DIR_)cff.c
+
+
+# driver - single object
+#
+#  the driver is recompiled if any of the header or source files is changed
+#  as well as any of the shared source files found in `shared/sfnt'
+#
+$(T2_DRV_OBJ_S): $(BASE_H) $(T2_DRV_H) $(T2_DRV_SRC) $(T2_DRV_SRC_S)
+	$(T2_COMPILE) $T$@ $(T2_DRV_SRC_S)
+
+
+
+# driver - multiple objects
+#
+#   All objects are recompiled if any of the header files is changed
+#
+$(OBJ_)t2%.$O: $(T2_DIR_)t2%.c $(BASE_H) $(T2_DRV_H)
+	$(T2_COMPILE) $T$@ $<
+
+$(OBJ_)t2x%.$O: $(T2_EXT_DIR_)t2x%.c $(BASE_H) $(SFNT_H) $(T2_EXT_H)
+	$(T2_COMPILE) $T$@ $<
+
+$(OBJ_)t2%.$O: $(SFNT_DIR_)t2%.c $(BASE_H) $(SFNT_H)
+	$(T2_COMPILE) $T$@ $<
+
+
+# update main driver object lists
+#
+DRV_OBJS_S += $(T2_DRV_OBJ_S)
+DRV_OBJS_M += $(T2_DRV_OBJ_M)
+
+# EOF
diff --git a/src/cff/t2driver.c b/src/cff/t2driver.c
new file mode 100644
index 0000000..cac43ca
--- /dev/null
+++ b/src/cff/t2driver.c
@@ -0,0 +1,444 @@
+/***************************************************************************/
+/*                                                                         */
+/*  t2driver.c                                                             */
+/*                                                                         */
+/*    OpenType font driver implementation (body).                          */
+/*                                                                         */
+/*  Copyright 1996-1999 by                                                 */
+/*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
+/*                                                                         */
+/*  This file is part of the FreeType project, and may only be used,       */
+/*  modified, and distributed under the terms of the FreeType project      */
+/*  license, LICENSE.TXT.  By continuing to use, modify, or distribute     */
+/*  this file you indicate that you have read the license and              */
+/*  understand and accept it fully.                                        */
+/*                                                                         */
+/***************************************************************************/
+
+
+#include <freetype/internal/ftdebug.h>
+#include <freetype/internal/ftstream.h>
+#include <freetype/internal/sfnt.h>
+#include <freetype/ttnameid.h>
+
+#include <t2driver.h>
+#include <t2gload.h>
+
+
+#undef  FT_COMPONENT
+#define FT_COMPONENT  trace_ttdriver
+
+
+
+  /*************************************************************************/
+  /*************************************************************************/
+  /*************************************************************************/
+  /****                                                                 ****/
+  /****                                                                 ****/
+  /****                          F A C E S                              ****/
+  /****                                                                 ****/
+  /****                                                                 ****/
+  /*************************************************************************/
+  /*************************************************************************/
+  /*************************************************************************/
+
+#undef  PAIR_TAG
+#define PAIR_TAG( left, right )  ( ((TT_ULong)left << 16) | (TT_ULong)right )
+
+  /*************************************************************************/
+  /*                                                                       */
+  /* <Function>                                                            */
+  /*    Get_Kerning                                                        */
+  /*                                                                       */
+  /* <Description>                                                         */
+  /*    A driver method used to return the kerning vector between two      */
+  /*    glyphs of the same face.                                           */
+  /*                                                                       */
+  /* <Input>                                                               */
+  /*    face        :: A handle to the source face object.                 */
+  /*                                                                       */
+  /*    left_glyph  :: The index of the left glyph in the kern pair.       */
+  /*                                                                       */
+  /*    right_glyph :: The index of the right glyph in the kern pair.      */
+  /*                                                                       */
+  /* <Output>                                                              */
+  /*    kerning     :: The kerning vector.  This is in font units for      */
+  /*                   scalable formats, and in pixels for fixed-sizes     */
+  /*                   formats.                                            */
+  /*                                                                       */
+  /* <Return>                                                              */
+  /*    FreeType error code.  0 means success.                             */
+  /*                                                                       */
+  /* <Note>                                                                */
+  /*    Only horizontal layouts (left-to-right & right-to-left) are        */
+  /*    supported by this function.  Other layouts, or more sophisticated  */
+  /*    kernings are out of scope of this method (the basic driver         */
+  /*    interface is meant to be simple).                                  */
+  /*                                                                       */
+  /*    They can be implemented by format-specific interfaces.             */
+  /*                                                                       */
+  static
+  TT_Error  Get_Kerning( TT_Face     face,
+                         TT_UInt     left_glyph,
+                         TT_UInt     right_glyph,
+                         TT_Vector*  kerning )
+  {
+    TT_Kern_0_Pair*  pair;
+
+
+    if ( !face )
+      return FT_Err_Invalid_Face_Handle;
+
+    kerning->x = 0;
+    kerning->y = 0;
+
+    if ( face->kern_pairs )
+    {
+      /* there are some kerning pairs in this font file! */
+      TT_ULong  search_tag = PAIR_TAG( left_glyph, right_glyph );
+      TT_Long   left, right;
+
+
+      left  = 0;
+      right = face->num_kern_pairs - 1;
+
+      while ( left <= right )
+      {
+        TT_Int    middle   = left + ((right-left) >> 1);
+        TT_ULong  cur_pair;
+
+
+        pair     = face->kern_pairs + middle;
+        cur_pair = PAIR_TAG( pair->left, pair->right );
+
+        if ( cur_pair == search_tag )
+          goto Found;
+
+        if ( cur_pair < search_tag )
+          left = middle+1;
+        else
+          right = middle-1;
+      }
+    }
+
+  Exit:
+    return FT_Err_Ok;
+
+  Found:
+    kerning->x = pair->value;
+    goto Exit;
+  }
+
+
+#undef PAIR_TAG
+
+
+  /*************************************************************************/
+  /*************************************************************************/
+  /*************************************************************************/
+  /****                                                                 ****/
+  /****                                                                 ****/
+  /****                           S I Z E S                             ****/
+  /****                                                                 ****/
+  /****                                                                 ****/
+  /*************************************************************************/
+  /*************************************************************************/
+  /*************************************************************************/
+
+
+  /*************************************************************************/
+  /*                                                                       */
+  /* <Function>                                                            */
+  /*    Set_Char_Sizes                                                     */
+  /*                                                                       */
+  /* <Description>                                                         */
+  /*    A driver method used to reset a size's character sizes (horizontal */
+  /*    and vertical) expressed in fractional points.                      */
+  /*                                                                       */
+  /* <Input>                                                               */
+  /*    char_width  :: The character width expressed in 26.6 fractional    */
+  /*                   points.                                             */
+  /*    char_height :: The character height expressed in 26.6 fractional   */
+  /*                   points.                                             */
+  /*                                                                       */
+  /* <InOut>                                                               */
+  /*    size        :: A handle to the target size object.                 */
+  /*                                                                       */
+  /* <Return>                                                              */
+  /*    FreeType error code.  0 means success.                             */
+  /*                                                                       */
+  static
+  TT_Error  Set_Char_Sizes( T2_Size     size,
+                            FT_F26Dot6  char_width,
+                            FT_F26Dot6  char_height,
+                            FT_UInt     horz_resolution,
+                            FT_UInt     vert_resolution )
+  {
+    FT_Size_Metrics*  metrics = &size->metrics;
+    T2_Face           face    = (T2_Face)size->face;
+    FT_Long           dim_x, dim_y;
+
+    /* This bit flag, when set, indicates that the pixel size must be */
+    /* truncated to an integer. Nearly all TrueType fonts have this   */
+    /* bit set, as hinting won't work really well otherwise.          */
+    /*                                                                */
+    /* However, for those rare fonts who do not set it, we override   */
+    /* the default computations performed by the base layer. I really */
+    /* don't know if this is useful, but hey, that's the spec :-)     */
+    /*                                                                */
+    if ( (face->header.Flags & 8) == 0 )
+    {
+      /* Compute pixel sizes in 26.6 units */
+      dim_x = (char_width * horz_resolution) / 72;
+      dim_y = (char_height * vert_resolution) / 72;
+
+      metrics->x_scale = FT_DivFix( dim_x, face->root.units_per_EM );
+      metrics->y_scale = FT_DivFix( dim_y, face->root.units_per_EM );
+
+      metrics->x_ppem    = (TT_UShort)(dim_x >> 6);
+      metrics->y_ppem    = (TT_UShort)(dim_y >> 6);
+    }
+
+    return T2_Reset_Size( size );
+  }
+
+
+  /*************************************************************************/
+  /*                                                                       */
+  /* <Function>                                                            */
+  /*    Set_Pixel_Sizes                                                    */
+  /*                                                                       */
+  /* <Description>                                                         */
+  /*    A driver method used to reset a size's character sizes (horizontal */
+  /*    and vertical) expressed in integer pixels.                         */
+  /*                                                                       */
+  /* <Input>                                                               */
+  /*    pixel_width  :: The character width expressed in integer pixels.   */
+  /*                                                                       */
+  /*    pixel_height :: The character height expressed in integer pixels.  */
+  /*                                                                       */
+  /* <InOut>                                                               */
+  /*    size         :: A handle to the target size object.                */
+  /*                                                                       */
+  /* <Return>                                                              */
+  /*    FreeType error code. 0 means success                               */
+  /*                                                                       */
+  static
+  FT_Error  Set_Pixel_Sizes( T2_Size  size,
+                             FT_UInt  pixel_width,
+                             FT_UInt  pixel_height )
+  {
+    UNUSED(pixel_width);
+    UNUSED(pixel_height);
+
+    return T2_Reset_Size( size );
+  }
+
+
+  /*************************************************************************/
+  /*                                                                       */
+  /* <Function>                                                            */
+  /*    Load_Glyph                                                         */
+  /*                                                                       */
+  /* <Description>                                                         */
+  /*    A driver method used to load a glyph within a given glyph slot.    */
+  /*                                                                       */
+  /* <Input>                                                               */
+  /*    slot        :: A handle to the target slot object where the glyph  */
+  /*                   will be loaded.                                     */
+  /*                                                                       */
+  /*    size        :: A handle to the source face size at which the glyph */
+  /*                   must be scaled/loaded/etc.                          */
+  /*                                                                       */
+  /*    glyph_index :: The index of the glyph in the font file.            */
+  /*                                                                       */
+  /*    load_flags  :: A flag indicating what to load for this glyph.  The */
+  /*                   FTLOAD_??? constants can be used to control the     */
+  /*                   glyph loading process (e.g., whether the outline    */
+  /*                   should be scaled, whether to load bitmaps or not,   */
+  /*                   whether to hint the outline, etc).                  */
+  /* <Output>                                                              */
+  /*    result      :: A set of bit flags indicating the type of data that */
+  /*                   was loaded in the glyph slot (outline, bitmap,      */
+  /*                   pixmap, etc).                                       */
+  /*                                                                       */
+  /* <Return>                                                              */
+  /*    FreeType error code.  0 means success.                             */
+  /*                                                                       */
+  static
+  FT_Error  Load_Glyph( T2_GlyphSlot  slot,
+                        T2_Size       size,
+                        FT_UShort     glyph_index,
+                        FT_UInt       load_flags )
+  {
+    FT_Error  error;
+
+
+    if ( !slot )
+      return FT_Err_Invalid_Handle;
+
+    /* check that we want a scaled outline or bitmap */
+    if ( !size )
+      load_flags |= FT_LOAD_NO_SCALE | FT_LOAD_NO_HINTING;
+
+    if ( load_flags & FT_LOAD_NO_SCALE )
+      size = NULL;
+
+    /* reset the size object if necessary */
+    if ( size )
+    {
+      /* these two object must have the same parent */
+      if ( size->face != slot->face )
+        return FT_Err_Invalid_Face_Handle;
+    }
+
+    /* now load the glyph outline if necessary */
+#if 1 /* XXXX: TODO */
+    error = FT_Err_Unimplemented_Feature;
+#else    
+    error = T2_Load_Glyph( size, slot, glyph_index, load_flags );
+#endif
+    /* force drop-out mode to 2 - irrelevant now */
+    /* slot->outline.dropout_mode = 2; */
+
+    return error;
+  }
+
+
+  /*************************************************************************/
+  /*************************************************************************/
+  /*************************************************************************/
+  /****                                                                 ****/
+  /****                                                                 ****/
+  /****             C H A R A C T E R   M A P P I N G S                 ****/
+  /****                                                                 ****/
+  /****                                                                 ****/
+  /*************************************************************************/
+  /*************************************************************************/
+  /*************************************************************************/
+
+  /*************************************************************************/
+  /*                                                                       */
+  /* <Function>                                                            */
+  /*    Get_Char_Index                                                     */
+  /*                                                                       */
+  /* <Description>                                                         */
+  /*    Uses a charmap to return a given character code's glyph index.     */
+  /*                                                                       */
+  /* <Input>                                                               */
+  /*    charmap  :: A handle to the source charmap object.                 */
+  /*    charcode :: The character code.                                    */
+  /*                                                                       */
+  /* <Return>                                                              */
+  /*    Glyph index.  0 means `undefined character code'.                  */
+  /*                                                                       */
+  static
+  FT_UInt  Get_Char_Index( TT_CharMap  charmap,
+                           FT_Long     charcode )
+  {
+    FT_Error       error;
+    T2_Face        face;
+    TT_CMapTable*  cmap;
+
+    cmap = &charmap->cmap;
+    face = (T2_Face)charmap->root.face;
+
+    /* Load table if needed */
+    if ( !cmap->loaded )
+    {
+      SFNT_Interface*  sfnt = (SFNT_Interface*)face->sfnt;
+
+      error = sfnt->load_charmap( face, cmap, face->root.stream );
+      if (error) return error;
+
+      cmap->loaded = TRUE;
+    }
+
+    return (cmap->get_index ? cmap->get_index( cmap, charcode ) : 0 );
+  }
+
+
+  static
+  FTDriver_Interface  t2_get_interface( T2_Driver  driver, const char* interface )
+  {
+    FT_Driver        sfntd = FT_Get_Driver( driver->root.library, "sfnt" );
+    SFNT_Interface*  sfnt;
+    
+    /* only return the default interface from the SFNT module */
+    if (sfntd)
+    {
+      sfnt = (SFNT_Interface*)(sfntd->interface.format_interface);
+      if (sfnt)
+        return sfnt->get_interface( (FT_Driver)driver, interface );
+    }
+    return 0;
+  }
+
+
+  /* The FT_DriverInterface structure is defined in ftdriver.h. */
+
+  const FT_DriverInterface  cff_driver_interface =
+  {
+    sizeof ( T2_DriverRec ),
+    sizeof ( TT_FaceRec ),
+    sizeof ( FT_SizeRec ),
+    sizeof ( FT_GlyphSlotRec ),
+
+    "cff",           /* driver name                           */
+    100,             /* driver version == 1.0                 */
+    200,             /* driver requires FreeType 2.0 or above */
+
+    (void*)0,
+
+    (FTDriver_initDriver)        T2_Init_Driver,
+    (FTDriver_doneDriver)        T2_Done_Driver,
+    (FTDriver_getInterface)      t2_get_interface,
+
+    (FTDriver_initFace)          T2_Init_Face,
+    (FTDriver_doneFace)          T2_Done_Face,
+    (FTDriver_getKerning)        Get_Kerning,
+
+    (FTDriver_initSize)          T2_Init_Size,
+    (FTDriver_doneSize)          T2_Done_Size,
+    (FTDriver_setCharSizes)      Set_Char_Sizes,
+    (FTDriver_setPixelSizes)     Set_Pixel_Sizes,
+
+    (FTDriver_initGlyphSlot)     T2_Init_GlyphSlot,
+    (FTDriver_doneGlyphSlot)     T2_Done_GlyphSlot,
+    (FTDriver_loadGlyph)         Load_Glyph,
+
+    (FTDriver_getCharIndex)      Get_Char_Index,
+  };
+
+
+
+  /*************************************************************************/
+  /*                                                                       */
+  /* <Function>                                                            */
+  /*    getDriverInterface                                                 */
+  /*                                                                       */
+  /* <Description>                                                         */
+  /*    This function is used when compiling the TrueType driver as a      */
+  /*    shared library (`.DLL' or `.so').  It will be used by the          */
+  /*    high-level library of FreeType to retrieve the address of the      */
+  /*    driver's generic interface.                                        */
+  /*                                                                       */
+  /*    It shouldn't be implemented in a static build, as each driver must */
+  /*    have the same function as an exported entry point.                 */
+  /*                                                                       */
+  /* <Return>                                                              */
+  /*    The address of the TrueType's driver generic interface.  The       */
+  /*    format-specific interface can then be retrieved through the method */
+  /*    interface->get_format_interface.                                   */
+  /*                                                                       */
+#ifdef FT_CONFIG_OPTION_DYNAMIC_DRIVERS
+
+  EXPORT_FUNC(FT_DriverInterface*)  getDriverInterface( void )
+  {
+    return &cff_driver_interface;
+  }
+
+#endif /* CONFIG_OPTION_DYNAMIC_DRIVERS */
+
+
+/* END */
diff --git a/src/cff/t2driver.h b/src/cff/t2driver.h
new file mode 100644
index 0000000..129096e
--- /dev/null
+++ b/src/cff/t2driver.h
@@ -0,0 +1,34 @@
+/***************************************************************************/
+/*                                                                         */
+/*  t2driver.h                                                             */
+/*                                                                         */
+/*    High-level OpenType driver interface (specification).                */
+/*                                                                         */
+/*  Copyright 1996-1999 by                                                 */
+/*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
+/*                                                                         */
+/*  This file is part of the FreeType project, and may only be used,       */
+/*  modified, and distributed under the terms of the FreeType project      */
+/*  license, LICENSE.TXT.  By continuing to use, modify, or distribute     */
+/*  this file you indicate that you have read the license and              */
+/*  understand and accept it fully.                                        */
+/*                                                                         */
+/***************************************************************************/
+
+
+#ifndef T2DRIVER_H
+#define T2DRIVER_H
+
+#include <freetype/internal/ftdriver.h>
+#include <freetype/ttnameid.h>
+#include <t2objs.h>
+#include <t2errors.h>
+
+
+  FT_EXPORT_VAR(const FT_DriverInterface)  cff_driver_interface;
+
+
+#endif /* T2DRIVER_H */
+
+
+/* END */
diff --git a/src/cff/t2errors.h b/src/cff/t2errors.h
new file mode 100644
index 0000000..ab3d4e4
--- /dev/null
+++ b/src/cff/t2errors.h
@@ -0,0 +1,126 @@
+/***************************************************************************/
+/*                                                                         */
+/*  t2errors.h                                                             */
+/*                                                                         */
+/*    OpenType error ID definitions (specification only).                  */
+/*                                                                         */
+/*  Copyright 1996-1999 by                                                 */
+/*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
+/*                                                                         */
+/*  This file is part of the FreeType project, and may only be used        */
+/*  modified and distributed under the terms of the FreeType project       */
+/*  license, LICENSE.TXT.  By continuing to use, modify, or distribute     */
+/*  this file you indicate that you have read the license and              */
+/*  understand and accept it fully.                                        */
+/*                                                                         */
+/***************************************************************************/
+
+
+#ifndef T2ERRORS_H
+#define T2ERRORS_H
+
+  /*************************************************************************/
+  /*                                                                       */
+  /* Error codes declaration                                               */
+  /*                                                                       */
+  /* The error codes are grouped in `classes' used to indicate the `level' */
+  /* at which the error happened.  The class is given by an error code's   */
+  /* high byte.                                                            */
+  /*                                                                       */
+  /*************************************************************************/
+
+
+  /* Success is always 0. */
+
+#define  T2_Err_Ok                       FT_Err_Ok
+
+  /* High level API errors. */
+
+#define  T2_Err_Invalid_File_Format      FT_Err_Invalid_File_Format
+#define  T2_Err_Invalid_Argument         FT_Err_Invalid_Argument
+#define  T2_Err_Invalid_Driver_Handle    FT_Err_Invalid_Driver_Handle
+#define  T2_Err_Invalid_Face_Handle      FT_Err_Invalid_Face_Handle
+#define  T2_Err_Invalid_Instance_Handle  FT_Err_Invalid_Size_Handle
+#define  T2_Err_Invalid_Glyph_Handle     FT_Err_Invalid_Slot_Handle
+#define  T2_Err_Invalid_CharMap_Handle   FT_Err_Invalid_CharMap_Handle
+#define  T2_Err_Invalid_Glyph_Index      FT_Err_Invalid_Glyph_Index
+
+#define  T2_Err_Unimplemented_Feature    FT_Err_Unimplemented_Feature
+#define  T2_Err_Unavailable_Outline      FT_Err_Unavailable_Outline
+#define  T2_Err_Unavailable_Bitmap       FT_Err_Unavailable_Bitmap
+#define  T2_Err_Unavailable_Pixmap       FT_Err_Unavailable_Pixmap
+#define  T2_Err_File_Is_Not_Collection   FT_Err_File_Is_Not_Collection
+
+#define  T2_Err_Invalid_Engine           FT_Err_Invalid_Driver_Handle
+
+  /* Internal errors. */
+
+#define  T2_Err_Out_Of_Memory            FT_Err_Out_Of_Memory
+#define  T2_Err_Unlisted_Object          FT_Err_Unlisted_Object
+
+  /* General glyph outline errors. */
+
+#define  T2_Err_Too_Many_Points          FT_Err_Too_Many_Points
+#define  T2_Err_Too_Many_Contours        FT_Err_Too_Many_Contours
+#define  T2_Err_Too_Many_Ins             FT_Err_Too_Many_Hints
+#define  T2_Err_Invalid_Composite        FT_Err_Invalid_Composite
+
+  /* Bytecode interpreter error codes. */
+
+  /* These error codes are produced by the TrueType */
+  /* bytecode interpreter.  They usually indicate a */
+  /* broken font file, a broken glyph within a font */
+  /* file, or a bug in the interpreter!             */
+
+#define T2_Err_Invalid_Opcode           0x400
+#define T2_Err_Too_Few_Arguments        0x401
+#define T2_Err_Stack_Overflow           0x402
+#define T2_Err_Code_Overflow            0x403
+#define T2_Err_Bad_Argument             0x404
+#define T2_Err_Divide_By_Zero           0x405
+#define T2_Err_Storage_Overflow         0x406
+#define T2_Err_Cvt_Overflow             0x407
+#define T2_Err_Invalid_Reference        0x408
+#define T2_Err_Invalid_Distance         0x409
+#define T2_Err_Interpolate_Twilight     0x40A
+#define T2_Err_Debug_OpCode             0x40B
+#define T2_Err_ENDF_In_Exec_Stream      0x40C
+#define T2_Err_Out_Of_CodeRanges        0x40D
+#define T2_Err_Nested_DEFS              0x40E
+#define T2_Err_Invalid_CodeRange        0x40F
+#define T2_Err_Invalid_Displacement     0x410
+#define T2_Err_Execution_Too_Long       0x411
+
+#define T2_Err_Too_Many_Instruction_Defs  0x412
+#define T2_Err_Too_Many_Function_Defs     0x412
+
+  /* Other TrueType specific error codes. */
+
+#define T2_Err_Table_Missing            0x420
+#define T2_Err_Too_Many_Extensions      0x421
+#define T2_Err_Extensions_Unsupported   0x422
+#define T2_Err_Invalid_Extension_Id     0x423
+
+#define T2_Err_No_Vertical_Data         0x424
+
+#define T2_Err_Max_Profile_Missing      0x430
+#define T2_Err_Header_Table_Missing     0x431
+#define T2_Err_Horiz_Header_Missing     0x432
+#define T2_Err_Locations_Missing        0x433
+#define T2_Err_Name_Table_Missing       0x434
+#define T2_Err_CMap_Table_Missing       0x435
+#define T2_Err_Hmtx_Table_Missing       0x436
+#define T2_Err_OS2_Table_Missing        0x437
+#define T2_Err_Post_Table_Missing       0x438
+
+#define T2_Err_Invalid_Horiz_Metrics    0x440
+#define T2_Err_Invalid_CharMap_Format   0x441
+#define T2_Err_Invalid_PPem             0x442
+#define T2_Err_Invalid_Vert_Metrics     0x443
+
+#define T2_Err_Could_Not_Find_Context   0x450
+
+#endif /* FTERRID_H */
+
+
+/* END */
diff --git a/src/cff/t2gload.c b/src/cff/t2gload.c
new file mode 100644
index 0000000..a5caa75
--- /dev/null
+++ b/src/cff/t2gload.c
@@ -0,0 +1,1177 @@
+/***************************************************************************/
+/*                                                                         */
+/*  t2gload.c                                                              */
+/*                                                                         */
+/*    OpenType Glyph Loader (body).                                        */
+/*                                                                         */
+/*  Copyright 1996-1999 by                                                 */
+/*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
+/*                                                                         */
+/*  This file is part of the FreeType project, and may only be used        */
+/*  modified and distributed under the terms of the FreeType project       */
+/*  license, LICENSE.TXT.  By continuing to use, modify, or distribute     */
+/*  this file you indicate that you have read the license and              */
+/*  understand and accept it fully.                                        */
+/*                                                                         */
+/***************************************************************************/
+
+
+#include <freetype/internal/ftdebug.h>
+#include <freetype/internal/ftcalc.h>
+#include <freetype/internal/ftstream.h>
+#include <freetype/internal/sfnt.h>
+#include <freetype/tttags.h>
+
+
+#include <t2gload.h>
+
+  /* required for the tracing mode */
+#undef  FT_COMPONENT
+#define FT_COMPONENT  trace_ttgload
+
+
+  /*************************************************************************/
+  /*                                                                       */
+  /* Composite font flags.                                                 */
+  /*                                                                       */
+#define ARGS_ARE_WORDS       0x001
+#define ARGS_ARE_XY_VALUES   0x002
+#define ROUND_XY_TO_GRID     0x004
+#define WE_HAVE_A_SCALE      0x008
+/* reserved                  0x010 */
+#define MORE_COMPONENTS      0x020
+#define WE_HAVE_AN_XY_SCALE  0x040
+#define WE_HAVE_A_2X2        0x080
+#define WE_HAVE_INSTR        0x100
+#define USE_MY_METRICS       0x200
+
+
+
+  /*************************************************************************/
+  /*    Returns the horizontal or vertical metrics in font units for a     */
+  /*    given glyph.  The metrics are the left side bearing (resp. top     */
+  /*    side bearing) and advance width (resp. advance height).            */
+  /*                                                                       */
+  LOCAL_FUNC
+  void  T2_Get_Metrics( TT_HoriHeader*  header,
+                        FT_UInt       index,
+                        FT_Short*       bearing,
+                        FT_UShort*      advance )
+  {
+    TT_LongMetrics*  longs_m;
+    TT_UShort        k = header->number_Of_HMetrics;
+
+
+    if ( index < k )
+    {
+      longs_m  = (TT_LongMetrics*)header->long_metrics + index;
+      *bearing = longs_m->bearing;
+      *advance = longs_m->advance;
+    }
+    else
+    {
+      *bearing = ((TT_ShortMetrics*)header->short_metrics)[index - k];
+      *advance = ((TT_LongMetrics*)header->long_metrics)[k - 1].advance;
+    }
+  }
+
+
+  /*************************************************************************/
+  /*    Returns the horizontal metrics in font units for a given glyph.    */
+  /*    If `check' is true, take care of monospaced fonts by returning the */
+  /*    advance width maximum.                                             */
+  /*                                                                       */
+  static
+  void Get_HMetrics( T2_Face     face,
+                     FT_UInt     index,
+                     FT_Bool     check,
+                     FT_Short*   lsb,
+                     FT_UShort*  aw )
+  {
+    T2_Get_Metrics( &face->horizontal, index, lsb, aw );
+
+    if ( check && face->postscript.isFixedPitch )
+      *aw = face->horizontal.advance_Width_Max;
+  }
+
+
+  /*************************************************************************/
+  /*    Returns the advance width table for a given pixel size if it is    */
+  /*    found in the font's `hdmx' table (if any).                         */
+  /*                                                                       */
+  static
+  FT_Byte*  Get_Advance_Widths( T2_Face    face,
+                                FT_UShort  ppem )
+  {
+    FT_UShort  n;
+
+    for ( n = 0; n < face->hdmx.num_records; n++ )
+      if ( face->hdmx.records[n].ppem == ppem )
+        return face->hdmx.records[n].widths;
+
+    return NULL;
+  }
+
+
+#define cur_to_org( n, zone )  \
+          MEM_Copy( (zone)->org, (zone)->cur, n * sizeof ( TT_Vector ) )
+
+#define org_to_cur( n, zone )  \
+          MEM_Copy( (zone)->cur, (zone)->org, n * sizeof ( TT_Vector ) )
+
+
+  /*************************************************************************/
+  /*    Translates an array of coordinates.                                */
+  /*                                                                       */
+  static
+  void  translate_array( FT_UInt     n,
+                         FT_Vector*  coords,
+                         FT_Pos      delta_x,
+                         FT_Pos      delta_y )
+  {
+    FT_UInt  k;
+
+    if ( delta_x )
+      for ( k = 0; k < n; k++ )
+        coords[k].x += delta_x;
+
+    if ( delta_y )
+      for ( k = 0; k < n; k++ )
+        coords[k].y += delta_y;
+  }
+
+
+
+  /*************************************************************************/
+  /*    Mounts one glyph zone on top of another.  This is needed to        */
+  /*    assemble composite glyphs.                                         */
+  /*                                                                       */
+  static
+  void  mount_zone( FT_GlyphZone*  source,
+                    FT_GlyphZone*  target )
+  {
+    FT_UInt  np;
+    FT_Int   nc;
+
+    np = source->n_points;
+    nc = source->n_contours;
+
+    target->org   = source->org + np;
+    target->cur   = source->cur + np;
+    target->tags = source->tags + np;
+
+    target->contours = source->contours + nc;
+
+    target->n_points   = 0;
+    target->n_contours = 0;
+  }
+
+
+#undef  IS_HINTED
+#define IS_HINTED(flags)  ((flags & FT_LOAD_NO_HINTING) == 0)
+
+  /*************************************************************************/
+  /*                                                                       */
+  /* <Function>                                                            */
+  /*    Load_Simple_Glyph                                                  */
+  /*                                                                       */
+  /* <Description>                                                         */
+  /*    Loads a simple (i.e, non-composite) glyph.  This function is used  */
+  /*    for the `Load_Simple' state of TT_Load_Glyph().  All composite     */
+  /*    glyphs elements will be loaded with routine.                       */
+  /*                                                                       */
+  static
+  FT_Error  Load_Simple( T2_Loader*       load,
+                         FT_UInt          byte_count,
+                         FT_Int           n_contours,
+                         FT_Bool          debug )
+  {
+    FT_Error       error;
+    FT_Stream      stream = load->stream;
+    FT_GlyphZone*  zone   = &load->zone;
+    T2_Face        face = load->face;
+
+    FT_UShort      n_ins;
+    FT_Int         n, n_points;
+
+    /*********************************************************************/
+    /* simple check                                                      */
+
+    if ( n_contours > load->left_contours )
+    {
+      FT_TRACE0(( "ERROR: Glyph index %ld has %d contours > left %d\n",
+                   load->glyph_index,
+                   n_contours,
+                   load->left_contours ));
+      return TT_Err_Too_Many_Contours;
+    }
+
+    /* preparing the execution context */
+    mount_zone( &load->base, zone );
+
+    /*********************************************************************/
+    /* reading the contours endpoints                                    */
+
+    if ( ACCESS_Frame( byte_count ) )
+      return error;
+
+    for ( n = 0; n < n_contours; n++ )
+      zone->contours[n] = GET_UShort();
+
+    n_points = 0;
+    if ( n_contours > 0 )
+      n_points = zone->contours[n_contours - 1] + 1;
+
+
+    /*********************************************************************/
+    /* reading the bytecode instructions                                 */
+
+    n_ins = GET_UShort();
+    load->face->root.glyph->control_len = n_ins;
+
+    if ( n_points > load->left_points )
+    {
+      FT_TRACE0(( "ERROR: Too many points in glyph %ld\n", load->glyph_index ));
+      error = TT_Err_Too_Many_Points;
+      goto Fail;
+    }
+
+    FT_TRACE4(( "Instructions size : %d\n", n_ins ));
+
+    if ( n_ins > face->max_profile.maxSizeOfInstructions )
+    {
+      FT_TRACE0(( "ERROR: Too many instructions!\n" ));
+      error = TT_Err_Too_Many_Ins;
+      goto Fail;
+    }
+
+    if (stream->cursor + n_ins > stream->limit)
+    {
+      FT_TRACE0(( "ERROR: Instruction count mismatch!\n" ));
+      error = TT_Err_Too_Many_Ins;
+      goto Fail;
+    }
+
+    stream->cursor += n_ins;
+
+    /*********************************************************************/
+    /* reading the point tags                                           */
+
+    {
+      FT_Byte*  flag  = load->zone.tags;
+      FT_Byte*  limit = flag + n_points;
+      FT_Byte   c, count;
+
+      for (; flag < limit; flag++)
+      {
+        *flag = c = GET_Byte();
+        if ( c & 8 )
+        {
+          for ( count = GET_Byte(); count > 0; count-- )
+            *++flag = c;
+        }
+      }
+    }
+
+    /*********************************************************************/
+    /* reading the X coordinates                                         */
+
+    {
+      FT_Vector*  vec   = zone->org;
+      FT_Vector*  limit = vec + n_points;
+      FT_Byte*    flag  = zone->tags;
+      FT_Pos      x     = 0;
+
+      for ( ; vec < limit; vec++, flag++ )
+      {
+        FT_Pos  y = 0;
+
+        if ( *flag & 2 )
+        {
+          y = GET_Byte();
+          if ((*flag & 16) == 0) y = -y;
+        }
+        else if ((*flag & 16) == 0)
+          y = GET_Short();
+
+        x     += y;
+        vec->x = x;
+      }
+    }
+
+    /*********************************************************************/
+    /* reading the Y coordinates                                         */
+
+    {
+      FT_Vector*  vec   = zone->org;
+      FT_Vector*  limit = vec + n_points;
+      FT_Byte*    flag  = zone->tags;
+      FT_Pos      x     = 0;
+
+      for ( ; vec < limit; vec++, flag++ )
+      {
+        FT_Pos  y = 0;
+
+        if ( *flag & 4 )
+        {
+          y = GET_Byte();
+          if ((*flag & 32) == 0) y = -y;
+        }
+        else if ((*flag & 32) == 0)
+          y = GET_Short();
+
+        x     += y;
+        vec->y = x;
+      }
+    }
+
+    FORGET_Frame();
+
+    /*********************************************************************/
+    /* Add shadow points                                                  */
+
+    /* Now add the two shadow points at n and n + 1.    */
+    /* We need the left side bearing and advance width. */
+
+    {
+      FT_Vector*  pp1;
+      FT_Vector*  pp2;
+
+      /* pp1 = xMin - lsb */
+      pp1    = zone->org + n_points;
+      pp1->x = load->bbox.xMin - load->left_bearing;
+      pp1->y = 0;
+
+      /* pp2 = pp1 + aw */
+      pp2    = pp1 + 1;
+      pp2->x = pp1->x + load->advance;
+      pp2->y = 0;
+
+      /* clear the touch tags */
+      for ( n = 0; n < n_points; n++ )
+        zone->tags[n] &= FT_Curve_Tag_On;
+
+      zone->tags[n_points    ] = 0;
+      zone->tags[n_points + 1] = 0;
+    }
+    /* Note that we return two more points that are not */
+    /* part of the glyph outline.                       */
+
+    zone->n_points   = n_points;
+    zone->n_contours = n_contours;
+    n_points        += 2;
+
+    /*******************************************/
+    /* now eventually scale and hint the glyph */
+
+    if (load->load_flags & FT_LOAD_NO_SCALE)
+    {
+      /* no scaling, just copy the orig arrays into the cur ones */
+      org_to_cur( n_points, zone );
+    }
+    else
+    {
+      FT_Vector*  vec = zone->org;
+      FT_Vector*  limit = vec + n_points;
+      FT_Fixed    x_scale = load->size->root.metrics.x_scale;
+      FT_Fixed    y_scale = load->size->root.metrics.y_scale;
+
+      /* first scale the glyph points */
+      for (; vec < limit; vec++)
+      {
+        vec->x = FT_MulFix( vec->x, x_scale );
+        vec->y = FT_MulFix( vec->y, y_scale );
+      }
+
+      /* if hinting, round pp1, and shift the glyph accordingly */
+      if ( !IS_HINTED(load->load_flags) )
+      {
+        org_to_cur( n_points, zone );
+      }
+      else
+      {
+        FT_Pos  x = zone->org[n_points-2].x;
+        x = ((x + 32) & -64) - x;
+        translate_array( n_points, zone->org, x, 0 );
+
+        org_to_cur( n_points, zone );
+
+        zone->cur[n_points-1].x = (zone->cur[n_points-1].x + 32) & -64;
+
+      }
+    }
+
+    /* save glyph phantom points */
+    if ( !load->preserve_pps )
+    {
+      load->pp1 = zone->cur[n_points - 2];
+      load->pp2 = zone->cur[n_points - 1];
+    }
+
+    return FT_Err_Ok;
+
+  Fail:
+    FORGET_Frame();
+    return error;
+  }
+
+
+
+
+
+
+  /*************************************************************************/
+  /*                                                                       */
+  /* <Function>                                                            */
+  /*    load_opentype_glyph                                                */
+  /*                                                                       */
+  /* <Description>                                                         */
+  /*    Loads a given truetype glyph. Handles composites and uses a        */
+  /*    T2_Loader object..                                                 */
+  /*                                                                       */
+  static
+  FT_Error  load_opentype_glyph( T2_Loader*  loader,
+                                 FT_UInt     glyph_index )
+  {
+    FT_Stream    stream = loader->stream;
+    FT_Error     error;
+    T2_Face      face   = loader->face;
+    FT_ULong     offset;
+    FT_Int       num_subglyphs = 0, contours_count;
+    FT_UInt      index, num_points, num_contours, count;
+    FT_Fixed     x_scale, y_scale;
+    FT_ULong     ins_offset;
+
+    /* check glyph index */
+    index = glyph_index;
+    if ( index >= (TT_UInt)face->root.num_glyphs )
+    {
+      error = TT_Err_Invalid_Glyph_Index;
+      goto Fail;
+    }
+
+    loader->glyph_index = glyph_index;
+    num_contours = 0;
+    num_points   = 0;
+    ins_offset   = 0;
+
+    x_scale = 0x10000;
+    y_scale = 0x10000;
+    if ( (loader->load_flags & FT_LOAD_NO_SCALE)==0 )
+    {
+      x_scale = loader->size->root.metrics.x_scale;
+      y_scale = loader->size->root.metrics.y_scale;
+    }
+
+    /* get horizontal metrics */
+    {
+      FT_Short   left_bearing;
+      FT_UShort  advance_width;
+
+      Get_HMetrics( face, index,
+                    (FT_Bool)!(loader->load_flags &
+                                 FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH),
+                    &left_bearing,
+                    &advance_width );
+
+      loader->left_bearing = left_bearing;
+      loader->advance      = advance_width;
+    }
+
+    /* load glyph header */
+    offset = face->glyph_locations[index];
+    count  = 0;
+    if (index < (TT_UInt)face->num_locations-1)
+       count = face->glyph_locations[index+1] - offset;
+
+
+    if (count == 0)
+    {
+      /* as described by Frederic Loyer, these are spaces, and */
+      /* not the unknown glyph.                                */
+      loader->bbox.xMin = 0;
+      loader->bbox.xMax = 0;
+      loader->bbox.yMin = 0;
+      loader->bbox.yMax = 0;
+
+      loader->pp1.x = 0;
+      loader->pp2.x = loader->advance;
+
+      if ( (loader->load_flags & FT_LOAD_NO_SCALE)==0 )
+        loader->pp2.x = FT_MulFix( loader->pp2.x, x_scale );
+
+      goto Load_End;
+    }
+
+    offset = loader->glyf_offset + offset;
+
+    /* read first glyph header */
+    if ( FILE_Seek( offset ) || ACCESS_Frame( 10L ) )
+      goto Fail;
+
+    contours_count = GET_Short();
+
+    loader->bbox.xMin = GET_Short();
+    loader->bbox.yMin = GET_Short();
+    loader->bbox.xMax = GET_Short();
+    loader->bbox.yMax = GET_Short();
+
+    FORGET_Frame();
+
+    FT_TRACE6(( "Glyph %ld\n", index ));
+    FT_TRACE6(( " # of contours : %d\n", num_contours ));
+    FT_TRACE6(( " xMin: %4d  xMax: %4d\n", loader->bbox.xMin,
+                                           loader->bbox.xMax ));
+    FT_TRACE6(( " yMin: %4d  yMax: %4d\n", loader->bbox.yMin,
+                                           loader->bbox.yMax ));
+    FT_TRACE6(( "-" ));
+
+    count -= 10;
+
+    if ( contours_count > loader->left_contours )
+    {
+      FT_TRACE0(( "ERROR: Too many contours for glyph %ld\n", index ));
+      error = TT_Err_Too_Many_Contours;
+      goto Fail;
+    }
+
+    loader->pp1.x = loader->bbox.xMin - loader->left_bearing;
+    loader->pp1.y = 0;
+    loader->pp2.x = loader->pp1.x + loader->advance;
+    loader->pp2.y = 0;
+
+    if ((loader->load_flags & FT_LOAD_NO_SCALE)==0)
+    {
+      loader->pp1.x = FT_MulFix( loader->pp1.x, x_scale );
+      loader->pp2.x = FT_MulFix( loader->pp2.x, x_scale );
+    }
+
+    /*************************************************************************/
+    /*************************************************************************/
+    /*************************************************************************/
+
+    /**********************************************************************/
+    /* if it is a simple glyph, load it                                   */
+    if (contours_count >= 0)
+    {
+      FT_UInt  num_base_points;
+
+      error = Load_Simple( loader, count, contours_count, 0 );
+      if ( error ) goto Fail;
+
+      /* Note: We could have put the simple loader source there */
+      /*       but the code is fat enough already :-)           */
+      num_points   = loader->zone.n_points;
+      num_contours = loader->zone.n_contours;
+
+      num_base_points = loader->base.n_points;
+      {
+        FT_UInt  k;
+        for ( k = 0; k < num_contours; k++ )
+          loader->zone.contours[k] += num_base_points;
+      }
+
+      loader->base.n_points   += num_points;
+      loader->base.n_contours += num_contours;
+
+      loader->zone.n_points    = 0;
+      loader->zone.n_contours  = 0;
+
+      loader->left_points   -= num_points;
+      loader->left_contours -= num_contours;
+    }
+    /*************************************************************************/
+    /*************************************************************************/
+    /*************************************************************************/
+
+    /************************************************************************/
+    else /* otherwise, load a composite !!                                  */
+    {
+      /* for each subglyph, read composite header */
+	  T2_GlyphSlot  glyph    = loader->glyph;
+      FT_SubGlyph*  subglyph = glyph->subglyphs + glyph->num_subglyphs;
+
+      if (ACCESS_Frame(count)) goto Fail;
+
+      num_subglyphs = 0;
+      do
+      {
+        TT_Fixed  xx, xy, yy, yx;
+		FT_UInt   total_subglyphs;
+
+        /* grow the 'glyph->subglyphs' table if necessary */
+		total_subglyphs = glyph->num_subglyphs + num_subglyphs;
+		if ( total_subglyphs >= glyph->max_subglyphs )
+		{
+		  FT_UInt    new_max = glyph->max_subglyphs;
+		  FT_Memory  memory = loader->face->root.memory;
+
+          while (new_max <= total_subglyphs)
+		    new_max += 4;
+			
+		  if ( REALLOC_ARRAY( glyph->subglyphs, glyph->max_subglyphs,
+		                      new_max, FT_SubGlyph ) )
+            goto Fail;							  
+			
+		  glyph->max_subglyphs = new_max;
+		  subglyph = glyph->subglyphs + glyph->num_subglyphs + num_subglyphs;
+		}
+
+        subglyph->arg1 = subglyph->arg2 = 0;
+
+        subglyph->flags = GET_UShort();
+        subglyph->index = GET_UShort();
+
+        /* read arguments */
+        if (subglyph->flags & ARGS_ARE_WORDS)
+        {
+          subglyph->arg1 = GET_Short();
+          subglyph->arg2 = GET_Short();
+        }
+        else
+        {
+          subglyph->arg1 = GET_Char();
+          subglyph->arg2 = GET_Char();
+        }
+
+        /* read transform */
+        xx = yy = 0x10000;
+        xy = yx = 0;
+
+        if (subglyph->flags & WE_HAVE_A_SCALE)
+        {
+          xx = (TT_Fixed)GET_Short() << 2;
+          yy = xx;
+        }
+        else if (subglyph->flags & WE_HAVE_AN_XY_SCALE)
+        {
+          xx = (TT_Fixed)GET_Short() << 2;
+          yy = (TT_Fixed)GET_Short() << 2;
+        }
+        else if (subglyph->flags & WE_HAVE_A_2X2)
+        {
+          xx = (TT_Fixed)GET_Short() << 2;
+          xy = (TT_Fixed)GET_Short() << 2;
+          yx = (TT_Fixed)GET_Short() << 2;
+          yy = (TT_Fixed)GET_Short() << 2;
+        }
+
+        subglyph->transform.xx = xx;
+        subglyph->transform.xy = xy;
+        subglyph->transform.yx = yx;
+        subglyph->transform.yy = yy;
+
+        subglyph++;
+        num_subglyphs++;
+      }
+      while (subglyph[-1].flags & MORE_COMPONENTS);
+
+      FORGET_Frame();
+
+      /* if the flag FT_LOAD_NO_RECURSE is set, we return the subglyph */
+      /* "as is" in the glyph slot (the client application will be     */
+      /* responsible for interpreting this data..)                     */
+      if ( loader->load_flags & FT_LOAD_NO_RECURSE )
+      {
+        /* set up remaining glyph fields */
+        glyph->num_subglyphs += num_subglyphs;
+        glyph->format         = ft_glyph_format_composite;
+        goto Load_End;
+      }
+
+
+    /*************************************************************************/
+    /*************************************************************************/
+    /*************************************************************************/
+
+      /*********************************************************************/
+      /* Now, read each subglyph independently..                           */
+      {
+        FT_Int  n, num_base_points, num_new_points;
+
+        subglyph = glyph->subglyphs + glyph->num_subglyphs;
+		glyph->num_subglyphs += num_subglyphs;
+		
+        for ( n = 0; n < num_subglyphs; n++, subglyph++ )
+        {
+          FT_Vector  pp1, pp2;
+          FT_Pos     x, y;
+
+          pp1 = loader->pp1;
+          pp2 = loader->pp2;
+
+          num_base_points = loader->base.n_points;
+
+          error = load_truetype_glyph( loader, subglyph->index );
+		  if (error) goto Fail;
+
+          if ( subglyph->flags & USE_MY_METRICS )
+          {
+            pp1 = loader->pp1;
+            pp2 = loader->pp2;
+          }
+          else
+          {
+            loader->pp1 = pp1;
+            loader->pp2 = pp2;
+          }
+
+          num_points   = loader->base.n_points;
+          num_contours = loader->base.n_contours;
+
+          num_new_points = num_points - num_base_points;
+
+          /********************************************************/
+          /* now perform the transform required for this subglyph */
+
+          if ( subglyph->flags & ( WE_HAVE_A_SCALE     |
+                                   WE_HAVE_AN_XY_SCALE |
+                                   WE_HAVE_A_2X2       ) )
+          {
+            FT_Vector*  cur = loader->zone.cur;
+            FT_Vector*  org = loader->zone.org;
+            FT_Vector*  limit = cur + num_new_points;
+
+            for ( ; cur < limit; cur++, org++ )
+            {
+              TT_Pos  nx, ny;
+
+              nx = FT_MulFix( cur->x, subglyph->transform.xx ) +
+                   FT_MulFix( cur->y, subglyph->transform.yx );
+
+              ny = FT_MulFix( cur->x, subglyph->transform.xy ) +
+                   FT_MulFix( cur->y, subglyph->transform.yy );
+
+              cur->x = nx;
+              cur->y = ny;
+
+              nx = FT_MulFix( org->x, subglyph->transform.xx ) +
+                   FT_MulFix( org->y, subglyph->transform.yx );
+
+              ny = FT_MulFix( org->x, subglyph->transform.xy ) +
+                   FT_MulFix( org->y, subglyph->transform.yy );
+
+              org->x = nx;
+              org->y = ny;
+            }
+          }
+
+          /* apply offset */
+
+          if ( !(subglyph->flags & ARGS_ARE_XY_VALUES) )
+          {
+            FT_Int   k = subglyph->arg1;
+            FT_UInt  l = subglyph->arg2;
+
+            if ( k >= num_base_points ||
+                 l >= (TT_UInt)num_new_points  )
+            {
+              error = TT_Err_Invalid_Composite;
+              goto Fail;
+            }
+
+            l += num_base_points;
+
+            x = loader->base.cur[k].x - loader->base.cur[l].x;
+            y = loader->base.cur[k].y - loader->base.cur[l].y;
+          }
+          else
+          {
+            x = subglyph->arg1;
+            y = subglyph->arg2;
+
+            if (!(loader->load_flags & FT_LOAD_NO_SCALE))
+            {
+              x = FT_MulFix( x, x_scale );
+              y = FT_MulFix( y, y_scale );
+
+              if ( subglyph->flags & ROUND_XY_TO_GRID )
+	          {
+	            x = (x + 32) & -64;
+	            y = (y + 32) & -64;
+	          }
+            }
+          }
+
+          translate_array( num_new_points, loader->zone.cur, x, y );
+          cur_to_org( num_new_points, &loader->zone );
+        }
+
+    /*************************************************************************/
+    /*************************************************************************/
+    /*************************************************************************/
+
+        /* we have finished loading all sub-glyphs, now, look for */
+        /* instructions for this composite !!                     */
+
+      }
+	  /* end of composite loading */
+    }
+
+    /*************************************************************************/
+    /*************************************************************************/
+    /*************************************************************************/
+    /*************************************************************************/
+
+  Load_End:
+    error = FT_Err_Ok;
+
+  Fail:
+    return error;
+  }
+
+
+
+
+
+  static
+  void  compute_glyph_metrics( T2_Loader*    loader,
+                               FT_UInt       glyph_index )
+  {
+    FT_UInt       num_points   = loader->base.n_points;
+    FT_UInt       num_contours = loader->base.n_contours;
+    FT_BBox       bbox;
+    T2_Face       face = loader->face;
+    FT_Fixed      x_scale, y_scale;
+    T2_GlyphSlot  glyph = loader->glyph;
+    T2_Size       size = loader->size;
+
+    /* when a simple glyph was loaded, the value of        */
+    /* "base.n_points" and "base.n_contours" is 0, we must */
+    /* take those in the "zone" instead..                  */
+    if ( num_points == 0 && num_contours == 0 )
+    {
+      num_points   = loader->zone.n_points;
+      num_contours = loader->zone.n_contours;
+    }
+
+    x_scale = 0x10000;
+    y_scale = 0x10000;
+    if ( (loader->load_flags & FT_LOAD_NO_SCALE) == 0)
+    {
+      x_scale = size->root.metrics.x_scale;
+      y_scale = size->root.metrics.y_scale;
+    }
+
+    if ( glyph->format != ft_glyph_format_composite )
+    {
+      FT_UInt  u;
+      for ( u = 0; u < num_points + 2; u++ )
+      {
+        glyph->outline.points[u] = loader->base.cur[u];
+        glyph->outline.tags [u] = loader->base.tags[u];
+      }
+
+      for ( u = 0; u < num_contours; u++ )
+        glyph->outline.contours[u] = loader->base.contours[u];
+
+      /* glyph->outline.second_pass = TRUE; */
+      glyph->outline.flags      &= ~ft_outline_single_pass;
+      glyph->outline.n_points    = num_points;
+      glyph->outline.n_contours  = num_contours;
+
+      /* translate array so that (0,0) is the glyph's origin */
+      translate_array( (TT_UShort)(num_points + 2),
+                       glyph->outline.points,
+                       -loader->pp1.x,
+                       0 );
+
+      FT_Outline_Get_CBox( &glyph->outline, &bbox );
+
+      if ( IS_HINTED(loader->load_flags) )
+      {
+        /* grid-fit the bounding box */
+        bbox.xMin &= -64;
+        bbox.yMin &= -64;
+        bbox.xMax  = (bbox.xMax + 63) & -64;
+        bbox.yMax  = (bbox.yMax + 63) & -64;
+      }
+    }
+    else
+      bbox = loader->bbox;
+
+    /* get the device-independent scaled horizontal metrics */
+    /* take care of fixed-pitch fonts...                    */
+    {
+      FT_Pos  left_bearing;
+      FT_Pos  advance;
+
+      left_bearing = loader->left_bearing;
+      advance      = loader->advance;
+
+     /* the flag FT_LOAD_NO_ADVANCE_CHECK was introduced to       */
+     /* correctly support DynaLab fonts, who have an incorrect    */
+     /* "advance_Width_Max" field !! It is used, to my knowledge  */
+     /* exclusively in the X-TrueType font server..               */
+     /*                                                           */
+      if ( face->postscript.isFixedPitch                        &&
+           (loader->load_flags & FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH) == 0 )
+        advance = face->horizontal.advance_Width_Max;
+
+      if ( !(loader->load_flags & FT_LOAD_NO_SCALE) )
+      {
+        left_bearing = FT_MulFix( left_bearing, x_scale );
+        advance      = FT_MulFix( advance, x_scale );
+      }
+
+      glyph->metrics2.horiBearingX = left_bearing;
+      glyph->metrics2.horiAdvance  = advance;
+    }
+
+    glyph->metrics.horiBearingX = bbox.xMin;
+    glyph->metrics.horiBearingY = bbox.yMax;
+    glyph->metrics.horiAdvance  = loader->pp2.x - loader->pp1.x;
+
+    /* Now take care of vertical metrics.  In the case where there is    */
+    /* no vertical information within the font (relatively common), make */
+    /* up some metrics by `hand'...                                      */
+
+    {
+      FT_Short   top_bearing;    /* vertical top side bearing (EM units) */
+      FT_UShort  advance_height; /* vertical advance height   (EM units) */
+
+      FT_Pos  left;     /* scaled vertical left side bearing         */
+      FT_Pos  Top;      /* scaled original vertical top side bearing */
+      FT_Pos  top;      /* scaled vertical top side bearing          */
+      FT_Pos  advance;  /* scaled vertical advance height            */
+
+
+      /* Get the unscaled `tsb' and `ah' */
+      if ( face->vertical_info                   &&
+           face->vertical.number_Of_VMetrics > 0 )
+      {
+        /* Don't assume that both the vertical header and vertical */
+        /* metrics are present in the same font :-)                */
+
+        T2_Get_Metrics( (TT_HoriHeader*)&face->vertical,
+                        glyph_index,
+                        &top_bearing,
+                        &advance_height );
+      }
+      else
+      {
+        /* Make up the distances from the horizontal header..     */
+
+        /* NOTE: The OS/2 values are the only `portable' ones,    */
+        /*       which is why we use them, when there is an       */
+        /*       OS/2 table in the font. Otherwise, we use the    */
+        /*       values defined in the horizontal header..        */
+        /*                                                        */
+        /* NOTE2: The sTypoDescender is negative, which is why    */
+        /*        we compute the baseline-to-baseline distance    */
+        /*        here with:                                      */
+        /*             ascender - descender + linegap             */
+        /*                                                        */
+        if ( face->os2.version != 0xFFFF )
+        {
+          top_bearing    = face->os2.sTypoLineGap / 2;
+          advance_height = (TT_UShort)(face->os2.sTypoAscender -
+                                       face->os2.sTypoDescender +
+                                       face->os2.sTypoLineGap);
+        }
+        else
+        {
+          top_bearing    = face->horizontal.Line_Gap / 2;
+          advance_height = (TT_UShort)(face->horizontal.Ascender  +
+                                       face->horizontal.Descender +
+                                       face->horizontal.Line_Gap);
+        }
+      }
+
+      /* We must adjust the top_bearing value from the bounding box given
+         in the glyph header to te bounding box calculated with
+         TT_Get_Outline_BBox()                                            */
+
+      /* scale the metrics */
+      if ( !(loader->load_flags & FT_LOAD_NO_SCALE) )
+      {
+        Top     = FT_MulFix( top_bearing, y_scale );
+        top     = FT_MulFix( top_bearing + loader->bbox.yMax, y_scale )
+                    - bbox.yMax;
+        advance = FT_MulFix( advance_height, y_scale );
+      }
+      else
+      {
+        Top     = top_bearing;
+        top     = top_bearing + loader->bbox.yMax - bbox.yMax;
+        advance = advance_height;
+      }
+
+      glyph->metrics2.vertBearingY = Top;
+      glyph->metrics2.vertAdvance  = advance;
+
+      /* XXX: for now, we have no better algorithm for the lsb, but it    */
+      /*      should work fine.                                           */
+      /*                                                                  */
+      left = ( bbox.xMin - bbox.xMax ) / 2;
+
+      /* grid-fit them if necessary */
+      if ( IS_HINTED(loader->load_flags) )
+      {
+        left   &= -64;
+        top     = (top + 63) & -64;
+        advance = (advance + 32) & -64;
+      }
+
+      glyph->metrics.vertBearingX = left;
+      glyph->metrics.vertBearingY = top;
+      glyph->metrics.vertAdvance  = advance;
+    }
+
+    /* Adjust advance width to the value contained in the hdmx table. */
+    if ( !face->postscript.isFixedPitch && size &&
+         IS_HINTED(loader->load_flags) )
+    {
+      FT_Byte* widths = Get_Advance_Widths( face,
+                                   size->root.metrics.x_ppem );
+      if ( widths )
+        glyph->metrics.horiAdvance = widths[glyph_index] << 6;
+    }
+
+    /* set glyph dimensions */
+    glyph->metrics.width  = bbox.xMax - bbox.xMin;
+    glyph->metrics.height = bbox.yMax - bbox.yMin;
+  }
+
+
+
+
+
+
+
+
+
+
+
+
+  LOCAL_FUNC
+  FT_Error  TT_Load_Glyph( T2_Size       size,
+                           T2_GlyphSlot  glyph,
+                           FT_UShort     glyph_index,
+                           FT_UInt       load_flags )
+  {
+    SFNT_Interface*  sfnt;
+    T2_Face          face;
+    FT_Stream        stream;
+    FT_Memory        memory;
+    FT_Error         error;
+    T2_Loader        loader;
+    FT_GlyphZone*    zone;
+
+    face   = (TT_Face)glyph->face;
+    sfnt   = (SFNT_Interface*)face->sfnt;
+    stream = face->root.stream;
+    memory = face->root.memory;
+    error  = 0;
+
+    if ( !size || (load_flags & FT_LOAD_NO_SCALE)  ||
+                  (load_flags & FT_LOAD_NO_RECURSE ))
+    {
+      size        = NULL;
+      load_flags |= FT_LOAD_NO_SCALE   |
+                    FT_LOAD_NO_HINTING |
+                    FT_LOAD_NO_BITMAP;
+    }
+
+    glyph->num_subglyphs = 0;
+
+#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS
+    /*********************************************************************/
+    /* Try to load embedded bitmap if any                                */
+    if ( size && (load_flags & FT_LOAD_NO_BITMAP) == 0 && sfnt->load_sbits )
+    {
+      TT_SBit_Metrics  metrics;
+
+      error = sfnt->load_sbit_image( face,
+                                     size->root.metrics.x_ppem,
+                                     size->root.metrics.y_ppem,
+                                     glyph_index,
+                                     load_flags,
+                                     stream,
+                                     &glyph->bitmap,
+                                     &metrics );
+      if ( !error )
+      {
+        glyph->outline.n_points   = 0;
+        glyph->outline.n_contours = 0;
+
+        glyph->metrics.width  = (FT_Pos)metrics.width  << 6;
+        glyph->metrics.height = (FT_Pos)metrics.height << 6;
+
+        glyph->metrics.horiBearingX = (FT_Pos)metrics.horiBearingX << 6;
+        glyph->metrics.horiBearingY = (FT_Pos)metrics.horiBearingY << 6;
+        glyph->metrics.horiAdvance  = (FT_Pos)metrics.horiAdvance  << 6;
+
+        glyph->metrics.vertBearingX = (FT_Pos)metrics.vertBearingX << 6;
+        glyph->metrics.vertBearingY = (FT_Pos)metrics.vertBearingY << 6;
+        glyph->metrics.vertAdvance  = (FT_Pos)metrics.vertAdvance  << 6;
+
+        glyph->format = ft_glyph_format_bitmap;
+        return error;
+      }
+    }
+#endif /* TT_CONFIG_OPTION_EMBEDDED_BITMAPS */
+
+    if ( load_flags & FT_LOAD_NO_OUTLINE )
+      return ( error ? error : TT_Err_Unavailable_Bitmap );
+
+   /* seek to the beginning of the glyph table. For Type 43 fonts       */
+   /* the table might be accessed from a Postscript stream or something */
+   /* else...                                                           */
+    error = face->goto_table( face, TTAG_glyf, stream, 0 );
+    if (error)
+    {
+      FT_ERROR(( "TT.GLoad: could not access glyph table\n" ));
+      goto Exit;
+    }
+
+    MEM_Set( &loader, 0, sizeof(loader) );
+
+    /* update the glyph zone bounds */
+    zone   = &((TT_Driver)face->root.driver)->zone;
+    error  = FT_Update_GlyphZone( zone,
+                                  face->root.max_points,
+                                  face->root.max_contours );
+    if (error)
+    {
+      FT_ERROR(( "TT.GLoad: could not update loader glyph zone\n" ));
+      goto Exit;
+    }
+    loader.base = *zone;
+
+    loader.zone.n_points   = 0;
+    loader.zone.n_contours = 0;
+
+    /* clear all outline flags, except the "owner" one */
+    glyph->outline.flags &= ft_outline_owner;
+
+    if (size && size->root.metrics.y_ppem < 24 )
+      glyph->outline.flags |= ft_outline_high_precision;
+
+    /************************************************************************/
+    /* let's initialise the rest of our loader now                          */
+    loader.left_points   = face->root.max_points;
+    loader.left_contours = face->root.max_contours;
+    loader.load_flags    = load_flags;
+
+    loader.face   = face;
+    loader.size   = size;
+    loader.glyph  = glyph;
+    loader.stream = stream;
+
+    loader.glyf_offset = FILE_Pos();
+
+    /* Main loading loop */
+    glyph->format        = ft_glyph_format_outline;
+	glyph->num_subglyphs = 0;
+    error = load_truetype_glyph( &loader, glyph_index );
+    if (!error)
+      compute_glyph_metrics( &loader, glyph_index );
+
+  Exit:
+    return error;
+  }
+
+
+
+/* END */
diff --git a/src/cff/t2gload.h b/src/cff/t2gload.h
new file mode 100644
index 0000000..012b7ac
--- /dev/null
+++ b/src/cff/t2gload.h
@@ -0,0 +1,140 @@
+/***************************************************************************/
+/*                                                                         */
+/*  t2gload.h                                                              */
+/*                                                                         */
+/*    OpenType Glyph Loader (specification).                               */
+/*                                                                         */
+/*  Copyright 1996-1999 by                                                 */
+/*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
+/*                                                                         */
+/*  This file is part of the FreeType project, and may only be used        */
+/*  modified and distributed under the terms of the FreeType project       */
+/*  license, LICENSE.TXT.  By continuing to use, modify, or distribute     */
+/*  this file you indicate that you have read the license and              */
+/*  understand and accept it fully.                                        */
+/*                                                                         */
+/***************************************************************************/
+
+
+#ifndef T2GLOAD_H
+#define T2GLOAD_H
+
+#include <t2objs.h>
+
+#ifdef __cplusplus
+  extern "C" {
+#endif
+
+  typedef struct T2_Loader_
+  {
+    T2_Face         face;
+    T2_Size         size;
+    T2_GlyphSlot    glyph;
+
+    FT_ULong        load_flags;
+    FT_UInt         glyph_index;
+
+    FT_Stream       stream;
+    FT_Int          byte_len;
+    FT_Int          left_points;
+    FT_Int          left_contours;
+
+    FT_BBox         bbox;
+    FT_Int          left_bearing;
+    FT_Int          advance;
+    FT_Bool         preserve_pps;
+    FT_Vector       pp1;
+    FT_Vector       pp2;
+
+    FT_ULong        glyf_offset;
+
+    /* the zone where we load our glyphs */
+    FT_GlyphZone    base;
+    FT_GlyphZone    zone;
+
+  } T2_Loader;
+
+
+#if 0
+  /*************************************************************************/
+  /*                                                                       */
+  /* <Function>                                                            */
+  /*    T2_Get_Metrics                                                     */
+  /*                                                                       */
+  /* <Description>                                                         */
+  /*    Returns the horizontal or vertical metrics in font units for a     */
+  /*    given glyph.  The metrics are the left side bearing (resp. top     */
+  /*    side bearing) and advance width (resp. advance height).            */
+  /*                                                                       */
+  /* <Input>                                                               */
+  /*    header  :: A pointer to either the horizontal or vertical metrics  */
+  /*               structure.                                              */
+  /*                                                                       */
+  /*    index   :: The glyph index.                                        */
+  /*                                                                       */
+  /* <Output>                                                              */
+  /*    bearing :: The bearing, either left side or top side.              */
+  /*                                                                       */
+  /*    advance :: The advance width resp. advance height.                 */
+  /*                                                                       */
+  /* <Note>                                                                */
+  /*    This function will much probably move to another component in the  */
+  /*    near future, but I haven't decided which yet.                      */
+  /*                                                                       */
+  LOCAL_DEF
+  void  T2_Get_Metrics( TT_HoriHeader*  header,
+                        FT_UInt         index,
+                        FT_Short*       bearing,
+                        FT_UShort*      advance );
+
+
+  /*************************************************************************/
+  /*                                                                       */
+  /* <Function>                                                            */
+  /*    T2_Load_Glyph                                                      */
+  /*                                                                       */
+  /* <Description>                                                         */
+  /*    A function used to load a single glyph within a given glyph slot,  */
+  /*    for a given size.                                                  */
+  /*                                                                       */
+  /* <Input>                                                               */
+  /*    glyph       :: A handle to a target slot object where the glyph    */
+  /*                   will be loaded.                                     */
+  /*                                                                       */
+  /*    size        :: A handle to the source face size at which the glyph */
+  /*                   must be scaled/loaded.                              */
+  /*                                                                       */
+  /*    glyph_index :: The index of the glyph in the font file.            */
+  /*                                                                       */
+  /*    load_flags  :: A flag indicating what to load for this glyph.  The */
+  /*                   FT_LOAD_XXX constants can be used to control the    */
+  /*                   glyph loading process (e.g., whether the outline    */
+  /*                   should be scaled, whether to load bitmaps or not,   */
+  /*                   whether to hint the outline, etc).                  */
+  /* <Output>                                                              */
+  /*    result      :: A set of bit flags indicating the type of data that */
+  /*                   was loaded in the glyph slot (outline or bitmap,    */
+  /*                   etc).                                               */
+  /*                                                                       */
+  /*                   You can set this field to 0 if you don't want this  */
+  /*                   information.                                        */
+  /*                                                                       */
+  /* <Return>                                                              */
+  /*    FreeType error code.  0 means success.                             */
+  /*                                                                       */
+  LOCAL_DEF
+  FT_Error  T2_Load_Glyph( T2_Size       size,
+                           T2_GlyphSlot  glyph,
+                           FT_UShort     glyph_index,
+                           FT_UInt       load_flags );
+#endif
+
+#ifdef __cplusplus
+  }
+#endif
+
+
+#endif /* T2GLOAD_H */
+
+
+/* END */
diff --git a/src/cff/t2load.c b/src/cff/t2load.c
new file mode 100644
index 0000000..b33aae5
--- /dev/null
+++ b/src/cff/t2load.c
@@ -0,0 +1,292 @@
+/***************************************************************************/
+/*                                                                         */
+/*  t2load.h                                                               */
+/*                                                                         */
+/*    TrueType glyph data/program tables loader (body).                    */
+/*                                                                         */
+/*  Copyright 1996-1999 by                                                 */
+/*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
+/*                                                                         */
+/*  This file is part of the FreeType project, and may only be used        */
+/*  modified and distributed under the terms of the FreeType project       */
+/*  license, LICENSE.TXT.  By continuing to use, modify, or distribute     */
+/*  this file you indicate that you have read the license and              */
+/*  understand and accept it fully.                                        */
+/*                                                                         */
+/***************************************************************************/
+
+
+#include <freetype/internal/ftdebug.h>
+#include <freetype/internal/ftobjs.h>
+#include <freetype/internal/ftstream.h>
+
+#include <freetype/fterrors.h>
+#include <freetype/tttags.h>
+#include <t2load.h>
+#include <t2parse.h>
+#include <t2errors.h>
+
+#undef  FT_COMPONENT
+#define FT_COMPONENT  trace_ttload
+
+ /* read a CFF offset from memory */
+  LOCAL_FUNC
+  FT_ULong  T2_Get_Offset( FT_Byte*  p,
+                           FT_Byte   off_size )
+  {
+    FT_ULong  result;
+    for ( result = 0; off_size > 0; off_size-- )
+      result = (result <<= 8) | *p++;
+    return result;
+  }
+
+
+#if 0
+ /* read a CFF offset from a stream */
+  LOCAL_FUNC
+  FT_ULong  T2_Read_Offset( FT_Byte    off_size,
+                            FT_Stream  stream )
+  {
+    FT_Byte   bytes[4];
+    FT_Byte*  p;
+    FT_ULong  result;
+
+    if (off_size > 4)
+      off_size = 4;
+
+    /* first of all, read or access the bytes - this should really go     */
+    /* in "src/base/ftstream.c", but there are great chances that it will */
+    /* never be used elsewhere, so..                                      */
+    if (stream->read)
+    {
+      p = bytes;
+      if ( stream->read( stream, stream->pos, (char*)bytes, off_size ) != off_size )
+        goto Fail;
+    }
+    else
+    {
+      p = (FT_Byte*)stream->base + stream->pos;
+      if (p+off_size-1 >= (FT_Byte*)stream->limit)
+        goto Fail;
+    }
+
+    result = 0;
+    while (off_size > 0)
+    {
+      result = (result <<= 8) | *p++;
+      off_size--;
+    }
+    stream->pos += off_size;
+    return result;
+
+  Fail:
+    FT_ERROR(( "T2_Read_Offset:" ));
+    FT_ERROR(( " invalid i/o, pos = 0x%lx, size = 0x%lx",
+               stream->pos, stream->size ));
+    return 0;
+  }
+#endif
+
+ /* return the memory address of a CFF index's element, when the index */
+ /* is already loaded in memory..                                      */
+
+  LOCAL_FUNC
+  FT_Error  T2_Access_Element( CFF_Index*   cff_index,
+                               FT_UInt      element,
+                               FT_Byte*    *pbytes,
+                               FT_ULong    *pbyte_len )
+  {
+    FT_Error  error;
+
+    if (cff_index && cff_index->bytes && element < (FT_UInt)cff_index->count)
+    {
+      FT_ULong  off1, off2;
+      FT_Byte   offsize = cff_index->off_size;
+      FT_Byte*  p       = cff_index->bytes + 3 + element*offsize;
+      FT_Byte*  limit   = cff_index->bytes + cff_index->data_offset;
+
+      /* read element offset */
+      off1 = T2_Get_Offset(p,offsize);
+
+      /* a value of 0 indicates no object !! */
+      if (off1)
+      {
+        /* compute offset of next element - skip empty elements */
+        do
+        {
+          p   += offsize;
+          off2 = T2_Get_Offset(p,offsize);
+        }
+        while (off2 == 0 && p < limit);
+
+        if (p >= limit)
+          off1 = 0;
+      }
+
+      *pbytes    = 0;
+      *pbyte_len = 0;
+      if (off1)
+      {
+        *pbytes    = cff_index->bytes + cff_index->data_offset + off1 - 1;
+        *pbyte_len = off2 - off1;
+      }
+      error = 0;
+    }
+    else
+      error = FT_Err_Invalid_Argument;
+
+    return error;
+  }
+
+
+  LOCAL_FUNC
+
+  LOCAL_FUNC
+  FT_Error  T2_Read_CFF_Index( CFF_Index*  index,
+                               FT_Stream   stream )
+  {
+    FT_Error  error;
+    FT_ULong  data_size;
+
+    MEM_Set( index, 0, sizeof(*index) );
+    index->file_offset = FILE_Pos();
+    if ( !READ_UShort( index->count ) &&
+         index->count > 0             )
+    {
+      FT_Byte*  p;
+      FT_Byte   offsize;
+
+      /* there is at least one element, read the offset size            */
+      /* then access the offset table to compute the index's total size */
+      if ( READ_Byte( offsize ) )
+        goto Exit;
+
+      index->off_size    = offsize;
+      index->data_offset = ((FT_Long)index->count + 1)*offsize;
+
+      if (ACCESS_Frame( index->data_offset ))
+        goto Exit;
+
+      /* now read element offset limit */
+      p         = (FT_Byte*)stream->cursor + index->data_offset - offsize;
+      data_size = T2_Get_Offset( p, offsize );
+
+      FORGET_Frame();
+
+      index->data_offset += 3;
+      index->total_size   = index->data_offset + data_size;
+
+      /* skip the data */
+      (void)FILE_Skip( data_size );
+    }
+  Exit:
+    return error;
+  }
+
+
+  LOCAL_FUNC
+  FT_Error  T2_Load_CFF_Index( CFF_Index*  index,
+                               FT_Stream   stream )
+  {
+    FT_Error   error;
+
+    /* we begin by reading the index's data */
+    error = T2_Read_CFF_Index( index, stream );
+    if (!error && index->total_size > 0)
+    {
+      /* OK, read it from the file */
+      if ( FILE_Seek( index->file_offset )                  ||
+           EXTRACT_Frame( index->total_size, index->bytes ) )
+        goto Exit;
+
+      /* done !! */
+    }
+  Exit:
+    return error;
+  }
+
+
+  LOCAL_FUNC
+  void  T2_Done_CFF_Index( CFF_Index*  index,
+                           FT_Stream   stream )
+  {
+    if (index->bytes)
+      RELEASE_Frame( index->bytes );
+
+    MEM_Set( index, 0, sizeof(*index) );
+  }
+
+
+  LOCAL_FUNC
+  FT_Error  T2_Load_CFF_Font( FT_Stream   stream,
+                              CFF_Font*   font )
+  {
+    static const FT_Frame_Field  cff_header_fields[] = {
+                     FT_FRAME_START(4),
+                       FT_FRAME_BYTE( CFF_Font,  version_major ),
+                       FT_FRAME_BYTE( CFF_Font,  version_minor ),
+                       FT_FRAME_BYTE( CFF_Font,  header_size   ),
+                       FT_FRAME_BYTE( CFF_Font,  absolute_offsize ),
+                     FT_FRAME_END };
+
+    FT_Error  error;
+
+    MEM_Set( font, 0, sizeof(*font) );
+    font->stream = stream;
+    font->memory = stream->memory;
+
+    /* read CFF font header */
+    if ( READ_Fields( cff_header_fields, font ) )
+      goto Exit;
+
+    /* check format */
+    if ( font->version_major   != 1 ||
+         font->header_size      < 4 ||
+         font->absolute_offsize > 4 )
+    {
+      FT_ERROR(( "incorrect CFF font header !!\n" ));
+      error = FT_Err_Unknown_File_Format;
+      goto Exit;
+    }
+
+    /* skip the rest of the header */
+    (void)FILE_Skip( font->header_size - 4 );
+
+    /* read the name, top dict, strong and global subrs index */
+    error = T2_Load_CFF_Index( &font->name_index, stream )     ||
+            T2_Load_CFF_Index( &font->top_dict_index, stream ) ||
+            T2_Read_CFF_Index( &font->string_index, stream )   ||
+            T2_Load_CFF_Index( &font->global_subrs_index, stream );
+    if (error) goto Exit;
+
+    /* well, we don't really forget the "disable" fonts.. */
+    font->num_faces = font->name_index.count;
+
+  Exit:
+    return error;
+  }
+
+  LOCAL_FUNC
+  void  T2_Done_CFF_Font( CFF_Font*  font )
+  {
+    FT_Stream  stream = font->stream;
+
+    T2_Done_CFF_Index( &font->global_subrs_index, stream );
+    T2_Done_CFF_Index( &font->string_index, stream );
+    T2_Done_CFF_Index( &font->top_dict_index, stream );
+    T2_Done_CFF_Index( &font->name_index, stream );
+  }
+
+
+
+ /***********************************************************************/
+ /***********************************************************************/
+ /***********************************************************************/
+ /*****                                                             *****/
+ /*****      TYPE 2 TABLES DECODING..                               *****/
+ /*****                                                             *****/
+ /***********************************************************************/
+ /***********************************************************************/
+ /***********************************************************************/
+
+/* END */
diff --git a/src/cff/t2load.h b/src/cff/t2load.h
new file mode 100644
index 0000000..720f05f
--- /dev/null
+++ b/src/cff/t2load.h
@@ -0,0 +1,36 @@
+/***************************************************************************/
+/*                                                                         */
+/*  t2load.h                                                               */
+/*                                                                         */
+/*    OpenType glyph data/program tables loader (specification).           */
+/*                                                                         */
+/*  Copyright 1996-1999 by                                                 */
+/*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
+/*                                                                         */
+/*  This file is part of the FreeType project, and may only be used        */
+/*  modified and distributed under the terms of the FreeType project       */
+/*  license, LICENSE.TXT.  By continuing to use, modify, or distribute     */
+/*  this file you indicate that you have read the license and              */
+/*  understand and accept it fully.                                        */
+/*                                                                         */
+/***************************************************************************/
+
+
+#ifndef T2LOAD_H
+#define T2LOAD_H
+
+#include <freetype/internal/t2types.h>
+
+#ifdef __cplusplus
+  extern "C" {
+#endif
+
+#ifdef __cplusplus
+  }
+#endif
+
+
+#endif /* T2LOAD_H */
+
+
+/* END */
diff --git a/src/cff/t2objs.c b/src/cff/t2objs.c
new file mode 100644
index 0000000..10fc38e
--- /dev/null
+++ b/src/cff/t2objs.c
@@ -0,0 +1,333 @@
+/***************************************************************************/
+/*                                                                         */
+/*  ttobjs.c                                                               */
+/*                                                                         */
+/*    Objects manager (body).                                              */
+/*                                                                         */
+/*  Copyright 1996-1999 by                                                 */
+/*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
+/*                                                                         */
+/*  This file is part of the FreeType project, and may only be used        */
+/*  modified and distributed under the terms of the FreeType project       */
+/*  license, LICENSE.TXT.  By continuing to use, modify, or distribute     */
+/*  this file you indicate that you have read the license and              */
+/*  understand and accept it fully.                                        */
+/*                                                                         */
+/***************************************************************************/
+
+
+#include <freetype/internal/ftdebug.h>
+#include <freetype/internal/ftcalc.h>
+#include <freetype/internal/ftstream.h>
+#include <freetype/ttnameid.h>
+#include <freetype/tttags.h>
+
+#include <freetype/internal/sfnt.h>
+#include <freetype/internal/psnames.h>
+#include <t2objs.h>
+
+#include <t2load.h>
+#include <t2errors.h>
+
+/* required by tracing mode */
+#undef   FT_COMPONENT
+#define  FT_COMPONENT  trace_ttobjs
+
+
+  /*************************************************************************/
+  /*                                                                       */
+  /*                       GLYPH ZONE FUNCTIONS                            */
+  /*                                                                       */
+  /*************************************************************************/
+
+
+  /*************************************************************************/
+  /*                                                                       */
+  /* <Function>                                                            */
+  /*    T2_Init_Face                                                       */
+  /*                                                                       */
+  /* <Description>                                                         */
+  /*    Initializes a given TrueType face object.                          */
+  /*                                                                       */
+  /* <Input>                                                               */
+  /*    resource   :: The source font resource.                            */
+  /*    face_index :: The index of the font face in the resource.          */
+  /*    face       :: The newly built face object.                         */
+  /*                                                                       */
+  /* <Return>                                                              */
+  /*    TrueType error code.  0 means success.                             */
+  /*                                                                       */
+  LOCAL_DEF
+  FT_Error  T2_Init_Face( FT_Stream      stream,
+                          T2_Face        face,
+                          FT_Int         face_index,
+                          FT_Int         num_params,
+                          FT_Parameter*  params )
+  {
+    TT_Error           error;
+    FT_Driver          sfnt_driver;
+    SFNT_Interface*    sfnt;
+
+    sfnt_driver = FT_Get_Driver( face->root.driver->library, "sfnt" );
+    if (!sfnt_driver) goto Bad_Format;
+
+    sfnt = (SFNT_Interface*)(sfnt_driver->interface.format_interface);
+    if (!sfnt) goto Bad_Format;
+
+    /* create input stream from resource */
+    if ( FILE_Seek(0) )
+      goto Exit;
+
+    /* check that we have a valid TrueType file */
+    error = sfnt->init_face( stream, face, face_index, num_params, params );
+    if (error) goto Exit;
+
+    /* We must also be able to accept Mac/GX fonts, as well as OT ones */
+    if ( face->format_tag != 0x4f54544f )     /* OpenType/CFF font */
+    {
+      FT_TRACE2(( "[not a valid OpenType/CFF font]" ));
+      goto Bad_Format;
+    }
+
+    /* If we're performing a simple font format check, exit immediately */
+    if ( face_index < 0 )
+      return FT_Err_Ok;
+
+    /* Load font directory */
+    error = sfnt->load_face( stream, face, face_index, num_params, params );
+    if ( error ) goto Exit;
+
+  Exit:
+    return error;
+  Bad_Format:    
+    error = FT_Err_Unknown_File_Format;
+    goto Exit;
+  }
+
+
+
+  /*************************************************************************/
+  /*                                                                       */
+  /* <Function>                                                            */
+  /*    T2_Done_Face                                                       */
+  /*                                                                       */
+  /* <Description>                                                         */
+  /*    Finalizes a given face object.                                     */
+  /*                                                                       */
+  /* <Input>                                                               */
+  /*    face :: A pointer to the face object to destroy.                   */
+  /*                                                                       */
+  LOCAL_DEF
+  void  T2_Done_Face( T2_Face  face )
+  {
+#if 0  
+    FT_Memory  memory = face->root.memory;
+    FT_Stream  stream = face->root.stream;
+#endif
+    SFNT_Interface*  sfnt = face->sfnt;
+
+    if (sfnt)
+      sfnt->done_face(face);
+
+    /* XXXXX: TO DO */
+  }
+
+
+  /*************************************************************************/
+  /*                                                                       */
+  /*                           SIZE  FUNCTIONS                             */
+  /*                                                                       */
+  /*************************************************************************/
+
+
+  /*************************************************************************/
+  /*                                                                       */
+  /* <Function>                                                            */
+  /*    T2_Init_Size                                                       */
+  /*                                                                       */
+  /* <Description>                                                         */
+  /*    Initializes a new OpenType size object.                            */
+  /*                                                                       */
+  /* <InOut>                                                               */
+  /*    size :: A handle to the size object.                               */
+  /*                                                                       */
+  /* <Return>                                                              */
+  /*    TrueType error code.  0 means success.                             */
+  /*                                                                       */
+  LOCAL_DEF
+  FT_Error  T2_Init_Size( T2_Size  size )
+  {
+    UNUSED(size);
+    return 0;
+  }
+
+
+  /*************************************************************************/
+  /*                                                                       */
+  /* <Function>                                                            */
+  /*    T2_Done_Size                                                       */
+  /*                                                                       */
+  /* <Description>                                                         */
+  /*    The OpenType size object finalizer.                                */
+  /*                                                                       */
+  /* <Input>                                                               */
+  /*    size :: A handle to the target size object.                        */
+  /*                                                                       */
+  LOCAL_FUNC
+  void  T2_Done_Size( T2_Size  size )
+  {
+    UNUSED(size);
+  }
+
+
+  /*************************************************************************/
+  /*                                                                       */
+  /* <Function>                                                            */
+  /*    T2_Reset_Size                                                      */
+  /*                                                                       */
+  /* <Description>                                                         */
+  /*    Resets a OpenType size when resolutions and character dimensions   */
+  /*    have been changed.                                                 */
+  /*                                                                       */
+  /* <Input>                                                               */
+  /*    size :: A handle to the target size object.                        */
+  /*                                                                       */
+  LOCAL_DEF
+  FT_Error  T2_Reset_Size( T2_Size  size )
+  {
+    T2_Face           face    = (T2_Face)size->face;
+    FT_Size_Metrics*  metrics = &size->metrics;
+    FT_Error          error   = FT_Err_Ok;
+
+    if ( metrics->x_ppem < 1 || metrics->y_ppem < 1 )
+      return FT_Err_Invalid_Argument;
+
+    /* Compute root ascender, descender, test height, and max_advance */
+    metrics->ascender = ( FT_MulFix( face->root.ascender,
+                                     metrics->y_scale ) + 32 ) & -64;
+
+    metrics->descender = ( FT_MulFix( face->root.descender,
+                                      metrics->y_scale ) + 32 ) & -64;
+
+    metrics->height = ( FT_MulFix( face->root.height,
+                                   metrics->y_scale ) + 32 ) & -64;
+
+    metrics->max_advance = ( FT_MulFix( face->root.max_advance_width,
+                                        metrics->x_scale ) + 32 ) & -64;
+    return error;
+  }
+
+
+  /*************************************************************************/
+  /*                                                                       */
+  /* <Function>                                                            */
+  /*    T2_Init_GlyphSlot                                                  */
+  /*                                                                       */
+  /* <Description>                                                         */
+  /*    The OpenType glyph slot initializer.                               */
+  /*                                                                       */
+  /* <Input>                                                               */
+  /*    slot :: The glyph record to build.                                 */
+  /*                                                                       */
+  /* <Output>                                                              */
+  /*    TrueType error code.  0 means success.                             */
+  /*                                                                       */
+  LOCAL_FUNC
+  FT_Error  T2_Init_GlyphSlot( T2_GlyphSlot  slot )
+  {
+    /* allocate the outline space */
+    FT_Face     face    = slot->face;
+    FT_Library  library = face->driver->library;
+
+    FT_TRACE4(( "TT.Init_GlyphSlot: Creating outline maxp = %d, maxc = %d\n",
+                face->max_points, face->max_contours ));
+
+    return FT_Outline_New( library,
+                           face->max_points + 2,
+                           face->max_contours,
+                           &slot->outline );
+  }
+
+
+  /*************************************************************************/
+  /*                                                                       */
+  /* <Function>                                                            */
+  /*    TT_Done_GlyphSlot                                                  */
+  /*                                                                       */
+  /* <Description>                                                         */
+  /*    The OpenType glyph slot finalizer.                                 */
+  /*                                                                       */
+  /* <Input>                                                               */
+  /*    slot :: A handle to the glyph slot object.                         */
+  /*                                                                       */
+  LOCAL_FUNC
+  void  T2_Done_GlyphSlot( T2_GlyphSlot  slot )
+  {
+    FT_Library  library = slot->face->driver->library;
+    FT_Memory   memory  = library->memory;
+
+    if (slot->flags & ft_glyph_own_bitmap)
+      FREE( slot->bitmap.buffer );
+
+    FT_Outline_Done( library, &slot->outline );
+    return;
+  }
+
+
+  /*************************************************************************/
+  /*                                                                       */
+  /* <Function>                                                            */
+  /*    T2_Init_Driver                                                     */
+  /*                                                                       */
+  /* <Description>                                                         */
+  /*    Initializes a given OpenType driver object.                        */
+  /*                                                                       */
+  /* <Input>                                                               */
+  /*    driver :: A handle to the target driver object.                    */
+  /*                                                                       */
+  /* <Return>                                                              */
+  /*    TrueType error code.  0 means success.                             */
+  /*                                                                       */
+  LOCAL_FUNC
+  FT_Error  T2_Init_Driver( T2_Driver  driver )
+  {
+    FT_Memory  memory = driver->root.memory;
+    FT_Error   error;
+
+    error = FT_New_GlyphZone( memory, 0, 0, &driver->zone );
+    if (error) return error;
+
+    /* init extension registry if needed */
+#ifdef T2_CONFIG_OPTION_EXTEND_ENGINE
+    return TT_Init_Extensions( driver );
+#else
+    return FT_Err_Ok;
+#endif
+  }
+
+
+  /*************************************************************************/
+  /*                                                                       */
+  /* <Function>                                                            */
+  /*    TT_Done_Driver                                                     */
+  /*                                                                       */
+  /* <Description>                                                         */
+  /*    Finalizes a given TrueType driver.                                 */
+  /*                                                                       */
+  /* <Input>                                                               */
+  /*    driver :: A handle to the target TrueType driver.                  */
+  /*                                                                       */
+  LOCAL_FUNC
+  void  T2_Done_Driver( T2_Driver  driver )
+  {
+    /* destroy extensions registry if needed */
+#ifdef T2_CONFIG_OPTION_EXTEND_ENGINE
+    TT_Done_Extensions( driver );
+#endif
+
+    /* remove the loading glyph zone */
+    FT_Done_GlyphZone( &driver->zone );
+  }
+
+
+/* END */
diff --git a/src/cff/t2objs.h b/src/cff/t2objs.h
new file mode 100644
index 0000000..aed60fc
--- /dev/null
+++ b/src/cff/t2objs.h
@@ -0,0 +1,141 @@
+/***************************************************************************/
+/*                                                                         */
+/*  t2objs.h                                                               */
+/*                                                                         */
+/*    Objects manager (specification).                                     */
+/*                                                                         */
+/*  Copyright 1996-1999 by                                                 */
+/*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
+/*                                                                         */
+/*  This file is part of the FreeType project, and may only be used        */
+/*  modified and distributed under the terms of the FreeType project       */
+/*  license, LICENSE.TXT.  By continuing to use, modify, or distribute     */
+/*  this file you indicate that you have read the license and              */
+/*  understand and accept it fully.                                        */
+/*                                                                         */
+/***************************************************************************/
+
+
+#ifndef T2OBJS_H
+#define T2OBJS_H
+
+
+#include <freetype/internal/ftobjs.h>
+#include <freetype/internal/t2types.h>
+#include <t2errors.h>
+
+
+#ifdef __cplusplus
+  extern "C" {
+#endif
+
+
+  /*************************************************************************/
+  /*                                                                       */
+  /* <Type>                                                                */
+  /*    T2_Driver                                                          */
+  /*                                                                       */
+  /* <Description>                                                         */
+  /*    A handle to an OpenType driver object.                             */
+  /*                                                                       */
+  typedef struct T2_DriverRec_*  T2_Driver;
+
+  typedef TT_Face  T2_Face;
+
+  /*************************************************************************/
+  /*                                                                       */
+  /* <Type>                                                                */
+  /*    T2_Size                                                            */
+  /*                                                                       */
+  /* <Description>                                                         */
+  /*    A handle to an OpenType size object.                               */
+  /*                                                                       */
+  typedef FT_Size  T2_Size;
+
+
+  /*************************************************************************/
+  /*                                                                       */
+  /* <Type>                                                                */
+  /*    T2_GlyphSlot                                                       */
+  /*                                                                       */
+  /* <Description>                                                         */
+  /*    A handle to an OpenType glyph slot object.                         */
+  /*                                                                       */
+  /* <Note>                                                                */
+  /*    This is a direct typedef of FT_GlyphSlot, as there is nothing      */
+  /*    specific about the OpenType glyph slot.                            */
+  /*                                                                       */
+  typedef FT_GlyphSlot  T2_GlyphSlot;
+
+
+
+  /*************************************************************************/
+  /*                                                                       */
+  /* Subglyph transformation record.                                       */
+  /*                                                                       */
+  typedef struct  T2_Transform_
+  {
+    FT_Fixed    xx, xy;     /* transformation matrix coefficients */
+    FT_Fixed    yx, yy;
+    FT_F26Dot6  ox, oy;     /* offsets        */
+
+  } T2_Transform;
+
+
+  /***********************************************************************/
+  /*                                                                     */
+  /* TrueType driver class.                                              */
+  /*                                                                     */
+  typedef struct  T2_DriverRec_
+  {
+    FT_DriverRec    root;
+    FT_GlyphZone    zone;     /* glyph loader points zone */
+
+    void*           extension_component;
+
+  } T2_DriverRec;
+
+
+ /*************************************************************************/
+ /*  Face Funcs                                                           */
+
+  LOCAL_DEF FT_Error  T2_Init_Face( FT_Stream      stream,
+                                    T2_Face        face,
+                                    TT_Int         face_index,
+                                    TT_Int         num_params,
+                                    FT_Parameter*  params );
+
+  LOCAL_DEF void      T2_Done_Face( T2_Face  face );
+
+
+ /*************************************************************************/
+ /*  Size funcs                                                           */
+
+  LOCAL_DEF FT_Error  T2_Init_Size ( T2_Size  size );
+  LOCAL_DEF void      T2_Done_Size ( T2_Size  size );
+  LOCAL_DEF FT_Error  T2_Reset_Size( T2_Size  size );
+
+
+ /*************************************************************************/
+ /*  GlyphSlot funcs                                                      */
+
+  LOCAL_DEF FT_Error  T2_Init_GlyphSlot( T2_GlyphSlot  slot );
+  LOCAL_DEF void      T2_Done_GlyphSlot( T2_GlyphSlot  slot );
+
+
+ /*************************************************************************/
+ /*  Driver funcs                                                         */
+
+  LOCAL_DEF  FT_Error  T2_Init_Driver( T2_Driver  driver );
+  LOCAL_DEF  void      T2_Done_Driver( T2_Driver  driver );
+
+
+#ifdef __cplusplus
+  }
+#endif
+
+
+#endif /* T2OBJS_H */
+
+
+/* END */
diff --git a/src/cff/t2parse.c b/src/cff/t2parse.c
new file mode 100644
index 0000000..7520209
--- /dev/null
+++ b/src/cff/t2parse.c
@@ -0,0 +1,514 @@
+#include <t2parse.h>
+#include <freetype/fterrors.h>
+
+#define T2_Err_Stack_Underflow   FT_Err_Invalid_Argument
+#define T2_Err_Syntax_Error      FT_Err_Invalid_Argument
+
+  enum
+  {
+    t2_kind_none = 0,
+    t2_kind_num,
+    t2_kind_fixed,
+    t2_kind_string,
+    t2_kind_bool,
+    t2_kind_delta,
+    t2_kind_callback,
+    
+    t2_kind_max  /* do not remove */
+  };
+
+
+  /* now generate handlers for the most simple fields */
+  typedef FT_Error  (*T2_Field_Reader)( T2_Parser*  parser );
+
+  typedef struct T2_Field_Handler_
+  {
+    int              kind;
+    int              code;
+    FT_UInt          offset;
+    FT_Byte          size;
+    T2_Field_Reader  reader;
+    FT_UInt          array_max;
+    FT_UInt          count_offset;
+    
+  } T2_Field_Handler;
+
+
+
+
+
+  LOCAL_FUNC
+  void  T2_Parser_Init( T2_Parser*  parser, FT_UInt code, void*  object )
+  {
+    MEM_Set(parser,0,sizeof(*parser));
+    parser->top         = parser->stack;
+    parser->object_code = code;
+    parser->object      = object;
+  }
+
+
+
+
+
+
+
+  /* reads an integer */
+  static
+  FT_Long   parse_t2_integer( FT_Byte* start,
+                              FT_Byte* limit )
+  {
+    FT_Byte* p   = start;
+    FT_Int   v   = *p++;
+    FT_Long  val = 0;
+
+    if (v == 28)
+    {
+      if ( p+2 > limit ) goto Bad;
+      val = ((FT_Long)p[0] << 8) | p[1];
+      p  += 2;
+    }
+    else if (v == 29)
+    {
+      if ( p+4 > limit ) goto Bad;
+      val = ((FT_Long)p[0] << 24) |
+            ((FT_Long)p[1] << 16) |
+            ((FT_Long)p[2] <<  8) | p[3];
+      p += 4;
+    }
+    else if (v < 247)
+    {
+      val = v - 139;
+    }
+    else if (v < 251)
+    {
+      if (p+1 > limit) goto Bad;
+      val = (v-247)*256 + p[0]+108;
+      p  ++;
+    }
+    else
+    {
+      if (p+1 > limit) goto Bad;
+      val = -(v-251)*256 - p[0]-108;
+      p  ++;
+    }
+
+  Exit:
+    return val;
+
+  Bad:
+    val = 0;
+    goto Exit;
+  }
+
+
+  /* reads a real */
+  static
+  FT_Fixed  parse_t2_real( FT_Byte*  start,
+                           FT_Byte*  limit,
+                           FT_Int    power_ten )
+  {
+    FT_Byte*  p    = start;
+    FT_Long   num, divider, result, exp;
+    FT_Int    sign = 0, exp_sign = 0;
+    FT_Byte   nib;
+    FT_Byte   phase;
+
+    result  = 0;
+    num     = 0;
+    divider = 1;
+
+    /* first of all, read the integer part */
+    phase = 4;
+    p--;
+    for (;;)
+    {
+      /* read one nibble at a time */
+      if (phase && ++p >= limit) goto Bad;
+      nib   = (p[0] >> phase) & 0xF;
+      phase = 4-phase;
+
+      if (nib == 0xE)
+        sign = 1;
+      else if (nib > 9)
+        break;
+      else
+        result = result*10 + nib;
+    }
+
+    /* read decimal part, if any */
+    if (nib == 0xa)
+      for (;;)
+      {
+        /* read one nibble at a time */
+        if (!phase && ++p >= limit) goto Bad;
+        phase = 4-phase;
+        nib   = (p[0] >> phase) & 0xF;
+
+        if (nib >= 10)
+          break;
+
+        if (divider < 10000000L)
+        {
+          num      = num*10 + nib;
+          divider *= 10;
+        }
+      }
+
+    /* read exponent, if any */
+    if (nib == 12)
+    {
+      exp_sign = 1;
+      nib      = 11;
+    }
+    if (nib == 11)
+    {
+      exp = 0;
+      for (;;)
+      {
+        /* read one nibble at a time */
+        if (!phase && ++p >= limit) goto Bad;
+        phase = 4-phase;
+        nib   = (p[0] >> phase) & 0xF;
+
+        if (nib >= 10)
+          break;
+
+        exp = exp*10 + nib;
+      }
+      if (exp_sign)
+        exp = -exp;
+
+      power_ten += exp;
+    }
+
+    /* raise to power of ten if needed */
+    while (power_ten > 0)
+    {
+      result = result*10;
+      num    = num*10;
+      power_ten--;
+    }
+
+    while (power_ten < 0)
+    {
+      result  = result/10;
+      divider = divider*10;
+      power_ten++;
+    }
+
+    if (num)
+      result += FT_DivFix( num, divider );
+
+    if (sign)
+      result = -result;
+
+  Exit:
+    return result;
+
+  Bad:
+    result = 0;
+    goto Exit;
+  }
+
+
+  /* reads a number, either integer or real */
+  static
+  FT_Long  t2_parse_num( FT_Byte** d )
+  {
+    return ( **d == 30 ? (parse_t2_real   ( d[0], d[1], 0 ) >> 16):
+                          parse_t2_integer( d[0], d[1] ) );
+  }
+
+  /* reads a floating point number, either integer or real */
+  static
+  FT_Fixed  t2_parse_fixed( FT_Byte** d )
+  {
+    return ( **d == 30 ? parse_t2_real( d[0], d[1], 0 ) :
+                         parse_t2_integer( d[0], d[1] ) << 16 );
+  }
+
+
+
+  static
+  FT_Error  parse_font_matrix( T2_Parser*  parser )
+  {
+    CFF_Top_Dict*  dict   = (CFF_Top_Dict*)parser->object;
+    FT_Matrix*     matrix = &dict->font_matrix;
+    FT_Byte**      data   = parser->stack;
+    FT_Error       error;
+
+    error = T2_Err_Stack_Underflow;
+    if (parser->top >= parser->stack + 4)
+    {
+      matrix->xx = t2_parse_fixed( data++ );
+      matrix->yx = t2_parse_fixed( data++ );
+      matrix->xy = t2_parse_fixed( data++ );
+      matrix->yy = t2_parse_fixed( data   );
+      error = 0;
+    }
+    return error;
+  }
+
+
+  static
+  FT_Error  parse_font_bbox( T2_Parser*  parser )
+  {
+    CFF_Top_Dict*  dict   = (CFF_Top_Dict*)parser->object;
+    FT_BBox*       bbox   = &dict->font_bbox;
+    FT_Byte**      data   = parser->stack;
+    FT_Error       error;
+
+    error = T2_Err_Stack_Underflow;
+    if (parser->top >= parser->stack + 4)
+    {
+      bbox->xMin = t2_parse_fixed( data++ );
+      bbox->yMin = t2_parse_fixed( data++ );
+      bbox->xMax = t2_parse_fixed( data++ );
+      bbox->yMax = t2_parse_fixed( data   );
+      error = 0;
+    }
+    return error;
+  }
+
+
+  static
+  FT_Error  parse_private_dict( T2_Parser*  parser )
+  {
+    CFF_Top_Dict*  dict   = (CFF_Top_Dict*)parser->object;
+    FT_Byte**      data   = parser->stack;
+    FT_Error       error;
+
+    error = T2_Err_Stack_Underflow;
+    if (parser->top >= parser->stack + 2)
+    {
+      dict->private_offset = t2_parse_num( data++ );
+      dict->private_size   = t2_parse_num( data );
+      error = 0;
+    }
+    return error;
+  }
+
+
+  static
+  FT_Error  parse_cid_ros( T2_Parser*  parser )
+  {
+    CFF_Top_Dict*  dict   = (CFF_Top_Dict*)parser->object;
+    FT_Byte**      data   = parser->stack;
+    FT_Error       error;
+
+    error = T2_Err_Stack_Underflow;
+    if (parser->top >= parser->stack + 3)
+    {
+      dict->cid_registry   = (FT_UInt)t2_parse_num( data++ );
+      dict->cid_ordering   = (FT_UInt)t2_parse_num( data++ );
+      dict->cid_supplement = (FT_ULong)t2_parse_num( data );
+      error = 0;
+    }
+    return error;
+  }
+
+
+
+#define T2_FIELD_NUM(code,name)        T2_FIELD( code, name, t2_kind_num )
+#define T2_FIELD_FIXED(code,name)      T2_FIELD( code, name, t2_kind_fixed )
+#define T2_FIELD_STRING(code,name)     T2_FIELD( code, name, t2_kind_string )
+#define T2_FIELD_BOOL(code,name)       T2_FIELD( code, name, t2_kind_bool )
+#define T2_FIELD_DELTA(code,name,max)  T2_FIELD( code, name, t2_kind_delta )
+
+
+#define T2_REF(s,f)   (((s*)0)->f)
+
+#define T2_FIELD_CALLBACK( code, name ) \
+     { t2_kind_callback, code, 0, 0, parse_ ## name, 0, 0 },
+     
+#undef  T2_FIELD
+#define T2_FIELD( code, name, kind )           \
+    { kind, code | T2CODE,                     \
+      (FT_UInt)(char*)&T2_REF( T2TYPE, name ), \
+      sizeof( T2_REF( T2TYPE, name ) ),        \
+      0 },
+
+#undef T2_FIELD_DELTA
+#define T2_FIELD_DELTA( code, name, max )                     \
+    { t2_kind_delta, code | T2CODE,                           \
+      (FT_UInt)(char*)&T2_REF( T2TYPE, name ),                \
+      sizeof( T2_REF( T2TYPE, name ) ),                       \
+      0,                                                      \
+      max, (FT_UInt)(char*)&T2_REF( T2TYPE, num_ ## name ) },
+
+
+#define T2CODE_TOPDICT  0x1000
+#define T2CODE_PRIVATE  0x2000
+
+  static const T2_Field_Handler  t2_field_handlers[] =
+  {
+    #include <t2tokens.h>
+    { 0, 0, 0, 0, 0, 0, 0 }
+  };
+
+
+  LOCAL_FUNC
+  FT_Error  T2_Parser_Run( T2_Parser*  parser,
+                           FT_Byte*    start,
+                           FT_Byte*    limit )
+  {
+    FT_Byte*  p;
+    FT_Error  error = 0;
+    
+    parser->top    = parser->stack;
+    parser->start  = start;
+    parser->limit  = limit;
+    parser->cursor = start;
+    
+    while (p < limit)
+    {
+      FT_Byte  v = *p;
+      if ( v >= 27 || v != 31 )
+      {
+        /* its a number, we'll push its position on the stack */
+        if (parser->top - parser->stack >= T2_MAX_STACK_DEPTH)
+          goto Stack_Overflow;
+
+        *parser->top ++ = p;
+        
+        /* now, skip it */
+        if (v == 30)
+        {
+          /* skip real number */
+          for (;;)
+          {
+            if (p >= limit) goto Syntax_Error;
+            v = p[0] >> 4;
+            if (v == 15) break;
+            v = p[0] & 0xF;
+            if (v == 15) break;
+            p++;
+          }
+          p++;
+        }
+        else if (v == 28) 
+          p += 2;
+        else if (v == 29)
+          p += 4;
+        else if (v > 246)
+          p += 1;
+      }
+      else
+      {
+        /* this is not a number, hence it's an operator. Compute its code */
+        /* and look for it in our current list..                          */
+        FT_UInt                  code;
+        FT_Int                   num_args = parser->top - parser->stack;
+        const T2_Field_Handler*  field;
+
+        /* first of all, a trivial check */
+        if ( num_args < 1 ) goto Stack_Underflow;
+
+        code = v;
+        if (v == 12)
+        {
+          /* two byte operator */
+          p++;
+          code = 0x100 | p[0];
+        }
+        code = code | parser->object_code;
+        
+        for ( field = t2_field_handlers; field->kind; field++ )
+        {
+          if (field->code == code)
+          {
+            /* we found our field's handler, read it.. */
+            FT_Long  val;
+            FT_Byte* q = (FT_Byte*)parser->object + field->offset;
+            
+            switch (field->kind)
+            {
+              case t2_kind_bool:
+              case t2_kind_string:
+              case t2_kind_num:
+                       val = t2_parse_num( parser->stack );
+                       goto Store_Number;
+                       
+              case t2_kind_fixed:
+                       val = t2_parse_fixed( parser->stack );
+                       
+                 Store_Number:                       
+                       switch (field->size)
+                       {
+                         case 1: *(FT_Byte*) q = (FT_Byte)val; break;
+                         case 2: *(FT_Short*)q = (FT_Short)val; break;
+                         default: *(FT_Long*)q = val;
+                       }
+                       break;
+              
+              
+              case t2_kind_delta:
+                       {
+                         FT_Byte*  qcount = (FT_Byte*)parser->object +
+                                                field->count_offset;
+
+                         FT_Long   val;
+                         FT_Byte** data = parser->stack;
+                                                
+                         if (num_args > field->array_max)
+                           num_args = field->array_max;
+                         
+                         /* store count */
+                         *qcount = (FT_Byte)num_args;
+                         
+                         val = 0;
+                         while (num_args > 0)
+                         {
+                           val += t2_parse_num( data++ );
+                           switch (field->size)
+                           {
+                             case 1: *(FT_Byte*) q = (FT_Byte)val; break;
+                             case 2: *(FT_Short*)q = (FT_Short)val; break;
+                             default: *(FT_Long*)q = val; 
+                           }
+                           q += field->size;
+                           num_args--;
+                         }
+                       }
+                       break;
+              
+              default:  /* callback */
+                  error = field->reader( parser );
+                  if (error) goto Exit;
+            }
+            /* clear stack */
+            parser->top = parser->stack;
+          }
+          goto Found;  /* exit loop */
+        }
+
+        /* this is an unknown operator, or it is unsupported, we will ignore */
+        /* it for now...                                                     */
+        
+      Found:
+        /* clear stack */
+        parser->top = parser->stack;
+      }
+      p++;
+    }
+  Exit:
+    return error;
+    
+  Stack_Overflow:
+    error = FT_Err_Invalid_Argument;
+    goto Exit;
+    
+  Stack_Underflow:
+    error = FT_Err_Invalid_Argument;
+    goto Exit;
+    
+  Syntax_Error:
+    error = FT_Err_Invalid_Argument;
+    goto Exit;
+    
+  }                           
+
+
+
+
+
diff --git a/src/cff/t2parse.h b/src/cff/t2parse.h
new file mode 100644
index 0000000..75aa48e
--- /dev/null
+++ b/src/cff/t2parse.h
@@ -0,0 +1,33 @@
+#ifndef T2PARSE_H
+#define T2PARSE_H
+
+#include <freetype/internal/t2types.h>
+#include <freetype/internal/ftobjs.h>
+
+#define T2_MAX_STACK_DEPTH  96
+
+  typedef struct T2_Parser_
+  {
+    FT_Byte*   start;
+    FT_Byte*   limit;
+    FT_Byte*   cursor;
+    
+    FT_Byte*   stack[ T2_MAX_STACK_DEPTH+1 ];
+    FT_Byte**  top;
+    
+    FT_UInt    object_code;
+    void*      object;
+    
+  } T2_Parser;
+
+
+  LOCAL_DEF
+  void  T2_Parser_Init( T2_Parser*  parser, FT_UInt code, void*  object );
+
+
+  LOCAL_DEF
+  FT_Error  T2_Parser_Run( T2_Parser*  parser,
+                           FT_Byte*    start,
+                           FT_Byte*    limit );
+
+#endif /* T2PARSE_H */
diff --git a/src/cff/t2tokens.h b/src/cff/t2tokens.h
new file mode 100644
index 0000000..878f6c5
--- /dev/null
+++ b/src/cff/t2tokens.h
@@ -0,0 +1,76 @@
+
+#undef  T2TYPE
+#undef  T2CODE
+#define T2TYPE  CFF_Top_Dict
+#define T2CODE  T2CODE_TOPDICT
+
+  T2_FIELD_STRING  ( 0, version )
+  T2_FIELD_STRING  ( 1, notice )
+  T2_FIELD_STRING  ( 0x100, copyright )
+  T2_FIELD_STRING  ( 2, full_name )
+  T2_FIELD_STRING  ( 3, family_name )
+  T2_FIELD_STRING  ( 4, weight )
+  T2_FIELD_BOOL    ( 0x101, is_fixed_pitch )
+  T2_FIELD_FIXED   ( 0x102, italic_angle )
+  T2_FIELD_NUM     ( 0x103, underline_position )
+  T2_FIELD_NUM     ( 0x104, underline_thickness )
+  T2_FIELD_NUM     ( 0x105, paint_type )
+  T2_FIELD_NUM     ( 0x106, charstring_type )
+  T2_FIELD_CALLBACK( 0x107, font_matrix )
+  T2_FIELD_NUM     ( 13, unique_id )
+  T2_FIELD_CALLBACK( 5, font_bbox )
+  T2_FIELD_NUM     ( 0x108, stroke_width )
+  T2_FIELD_NUM     ( 15, charset_offset )
+  T2_FIELD_NUM     ( 16, encoding_offset )
+  T2_FIELD_NUM     ( 17, charstrings_offset )
+  T2_FIELD_CALLBACK( 18, private_dict )
+  T2_FIELD_NUM     ( 0x114, synthetic_base )
+  T2_FIELD_STRING  ( 0x115, postscript )
+  T2_FIELD_STRING  ( 0x116, base_font_name )
+
+#if 0  
+  T2_FIELD_DELTA   ( 0x117, base_font_blend, 16 )
+  T2_FIELD_CALLBACK( 0x118, multiple_master )
+  T2_FIELD_CALLBACK( 0x119, blend_axit_types )
+#endif
+
+  T2_FIELD_CALLBACK( 0x11E, cid_ros )
+  T2_FIELD_NUM     ( 0x11F, cid_font_version )
+  T2_FIELD_NUM     ( 0x120, cid_font_revision )
+  T2_FIELD_NUM     ( 0x121, cid_font_type )
+  T2_FIELD_NUM     ( 0x122, cid_count )
+  T2_FIELD_NUM     ( 0x123, cid_uid_base )
+  T2_FIELD_NUM     ( 0x124, cid_fd_array_offset )
+  T2_FIELD_NUM     ( 0x125, cid_fd_select_offset )
+  T2_FIELD_STRING  ( 0x126, cid_font_name )
+
+#if 0
+  T2_FIELD_NUM     ( 0x127, chameleon )
+#endif
+
+#undef T2TYPE
+#undef T2CODE
+#define T2TYPE  CFF_Private
+#define T2CODE  T2CODE_PRIVATE
+
+  T2_FIELD_DELTA( 6, blue_values, 14 )
+  T2_FIELD_DELTA( 7, other_blues, 10 )
+  T2_FIELD_DELTA( 8, family_blues, 14 )
+  T2_FIELD_DELTA( 9, family_other_blues, 10 )
+  T2_FIELD_FIXED( 0x109, blue_scale )
+  T2_FIELD_NUM  ( 0x10A, blue_shift )
+  T2_FIELD_NUM  ( 0x10B, blue_fuzz )
+  T2_FIELD_NUM  ( 10, standard_width )
+  T2_FIELD_NUM  ( 11, standard_height )
+  T2_FIELD_DELTA( 0x10C, snap_widths, 13 )
+  T2_FIELD_DELTA( 0x10D, snap_heights, 13 )
+  T2_FIELD_BOOL ( 0x10E, force_bold )
+  T2_FIELD_FIXED( 0x10F, force_bold_threshold )
+  T2_FIELD_NUM  ( 0x110, lenIV )
+  T2_FIELD_NUM  ( 0x111, language_group )
+  T2_FIELD_FIXED( 0x112, expansion_factor )
+  T2_FIELD_NUM  ( 0x113, initial_random_seed )
+  T2_FIELD_NUM  ( 19, local_subrs_offset )
+  T2_FIELD_NUM  ( 20, default_width )
+  T2_FIELD_NUM  ( 21, nominal_width )
+