Commit 1f7f0e87e58168b2e739e2622db0ee06e0c9accc

Werner Lemberg 2001-06-06T17:30:41

Complete redesign of error codes. Please check ftmoderr.h for more details. * include/freetype/internal/cfferrs.h, include/freetype/internal/tterrors.h, include/freetype/internal/t1errors.h: Removed. Replaced with files local to the module. All extra error codes have been moved to `fterrors.h'. * src/sfnt/ttpost.h: Move error codes to `fterrors.h'. * src/autohint/aherrors.h, src/cache/ftcerror.h, src/cff/cfferrs.h, src/cid/ciderrs.h, src/pcf/pcferror.h, src/psaux/psauxerr.h, src/psnames/psnamerr.h, src/raster/rasterrs.h, src/sfnt/sferrors.h, src/smooth/ftsmerrs.h, src/truetype/tterrors.h, src/type1/t1errors.h, src/winfonts/fnterrs.h: New files defining the error names for the module it belongs to. * include/freetype/ftmoderr.h: New file, defining the module error offsets. Its structure is similar to `fterrors.h'. * include/freetype/fterrors.h (FT_NOERRORDEF): New macro. (FT_ERRORDEF): Redefined to use module error offsets. All internal error codes are now public; unused error codes have been removed, some are new. * include/freetype/config/ftheader.h (FT_MODULE_ERRORS_H): New macro. * include/freetype/config/ftoption.h (FT_CONFIG_OPTION_USE_MODULE_ERRORS): New macro. All other source files have been updated to use the new error codes; some already existing (internal) error codes local to a module have been renamed to give them the same name as in the base module. All make files have been updated to include the local error files. * src/cid/cidtokens.h: Replaced with... * src/cid/cidtoken.h: This file for 8+3 consistency. * src/raster/ftraster.c: Use macros for header file names.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
diff --git a/ChangeLog b/ChangeLog
index ed35604..8bdd796 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,49 @@
 2001-06-06  Werner Lemberg  <wl@gnu.org>
 
+	Complete redesign of error codes.  Please check ftmoderr.h for more
+	details.
+
+	* include/freetype/internal/cfferrs.h,
+	include/freetype/internal/tterrors.h,
+	include/freetype/internal/t1errors.h: Removed.  Replaced with files
+	local to the module.  All extra error codes have been moved to
+	`fterrors.h'.
+
+	* src/sfnt/ttpost.h: Move error codes to `fterrors.h'.
+
+	* src/autohint/aherrors.h, src/cache/ftcerror.h, src/cff/cfferrs.h,
+	src/cid/ciderrs.h, src/pcf/pcferror.h, src/psaux/psauxerr.h,
+	src/psnames/psnamerr.h, src/raster/rasterrs.h, src/sfnt/sferrors.h,
+	src/smooth/ftsmerrs.h, src/truetype/tterrors.h,
+	src/type1/t1errors.h, src/winfonts/fnterrs.h: New files defining the
+	error names for the module it belongs to.
+
+	* include/freetype/ftmoderr.h: New file, defining the module error
+	offsets.  Its structure is similar to `fterrors.h'.
+
+	* include/freetype/fterrors.h (FT_NOERRORDEF): New macro.
+	(FT_ERRORDEF): Redefined to use module error offsets.
+	All internal error codes are now public; unused error codes have
+	been removed, some are new.
+
+	* include/freetype/config/ftheader.h (FT_MODULE_ERRORS_H): New
+	macro.
+	* include/freetype/config/ftoption.h
+	(FT_CONFIG_OPTION_USE_MODULE_ERRORS): New macro.
+
+	All other source files have been updated to use the new error codes;
+	some already existing (internal) error codes local to a module have
+	been renamed to give them the same name as in the base module.
+
+	All make files have been updated to include the local error files.
+
+2001-06-06  Werner Lemberg  <wl@gnu.org>
+
+	* src/cid/cidtokens.h: Replaced with...
+	* src/cid/cidtoken.h: This file for 8+3 consistency.
+
+	* src/raster/ftraster.c: Use macros for header file names.
+
 	* src/include/freetype/tttables.h (TT_HoriHeader_, TT_VertHeader_):
 	Fix length of `Reserved' array.  Note that this isn't the real fix
 	since recent OpenType specs have introduced a `CaretOffset' field
diff --git a/include/freetype/config/ftheader.h b/include/freetype/config/ftheader.h
index e39c3cd..01a0f65 100644
--- a/include/freetype/config/ftheader.h
+++ b/include/freetype/config/ftheader.h
@@ -167,6 +167,18 @@
   /*************************************************************************/
   /*                                                                       */
   /* @macro:                                                               */
+  /*    FT_MODULE_ERRORS_H                                                 */
+  /*                                                                       */
+  /* @description:                                                         */
+  /*    A macro used in #include statements to name the file containing    */
+  /*    the list of FreeType 2 module error offsets (and messages).        */
+  /*                                                                       */
+#define FT_MODULE_ERRORS_H  <freetype/ftmoderr.h>
+
+
+  /*************************************************************************/
+  /*                                                                       */
+  /* @macro:                                                               */
   /*    FT_SYSTEM_H                                                        */
   /*                                                                       */
   /* @description:                                                         */
diff --git a/include/freetype/config/ftoption.h b/include/freetype/config/ftoption.h
index f5f7337..567c865 100644
--- a/include/freetype/config/ftoption.h
+++ b/include/freetype/config/ftoption.h
@@ -75,6 +75,22 @@ FT_BEGIN_HEADER
 
   /*************************************************************************/
   /*                                                                       */
+  /* Module errors                                                         */
+  /*                                                                       */
+  /*   If this macro is set (which is the default), the higher byte of an  */
+  /*   error code gives the module in which the error has occurred, while  */
+  /*   the lower byte is the real error code.                              */
+  /*                                                                       */
+  /*   Unsetting this macro makes sense for backwards compatibility; only  */
+  /*   the real error code is emitted, and the higher byte is always zero. */
+  /*                                                                       */
+  /*   More details can be found in the files ftmoderr.h and fterrors.h.   */
+  /*                                                                       */
+#define FT_CONFIG_OPTION_USE_MODULE_ERRORS
+
+
+  /*************************************************************************/
+  /*                                                                       */
   /* Alternate Glyph Image Format support                                  */
   /*                                                                       */
   /*   By default, the glyph images returned by the FreeType glyph loader  */
diff --git a/include/freetype/fterrors.h b/include/freetype/fterrors.h
index 5db4509..5cd3e09 100644
--- a/include/freetype/fterrors.h
+++ b/include/freetype/fterrors.h
@@ -19,14 +19,25 @@
   /*************************************************************************/
   /*                                                                       */
   /* This file is used to define the FreeType error enumeration constants. */
+  /*                                                                       */
+  /* The lower byte gives the error code, the higher byte gives the        */
+  /* module.  The base module has error offset 0.  For example, the error  */
+  /* `FT_Err_Invalid_File_Format' has value 0x003, the error               */
+  /* `TT_Err_Invalid_File_Format' has value 0xB03, the error               */
+  /* `T1_Err_Invalid_File_Format' has value 0xC03, etc.                    */
+  /*                                                                       */
+  /* Undefine the macro FT_CONFIG_OPTION_USE_MODULE_ERRORS (in ftoption.h) */
+  /* to make the higher byte always zero.                                  */
+  /*                                                                       */
   /* It can also be used to create an error message table easily with      */
   /* something like                                                        */
   /*                                                                       */
   /*   {                                                                   */
   /*     #undef __FTERRORS_H__                                             */
-  /*     #define FT_ERRORDEF( e, v, s )  { e, s },                         */
-  /*     #define FT_ERROR_START_LIST  {                                    */
-  /*     #define FT_ERROR_END_LIST    { 0, 0 } };                          */
+  /*     #define FT_ERRORDEF( e, v, s )   { FT_Err_ ## e, s },             */
+  /*     #define FT_NOERRORDEF( e, v, s ) { FT_Err_ ## e, s },             */
+  /*     #define FT_ERROR_START_LIST      {                                */
+  /*     #define FT_ERROR_END_LIST        { 0, 0 } };                      */
   /*                                                                       */
   /*     const struct                                                      */
   /*     {                                                                 */
@@ -37,8 +48,8 @@
   /*     #include FT_ERRORS_H                                              */
   /*   }                                                                   */
   /*                                                                       */
-  /* For C++ it might be necessary to use `extern "C" {' and to define     */
-  /* FT_NEED_EXTERN_C also.                                                */
+  /* To use such a table, all errors must be ANDed with 0x00FF to remove   */
+  /* the module error offset.                                              */
   /*                                                                       */
   /*************************************************************************/
 
@@ -46,15 +57,18 @@
 #ifndef __FTERRORS_H__
 #define __FTERRORS_H__
 
+#include FT_MODULE_ERRORS_H
 
 #undef FT_NEED_EXTERN_C
 
 
 #ifndef FT_ERRORDEF
 
-#define FT_ERRORDEF( e, v, s )  e = v,
-#define FT_ERROR_START_LIST     enum {
-#define FT_ERROR_END_LIST       FT_Err_Max };
+#define FT_ERRORDEF( e, v, s )    FT_Err_ ## e = v + FT_Mod_Err_Base,
+#define FT_NOERRORDEF( e, v, s )  FT_Err_ ## e = v,
+
+#define FT_ERROR_START_LIST       enum {
+#define FT_ERROR_END_LIST         FT_Err_Max };
 
 #ifdef __cplusplus
 #define FT_NEED_EXTERN_C
@@ -68,119 +82,182 @@
   FT_ERROR_START_LIST
 #endif
 
+
   /* generic errors */
 
-  FT_ERRORDEF( FT_Err_Ok,                           0x0000, \
-               "no error" )
-  FT_ERRORDEF( FT_Err_Cannot_Open_Resource,         0x0001, \
+  FT_NOERRORDEF( Ok,                                        0x00, \
+                 "no error" )
+
+  FT_ERRORDEF( Cannot_Open_Resource,                        0x01, \
                "cannot open resource" )
-  FT_ERRORDEF( FT_Err_Unknown_File_Format,          0x0002, \
+  FT_ERRORDEF( Unknown_File_Format,                         0x02, \
                "unknown file format" )
-  FT_ERRORDEF( FT_Err_Invalid_File_Format,          0x0003, \
+  FT_ERRORDEF( Invalid_File_Format,                         0x03, \
                "broken file" )
-  FT_ERRORDEF( FT_Err_Invalid_Version,              0x0004, \
+  FT_ERRORDEF( Invalid_Version,                             0x04, \
                "invalid FreeType version" )
-  FT_ERRORDEF( FT_Err_Lower_Module_Version,         0x0005, \
+  FT_ERRORDEF( Lower_Module_Version,                        0x05, \
                "module version is too low" )
-  FT_ERRORDEF( FT_Err_Invalid_Argument,             0x0006, \
+  FT_ERRORDEF( Invalid_Argument,                            0x06, \
                "invalid argument" )
-  FT_ERRORDEF( FT_Err_Unimplemented_Feature,        0x0007, \
+  FT_ERRORDEF( Unimplemented_Feature,                       0x07, \
                "unimplemented feature" )
 
   /* glyph/character errors */
 
-  FT_ERRORDEF( FT_Err_Invalid_Glyph_Index,          0x0010, \
+  FT_ERRORDEF( Invalid_Glyph_Index,                         0x10, \
                "invalid glyph index" )
-  FT_ERRORDEF( FT_Err_Invalid_Character_Code,       0x0011, \
+  FT_ERRORDEF( Invalid_Character_Code,                      0x11, \
                "invalid character code" )
-  FT_ERRORDEF( FT_Err_Invalid_Glyph_Format,         0x0012, \
+  FT_ERRORDEF( Invalid_Glyph_Format,                        0x12, \
                "unsupported glyph image format" )
-  FT_ERRORDEF( FT_Err_Cannot_Render_Glyph,          0x0013, \
+  FT_ERRORDEF( Cannot_Render_Glyph,                         0x13, \
                "cannot render this glyph format" )
-  FT_ERRORDEF( FT_Err_Invalid_Outline,              0x0014, \
+  FT_ERRORDEF( Invalid_Outline,                             0x14, \
                "invalid outline" )
-  FT_ERRORDEF( FT_Err_Invalid_Composite,            0x0015, \
+  FT_ERRORDEF( Invalid_Composite,                           0x15, \
                "invalid composite glyph" )
-  FT_ERRORDEF( FT_Err_Too_Many_Hints,               0x0016, \
+  FT_ERRORDEF( Too_Many_Hints,                              0x16, \
                "too many hints" )
-  FT_ERRORDEF( FT_Err_Invalid_Pixel_Size,           0x0017, \
+  FT_ERRORDEF( Invalid_Pixel_Size,                          0x17, \
                "invalid pixel size" )
 
   /* handle errors */
 
-  FT_ERRORDEF( FT_Err_Invalid_Handle,               0x0020, \
+  FT_ERRORDEF( Invalid_Handle,                              0x20, \
                "invalid object handle" )
-  FT_ERRORDEF( FT_Err_Invalid_Library_Handle,       0x0021, \
+  FT_ERRORDEF( Invalid_Library_Handle,                      0x21, \
                "invalid library handle" )
-  FT_ERRORDEF( FT_Err_Invalid_Driver_Handle,        0x0022, \
+  FT_ERRORDEF( Invalid_Driver_Handle,                       0x22, \
                "invalid module handle" )
-  FT_ERRORDEF( FT_Err_Invalid_Face_Handle,          0x0023, \
+  FT_ERRORDEF( Invalid_Face_Handle,                         0x23, \
                "invalid face handle" )
-  FT_ERRORDEF( FT_Err_Invalid_Size_Handle,          0x0024, \
+  FT_ERRORDEF( Invalid_Size_Handle,                         0x24, \
                "invalid size handle" )
-  FT_ERRORDEF( FT_Err_Invalid_Slot_Handle,          0x0025, \
+  FT_ERRORDEF( Invalid_Slot_Handle,                         0x25, \
                "invalid glyph slot handle" )
-  FT_ERRORDEF( FT_Err_Invalid_CharMap_Handle,       0x0026, \
+  FT_ERRORDEF( Invalid_CharMap_Handle,                      0x26, \
                "invalid charmap handle" )
-  FT_ERRORDEF( FT_Err_Invalid_Cache_Handle,         0x0027, \
+  FT_ERRORDEF( Invalid_Cache_Handle,                        0x27, \
                "invalid cache manager handle" )
-  FT_ERRORDEF( FT_Err_Invalid_Stream_Handle,        0x0028, \
+  FT_ERRORDEF( Invalid_Stream_Handle,                       0x28, \
                "invalid stream handle" )
 
   /* driver errors */
 
-  FT_ERRORDEF( FT_Err_Too_Many_Drivers,             0x0030, \
+  FT_ERRORDEF( Too_Many_Drivers,                            0x30, \
                "too many modules" )
-  FT_ERRORDEF( FT_Err_Too_Many_Extensions,          0x0031, \
+  FT_ERRORDEF( Too_Many_Extensions,                         0x31, \
                "too many extensions" )
 
   /* memory errors */
 
-  FT_ERRORDEF( FT_Err_Out_Of_Memory,                0x0040, \
+  FT_ERRORDEF( Out_Of_Memory,                               0x40, \
                "out of memory" )
-  FT_ERRORDEF( FT_Err_Unlisted_Object,              0x0041, \
+  FT_ERRORDEF( Unlisted_Object,                             0x41, \
                "unlisted object" )
 
   /* stream errors */
 
-  FT_ERRORDEF( FT_Err_Cannot_Open_Stream,           0x0051, \
+  FT_ERRORDEF( Cannot_Open_Stream,                          0x51, \
                "cannot open stream" )
-  FT_ERRORDEF( FT_Err_Invalid_Stream_Seek,          0x0052, \
+  FT_ERRORDEF( Invalid_Stream_Seek,                         0x52, \
                "invalid stream seek" )
-  FT_ERRORDEF( FT_Err_Invalid_Stream_Skip,          0x0053, \
+  FT_ERRORDEF( Invalid_Stream_Skip,                         0x53, \
                "invalid stream skip" )
-  FT_ERRORDEF( FT_Err_Invalid_Stream_Read,          0x0054, \
+  FT_ERRORDEF( Invalid_Stream_Read,                         0x54, \
                "invalid stream read" )
-  FT_ERRORDEF( FT_Err_Invalid_Stream_Operation,     0x0055, \
+  FT_ERRORDEF( Invalid_Stream_Operation,                    0x55, \
                "invalid stream operation" )
-  FT_ERRORDEF( FT_Err_Invalid_Frame_Operation,      0x0056, \
+  FT_ERRORDEF( Invalid_Frame_Operation,                     0x56, \
                "invalid frame operation" )
-  FT_ERRORDEF( FT_Err_Nested_Frame_Access,          0x0057, \
+  FT_ERRORDEF( Nested_Frame_Access,                         0x57, \
                "nested frame access" )
-  FT_ERRORDEF( FT_Err_Invalid_Frame_Read,           0x0058, \
+  FT_ERRORDEF( Invalid_Frame_Read,                          0x58, \
                "invalid frame read" )
 
   /* raster errors */
 
-  FT_ERRORDEF( FT_Err_Raster_Uninitialized,         0x0060, \
+  FT_ERRORDEF( Raster_Uninitialized,                        0x60, \
                "raster uninitialized" )
-  FT_ERRORDEF( FT_Err_Raster_Corrupted,             0x0061, \
+  FT_ERRORDEF( Raster_Corrupted,                            0x61, \
                "raster corrupted" )
-  FT_ERRORDEF( FT_Err_Raster_Overflow,              0x0062, \
+  FT_ERRORDEF( Raster_Overflow,                             0x62, \
                "raster overflow" )
-  FT_ERRORDEF( FT_Err_Raster_Negative_Height,       0x0063, \
+  FT_ERRORDEF( Raster_Negative_Height,                      0x63, \
                "negative height while rastering" )
 
   /* cache errors */
 
-  FT_ERRORDEF( FT_Err_Too_Many_Caches,              0x0070, \
+  FT_ERRORDEF( Too_Many_Caches,                             0x70, \
                "too many registered caches" )
 
-  /* range 0x400 - 0x4FF is reserved for TrueType specific stuff */
-
-  /* range 0x500 - 0x5FF is reserved for CFF specific stuff */
+  /* TrueType and SFNT errors */
+
+  FT_ERRORDEF( Invalid_Opcode,                              0x80, \
+               "invalid opcode" )
+  FT_ERRORDEF( Too_Few_Arguments,                           0x81, \
+               "too few arguments" )
+  FT_ERRORDEF( Stack_Overflow,                              0x82, \
+               "stack overflow" )
+  FT_ERRORDEF( Code_Overflow,                               0x83, \
+               "code overflow" )
+  FT_ERRORDEF( Bad_Argument,                                0x84, \
+               "bad argument" )
+  FT_ERRORDEF( Divide_By_Zero,                              0x85, \
+               "division by zero" )
+  FT_ERRORDEF( Invalid_Reference,                           0x86, \
+               "invalid reference" )
+  FT_ERRORDEF( Debug_OpCode,                                0x87, \
+               "found debug opcode" )
+  FT_ERRORDEF( ENDF_In_Exec_Stream,                         0x88, \
+               "found ENDF opcode in execution stream" )
+  FT_ERRORDEF( Nested_DEFS,                                 0x89, \
+               "nested DEFS" )
+  FT_ERRORDEF( Invalid_CodeRange,                           0x8A, \
+               "invalid code range" )
+  FT_ERRORDEF( Execution_Too_Long,                          0x8B, \
+               "execution context too long" )
+  FT_ERRORDEF( Too_Many_Function_Defs,                      0x8C, \
+               "too many function definitions" )
+  FT_ERRORDEF( Too_Many_Instruction_Defs,                   0x8D, \
+               "too many instruction definitions" )
+  FT_ERRORDEF( Table_Missing,                               0x8E, \
+               "SFNT font table missing" )
+  FT_ERRORDEF( Horiz_Header_Missing,                        0x8F, \
+               "horizontal header (hhea) table missing" )
+  FT_ERRORDEF( Locations_Missing,                           0x90, \
+               "locations (loca) table missing" )
+  FT_ERRORDEF( Name_Table_Missing,                          0x91, \
+               "name table missing" )
+  FT_ERRORDEF( CMap_Table_Missing,                          0x92, \
+               "character map (cmap) table missing" )
+  FT_ERRORDEF( Hmtx_Table_Missing,                          0x93, \
+               "horizontal metrics (hmtx) table missing" )
+  FT_ERRORDEF( Post_Table_Missing,                          0x94, \
+               "PostScript (post) table missing" )
+  FT_ERRORDEF( Invalid_Horiz_Metrics,                       0x95, \
+               "invalid horizontal metrics" )
+  FT_ERRORDEF( Invalid_CharMap_Format,                      0x96, \
+               "invalid character map (cmap) format" )
+  FT_ERRORDEF( Invalid_PPem,                                0x97, \
+               "invalid ppem value" )
+  FT_ERRORDEF( Invalid_Vert_Metrics,                        0x98, \
+               "invalid vertical metrics" )
+  FT_ERRORDEF( Could_Not_Find_Context,                      0x99, \
+               "could not find context" )
+  FT_ERRORDEF( Invalid_Post_Table_Format,                   0x9A, \
+               "invalid PostScript (post) table format" )
+  FT_ERRORDEF( Invalid_Post_Table,                          0x9B, \
+               "invalid PostScript (post) table" )
+
+  /* CFF, CID, and Type 1 errors */
+
+  FT_ERRORDEF( Syntax_Error,                                0xA0, \
+               "opcode syntax error" )
+  FT_ERRORDEF( Stack_Underflow,                             0xA1, \
+               "argument stack underflow" )
 
-  /* range 0x600 - 0x6FF is reserved for Type1 specific stuff */
 
 #ifdef FT_ERROR_END_LIST
   FT_ERROR_END_LIST
@@ -190,6 +267,7 @@
 #undef FT_ERROR_START_LIST
 #undef FT_ERROR_END_LIST
 #undef FT_ERRORDEF
+#undef FT_NOERRORDEF
 
 
 #ifdef FT_NEED_EXTERN_C
diff --git a/include/freetype/ftmoderr.h b/include/freetype/ftmoderr.h
new file mode 100644
index 0000000..71252a1
--- /dev/null
+++ b/include/freetype/ftmoderr.h
@@ -0,0 +1,123 @@
+/***************************************************************************/
+/*                                                                         */
+/*  ftmoderr.h                                                             */
+/*                                                                         */
+/*    FreeType module error offsets (specification).                       */
+/*                                                                         */
+/*  Copyright 2001 by                                                      */
+/*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
+/*                                                                         */
+/*  This file is part of the FreeType project, and may only be used,       */
+/*  modified, and distributed under the terms of the FreeType project      */
+/*  license, LICENSE.TXT.  By continuing to use, modify, or distribute     */
+/*  this file you indicate that you have read the license and              */
+/*  understand and accept it fully.                                        */
+/*                                                                         */
+/***************************************************************************/
+
+
+  /*************************************************************************/
+  /*                                                                       */
+  /* This file is used to define the FreeType module error offsets.        */
+  /*                                                                       */
+  /* The lower byte gives the error code, the higher byte gives the        */
+  /* module.  The base module has error offset 0.  For example, the error  */
+  /* `FT_Err_Invalid_File_Format' has value 0x003, the error               */
+  /* `TT_Err_Invalid_File_Format' has value 0xB03, the error               */
+  /* `T1_Err_Invalid_File_Format' has value 0xC03, etc.                    */
+  /*                                                                       */
+  /* Undefine the macro FT_CONFIG_OPTION_USE_MODULE_ERRORS in ftoption.h   */
+  /* to make the higher byte always zero (disabling the module error       */
+  /* mechanism).                                                           */
+  /*                                                                       */
+  /* It can also be used to create a module error message table easily     */
+  /* with something like                                                   */
+  /*                                                                       */
+  /*   {                                                                   */
+  /*     #undef __FTMODERR_H__                                             */
+  /*     #define FT_MODERRDEF( e, v, s )  { FT_Mod_Err_ ## e, s },         */
+  /*     #define FT_MODERR_START_LIST     {                                */
+  /*     #define FT_MODERR_END_LIST       { 0, 0 } };                      */
+  /*                                                                       */
+  /*     const struct                                                      */
+  /*     {                                                                 */
+  /*       int          mod_err_offset;                                    */
+  /*       const char*  mod_err_msg                                        */
+  /*     } ft_mod_errors[] =                                               */
+  /*                                                                       */
+  /*     #include FT_MODULE_ERRORS_H                                       */
+  /*   }                                                                   */
+  /*                                                                       */
+  /* To use such a table, all errors must be ANDed with 0xFF00 to remove   */
+  /* the error code.                                                       */
+  /*                                                                       */
+  /*************************************************************************/
+
+
+#ifndef __FTMODERR_H__
+#define __FTMODERR_H__
+
+
+#undef FT_NEED_EXTERN_C
+
+
+
+
+#ifndef FT_MODERRDEF
+
+#ifdef FT_CONFIG_OPTION_USE_MODULE_ERRORS
+#define FT_MODERRDEF( e, v, s )  FT_Mod_Err_ ## e = v,
+#else
+#define FT_MODERRDEF( e, v, s )  FT_Mod_Err_ ## e = 0,
+#endif
+
+#define FT_MODERR_START_LIST     enum {
+#define FT_MODERR_END_LIST       FT_Mod_Err_Max };
+
+#ifdef __cplusplus
+#define FT_NEED_EXTERN_C
+  extern "C" {
+#endif
+
+#endif /* !FT_MODERRDEF */
+
+
+#ifdef FT_MODERR_START_LIST
+  FT_MODERR_START_LIST
+#endif
+
+
+  FT_MODERRDEF( Base,     0x000, "base module" )
+  FT_MODERRDEF( Autohint, 0x100, "autohinter module" )
+  FT_MODERRDEF( Cache,    0x200, "cache module" )
+  FT_MODERRDEF( CFF,      0x300, "CFF module" )
+  FT_MODERRDEF( CID,      0x400, "CID module" )
+  FT_MODERRDEF( PCF,      0x500, "PCF module" )
+  FT_MODERRDEF( PSaux,    0x600, "PS auxiliary module" )
+  FT_MODERRDEF( PSnames,  0x700, "PS names module" )
+  FT_MODERRDEF( Raster,   0x800, "raster module" )
+  FT_MODERRDEF( SFNT,     0x900, "SFNT module" )
+  FT_MODERRDEF( Smooth,   0xA00, "smooth raster module" )
+  FT_MODERRDEF( TrueType, 0xB00, "TrueType module" )
+  FT_MODERRDEF( Type1,    0xC00, "Type 1 module" )
+  FT_MODERRDEF( Winfonts, 0xD00, "Windows FON/FNT module" )
+
+
+#ifdef FT_MODERR_END_LIST
+  FT_MODERR_END_LIST
+#endif
+
+
+#undef FT_MODERR_START_LIST
+#undef FT_MODERR_END_LIST
+#undef FT_MODERRDEF
+
+
+#ifdef FT_NEED_EXTERN_C
+  }
+#endif
+
+#endif /* __FTMODERR_H__ */
+
+
+/* END */
diff --git a/include/freetype/internal/cfferrs.h b/include/freetype/internal/cfferrs.h
deleted file mode 100644
index c84e875..0000000
--- a/include/freetype/internal/cfferrs.h
+++ /dev/null
@@ -1,136 +0,0 @@
-/***************************************************************************/
-/*                                                                         */
-/*  cfferrs.h                                                              */
-/*                                                                         */
-/*    OpenType error ID definitions (specification only).                  */
-/*                                                                         */
-/*  Copyright 1996-2000 by                                                 */
-/*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
-/*                                                                         */
-/*  This file is part of the FreeType project, and may only be used,       */
-/*  modified, and distributed under the terms of the FreeType project      */
-/*  license, LICENSE.TXT.  By continuing to use, modify, or distribute     */
-/*  this file you indicate that you have read the license and              */
-/*  understand and accept it fully.                                        */
-/*                                                                         */
-/***************************************************************************/
-
-
-#ifndef __CFFERRORS_H__
-#define __CFFERRORS_H__
-
-
-#include <ft2build.h>
-
-
-FT_BEGIN_HEADER
-
-
-  /*************************************************************************/
-  /*                                                                       */
-  /* 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 CFF_Err_Ok                         FT_Err_Ok
-
-  /* High level API errors. */
-
-#define CFF_Err_Unknown_File_Format        FT_Err_Unknown_File_Format
-#define CFF_Err_Invalid_File_Format        FT_Err_Invalid_File_Format
-#define CFF_Err_Invalid_Argument           FT_Err_Invalid_Argument
-#define CFF_Err_Invalid_Driver_Handle      FT_Err_Invalid_Driver_Handle
-#define CFF_Err_Invalid_Face_Handle        FT_Err_Invalid_Face_Handle
-#define CFF_Err_Invalid_Instance_Handle    FT_Err_Invalid_Size_Handle
-#define CFF_Err_Invalid_Glyph_Handle       FT_Err_Invalid_Slot_Handle
-#define CFF_Err_Invalid_CharMap_Handle     FT_Err_Invalid_CharMap_Handle
-#define CFF_Err_Invalid_Glyph_Index        FT_Err_Invalid_Glyph_Index
-
-#define CFF_Err_Unimplemented_Feature      FT_Err_Unimplemented_Feature
-
-#define CFF_Err_Invalid_Engine             FT_Err_Invalid_Driver_Handle
-
-  /* Internal errors. */
-
-#define CFF_Err_Out_Of_Memory              FT_Err_Out_Of_Memory
-#define CFF_Err_Unlisted_Object            FT_Err_Unlisted_Object
-
-  /* General glyph outline errors. */
-
-#define CFF_Err_Invalid_Composite          FT_Err_Invalid_Composite
-
-  /* CFF parser errors. */
-
-#define CFF_Err_Stack_Underflow            FT_Err_Invalid_Argument
-#define CFF_Err_Syntax_Error               FT_Err_Invalid_Argument
-
-  /* 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 CFF_Err_Invalid_Opcode             0x500
-#define CFF_Err_Too_Few_Arguments          0x501
-#define CFF_Err_Stack_Overflow             0x502
-#define CFF_Err_Code_Overflow              0x503
-#define CFF_Err_Bad_Argument               0x504
-#define CFF_Err_Divide_By_Zero             0x505
-#define CFF_Err_Storage_Overflow           0x506
-#define CFF_Err_Cvt_Overflow               0x507
-#define CFF_Err_Invalid_Reference          0x508
-#define CFF_Err_Invalid_Distance           0x509
-#define CFF_Err_Interpolate_Twilight       0x50A
-#define CFF_Err_Debug_OpCode               0x50B
-#define CFF_Err_ENDF_In_Exec_Stream        0x50C
-#define CFF_Err_Out_Of_CodeRanges          0x50D
-#define CFF_Err_Nested_DEFS                0x50E
-#define CFF_Err_Invalid_CodeRange          0x50F
-#define CFF_Err_Invalid_Displacement       0x510
-#define CFF_Err_Execution_Too_Long         0x511
-
-#define CFF_Err_Too_Many_Instruction_Defs  0x512
-#define CFF_Err_Too_Many_Function_Defs     0x513
-
-  /* Other TrueType specific error codes. */
-
-#define CFF_Err_Table_Missing              0x520
-#define CFF_Err_Too_Many_Extensions        0x521
-#define CFF_Err_Extensions_Unsupported     0x522
-#define CFF_Err_Invalid_Extension_Id       0x523
-
-#define CFF_Err_No_Vertical_Data           0x524
-
-#define CFF_Err_Max_Profile_Missing        0x530
-#define CFF_Err_Header_Table_Missing       0x531
-#define CFF_Err_Horiz_Header_Missing       0x532
-#define CFF_Err_Locations_Missing          0x533
-#define CFF_Err_Name_Table_Missing         0x534
-#define CFF_Err_CMap_Table_Missing         0x535
-#define CFF_Err_Hmtx_Table_Missing         0x536
-#define CFF_Err_OS2_Table_Missing          0x537
-#define CFF_Err_Post_Table_Missing         0x538
-
-#define CFF_Err_Invalid_Horiz_Metrics      0x540
-#define CFF_Err_Invalid_CharMap_Format     0x541
-#define CFF_Err_Invalid_PPem               0x542
-#define CFF_Err_Invalid_Vert_Metrics       0x543
-
-#define CFF_Err_Could_Not_Find_Context     0x550
-
-
-FT_END_HEADER
-
-
-#endif /* __CFFERRORS_H__ */
-
-
-/* END */
diff --git a/include/freetype/internal/internal.h b/include/freetype/internal/internal.h
index ecda8a7..58003e9 100644
--- a/include/freetype/internal/internal.h
+++ b/include/freetype/internal/internal.h
@@ -36,19 +36,14 @@
 #define FT_INTERNAL_SFNT_H              <freetype/internal/sfnt.h>
 
 #define FT_INTERNAL_TRUETYPE_TYPES_H    <freetype/internal/tttypes.h>
-#define FT_INTERNAL_TRUETYPE_ERRORS_H   <freetype/internal/tterrors.h>
-
-#define FT_INTERNAL_TYPE1_ERRORS_H      <freetype/internal/t1errors.h>
 #define FT_INTERNAL_TYPE1_TYPES_H       <freetype/internal/t1types.h>
-
-#define FT_INTERNAL_CFF_ERRORS_H        <freetype/internal/cfferrs.h>
 #define FT_INTERNAL_CFF_TYPES_H         <freetype/internal/cfftypes.h>
+#define FT_INTERNAL_FNT_TYPES_H         <freetype/internal/fnttypes.h>
 
 #define FT_INTERNAL_POSTSCRIPT_NAMES_H  <freetype/internal/psnames.h>
 #define FT_INTERNAL_POSTSCRIPT_AUX_H    <freetype/internal/psaux.h>
 
 #define FT_INTERNAL_AUTOHINT_H          <freetype/internal/autohint.h>
-#define FT_INTERNAL_FNT_TYPES_H         <freetype/internal/fnttypes.h>
 
 
 /* END */
diff --git a/include/freetype/internal/t1errors.h b/include/freetype/internal/t1errors.h
deleted file mode 100644
index 20a64ae..0000000
--- a/include/freetype/internal/t1errors.h
+++ /dev/null
@@ -1,76 +0,0 @@
-/***************************************************************************/
-/*                                                                         */
-/*  t1errors.h                                                             */
-/*                                                                         */
-/*    Type 1 error ID definitions (specification only).                    */
-/*                                                                         */
-/*  Copyright 1996-2000 by                                                 */
-/*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
-/*                                                                         */
-/*  This file is part of the FreeType project, and may only be used,       */
-/*  modified, and distributed under the terms of the FreeType project      */
-/*  license, LICENSE.TXT.  By continuing to use, modify, or distribute     */
-/*  this file you indicate that you have read the license and              */
-/*  understand and accept it fully.                                        */
-/*                                                                         */
-/***************************************************************************/
-
-
-#ifndef __T1ERRORS_H__
-#define __T1ERRORS_H__
-
-
-#include <ft2build.h>
-
-
-FT_BEGIN_HEADER
-
-
-  /************************ error codes declaration **************/
-
-  /* The error codes are grouped into `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 T1_Err_Ok                      FT_Err_Ok
-
-  /* ----------- high level API errors -------- */
-
-#define T1_Err_Unknown_File_Format     FT_Err_Unknown_File_Format
-#define T1_Err_Invalid_File_Format     FT_Err_Invalid_File_Format
-#define T1_Err_Invalid_Argument        FT_Err_Invalid_Argument
-#define T1_Err_Invalid_Driver_Handle   FT_Err_Invalid_Driver_Handle
-#define T1_Err_Invalid_Face_Handle     FT_Err_Invalid_Face_Handle
-#define T1_Err_Invalid_Size_Handle     FT_Err_Invalid_Size_Handle
-#define T1_Err_Invalid_Glyph_Handle    FT_Err_Invalid_Slot_Handle
-#define T1_Err_Invalid_CharMap_Handle  FT_Err_Invalid_CharMap_Handle
-#define T1_Err_Invalid_Glyph_Index     FT_Err_Invalid_Glyph_Index
-
-#define T1_Err_Unimplemented_Feature   FT_Err_Unimplemented_Feature
-
-#define T1_Err_Invalid_Engine          FT_Err_Invalid_Driver_Handle
-
-  /* ------------- internal errors ------------ */
-
-#define T1_Err_Out_Of_Memory           FT_Err_Out_Of_Memory
-#define T1_Err_Unlisted_Object         FT_Err_Unlisted_Object
-
-  /* ------------ general glyph outline errors ------ */
-
-#define T1_Err_Invalid_Composite       FT_Err_Invalid_Composite
-
-#define T1_Err_Syntax_Error            FT_Err_Invalid_File_Format
-#define T1_Err_Stack_Underflow         FT_Err_Invalid_File_Format
-#define T1_Err_Stack_Overflow          FT_Err_Invalid_File_Format
-
-
-FT_END_HEADER
-
-#endif /* __T1ERRORS_H__ */
-
-
-/* END */
diff --git a/include/freetype/internal/tterrors.h b/include/freetype/internal/tterrors.h
deleted file mode 100644
index d4da576..0000000
--- a/include/freetype/internal/tterrors.h
+++ /dev/null
@@ -1,131 +0,0 @@
-/***************************************************************************/
-/*                                                                         */
-/*  tterrors.h                                                             */
-/*                                                                         */
-/*    TrueType error ID definitions (specification only).                  */
-/*                                                                         */
-/*  Copyright 1996-2000 by                                                 */
-/*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
-/*                                                                         */
-/*  This file is part of the FreeType project, and may only be used,       */
-/*  modified, and distributed under the terms of the FreeType project      */
-/*  license, LICENSE.TXT.  By continuing to use, modify, or distribute     */
-/*  this file you indicate that you have read the license and              */
-/*  understand and accept it fully.                                        */
-/*                                                                         */
-/***************************************************************************/
-
-
-#ifndef __TTERRORS_H__
-#define __TTERRORS_H__
-
-
-#include <ft2build.h>
-
-
-FT_BEGIN_HEADER
-
-
-  /*************************************************************************/
-  /*                                                                       */
-  /* 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 TT_Err_Ok                         FT_Err_Ok
-
-  /* High level API errors. */
-
-#define TT_Err_Unknown_File_Format        FT_Err_Unknown_File_Format
-#define TT_Err_Invalid_File_Format        FT_Err_Invalid_File_Format
-#define TT_Err_Invalid_Argument           FT_Err_Invalid_Argument
-#define TT_Err_Invalid_Driver_Handle      FT_Err_Invalid_Driver_Handle
-#define TT_Err_Invalid_Face_Handle        FT_Err_Invalid_Face_Handle
-#define TT_Err_Invalid_Instance_Handle    FT_Err_Invalid_Size_Handle
-#define TT_Err_Invalid_Glyph_Handle       FT_Err_Invalid_Slot_Handle
-#define TT_Err_Invalid_CharMap_Handle     FT_Err_Invalid_CharMap_Handle
-#define TT_Err_Invalid_Glyph_Index        FT_Err_Invalid_Glyph_Index
-
-#define TT_Err_Unimplemented_Feature      FT_Err_Unimplemented_Feature
-
-#define TT_Err_Invalid_Engine             FT_Err_Invalid_Driver_Handle
-
-  /* Internal errors. */
-
-#define TT_Err_Out_Of_Memory              FT_Err_Out_Of_Memory
-#define TT_Err_Unlisted_Object            FT_Err_Unlisted_Object
-
-  /* General glyph outline errors. */
-
-#define TT_Err_Too_Many_Ins               FT_Err_Too_Many_Hints
-#define TT_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 TT_Err_Invalid_Opcode             0x400
-#define TT_Err_Too_Few_Arguments          0x401
-#define TT_Err_Stack_Overflow             0x402
-#define TT_Err_Code_Overflow              0x403
-#define TT_Err_Bad_Argument               0x404
-#define TT_Err_Divide_By_Zero             0x405
-#define TT_Err_Storage_Overflow           0x406
-#define TT_Err_Cvt_Overflow               0x407
-#define TT_Err_Invalid_Reference          0x408
-#define TT_Err_Invalid_Distance           0x409
-#define TT_Err_Interpolate_Twilight       0x40A
-#define TT_Err_Debug_OpCode               0x40B
-#define TT_Err_ENDF_In_Exec_Stream        0x40C
-#define TT_Err_Out_Of_CodeRanges          0x40D
-#define TT_Err_Nested_DEFS                0x40E
-#define TT_Err_Invalid_CodeRange          0x40F
-#define TT_Err_Invalid_Displacement       0x410
-#define TT_Err_Execution_Too_Long         0x411
-#define TT_Err_Too_Many_Function_Defs     0x412
-#define TT_Err_Too_Many_Instruction_Defs  0x413
-
-  /* Other TrueType specific error codes. */
-
-#define TT_Err_Table_Missing              0x420
-#define TT_Err_Too_Many_Extensions        0x421
-#define TT_Err_Extensions_Unsupported     0x422
-#define TT_Err_Invalid_Extension_Id       0x423
-
-#define TT_Err_No_Vertical_Data           0x424
-
-#define TT_Err_Max_Profile_Missing        0x430
-#define TT_Err_Header_Table_Missing       0x431
-#define TT_Err_Horiz_Header_Missing       0x432
-#define TT_Err_Locations_Missing          0x433
-#define TT_Err_Name_Table_Missing         0x434
-#define TT_Err_CMap_Table_Missing         0x435
-#define TT_Err_Hmtx_Table_Missing         0x436
-#define TT_Err_OS2_Table_Missing          0x437
-#define TT_Err_Post_Table_Missing         0x438
-
-#define TT_Err_Invalid_Horiz_Metrics      0x440
-#define TT_Err_Invalid_CharMap_Format     0x441
-#define TT_Err_Invalid_PPem               0x442
-#define TT_Err_Invalid_Vert_Metrics       0x443
-
-#define TT_Err_Could_Not_Find_Context     0x450
-
-
-FT_END_HEADER
-
-
-#endif /* __TTERRORS_H__ */
-
-
-/* END */
diff --git a/src/autohint/aherrors.h b/src/autohint/aherrors.h
new file mode 100644
index 0000000..25a6f8b
--- /dev/null
+++ b/src/autohint/aherrors.h
@@ -0,0 +1,43 @@
+/***************************************************************************/
+/*                                                                         */
+/*  aherrors.h                                                             */
+/*                                                                         */
+/*    Autohinter error codes (specification only).                         */
+/*                                                                         */
+/*  Copyright 2001 by                                                      */
+/*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
+/*                                                                         */
+/*  This file is part of the FreeType project, and may only be used,       */
+/*  modified, and distributed under the terms of the FreeType project      */
+/*  license, LICENSE.TXT.  By continuing to use, modify, or distribute     */
+/*  this file you indicate that you have read the license and              */
+/*  understand and accept it fully.                                        */
+/*                                                                         */
+/***************************************************************************/
+
+
+  /*************************************************************************/
+  /*                                                                       */
+  /* This file is used to define the Autohinter error enumeration          */
+  /* constants.                                                            */
+  /*                                                                       */
+  /*************************************************************************/
+
+#ifndef __AHERRORS_H__
+#define __AHERRORS_H__
+
+#include FT_MODULE_ERRORS_H
+
+#undef __FTERRORS_H__
+
+#define FT_ERRORDEF( e, v, s )    AH_Err_ ## e = v + FT_Mod_Err_Autohint,
+#define FT_NOERRORDEF( e, v, s )  AH_Err_ ## e = v,
+
+#define FT_ERROR_START_LIST       enum {
+#define FT_ERROR_END_LIST         AH_Err_Max };
+
+#include FT_ERRORS_H
+
+#endif /* __AHERRORS_H__ */
+
+/* END */
diff --git a/src/autohint/ahglyph.c b/src/autohint/ahglyph.c
index 6656ba4..7df9e41 100644
--- a/src/autohint/ahglyph.c
+++ b/src/autohint/ahglyph.c
@@ -24,6 +24,7 @@
 #include "ahglyph.h"
 #include "ahangles.h"
 #include "ahglobal.h"
+#include "aherrors.h"
 
 #include <stdio.h>
 
@@ -388,7 +389,7 @@
                              FT_Face      face )
   {
     FT_Memory   memory       = outline->memory;
-    FT_Error    error        = FT_Err_Ok;
+    FT_Error    error        = AH_Err_Ok;
     FT_Outline* source       = &face->glyph->outline;
     FT_Int      num_points   = source->n_points;
     FT_Int      num_contours = source->n_contours;
@@ -399,7 +400,7 @@
     if ( !face                                          ||
          !face->size                                    ||
          face->glyph->format != ft_glyph_format_outline )
-      return FT_Err_Invalid_Argument;
+      return AH_Err_Invalid_Argument;
 
     /* first of all, reallocate the contours array if necessary */
     if ( num_contours > outline->max_contours )
@@ -1316,7 +1317,7 @@
     AH_Globals*  globals    = &face_globals->design;
     FT_Fixed     y_scale    = outline->y_scale;
 
-    FT_Bool      blue_active[ ah_blue_max ];
+    FT_Bool      blue_active[ah_blue_max];
 
 
     /* compute which blue zones are active, i.e. have their scaled */
@@ -1325,14 +1326,16 @@
       AH_Blue  blue;
       FT_Bool  check = 0;
 
+
       for ( blue = ah_blue_capital_top; blue < ah_blue_max; blue++ )
       {
         FT_Pos  ref, shoot, dist;
 
+
         ref   = globals->blue_refs[blue];
         shoot = globals->blue_shoots[blue];
         dist  = ref-shoot;
-        if (dist < 0)
+        if ( dist < 0 )
           dist = -dist;
 
         blue_active[blue] = 0;
@@ -1345,7 +1348,7 @@
       }
 
       /* return immediately if no blue zone is active */
-      if (!check)
+      if ( !check )
         return;
     }
 
diff --git a/src/autohint/ahhint.c b/src/autohint/ahhint.c
index ead32fd..5f177d1 100644
--- a/src/autohint/ahhint.c
+++ b/src/autohint/ahhint.c
@@ -23,6 +23,7 @@
 #include "ahhint.h"
 #include "ahglyph.h"
 #include "ahangles.h"
+#include "aherrors.h"
 #include FT_OUTLINE_H
 
 
@@ -1241,7 +1242,7 @@
             if ( start_point + k >= num_base_points          ||
                                l >= (FT_UInt)num_new_points  )
             {
-              error = FT_Err_Invalid_Composite;
+              error = AH_Err_Invalid_Composite;
               goto Exit;
             }
 
@@ -1279,7 +1280,7 @@
 
     default:
       /* we don't support other formats (yet?) */
-      error = FT_Err_Unimplemented_Feature;
+      error = AH_Err_Unimplemented_Feature;
     }
 
   Hint_Metrics:
diff --git a/src/autohint/rules.mk b/src/autohint/rules.mk
index c6f275b..5b8d46c 100644
--- a/src/autohint/rules.mk
+++ b/src/autohint/rules.mk
@@ -39,7 +39,8 @@ AUTO_DRV_SRC := $(AUTO_DIR_)ahangles.c  \
 #
 AUTO_DRV_H := $(AUTO_DRV_SRC:%c=%h)  \
               $(AUTO_DIR_)ahloader.h \
-              $(AUTO_DIR_)ahtypes.h
+              $(AUTO_DIR_)ahtypes.h \
+              $(AUTO_DIR_)aherrors.h
 
 
 # AUTO driver object(s)
diff --git a/src/cache/ftcchunk.c b/src/cache/ftcchunk.c
index f7bb541..788098d 100644
--- a/src/cache/ftcchunk.c
+++ b/src/cache/ftcchunk.c
@@ -23,6 +23,8 @@
 #include FT_ERRORS_H
 #include FT_INTERNAL_OBJECTS_H
 
+#include "ftcerror.h"
+
 
   /*************************************************************************/
   /*************************************************************************/
@@ -223,7 +225,7 @@
     *anode = 0;
 
     if ( glyph_index >= cset->element_max )
-      error = FT_Err_Invalid_Argument;
+      error = FTC_Err_Invalid_Argument;
     else
     {
       FT_UInt         chunk_size  = cset->element_count;
@@ -401,7 +403,7 @@
     /* check for valid `desc' delayed to FT_Lru_Lookup() */
 
     if ( !cache || !anode || !aindex )
-      return FT_Err_Invalid_Argument;
+      return FTC_Err_Invalid_Argument;
 
     *anode  = 0;
     *aindex = 0;
diff --git a/src/cache/ftcerror.h b/src/cache/ftcerror.h
new file mode 100644
index 0000000..456c249
--- /dev/null
+++ b/src/cache/ftcerror.h
@@ -0,0 +1,43 @@
+/***************************************************************************/
+/*                                                                         */
+/*  ftcerror.h                                                             */
+/*                                                                         */
+/*    Caching sub-system error codes (specification only).                 */
+/*                                                                         */
+/*  Copyright 2001 by                                                      */
+/*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
+/*                                                                         */
+/*  This file is part of the FreeType project, and may only be used,       */
+/*  modified, and distributed under the terms of the FreeType project      */
+/*  license, LICENSE.TXT.  By continuing to use, modify, or distribute     */
+/*  this file you indicate that you have read the license and              */
+/*  understand and accept it fully.                                        */
+/*                                                                         */
+/***************************************************************************/
+
+
+  /*************************************************************************/
+  /*                                                                       */
+  /* This file is used to define the caching sub-system error enumeration  */
+  /* constants.                                                            */
+  /*                                                                       */
+  /*************************************************************************/
+
+#ifndef __FTCERROR_H__
+#define __FTCERROR_H__
+
+#include FT_MODULE_ERRORS_H
+
+#undef __FTERRORS_H__
+
+#define FT_ERRORDEF( e, v, s )    FTC_Err_ ## e = v + FT_Mod_Err_Cache,
+#define FT_NOERRORDEF( e, v, s )  FTC_Err_ ## e = v,
+
+#define FT_ERROR_START_LIST       enum {
+#define FT_ERROR_END_LIST         FTC_Err_Max };
+
+#include FT_ERRORS_H
+
+#endif /* __FTCERROR_H__ */
+
+/* END */
diff --git a/src/cache/ftcglyph.c b/src/cache/ftcglyph.c
index 40633e6..9af2af9 100644
--- a/src/cache/ftcglyph.c
+++ b/src/cache/ftcglyph.c
@@ -24,6 +24,8 @@
 #include FT_INTERNAL_OBJECTS_H
 #include FT_INTERNAL_DEBUG_H
 
+#include "ftcerror.h"
+
 
   /*************************************************************************/
   /*************************************************************************/
@@ -433,7 +435,7 @@
     /* check for valid `desc' delayed to FT_Lru_Lookup() */
 
     if ( !cache || !anode )
-      return FT_Err_Invalid_Argument;
+      return FTC_Err_Invalid_Argument;
 
     *anode = 0;
     gset   = cache->last_gset;
diff --git a/src/cache/ftcimage.c b/src/cache/ftcimage.c
index 9d48bbe..1ad044f 100644
--- a/src/cache/ftcimage.c
+++ b/src/cache/ftcimage.c
@@ -21,6 +21,8 @@
 #include FT_CACHE_IMAGE_H
 #include FT_INTERNAL_MEMORY_H
 
+#include "ftcerror.h"
+
 #include <string.h>     /* memcmp() */
 #include <stdlib.h>     /* labs()   */
 
@@ -143,7 +145,7 @@
             node->ft_glyph = glyph;
         }
         else
-          error = FT_Err_Invalid_Argument;
+          error = FTC_Err_Invalid_Argument;
       }
     }
 
@@ -284,7 +286,7 @@
     /* some argument checks are delayed to FTC_Glyph_Cache_Lookup */
 
     if (!aglyph)
-      return FT_Err_Invalid_Argument;
+      return FTC_Err_Invalid_Argument;
 
     error = FTC_Glyph_Cache_Lookup( (FTC_Glyph_Cache)cache,
                                     desc, gindex, &node );
diff --git a/src/cache/ftcmanag.c b/src/cache/ftcmanag.c
index a39e7fa..dad724a 100644
--- a/src/cache/ftcmanag.c
+++ b/src/cache/ftcmanag.c
@@ -23,6 +23,8 @@
 #include FT_INTERNAL_DEBUG_H
 #include FT_LIST_H
 
+#include "ftcerror.h"
+
 
 #undef  FT_COMPONENT
 #define FT_COMPONENT  trace_cache
@@ -224,7 +226,7 @@
 
 
     if ( !library )
-      return FT_Err_Invalid_Library_Handle;
+      return FTC_Err_Invalid_Library_Handle;
 
     memory = library->memory;
 
@@ -328,7 +330,7 @@
                                                       FT_Face     *aface )
   {
     if ( !manager )
-      return FT_Err_Invalid_Cache_Handle;
+      return FTC_Err_Invalid_Cache_Handle;
 
     return  FT_Lru_Lookup( manager->faces_lru,
                            (FT_LruKey)face_id,
@@ -436,7 +438,7 @@
                                FTC_Cache_Class*  clazz,
                                FTC_Cache        *acache )
   {
-    FT_Error  error = FT_Err_Invalid_Argument;
+    FT_Error  error = FTC_Err_Invalid_Argument;
 
 
     if ( manager && clazz && acache )
@@ -459,7 +461,7 @@
       /* return an error if there are too many registered caches */
       if ( index >= FTC_MAX_CACHES )
       {
-        error = FT_Err_Too_Many_Caches;
+        error = FTC_Err_Too_Many_Caches;
         FT_ERROR(( "FTC_Manager_Register_Cache:" ));
         FT_ERROR(( " too many registered caches\n" ));
         goto Exit;
diff --git a/src/cache/ftcsbits.c b/src/cache/ftcsbits.c
index adb295b..7d22b6e 100644
--- a/src/cache/ftcsbits.c
+++ b/src/cache/ftcsbits.c
@@ -23,6 +23,8 @@
 #include FT_INTERNAL_DEBUG_H
 #include FT_ERRORS_H
 
+#include "ftcerror.h"
+
 #include <string.h>         /* memcmp() */
 
 
@@ -144,7 +146,7 @@
       {
         FT_ERROR(( "FTC_SBit_Cache: cannot load scalable glyphs in an"
                    " sbit cache, please check your arguments!\n" ));
-        error = FT_Err_Invalid_Argument;
+        error = FTC_Err_Invalid_Argument;
         goto Exit;
       }
 
@@ -378,7 +380,7 @@
 
     /* argument checks delayed to FTC_Chunk_Cache_Lookup */
     if ( !ansbit )
-      return FT_Err_Invalid_Argument;
+      return FTC_Err_Invalid_Argument;
       
     *ansbit = 0;
     error   = FTC_Chunk_Cache_Lookup( &cache->root, desc, gindex,
diff --git a/src/cache/ftlru.c b/src/cache/ftlru.c
index 783ccbe..57575ae 100644
--- a/src/cache/ftlru.c
+++ b/src/cache/ftlru.c
@@ -22,6 +22,8 @@
 #include FT_LIST_H
 #include FT_INTERNAL_OBJECTS_H
 
+#include "ftcerror.h"
+
 
   static
   void  lru_build_free_list( FT_LruNode  nodes,
@@ -50,7 +52,7 @@
 
 
     if ( !anlru )
-      return FT_Err_Invalid_Argument;
+      return FTC_Err_Invalid_Argument;
 
     *anlru = 0;
     if ( !ALLOC( lru, sizeof ( *lru ) ) )
@@ -146,7 +148,7 @@
 
 
     if ( !lru || !key || !anode )
-      return FT_Err_Invalid_Argument;
+      return FTC_Err_Invalid_Argument;
 
     node   = lru->elements.head;
     clazz  = lru->clazz;
@@ -271,7 +273,7 @@
     /* check for valid `lru' and `key' delayed to FT_Lru_Lookup_Node() */
 
     if ( !anobject )
-      return FT_Err_Invalid_Argument;
+      return FTC_Err_Invalid_Argument;
 
     *anobject = 0;
     error = FT_Lru_Lookup_Node( lru, key, &node );
diff --git a/src/cache/rules.mk b/src/cache/rules.mk
index a83416a..1e84af2 100644
--- a/src/cache/rules.mk
+++ b/src/cache/rules.mk
@@ -40,7 +40,8 @@ Cache_DRV_SRC := $(CACHE_DIR_)ftlru.c    \
 Cache_DRV_H := $(CACHE_H_DIR_)ftlru.h    \
                $(CACHE_H_DIR_)ftcmanag.h \
                $(CACHE_H_DIR_)ftcglyph.h \
-               $(CACHE_H_DIR_)ftcimage.h
+               $(CACHE_H_DIR_)ftcimage.h \
+               $(CACHE_DIR_)ftcerror.h
 
 
 # Cache driver object(s)
diff --git a/src/cff/cffdrivr.c b/src/cff/cffdrivr.c
index 6016ee1..e7648b1 100644
--- a/src/cff/cffdrivr.c
+++ b/src/cff/cffdrivr.c
@@ -22,12 +22,14 @@
 #include FT_INTERNAL_STREAM_H
 #include FT_INTERNAL_SFNT_H
 #include FT_TRUETYPE_IDS_H
-#include FT_INTERNAL_CFF_ERRORS_H
 
 #include "cffdrivr.h"
 #include "cffgload.h"
 #include "cffload.h"
 
+#include "cfferrs.h"
+
+
   /*************************************************************************/
   /*                                                                       */
   /* The macro FT_COMPONENT is used in trace mode.  It is an implicit      */
@@ -180,7 +182,7 @@
 
 
     if ( !slot )
-      return CFF_Err_Invalid_Glyph_Handle;
+      return CFF_Err_Invalid_Slot_Handle;
 
     /* check whether we want a scaled outline or bitmap */
     if ( !size )
diff --git a/src/cff/cfferrs.h b/src/cff/cfferrs.h
new file mode 100644
index 0000000..99c0c3d
--- /dev/null
+++ b/src/cff/cfferrs.h
@@ -0,0 +1,43 @@
+/***************************************************************************/
+/*                                                                         */
+/*  cfferrs.h                                                              */
+/*                                                                         */
+/*    CFF error codes (specification only).                                */
+/*                                                                         */
+/*  Copyright 2001 by                                                      */
+/*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
+/*                                                                         */
+/*  This file is part of the FreeType project, and may only be used,       */
+/*  modified, and distributed under the terms of the FreeType project      */
+/*  license, LICENSE.TXT.  By continuing to use, modify, or distribute     */
+/*  this file you indicate that you have read the license and              */
+/*  understand and accept it fully.                                        */
+/*                                                                         */
+/***************************************************************************/
+
+
+  /*************************************************************************/
+  /*                                                                       */
+  /* This file is used to define the CFF error enumeration constants.      */
+  /*                                                                       */
+  /*************************************************************************/
+
+#ifndef __CFFERRS_H__
+#define __CFFERRS_H__
+
+#include FT_MODULE_ERRORS_H
+
+#undef __FTERRORS_H__
+
+#define FT_ERRORDEF( e, v, s )    CFF_Err_ ## e = v + FT_Mod_Err_CFF,
+#define FT_NOERRORDEF( e, v, s )  CFF_Err_ ## e = v,
+
+#define FT_ERROR_START_LIST       enum {
+#define FT_ERROR_END_LIST         CFF_Err_Max };
+
+#include FT_ERRORS_H
+
+#endif /* __CFFERRS_H__ */
+
+
+/* END */
diff --git a/src/cff/cffgload.c b/src/cff/cffgload.c
index 4764e71..557cd6e 100644
--- a/src/cff/cffgload.c
+++ b/src/cff/cffgload.c
@@ -27,7 +27,7 @@
 #include "cffload.h"
 #include "cffgload.h"
 
-#include FT_INTERNAL_CFF_ERRORS_H
+#include "cfferrs.h"
 
 
   /*************************************************************************/
diff --git a/src/cff/cffload.c b/src/cff/cffload.c
index 301b2d8..e469dc7 100644
--- a/src/cff/cffload.c
+++ b/src/cff/cffload.c
@@ -21,12 +21,13 @@
 #include FT_INTERNAL_OBJECTS_H
 #include FT_INTERNAL_STREAM_H
 #include FT_INTERNAL_POSTSCRIPT_NAMES_H
-#include FT_INTERNAL_CFF_ERRORS_H
 #include FT_TRUETYPE_TAGS_H
 
 #include "cffload.h"
 #include "cffparse.h"
 
+#include "cfferrs.h"
+
 
   /*************************************************************************/
   /*                                                                       */
diff --git a/src/cff/cffobjs.c b/src/cff/cffobjs.c
index 97e8237..aa2457d 100644
--- a/src/cff/cffobjs.c
+++ b/src/cff/cffobjs.c
@@ -27,7 +27,8 @@
 #include FT_INTERNAL_POSTSCRIPT_NAMES_H
 #include "cffobjs.h"
 #include "cffload.h"
-#include FT_INTERNAL_CFF_ERRORS_H
+
+#include "cfferrs.h"
 
 #include <string.h>         /* for strlen() */
 
diff --git a/src/cff/cffobjs.h b/src/cff/cffobjs.h
index fef2b79..d8f5608 100644
--- a/src/cff/cffobjs.h
+++ b/src/cff/cffobjs.h
@@ -23,7 +23,6 @@
 #include <ft2build.h>
 #include FT_INTERNAL_OBJECTS_H
 #include FT_INTERNAL_CFF_TYPES_H
-#include FT_INTERNAL_CFF_ERRORS_H
 #include FT_INTERNAL_POSTSCRIPT_NAMES_H
 
 
diff --git a/src/cff/cffparse.c b/src/cff/cffparse.c
index 833676b..5121b23 100644
--- a/src/cff/cffparse.c
+++ b/src/cff/cffparse.c
@@ -18,9 +18,10 @@
 
 #include <ft2build.h>
 #include "cffparse.h"
-#include FT_INTERNAL_CFF_ERRORS_H
 #include FT_INTERNAL_STREAM_H
 
+#include "cfferrs.h"
+
 
   /*************************************************************************/
   /*                                                                       */
diff --git a/src/cff/rules.mk b/src/cff/rules.mk
index f87634f..73fea4d 100644
--- a/src/cff/rules.mk
+++ b/src/cff/rules.mk
@@ -33,7 +33,8 @@ CFF_DRV_SRC := $(CFF_DIR_)cffobjs.c   \
 # CFF driver headers
 #
 CFF_DRV_H := $(CFF_DRV_SRC:%.c=%.h) \
-            $(CFF_DIR_)cfftoken.h
+             $(CFF_DIR_)cfftoken.h \
+             $(CFF_DIR_)cfferrs.h
 
 
 # CFF driver object(s)
diff --git a/src/cid/ciderrs.h b/src/cid/ciderrs.h
new file mode 100644
index 0000000..25a043a
--- /dev/null
+++ b/src/cid/ciderrs.h
@@ -0,0 +1,43 @@
+/***************************************************************************/
+/*                                                                         */
+/*  ciderrs.h                                                              */
+/*                                                                         */
+/*    CID error codes (specification only).                                */
+/*                                                                         */
+/*  Copyright 2001 by                                                      */
+/*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
+/*                                                                         */
+/*  This file is part of the FreeType project, and may only be used,       */
+/*  modified, and distributed under the terms of the FreeType project      */
+/*  license, LICENSE.TXT.  By continuing to use, modify, or distribute     */
+/*  this file you indicate that you have read the license and              */
+/*  understand and accept it fully.                                        */
+/*                                                                         */
+/***************************************************************************/
+
+
+  /*************************************************************************/
+  /*                                                                       */
+  /* This file is used to define the CID error enumeration constants.      */
+  /*                                                                       */
+  /*************************************************************************/
+
+#ifndef __CIDERRS_H__
+#define __CIDERRS_H__
+
+#include FT_MODULE_ERRORS_H
+
+#undef __FTERRORS_H__
+
+#define FT_ERRORDEF( e, v, s )    CID_Err_ ## e = v + FT_Mod_Err_CID,
+#define FT_NOERRORDEF( e, v, s )  CID_Err_ ## e = v,
+
+#define FT_ERROR_START_LIST       enum {
+#define FT_ERROR_END_LIST         CID_Err_Max };
+
+#include FT_ERRORS_H
+
+#endif /* __CIDERRS_H__ */
+
+
+/* END */
diff --git a/src/cid/cidgload.c b/src/cid/cidgload.c
index 2732784..73187f0 100644
--- a/src/cid/cidgload.c
+++ b/src/cid/cidgload.c
@@ -23,6 +23,8 @@
 #include FT_INTERNAL_STREAM_H
 #include FT_OUTLINE_H
 
+#include "ciderrs.h"
+
 
   /*************************************************************************/
   /*                                                                       */
@@ -175,7 +177,7 @@
 
     *max_advance = decoder.builder.advance.x;
 
-    return T1_Err_Ok;
+    return CID_Err_Ok;
   }
 
 
diff --git a/src/cid/cidload.c b/src/cid/cidload.c
index 5e7b188..a0e937f 100644
--- a/src/cid/cidload.c
+++ b/src/cid/cidload.c
@@ -21,9 +21,11 @@
 #include FT_CONFIG_CONFIG_H
 #include FT_MULTIPLE_MASTERS_H
 #include FT_INTERNAL_TYPE1_TYPES_H
-#include FT_INTERNAL_TYPE1_ERRORS_H
+
 #include "cidload.h"
 
+#include "ciderrs.h"
+
 #include <stdio.h>
 #include <ctype.h>  /* for isspace(), isalnum() */
 
@@ -125,7 +127,7 @@
         {
           FT_ERROR(( "cid_load_keyword: invalid use of `%s'!\n",
                      keyword->ident ));
-          error = T1_Err_Syntax_Error;
+          error = CID_Err_Syntax_Error;
           goto Exit;
         }
 
@@ -170,7 +172,7 @@
     bbox->xMax = FT_RoundFix( temp[2] );
     bbox->yMax = FT_RoundFix( temp[3] );
 
-    return T1_Err_Ok;       /* this is a callback function; */
+    return CID_Err_Ok;       /* this is a callback function; */
                             /* we must return an error code */
   }
 
@@ -224,7 +226,7 @@
       offset->y  = temp[5] >> 16;
     }
 
-    return T1_Err_Ok;       /* this is a callback function; */
+    return CID_Err_Ok;       /* this is a callback function; */
                             /* we must return an error code */
   }
 
@@ -235,7 +237,7 @@
   {
     CID_Info*  cid    = &face->cid;
     FT_Memory  memory = face->root.memory;
-    FT_Error   error  = T1_Err_Ok;
+    FT_Error   error  = CID_Err_Ok;
     FT_Long    num_dicts;
 
 
@@ -271,7 +273,7 @@
   const T1_Field  cid_field_records[] =
   {
 
-#include "cidtokens.h"
+#include "cidtoken.h"
 
     T1_FIELD_CALLBACK( "FontBBox", parse_font_bbox )
     T1_FIELD_CALLBACK( "FDArray", parse_fd_array )
diff --git a/src/cid/cidobjs.c b/src/cid/cidobjs.c
index 6347fba..df5395e 100644
--- a/src/cid/cidobjs.c
+++ b/src/cid/cidobjs.c
@@ -24,6 +24,8 @@
 #include FT_INTERNAL_POSTSCRIPT_NAMES_H
 #include FT_INTERNAL_POSTSCRIPT_AUX_H
 
+#include "ciderrs.h"
+
 
   /*************************************************************************/
   /*                                                                       */
@@ -165,7 +167,7 @@
     if ( face_index != 0 )
     {
       FT_ERROR(( "CID_Init_Face: invalid face index\n" ));
-      error = T1_Err_Invalid_Argument;
+      error = CID_Err_Invalid_Argument;
       goto Exit;
     }
 
@@ -356,7 +358,7 @@
   {
     FT_UNUSED( driver );
 
-    return T1_Err_Ok;
+    return CID_Err_Ok;
   }
 
 
diff --git a/src/cid/cidobjs.h b/src/cid/cidobjs.h
index 4b4baaf..6003cf5 100644
--- a/src/cid/cidobjs.h
+++ b/src/cid/cidobjs.h
@@ -23,7 +23,6 @@
 #include <ft2build.h>
 #include FT_INTERNAL_OBJECTS_H
 #include FT_CONFIG_CONFIG_H
-#include FT_INTERNAL_TYPE1_ERRORS_H
 #include FT_INTERNAL_TYPE1_TYPES_H
 
 
diff --git a/src/cid/cidparse.c b/src/cid/cidparse.c
index a95a742..c243687 100644
--- a/src/cid/cidparse.c
+++ b/src/cid/cidparse.c
@@ -21,9 +21,11 @@
 #include FT_INTERNAL_CALC_H
 #include FT_INTERNAL_OBJECTS_H
 #include FT_INTERNAL_STREAM_H
-#include FT_INTERNAL_TYPE1_ERRORS_H
+
 #include "cidparse.h"
 
+#include "ciderrs.h"
+
 #include <string.h>     /* for strncmp() */
 
 
@@ -75,7 +77,7 @@
                   "%!PS-Adobe-3.0 Resource-CIDFont", 31 ) )
     {
       FT_TRACE2(( "[not a valid CID-keyed font]\n" ));
-      error = T1_Err_Unknown_File_Format;
+      error = CID_Err_Unknown_File_Format;
     }
 
     FORGET_Frame();
diff --git a/src/cid/cidriver.c b/src/cid/cidriver.c
index c86f0a2..566fba8 100644
--- a/src/cid/cidriver.c
+++ b/src/cid/cidriver.c
@@ -23,6 +23,8 @@
 #include FT_INTERNAL_STREAM_H
 #include FT_INTERNAL_POSTSCRIPT_NAMES_H
 
+#include "ciderrs.h"
+
 #include <string.h>         /* for strcmp() */
 
 
@@ -65,7 +67,7 @@
     if ( afm )
       CID_Get_Kerning( afm, left_glyph, right_glyph, kerning );
 
-    return T1_Err_Ok;
+    return CID_Err_Ok;
   }
 
 
diff --git a/src/cid/cidtoken.h b/src/cid/cidtoken.h
new file mode 100644
index 0000000..5a3981e
--- /dev/null
+++ b/src/cid/cidtoken.h
@@ -0,0 +1,96 @@
+/***************************************************************************/
+/*                                                                         */
+/*  cidtoken.h                                                             */
+/*                                                                         */
+/*    CID token definitions (specification only).                          */
+/*                                                                         */
+/*  Copyright 1996-2000 by                                                 */
+/*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
+/*                                                                         */
+/*  This file is part of the FreeType project, and may only be used,       */
+/*  modified, and distributed under the terms of the FreeType project      */
+/*  license, LICENSE.TXT.  By continuing to use, modify, or distribute     */
+/*  this file you indicate that you have read the license and              */
+/*  understand and accept it fully.                                        */
+/*                                                                         */
+/***************************************************************************/
+
+
+#undef  FT_STRUCTURE
+#define FT_STRUCTURE  CID_Info
+#undef  T1CODE
+#define T1CODE        t1_field_cid_info
+
+  T1_FIELD_STRING( "CIDFontName", cid_font_name )
+  T1_FIELD_NUM   ( "CIDFontVersion", cid_version )
+  T1_FIELD_NUM   ( "CIDFontType", cid_font_type )
+  T1_FIELD_STRING( "Registry", registry )
+  T1_FIELD_STRING( "Ordering", ordering )
+  T1_FIELD_NUM   ( "Supplement", supplement )
+  T1_FIELD_NUM   ( "UIDBase", uid_base )
+  T1_FIELD_NUM   ( "CIDMapOffset", cidmap_offset )
+  T1_FIELD_NUM   ( "FDBytes", fd_bytes )
+  T1_FIELD_NUM   ( "GDBytes", gd_bytes )
+  T1_FIELD_NUM   ( "CIDCount", cid_count )
+
+
+#undef  FT_STRUCTURE
+#define FT_STRUCTURE  T1_FontInfo
+#undef  T1CODE
+#define T1CODE        t1_field_font_info
+
+  T1_FIELD_STRING( "version", version )
+  T1_FIELD_STRING( "Notice", notice )
+  T1_FIELD_STRING( "FullName", full_name )
+  T1_FIELD_STRING( "FamilyName", family_name )
+  T1_FIELD_STRING( "Weight", weight )
+  T1_FIELD_FIXED ( "ItalicAngle", italic_angle )
+  T1_FIELD_BOOL  ( "isFixedPitch", is_fixed_pitch )
+  T1_FIELD_NUM   ( "UnderlinePosition", underline_position )
+  T1_FIELD_NUM   ( "UnderlineThickness", underline_thickness )
+
+
+#undef  FT_STRUCTURE
+#define FT_STRUCTURE  CID_FontDict
+#undef  T1CODE
+#define T1CODE        t1_field_font_dict
+
+  T1_FIELD_NUM  ( "PaintType", paint_type )
+  T1_FIELD_NUM  ( "FontType", font_type )
+  T1_FIELD_NUM  ( "SubrMapOffset", subrmap_offset )
+  T1_FIELD_NUM  ( "SDBytes", sd_bytes )
+  T1_FIELD_NUM  ( "SubrCount", num_subrs )
+  T1_FIELD_NUM  ( "lenBuildCharArray", len_buildchar )
+  T1_FIELD_FIXED( "ForceBoldThreshold", forcebold_threshold )
+  T1_FIELD_FIXED( "ExpansionFactor", expansion_factor )
+  T1_FIELD_NUM  ( "StrokeWidth", stroke_width )
+
+
+#undef  FT_STRUCTURE
+#define FT_STRUCTURE  T1_Private
+#undef  T1CODE
+#define T1CODE        t1_field_private
+
+  T1_FIELD_NUM       ( "UniqueID", unique_id )
+  T1_FIELD_NUM       ( "lenIV", lenIV )
+  T1_FIELD_NUM       ( "LanguageGroup", language_group )
+  T1_FIELD_NUM       ( "password", password )
+
+  T1_FIELD_FIXED     ( "BlueScale", blue_scale )
+  T1_FIELD_NUM       ( "BlueShift", blue_shift )
+  T1_FIELD_NUM       ( "BlueFuzz",  blue_fuzz )
+
+  T1_FIELD_NUM_TABLE ( "BlueValues", blue_values, 14 )
+  T1_FIELD_NUM_TABLE ( "OtherBlues", other_blues, 10 )
+  T1_FIELD_NUM_TABLE ( "FamilyBlues", family_blues, 14 )
+  T1_FIELD_NUM_TABLE ( "FamilyOtherBlues", family_other_blues, 10 )
+
+  T1_FIELD_NUM_TABLE2( "StdHW", standard_width,  1 )
+  T1_FIELD_NUM_TABLE2( "StdVW", standard_height, 1 )
+  T1_FIELD_NUM_TABLE2( "MinFeature", min_feature, 2 )
+
+  T1_FIELD_NUM_TABLE ( "StemSnapH", snap_widths, 12 )
+  T1_FIELD_NUM_TABLE ( "StemSnapV", snap_heights, 12 )
+
+
+/* END */
diff --git a/src/cid/cidtokens.h b/src/cid/cidtokens.h
deleted file mode 100644
index 81f9f36..0000000
--- a/src/cid/cidtokens.h
+++ /dev/null
@@ -1,96 +0,0 @@
-/***************************************************************************/
-/*                                                                         */
-/*  cidtokens.h                                                            */
-/*                                                                         */
-/*    CID token definitions (specification only).                          */
-/*                                                                         */
-/*  Copyright 1996-2000 by                                                 */
-/*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
-/*                                                                         */
-/*  This file is part of the FreeType project, and may only be used,       */
-/*  modified, and distributed under the terms of the FreeType project      */
-/*  license, LICENSE.TXT.  By continuing to use, modify, or distribute     */
-/*  this file you indicate that you have read the license and              */
-/*  understand and accept it fully.                                        */
-/*                                                                         */
-/***************************************************************************/
-
-
-#undef  FT_STRUCTURE
-#define FT_STRUCTURE  CID_Info
-#undef  T1CODE
-#define T1CODE        t1_field_cid_info
-
-  T1_FIELD_STRING( "CIDFontName", cid_font_name )
-  T1_FIELD_NUM   ( "CIDFontVersion", cid_version )
-  T1_FIELD_NUM   ( "CIDFontType", cid_font_type )
-  T1_FIELD_STRING( "Registry", registry )
-  T1_FIELD_STRING( "Ordering", ordering )
-  T1_FIELD_NUM   ( "Supplement", supplement )
-  T1_FIELD_NUM   ( "UIDBase", uid_base )
-  T1_FIELD_NUM   ( "CIDMapOffset", cidmap_offset )
-  T1_FIELD_NUM   ( "FDBytes", fd_bytes )
-  T1_FIELD_NUM   ( "GDBytes", gd_bytes )
-  T1_FIELD_NUM   ( "CIDCount", cid_count )
-
-
-#undef  FT_STRUCTURE
-#define FT_STRUCTURE  T1_FontInfo
-#undef  T1CODE
-#define T1CODE        t1_field_font_info
-
-  T1_FIELD_STRING( "version", version )
-  T1_FIELD_STRING( "Notice", notice )
-  T1_FIELD_STRING( "FullName", full_name )
-  T1_FIELD_STRING( "FamilyName", family_name )
-  T1_FIELD_STRING( "Weight", weight )
-  T1_FIELD_FIXED ( "ItalicAngle", italic_angle )
-  T1_FIELD_BOOL  ( "isFixedPitch", is_fixed_pitch )
-  T1_FIELD_NUM   ( "UnderlinePosition", underline_position )
-  T1_FIELD_NUM   ( "UnderlineThickness", underline_thickness )
-
-
-#undef  FT_STRUCTURE
-#define FT_STRUCTURE  CID_FontDict
-#undef  T1CODE
-#define T1CODE        t1_field_font_dict
-
-  T1_FIELD_NUM  ( "PaintType", paint_type )
-  T1_FIELD_NUM  ( "FontType", font_type )
-  T1_FIELD_NUM  ( "SubrMapOffset", subrmap_offset )
-  T1_FIELD_NUM  ( "SDBytes", sd_bytes )
-  T1_FIELD_NUM  ( "SubrCount", num_subrs )
-  T1_FIELD_NUM  ( "lenBuildCharArray", len_buildchar )
-  T1_FIELD_FIXED( "ForceBoldThreshold", forcebold_threshold )
-  T1_FIELD_FIXED( "ExpansionFactor", expansion_factor )
-  T1_FIELD_NUM  ( "StrokeWidth", stroke_width )
-
-
-#undef  FT_STRUCTURE
-#define FT_STRUCTURE  T1_Private
-#undef  T1CODE
-#define T1CODE        t1_field_private
-
-  T1_FIELD_NUM       ( "UniqueID", unique_id )
-  T1_FIELD_NUM       ( "lenIV", lenIV )
-  T1_FIELD_NUM       ( "LanguageGroup", language_group )
-  T1_FIELD_NUM       ( "password", password )
-
-  T1_FIELD_FIXED     ( "BlueScale", blue_scale )
-  T1_FIELD_NUM       ( "BlueShift", blue_shift )
-  T1_FIELD_NUM       ( "BlueFuzz",  blue_fuzz )
-
-  T1_FIELD_NUM_TABLE ( "BlueValues", blue_values, 14 )
-  T1_FIELD_NUM_TABLE ( "OtherBlues", other_blues, 10 )
-  T1_FIELD_NUM_TABLE ( "FamilyBlues", family_blues, 14 )
-  T1_FIELD_NUM_TABLE ( "FamilyOtherBlues", family_other_blues, 10 )
-
-  T1_FIELD_NUM_TABLE2( "StdHW", standard_width,  1 )
-  T1_FIELD_NUM_TABLE2( "StdVW", standard_height, 1 )
-  T1_FIELD_NUM_TABLE2( "MinFeature", min_feature, 2 )
-
-  T1_FIELD_NUM_TABLE ( "StemSnapH", snap_widths, 12 )
-  T1_FIELD_NUM_TABLE ( "StemSnapV", snap_heights, 12 )
-
-
-/* END */
diff --git a/src/cid/rules.mk b/src/cid/rules.mk
index d7ab026..7585afa 100644
--- a/src/cid/rules.mk
+++ b/src/cid/rules.mk
@@ -33,7 +33,8 @@ CID_DRV_SRC := $(CID_DIR_)cidparse.c \
 # CID driver headers
 #
 CID_DRV_H := $(CID_DRV_SRC:%.c=%.h) \
-             $(CID_DIR_)cidtokens.h
+             $(CID_DIR_)cidtoken.h  \
+             $(CID_DIR_)ciderrs.h
 
 
 # CID driver object(s)
diff --git a/src/pcf/pcfdriver.c b/src/pcf/pcfdriver.c
index a3c4c93..7fac5a2 100644
--- a/src/pcf/pcfdriver.c
+++ b/src/pcf/pcfdriver.c
@@ -27,7 +27,6 @@ THE SOFTWARE.
 
 #include <ft2build.h>
 
-#include FT_ERRORS_H
 #include FT_INTERNAL_DEBUG_H
 #include FT_INTERNAL_STREAM_H
 #include FT_INTERNAL_OBJECTS_H
@@ -36,6 +35,8 @@ THE SOFTWARE.
 #include "pcfdriver.h"
 #include "pcfutil.h"
 
+#include "pcferror.h"
+
 
   /*************************************************************************/
   /*                                                                       */
@@ -68,7 +69,7 @@ THE SOFTWARE.
 
     FT_TRACE4(( "DONE_FACE!!!\n" ));
 
-    return FT_Err_Ok;
+    return PCF_Err_Ok;
   }
 
 
@@ -79,7 +80,7 @@ THE SOFTWARE.
                            FT_Int         num_params,
                            FT_Parameter*  params )
   {
-    FT_Error  error = FT_Err_Ok;
+    FT_Error  error = PCF_Err_Ok;
   
     FT_UNUSED( num_params );
     FT_UNUSED( params );
@@ -90,13 +91,13 @@ THE SOFTWARE.
     if ( error )
       goto Fail;
 
-    return FT_Err_Ok;
+    return PCF_Err_Ok;
 
   Fail: 
     FT_TRACE2(( "[not a valid PCF file]\n" ));
     PCF_Done_Face( face );
 
-    return FT_Err_Unknown_File_Format; /* error */
+    return PCF_Err_Unknown_File_Format; /* error */
   }
 
 
@@ -119,12 +120,12 @@ THE SOFTWARE.
       size->metrics.height    = size->metrics.ascender -
                                 size->metrics.descender;
       
-      return FT_Err_Ok;
+      return PCF_Err_Ok;
     }
     else
     {
       FT_TRACE4(( "size WRONG\n" ));
-      return FT_Err_Invalid_Pixel_Size;
+      return PCF_Err_Invalid_Pixel_Size;
     }
   }
 
@@ -136,7 +137,7 @@ THE SOFTWARE.
                             FT_Int        load_flags )
   { 
     PCF_Face    face   = (PCF_Face)FT_SIZE_FACE( size );
-    FT_Error    error  = FT_Err_Ok;
+    FT_Error    error  = PCF_Err_Ok;
     FT_Memory   memory = FT_FACE(face)->memory;
     FT_Bitmap*  bitmap = &slot->bitmap;
     PCF_Metric  metric;
@@ -151,7 +152,7 @@ THE SOFTWARE.
 
     if ( !face )
     {
-      error = FT_Err_Invalid_Argument;
+      error = PCF_Err_Invalid_Argument;
       goto Exit;
     }
 
@@ -186,7 +187,7 @@ THE SOFTWARE.
       break;
 
     default:
-      return FT_Err_Invalid_File_Format;
+      return PCF_Err_Invalid_File_Format;
     }
 
     /* XXX: to do: are there cases that need repadding the bitmap? */
diff --git a/src/pcf/pcferror.h b/src/pcf/pcferror.h
new file mode 100644
index 0000000..c01bcab
--- /dev/null
+++ b/src/pcf/pcferror.h
@@ -0,0 +1,43 @@
+/***************************************************************************/
+/*                                                                         */
+/*  pcferror.h                                                             */
+/*                                                                         */
+/*    PCF error codes (specification only).                                */
+/*                                                                         */
+/*  Copyright 2001 by                                                      */
+/*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
+/*                                                                         */
+/*  This file is part of the FreeType project, and may only be used,       */
+/*  modified, and distributed under the terms of the FreeType project      */
+/*  license, LICENSE.TXT.  By continuing to use, modify, or distribute     */
+/*  this file you indicate that you have read the license and              */
+/*  understand and accept it fully.                                        */
+/*                                                                         */
+/***************************************************************************/
+
+
+  /*************************************************************************/
+  /*                                                                       */
+  /* This file is used to define the PCF error enumeration constants.      */
+  /*                                                                       */
+  /*************************************************************************/
+
+#ifndef __PCFERROR_H__
+#define __PCFERROR_H__
+
+#include FT_MODULE_ERRORS_H
+
+#undef __FTERRORS_H__
+
+#define FT_ERRORDEF( e, v, s )    PCF_Err_ ## e = v + FT_Mod_Err_PCF,
+#define FT_NOERRORDEF( e, v, s )  PCF_Err_ ## e = v,
+
+#define FT_ERROR_START_LIST       enum {
+#define FT_ERROR_END_LIST         PCF_Err_Max };
+
+#include FT_ERRORS_H
+
+#endif /* __PCFERROR_H__ */
+
+
+/* END */
diff --git a/src/pcf/pcfread.c b/src/pcf/pcfread.c
index ca38ca7..b261515 100644
--- a/src/pcf/pcfread.c
+++ b/src/pcf/pcfread.c
@@ -27,7 +27,6 @@ THE SOFTWARE.
 
 #include <ft2build.h>
 
-#include FT_ERRORS_H
 #include FT_INTERNAL_DEBUG_H
 #include FT_INTERNAL_STREAM_H
 #include FT_INTERNAL_OBJECTS_H
@@ -35,6 +34,8 @@ THE SOFTWARE.
 #include "pcf.h"
 #include "pcfdriver.h"
 
+#include "pcferror.h"
+
 #include <string.h>     /* strlen(), strcpy() */
 
   /*************************************************************************/
@@ -98,13 +99,13 @@ THE SOFTWARE.
 
     if ( FILE_Seek ( 0 )                   ||
          READ_Fields ( pcf_toc_header, toc ) )
-      return FT_Err_Cannot_Open_Resource;
+      return PCF_Err_Cannot_Open_Resource;
   
     if ( toc->version != PCF_FILE_VERSION )
-      return FT_Err_Invalid_File_Format;
+      return PCF_Err_Invalid_File_Format;
 
     if ( ALLOC( face->toc.tables, toc->count * sizeof ( PCF_TableRec ) ) )
-      return FT_Err_Out_Of_Memory;
+      return PCF_Err_Out_Of_Memory;
 
     tables = face->toc.tables;
     for ( i = 0; i < toc->count; i++ )
@@ -139,7 +140,7 @@ THE SOFTWARE.
 
 #endif
 
-    return FT_Err_Ok;
+    return PCF_Err_Ok;
 
   Exit:
     FREE( face->toc.tables );
@@ -202,13 +203,13 @@ THE SOFTWARE.
                               const FT_Frame_Field*  header, 
                               PCF_Metric             metric )
   {
-    FT_Error  error = FT_Err_Ok;
+    FT_Error  error = PCF_Err_Ok;
   
 
     if ( READ_Fields( header, metric ) )
       return error;
   
-    return FT_Err_Ok;
+    return PCF_Err_Ok;
   }
 
 
@@ -217,7 +218,7 @@ THE SOFTWARE.
                                          PCF_Metric  metric )
   {
     PCF_Compressed_MetricRec  compr_metric;
-    FT_Error                  error = FT_Err_Ok;
+    FT_Error                  error = PCF_Err_Ok;
   
 
     if ( READ_Fields( pcf_compressed_metric_header, &compr_metric ) )
@@ -230,7 +231,7 @@ THE SOFTWARE.
     metric->descent          = (FT_Short)compr_metric.descent - 0x80;
     metric->attributes       = 0;
   
-    return FT_Err_Ok;
+    return PCF_Err_Ok;
   }
 
 
@@ -239,7 +240,7 @@ THE SOFTWARE.
                             FT_ULong    format,
                             PCF_Metric  metric )
   {
-    FT_Error error = FT_Err_Ok;
+    FT_Error error = PCF_Err_Ok;
 
 
     if ( PCF_FORMAT_MATCH( format, PCF_DEFAULT_FORMAT ) )
@@ -272,15 +273,15 @@ THE SOFTWARE.
       if ( tables[i].type == type )
       {
         if ( stream->pos > tables[i].offset )
-          return FT_Err_Invalid_Stream_Skip;
+          return PCF_Err_Invalid_Stream_Skip;
         if ( FILE_Skip( tables[i].offset - stream->pos ) )
-          return FT_Err_Invalid_Stream_Skip;
+          return PCF_Err_Invalid_Stream_Skip;
         *sizep   = tables[i].size;  /* unused - to be removed */
         *formatp = tables[i].format;
-        return FT_Err_Ok;
+        return PCF_Err_Ok;
       }
 
-    return FT_Err_Invalid_File_Format;
+    return PCF_Err_Invalid_File_Format;
   }
 
 
@@ -466,7 +467,7 @@ THE SOFTWARE.
     FREE( props );
     FREE( strings );
   
-    return FT_Err_Ok;
+    return PCF_Err_Ok;
  
   Bail:
     FREE( props );
@@ -480,7 +481,7 @@ THE SOFTWARE.
   FT_Error  pcf_get_metrics( FT_Stream  stream,
                              PCF_Face   face )
   { 
-    FT_Error    error    = FT_Err_Ok;
+    FT_Error    error    = PCF_Err_Ok;
     FT_Memory   memory   = FT_FACE(face)->memory;
     FT_ULong    format   = 0;
     FT_ULong    size     = 0;
@@ -502,7 +503,7 @@ THE SOFTWARE.
 
     if ( !PCF_FORMAT_MATCH( format, PCF_DEFAULT_FORMAT )   &&
          !PCF_FORMAT_MATCH( format, PCF_COMPRESSED_METRICS ) )
-      return FT_Err_Invalid_File_Format;
+      return PCF_Err_Invalid_File_Format;
 
     if ( PCF_FORMAT_MATCH( format, PCF_DEFAULT_FORMAT ) )
     {
@@ -519,12 +520,12 @@ THE SOFTWARE.
         (void)READ_UShortLE( nmetrics );
     }
     if ( error || nmetrics == -1 )
-      return FT_Err_Invalid_File_Format;
+      return PCF_Err_Invalid_File_Format;
   
     face->nmetrics = nmetrics;
 
     if ( ALLOC( face->metrics, nmetrics * sizeof ( PCF_MetricRec ) ) )
-      return FT_Err_Out_Of_Memory;
+      return PCF_Err_Out_Of_Memory;
 
     metrics = face->metrics;
     for ( i = 0; i < nmetrics; i++ )
@@ -557,7 +558,7 @@ THE SOFTWARE.
   FT_Error  pcf_get_bitmaps( FT_Stream  stream,
                              PCF_Face   face )
   {
-    FT_Error   error  = FT_Err_Ok;
+    FT_Error   error  = PCF_Err_Ok;
     FT_Memory  memory = FT_FACE(face)->memory;
     FT_Long*   offsets;
     FT_Long    bitmapSizes[GLYPHPADOPTIONS];
@@ -580,7 +581,7 @@ THE SOFTWARE.
       return error;
     format = GET_ULongLE();
     if ( !PCF_FORMAT_MATCH( format, PCF_DEFAULT_FORMAT ) )
-      return FT_Err_Invalid_File_Format;
+      return PCF_Err_Invalid_File_Format;
   
     if ( PCF_BYTE_ORDER( format ) == MSBFirst )
       nbitmaps  = GET_ULong();
@@ -588,7 +589,7 @@ THE SOFTWARE.
       nbitmaps  = GET_ULongLE();
     FT_Forget_Frame( stream );
     if ( nbitmaps != face->nmetrics )
-      return FT_Err_Invalid_File_Format;
+      return PCF_Err_Invalid_File_Format;
 
     if ( ALLOC( offsets, nbitmaps * sizeof ( FT_ULong ) ) )
       return error;
@@ -647,7 +648,7 @@ THE SOFTWARE.
   FT_Error  pcf_get_encodings( FT_Stream  stream,
                                PCF_Face   face )
   {
-    FT_Error      error   = FT_Err_Ok;
+    FT_Error      error   = PCF_Err_Ok;
     FT_Memory     memory  = FT_FACE(face)->memory;
     FT_ULong      format, size;
     int           firstCol, lastCol;
@@ -671,7 +672,7 @@ THE SOFTWARE.
       return error;
     format = GET_ULongLE();
     if ( !PCF_FORMAT_MATCH( format, PCF_DEFAULT_FORMAT ) )
-      return FT_Err_Invalid_File_Format;
+      return PCF_Err_Invalid_File_Format;
   
     if ( PCF_BYTE_ORDER( format ) == MSBFirst )
     {
@@ -698,7 +699,7 @@ THE SOFTWARE.
     nencoding = ( lastCol - firstCol + 1 ) * ( lastRow - firstRow + 1 );
 
     if ( ALLOC( tmpEncoding, nencoding * sizeof ( PCF_EncodingRec ) ) )
-      return FT_Err_Out_Of_Memory;
+      return PCF_Err_Out_Of_Memory;
   
     error = FT_Access_Frame( stream, 2 * nencoding );
     if ( error )
@@ -799,7 +800,7 @@ THE SOFTWARE.
                            FT_ULong   type )
   {
     FT_ULong   format, size;
-    FT_Error   error = FT_Err_Ok;
+    FT_Error   error = PCF_Err_Ok;
     PCF_Accel  accel = &face->accel;
 
 
@@ -860,7 +861,7 @@ THE SOFTWARE.
   FT_Error  pcf_load_font( FT_Stream  stream,
                            PCF_Face   face )
   {
-    FT_Error   error  = FT_Err_Ok;
+    FT_Error   error  = PCF_Err_Ok;
     FT_Memory  memory = FT_FACE(face)->memory;
     FT_Bool    hasBDFAccelerators;
 
@@ -1033,7 +1034,7 @@ THE SOFTWARE.
               face->charmap.face        = root;
               face->charmap_handle
 
-              return FT_Err_Ok;
+              return PCF_Err_Ok;
             }
 #endif
           }
@@ -1047,11 +1048,11 @@ THE SOFTWARE.
       face->charmap_handle      = &face->charmap;
       root->charmap             = face->charmap_handle;
     }  
-    return FT_Err_Ok;
+    return PCF_Err_Ok;
 
   Bail:
     PCF_Done_Face( face );
-    return FT_Err_Invalid_File_Format;
+    return PCF_Err_Invalid_File_Format;
   }
 
 
diff --git a/src/pcf/rules.mk b/src/pcf/rules.mk
index 67a0dce..3bd1a25 100644
--- a/src/pcf/rules.mk
+++ b/src/pcf/rules.mk
@@ -44,7 +44,8 @@ PCF_DRV_SRC := $(PCF_DIR_)pcfread.c   \
 #
 PCF_DRV_H := $(PCF_DIR_)pcf.h       \
              $(PCF_DIR_)pcfdriver.h \
-             $(PCF_DIR_)pcfutil.h
+             $(PCF_DIR_)pcfutil.h   \
+             $(PCF_DIR_)pcferror.h
 
 # pcf driver object(s)
 #
diff --git a/src/psaux/psauxerr.h b/src/psaux/psauxerr.h
new file mode 100644
index 0000000..720c28c
--- /dev/null
+++ b/src/psaux/psauxerr.h
@@ -0,0 +1,44 @@
+/***************************************************************************/
+/*                                                                         */
+/*  psauxerr.h                                                             */
+/*                                                                         */
+/*    PS auxiliary module error codes (specification only).                */
+/*                                                                         */
+/*  Copyright 2001 by                                                      */
+/*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
+/*                                                                         */
+/*  This file is part of the FreeType project, and may only be used,       */
+/*  modified, and distributed under the terms of the FreeType project      */
+/*  license, LICENSE.TXT.  By continuing to use, modify, or distribute     */
+/*  this file you indicate that you have read the license and              */
+/*  understand and accept it fully.                                        */
+/*                                                                         */
+/***************************************************************************/
+
+
+  /*************************************************************************/
+  /*                                                                       */
+  /* This file is used to define the PS auxiliary module error enumeration */
+  /* constants.                                                            */
+  /*                                                                       */
+  /*************************************************************************/
+
+#ifndef __PSAUXERR_H__
+#define __PSAUXERR_H__
+
+#include FT_MODULE_ERRORS_H
+
+#undef __FTERRORS_H__
+
+#define FT_ERRORDEF( e, v, s )    PSaux_Err_ ## e = v + FT_Mod_Err_PSaux,
+#define FT_NOERRORDEF( e, v, s )  PSaux_Err_ ## e = v,
+
+#define FT_ERROR_START_LIST       enum {
+#define FT_ERROR_END_LIST         PSaux_Err_Max };
+
+#include FT_ERRORS_H
+
+#endif /* __PSAUXERR_H__ */
+
+
+/* END */
diff --git a/src/psaux/psobjs.c b/src/psaux/psobjs.c
index 4d98288..a2c6688 100644
--- a/src/psaux/psobjs.c
+++ b/src/psaux/psobjs.c
@@ -18,11 +18,12 @@
 
 #include <ft2build.h>
 #include FT_INTERNAL_POSTSCRIPT_AUX_H
-#include FT_INTERNAL_TYPE1_ERRORS_H
 #include FT_INTERNAL_DEBUG_H
-#include FT_ERRORS_H
+
 #include "psobjs.h"
 
+#include "psauxerr.h"
+
 
   /*************************************************************************/
   /*************************************************************************/
@@ -121,7 +122,7 @@
 
     table->capacity = new_size;
 
-    return T1_Err_Ok;
+    return PSaux_Err_Ok;
   }
 
 
@@ -156,7 +157,7 @@
     if ( index < 0 || index > table->max_elems )
     {
       FT_ERROR(( "PS_Table_Add: invalid index\n" ));
-      return T1_Err_Invalid_Argument;
+      return PSaux_Err_Invalid_Argument;
     }
 
     /* grow the base block if needed */
@@ -180,7 +181,7 @@
     MEM_Copy( table->block + table->cursor, object, length );
 
     table->cursor += length;
-    return T1_Err_Ok;
+    return PSaux_Err_Ok;
   }
 
 
@@ -878,13 +879,13 @@
     FT_UNUSED( pflags );
 #endif
 
-    error = T1_Err_Ok;
+    error = PSaux_Err_Ok;
 
   Exit:
     return error;
 
   Fail:
-    error = T1_Err_Invalid_File_Format;
+    error = PSaux_Err_Invalid_File_Format;
     goto Exit;
   }
 
@@ -950,7 +951,7 @@
     return error;
 
   Fail:
-    error = T1_Err_Invalid_File_Format;
+    error = PSaux_Err_Invalid_File_Format;
     goto Exit;
   }
 
@@ -1191,7 +1192,7 @@
     if ( !builder->load_points )
     {
       outline->n_contours++;
-      return T1_Err_Ok;
+      return PSaux_Err_Ok;
     }
 
     error = FT_GlyphLoader_Check_Points( builder->loader, 0, 1 );
diff --git a/src/psaux/rules.mk b/src/psaux/rules.mk
index dd5c8a6..671b14d 100644
--- a/src/psaux/rules.mk
+++ b/src/psaux/rules.mk
@@ -32,7 +32,8 @@ PSAUX_DRV_SRC := $(PSAUX_DIR_)psobjs.c   \
 
 # PSAUX driver headers
 #
-PSAUX_DRV_H := $(PSAUX_DRV_SRC:%c=%h)
+PSAUX_DRV_H := $(PSAUX_DRV_SRC:%c=%h)  \
+               $(PSAUX_DIR_)psauxerr.h
 
 
 # PSAUX driver object(s)
diff --git a/src/psaux/t1decode.c b/src/psaux/t1decode.c
index a700e37..04f1654 100644
--- a/src/psaux/t1decode.c
+++ b/src/psaux/t1decode.c
@@ -18,11 +18,13 @@
 
 #include <ft2build.h>
 #include FT_INTERNAL_DEBUG_H
-#include FT_INTERNAL_TYPE1_ERRORS_H
 #include FT_OUTLINE_H
+
 #include "t1decode.h"
 #include "psobjs.h"
 
+#include "psauxerr.h"
+
 
   /*************************************************************************/
   /*                                                                       */
@@ -193,7 +195,7 @@
     {
       FT_ERROR(( "t1operator_seac:" ));
       FT_ERROR(( " glyph names table not available in this font!\n" ));
-      return T1_Err_Syntax_Error;
+      return PSaux_Err_Syntax_Error;
     }
 
     bchar_index = t1_lookup_glyph_by_stdcharcode( decoder, bchar );
@@ -203,7 +205,7 @@
     {
       FT_ERROR(( "t1operator_seac:" ));
       FT_ERROR(( " invalid seac character code arguments\n" ));
-      return T1_Err_Syntax_Error;
+      return PSaux_Err_Syntax_Error;
     }
 
     /* if we are trying to load a composite glyph, do not load the */
@@ -344,7 +346,7 @@
     limit = zone->limit  = charstring_base + charstring_len;
     ip    = zone->cursor = zone->base;
 
-    error   = T1_Err_Ok;
+    error   = PSaux_Err_Ok;
     outline = builder->current;
 
     x = builder->pos_x;
@@ -713,7 +715,7 @@
 
           /* return now! */
           FT_TRACE4(( "\n\n" ));
-          return T1_Err_Ok;
+          return PSaux_Err_Ok;
 
         case op_hsbw:
           FT_TRACE4(( " hsbw" ));
@@ -729,7 +731,7 @@
           /* the glyph's metrics (lsb + advance width), not load the   */
           /* rest of it; so exit immediately                           */
           if ( builder->metrics_only )
-            return T1_Err_Ok;
+            return PSaux_Err_Ok;
 
           break;
 
@@ -753,7 +755,7 @@
           /* the glyph's metrics (lsb + advance width), not load the   */
           /* rest of it; so exit immediately                           */
           if ( builder->metrics_only )
-            return T1_Err_Ok;
+            return PSaux_Err_Ok;
 
           break;
 
@@ -1014,10 +1016,10 @@
     return error;
 
   Syntax_Error:
-    return T1_Err_Syntax_Error;
+    return PSaux_Err_Syntax_Error;
 
   Stack_Underflow:
-    return T1_Err_Stack_Underflow;
+    return PSaux_Err_Stack_Underflow;
 
   Memory_Error:
     return builder->error;
@@ -1054,7 +1056,7 @@
       {
         FT_ERROR(( "T1_Decoder_Init: " ));
         FT_ERROR(( "the `psnames' module is not available\n" ));
-        return T1_Err_Unimplemented_Feature;
+        return PSaux_Err_Unimplemented_Feature;
       }
 
       decoder->psnames = psnames;
diff --git a/src/psnames/psmodule.c b/src/psnames/psmodule.c
index 389e1a0..f5c5437 100644
--- a/src/psnames/psmodule.c
+++ b/src/psnames/psmodule.c
@@ -19,9 +19,12 @@
 #include <ft2build.h>
 #include FT_INTERNAL_POSTSCRIPT_NAMES_H
 #include FT_INTERNAL_OBJECTS_H
+
 #include "psmodule.h"
 #include "pstables.h"
 
+#include "psnamerr.h"
+
 #include <stdlib.h>     /* for qsort()             */
 #include <string.h>     /* for strcmp(), strncpy() */
 
@@ -192,7 +195,7 @@
       {
         FREE( table->maps );
         if ( !error )
-          error = FT_Err_Invalid_Argument;  /* no unicode chars here! */
+          error = PSnames_Err_Invalid_Argument;  /* no unicode chars here! */
       }
       else
         /* sort the table in increasing order of unicode values */
diff --git a/src/psnames/psnamerr.h b/src/psnames/psnamerr.h
new file mode 100644
index 0000000..b95a33e
--- /dev/null
+++ b/src/psnames/psnamerr.h
@@ -0,0 +1,44 @@
+/***************************************************************************/
+/*                                                                         */
+/*  psnamerr.h                                                             */
+/*                                                                         */
+/*    PS names module error codes (specification only).                    */
+/*                                                                         */
+/*  Copyright 2001 by                                                      */
+/*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
+/*                                                                         */
+/*  This file is part of the FreeType project, and may only be used,       */
+/*  modified, and distributed under the terms of the FreeType project      */
+/*  license, LICENSE.TXT.  By continuing to use, modify, or distribute     */
+/*  this file you indicate that you have read the license and              */
+/*  understand and accept it fully.                                        */
+/*                                                                         */
+/***************************************************************************/
+
+
+  /*************************************************************************/
+  /*                                                                       */
+  /* This file is used to define the PS names module error enumeration     */
+  /* constants.                                                            */
+  /*                                                                       */
+  /*************************************************************************/
+
+#ifndef __PSNAMERR_H__
+#define __PSNAMERR_H__
+
+#include FT_MODULE_ERRORS_H
+
+#undef __FTERRORS_H__
+
+#define FT_ERRORDEF( e, v, s )    PSnames_Err_ ## e = v + FT_Mod_Err_PSnames,
+#define FT_NOERRORDEF( e, v, s )  PSnames_Err_ ## e = v,
+
+#define FT_ERROR_START_LIST       enum {
+#define FT_ERROR_END_LIST         PSnames_Err_Max };
+
+#include FT_ERRORS_H
+
+#endif /* __PSNAMERR_H__ */
+
+
+/* END */
diff --git a/src/psnames/rules.mk b/src/psnames/rules.mk
index 7612e82..cb51272 100644
--- a/src/psnames/rules.mk
+++ b/src/psnames/rules.mk
@@ -32,7 +32,8 @@ PSNAMES_DRV_SRC := $(PSNAMES_DIR_)psmodule.c
 # PSNames driver headers
 #
 PSNAMES_DRV_H := $(PSNAMES_DRV_SRC:%.c=%.h) \
-                 $(PSNAMES_DIR_)pstables.h
+                 $(PSNAMES_DIR_)pstables.h  \
+                 $(PSNAMES_DIR_)psnamerr.h
 
 
 # PSNames driver object(s)
diff --git a/src/raster/ftraster.c b/src/raster/ftraster.c
index d8cf1d7..de4b28b 100644
--- a/src/raster/ftraster.c
+++ b/src/raster/ftraster.c
@@ -170,15 +170,17 @@
 #else /* _STANDALONE_ */
 
 
-#include <freetype/internal/ftobjs.h>
-#include <freetype/internal/ftdebug.h> /* for FT_TRACE() and FT_ERROR() */
+#include FT_INTERNAL_OBJECTS_H
+#include FT_INTERNAL_DEBUG_H        /* for FT_TRACE() and FT_ERROR() */
 
-#define Raster_Err_None         FT_Err_Ok
-#define Raster_Err_Not_Ini      FT_Err_Raster_Uninitialized
-#define Raster_Err_Overflow     FT_Err_Raster_Overflow
-#define Raster_Err_Neg_Height   FT_Err_Raster_Negative_Height
-#define Raster_Err_Invalid      FT_Err_Invalid_Outline
-#define Raster_Err_Unsupported  FT_Err_Cannot_Render_Glyph
+#include "rasterrs.h"
+
+#define Raster_Err_None         Raster_Err_Ok
+#define Raster_Err_Not_Ini      Raster_Err_Raster_Uninitialized
+#define Raster_Err_Overflow     Raster_Err_Raster_Overflow
+#define Raster_Err_Neg_Height   Raster_Err_Raster_Negative_Height
+#define Raster_Err_Invalid      Raster_Err_Invalid_Outline
+#define Raster_Err_Unsupported  Raster_Err_Cannot_Render_Glyph
 
 
 #endif /* _STANDALONE_ */
@@ -3012,7 +3014,7 @@
         return error;
     }
 
-    return FT_Err_Ok;
+    return Raster_Err_Ok;
   }
 
 
@@ -3085,7 +3087,7 @@
         return error;
     }
 
-    return FT_Err_Ok;
+    return Raster_Err_Ok;
   }
 
 #else /* FT_RASTER_OPTION_ANTI_ALIASING */
@@ -3095,7 +3097,7 @@
   {
     FT_UNUSED_RASTER;
 
-    return FT_Err_Cannot_Render_Glyph;
+    return Raster_Err_Cannot_Render_Glyph;
   }
 
 #endif /* FT_RASTER_OPTION_ANTI_ALIASING */
diff --git a/src/raster/ftrend1.c b/src/raster/ftrend1.c
index 19c741c..febf943 100644
--- a/src/raster/ftrend1.c
+++ b/src/raster/ftrend1.c
@@ -22,6 +22,8 @@
 #include "ftrend1.h"
 #include "ftraster.h"
 
+#include "rasterrs.h"
+
 
   /* initialize renderer -- init its raster */
   static
@@ -34,7 +36,7 @@
                                                library->raster_pool,
                                                library->raster_pool_size );
 
-    return FT_Err_Ok;
+    return Raster_Err_Ok;
   }
 
 
@@ -58,12 +60,12 @@
                                   FT_Matrix*    matrix,
                                   FT_Vector*    delta )
   {
-    FT_Error error = FT_Err_Ok;
+    FT_Error error = Raster_Err_Ok;
 
 
     if ( slot->format != render->glyph_format )
     {
-      error = FT_Err_Invalid_Argument;
+      error = Raster_Err_Invalid_Argument;
       goto Exit;
     }
 
@@ -111,7 +113,7 @@
     /* check glyph image format */
     if ( slot->format != render->glyph_format )
     {
-      error = FT_Err_Invalid_Argument;
+      error = Raster_Err_Invalid_Argument;
       goto Exit;
     }
 
@@ -120,13 +122,13 @@
     {
       /* raster1 is only capable of producing monochrome bitmaps */
       if ( render->clazz == &ft_raster1_renderer_class )
-        return FT_Err_Cannot_Render_Glyph;
+        return Raster_Err_Cannot_Render_Glyph;
     }
     else
     {
       /* raster5 is only capable of producing 5-gray-levels bitmaps */
       if ( render->clazz == &ft_raster5_renderer_class )
-        return FT_Err_Cannot_Render_Glyph;
+        return Raster_Err_Cannot_Render_Glyph;
     }
 
     outline = &slot->outline;
diff --git a/src/raster/rasterrs.h b/src/raster/rasterrs.h
new file mode 100644
index 0000000..dd689a2
--- /dev/null
+++ b/src/raster/rasterrs.h
@@ -0,0 +1,44 @@
+/***************************************************************************/
+/*                                                                         */
+/*  rasterrs.h                                                             */
+/*                                                                         */
+/*    monochrome renderer error codes (specification only).                */
+/*                                                                         */
+/*  Copyright 2001 by                                                      */
+/*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
+/*                                                                         */
+/*  This file is part of the FreeType project, and may only be used,       */
+/*  modified, and distributed under the terms of the FreeType project      */
+/*  license, LICENSE.TXT.  By continuing to use, modify, or distribute     */
+/*  this file you indicate that you have read the license and              */
+/*  understand and accept it fully.                                        */
+/*                                                                         */
+/***************************************************************************/
+
+
+  /*************************************************************************/
+  /*                                                                       */
+  /* This file is used to define the monochrome renderer error enumeration */
+  /* constants.                                                            */
+  /*                                                                       */
+  /*************************************************************************/
+
+#ifndef __RASTERRS_H__
+#define __RASTERRS_H__
+
+#include FT_MODULE_ERRORS_H
+
+#undef __FTERRORS_H__
+
+#define FT_ERRORDEF( e, v, s )    Raster_Err_ ## e = v + FT_Mod_Err_Raster,
+#define FT_NOERRORDEF( e, v, s )  Raster_Err_ ## e = v,
+
+#define FT_ERROR_START_LIST       enum {
+#define FT_ERROR_END_LIST         Raster_Err_Max };
+
+#include FT_ERRORS_H
+
+#endif /* __RASTERRS_H__ */
+
+
+/* END */
diff --git a/src/raster/rules.mk b/src/raster/rules.mk
index 2dba013..7d3f65c 100644
--- a/src/raster/rules.mk
+++ b/src/raster/rules.mk
@@ -31,7 +31,8 @@ RAS1_DRV_SRC := $(RAS1_DIR_)ftraster.c \
 
 # raster1 driver headers
 #
-RAS1_DRV_H := $(RAS1_DRV_SRC:%.c=%.h)
+RAS1_DRV_H := $(RAS1_DRV_SRC:%.c=%.h) \
+              $(RAS1_DIR_)rasterrs.h
 
 
 # raster1 driver object(s)
diff --git a/src/sfnt/rules.mk b/src/sfnt/rules.mk
index 4502b5c..3089de3 100644
--- a/src/sfnt/rules.mk
+++ b/src/sfnt/rules.mk
@@ -35,7 +35,8 @@ SFNT_DRV_SRC := $(SFNT_DIR_)ttload.c   \
 
 # SFNT driver headers
 #
-SFNT_DRV_H := $(SFNT_DRV_SRC:%c=%h)
+SFNT_DRV_H := $(SFNT_DRV_SRC:%c=%h) \
+              $(SFNT_DIR_)sferrors.h
 
 
 # SFNT driver object(s)
diff --git a/src/sfnt/sferrors.h b/src/sfnt/sferrors.h
new file mode 100644
index 0000000..776e115
--- /dev/null
+++ b/src/sfnt/sferrors.h
@@ -0,0 +1,42 @@
+/***************************************************************************/
+/*                                                                         */
+/*  sferrors.h                                                             */
+/*                                                                         */
+/*    SFNT error codes (specification only).                               */
+/*                                                                         */
+/*  Copyright 2001 by                                                      */
+/*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
+/*                                                                         */
+/*  This file is part of the FreeType project, and may only be used,       */
+/*  modified, and distributed under the terms of the FreeType project      */
+/*  license, LICENSE.TXT.  By continuing to use, modify, or distribute     */
+/*  this file you indicate that you have read the license and              */
+/*  understand and accept it fully.                                        */
+/*                                                                         */
+/***************************************************************************/
+
+
+  /*************************************************************************/
+  /*                                                                       */
+  /* This file is used to define the SFNT error enumeration constants.     */
+  /*                                                                       */
+  /*************************************************************************/
+
+#ifndef __SFERRORS_H__
+#define __SFERRORS_H__
+
+#include FT_MODULE_ERRORS_H
+
+#undef __FTERRORS_H__
+
+#define FT_ERRORDEF( e, v, s )    SFNT_Err_ ## e = v + FT_Mod_Err_SFNT,
+#define FT_NOERRORDEF( e, v, s )  SFNT_Err_ ## e = v,
+
+#define FT_ERROR_START_LIST       enum {
+#define FT_ERROR_END_LIST         SFNT_Err_Max };
+
+#include FT_ERRORS_H
+
+#endif /* __SFERRORS_H__ */
+
+/* END */
diff --git a/src/sfnt/sfobjs.c b/src/sfnt/sfobjs.c
index 31b94e6..438e47a 100644
--- a/src/sfnt/sfobjs.c
+++ b/src/sfnt/sfobjs.c
@@ -23,7 +23,8 @@
 #include FT_INTERNAL_POSTSCRIPT_NAMES_H
 #include FT_TRUETYPE_IDS_H
 #include FT_TRUETYPE_TAGS_H
-#include FT_INTERNAL_TRUETYPE_ERRORS_H
+
+#include "sferrors.h"
 
 
   /*************************************************************************/
@@ -199,7 +200,7 @@
       sfnt = (SFNT_Interface*)FT_Get_Module_Interface( library, "sfnt" );
       if ( !sfnt )
       {
-        error = TT_Err_Invalid_File_Format;
+        error = SFNT_Err_Invalid_File_Format;
         goto Exit;
       }
 
@@ -237,7 +238,7 @@
 
 #undef  LOAD_
 #define LOAD_( x )  ( ( error = sfnt->load_##x( face, stream ) ) \
-                      != TT_Err_Ok )
+                      != SFNT_Err_Ok )
 
 
   FT_LOCAL_DEF
@@ -327,8 +328,8 @@
     if ( sfnt->load_sbits && LOAD_( sbits ) )
     {
       /* return an error if this font file has no outlines */
-      if ( error == TT_Err_Table_Missing && has_outline )
-        error = TT_Err_Ok;
+      if ( error == SFNT_Err_Table_Missing && has_outline )
+        error = SFNT_Err_Ok;
       else
         goto Exit;
     }
@@ -341,7 +342,7 @@
       goto Exit;
 
 #ifdef TT_CONFIG_OPTION_EXTEND_ENGINE
-    if ( ( error = TT_Extension_Create( face ) ) != TT_Err_Ok )
+    if ( ( error = TT_Extension_Create( face ) ) != SFNT_Err_Ok )
       goto Exit;
 #endif
 
diff --git a/src/sfnt/ttcmap.c b/src/sfnt/ttcmap.c
index c9eb946..37f1034 100644
--- a/src/sfnt/ttcmap.c
+++ b/src/sfnt/ttcmap.c
@@ -18,10 +18,11 @@
 
 #include <ft2build.h>
 #include FT_INTERNAL_DEBUG_H
-#include FT_INTERNAL_TRUETYPE_ERRORS_H
 #include "ttload.h"
 #include "ttcmap.h"
 
+#include "sferrors.h"
+
 
   /*************************************************************************/
   /*                                                                       */
@@ -91,7 +92,7 @@
 
 
     if ( cmap->loaded )
-      return TT_Err_Ok;
+      return SFNT_Err_Ok;
 
     memory = stream->memory;
 
@@ -260,11 +261,11 @@
       break;
 
     default:   /* corrupt character mapping table */
-      return TT_Err_Invalid_CharMap_Format;
+      return SFNT_Err_Invalid_CharMap_Format;
 
     }
 
-    return TT_Err_Ok;
+    return SFNT_Err_Ok;
 
   Fail:
     TT_CharMap_Free( face, cmap );
@@ -295,7 +296,7 @@
 
 
     if ( !cmap )
-      return TT_Err_Ok;
+      return SFNT_Err_Ok;
 
     memory = face->root.driver->root.memory;
 
@@ -328,7 +329,7 @@
     }
 
     cmap->loaded = FALSE;
-    return TT_Err_Ok;
+    return SFNT_Err_Ok;
   }
 
 
diff --git a/src/sfnt/ttload.c b/src/sfnt/ttload.c
index 9ef433c..1783b43 100644
--- a/src/sfnt/ttload.c
+++ b/src/sfnt/ttload.c
@@ -19,12 +19,13 @@
 
 #include <ft2build.h>
 #include FT_INTERNAL_DEBUG_H
-#include FT_INTERNAL_TRUETYPE_ERRORS_H
 #include FT_INTERNAL_STREAM_H
 #include FT_TRUETYPE_TAGS_H
 #include "ttload.h"
 #include "ttcmap.h"
 
+#include "sferrors.h"
+
 
   /*************************************************************************/
   /*                                                                       */
@@ -122,7 +123,7 @@
        goto Exit;
     }
     else
-      error = TT_Err_Table_Missing;
+      error = SFNT_Err_Table_Missing;
 
   Exit:
     return error;
@@ -233,7 +234,7 @@
       /* check face index */
       if ( face_index >= face->ttc_header.count )
       {
-        error = TT_Err_Bad_Argument;
+        error = SFNT_Err_Bad_Argument;
         goto Exit;
       }
 
@@ -262,7 +263,7 @@
            entry_selector * 2 <= num_tables )
       {
         FT_TRACE2(( "TT_Load_SFNT_Header: file is not SFNT!\n" ));
-        error = TT_Err_Unknown_File_Format;
+        error = SFNT_Err_Unknown_File_Format;
       }
     }
 
@@ -405,7 +406,7 @@
       table = TT_LookUp_Table( face, tag );
       if ( !table )
       {
-        error = TT_Err_Table_Missing;
+        error = SFNT_Err_Table_Missing;
         goto Exit;
       }
 
@@ -420,7 +421,7 @@
     {
       *length = size;
 
-      return TT_Err_Ok;
+      return SFNT_Err_Ok;
     }
 
     if ( length )
@@ -679,7 +680,7 @@
         /* Set number_Of_VMetrics to 0! */
         FT_TRACE2(( "  no vertical header in file.\n" ));
         face->vertical.number_Of_VMetrics = 0;
-        error = TT_Err_Ok;
+        error = SFNT_Err_Ok;
         goto Exit;
       }
 
@@ -693,7 +694,7 @@
       if ( error )
       {
         FT_ERROR(( " no horizontal metrics in file!\n" ));
-        error = TT_Err_Hmtx_Table_Missing;
+        error = SFNT_Err_Hmtx_Table_Missing;
         goto Exit;
       }
 
@@ -713,8 +714,8 @@
                  vertical ? "Vertical"
                           : "Horizontal" ));
 
-      error = vertical ? TT_Err_Invalid_Vert_Metrics
-                       : TT_Err_Invalid_Horiz_Metrics;
+      error = vertical ? SFNT_Err_Invalid_Vert_Metrics
+                       : SFNT_Err_Invalid_Horiz_Metrics;
       goto Exit;
     }
 
@@ -831,7 +832,7 @@
       error = face->goto_table( face, TTAG_vhea, stream, 0 );
       if ( error )
       {
-        error = TT_Err_Ok;
+        error = SFNT_Err_Ok;
         goto Exit;
       }
 
@@ -845,7 +846,7 @@
       error = face->goto_table( face, TTAG_hhea, stream, 0 );
       if ( error )
       {
-        error = TT_Err_Horiz_Header_Missing;
+        error = SFNT_Err_Horiz_Header_Missing;
         goto Exit;
       }
 
@@ -931,7 +932,7 @@
     {
       /* The name table is required so indicate failure. */
       FT_TRACE2(( "is missing!\n" ));
-      error = TT_Err_Name_Table_Missing;
+      error = SFNT_Err_Name_Table_Missing;
       goto Exit;
     }
 
@@ -1123,7 +1124,7 @@
     error = face->goto_table( face, TTAG_cmap, stream, 0 );
     if ( error )
     {
-      error = TT_Err_CMap_Table_Missing;
+      error = SFNT_Err_CMap_Table_Missing;
       goto Exit;
     }
 
@@ -1289,7 +1290,7 @@
     {
       FT_TRACE2(( "is missing!\n" ));
       face->os2.version = 0xFFFF;
-      error = TT_Err_Ok;
+      error = SFNT_Err_Ok;
       goto Exit;
     }
 
@@ -1367,7 +1368,7 @@
 
     error = face->goto_table( face, TTAG_post, stream, 0 );
     if ( error )
-      return TT_Err_Post_Table_Missing;
+      return SFNT_Err_Post_Table_Missing;
 
     if ( READ_Fields( post_fields, post ) )
       return error;
@@ -1376,7 +1377,7 @@
     /* module (ttpost).                                     */
     FT_TRACE2(( "loaded\n" ));
 
-    return TT_Err_Ok;
+    return SFNT_Err_Ok;
   }
 
 
@@ -1434,7 +1435,7 @@
     {
       FT_TRACE2(( "missing (optional)\n" ));
       pclt->Version = 0;
-      return TT_Err_Ok;
+      return SFNT_Err_Ok;
     }
 
     if ( READ_Fields( pclt_fields, pclt ) )
@@ -1478,7 +1479,7 @@
     /* the gasp table is optional */
     error = face->goto_table( face, TTAG_gasp, stream, 0 );
     if ( error )
-      return TT_Err_Ok;
+      return SFNT_Err_Ok;
 
     if ( ACCESS_Frame( 4L ) )
       goto Exit;
@@ -1547,7 +1548,7 @@
     /* the kern table is optional; exit silently if it is missing */
     error = face->goto_table( face, TTAG_kern, stream, 0 );
     if ( error )
-      return TT_Err_Ok;
+      return SFNT_Err_Ok;
 
     if ( ACCESS_Frame( 4L ) )
       goto Exit;
@@ -1658,7 +1659,7 @@
     /* this table is optional */
     error = face->goto_table( face, TTAG_hdmx, stream, 0 );
     if ( error )
-      return TT_Err_Ok;
+      return SFNT_Err_Ok;
 
     if ( ACCESS_Frame( 8L ) )
       goto Exit;
diff --git a/src/sfnt/ttpost.c b/src/sfnt/ttpost.c
index 3f85170..8a9df12 100644
--- a/src/sfnt/ttpost.c
+++ b/src/sfnt/ttpost.c
@@ -27,11 +27,11 @@
 
 #include <ft2build.h>
 #include FT_INTERNAL_STREAM_H
-#include FT_INTERNAL_TRUETYPE_ERRORS_H
 #include FT_TRUETYPE_TAGS_H
 #include "ttpost.h"
 #include "ttload.h"
 
+#include "sferrors.h"
 
   /*************************************************************************/
   /*                                                                       */
@@ -176,7 +176,7 @@
 
     if ( num_glyphs > face->root.num_glyphs )
     {
-      error = TT_Err_Invalid_File_Format;
+      error = SFNT_Err_Invalid_File_Format;
       goto Exit;
     }
 
@@ -249,7 +249,7 @@
       table->glyph_indices = glyph_indices;
       table->glyph_names   = name_strings;
     }
-    return TT_Err_Ok;
+    return SFNT_Err_Ok;
 
 
   Fail1:
@@ -288,7 +288,7 @@
     /* check the number of glyphs */
     if ( num_glyphs > face->root.num_glyphs || num_glyphs > 258 )
     {
-      error = TT_Err_Invalid_File_Format;
+      error = SFNT_Err_Invalid_File_Format;
       goto Exit;
     }
 
@@ -308,7 +308,7 @@
 
         if ( index < 0 || index > num_glyphs )
         {
-          error = TT_Err_Invalid_File_Format;
+          error = SFNT_Err_Invalid_File_Format;
           goto Fail;
         }
       }
@@ -323,7 +323,7 @@
       table->offsets    = offset_table;
     }
 
-    return TT_Err_Ok;
+    return SFNT_Err_Ok;
 
   Fail:
     FREE( offset_table );
@@ -367,7 +367,7 @@
       break;
 
     default:
-      error = TT_Err_Invalid_File_Format;
+      error = SFNT_Err_Invalid_File_Format;
     }
 
     face->postscript_names.loaded = 1;
@@ -455,15 +455,15 @@
 
 
     if ( !face )
-      return TT_Err_Invalid_Face_Handle;
+      return SFNT_Err_Invalid_Face_Handle;
 
     if ( index >= (FT_UInt)face->root.num_glyphs )
-      return TT_Err_Invalid_Glyph_Index;
+      return SFNT_Err_Invalid_Glyph_Index;
 
 #ifdef FT_CONFIG_OPTION_POSTSCRIPT_NAMES
     psnames = (PSNames_Interface*)face->psnames;
     if ( !psnames )
-      return TT_Err_Unimplemented_Feature;
+      return SFNT_Err_Unimplemented_Feature;
 #endif
 
     names = &face->postscript_names;
@@ -527,7 +527,7 @@
       break;                                /* nothing to do */
     }
 
-    return TT_Err_Ok;
+    return SFNT_Err_Ok;
   }
 
 
diff --git a/src/sfnt/ttpost.h b/src/sfnt/ttpost.h
index 094f239..0aa5ab1 100644
--- a/src/sfnt/ttpost.h
+++ b/src/sfnt/ttpost.h
@@ -29,10 +29,6 @@
 FT_BEGIN_HEADER
 
 
-#define TT_Err_Invalid_Post_Table_Format  0x0B00
-#define TT_Err_Invalid_Post_Table         0x0B01
-
-
   FT_LOCAL
   FT_Error TT_Get_PS_Name( TT_Face      face,
                            FT_UInt      index,
diff --git a/src/sfnt/ttsbit.c b/src/sfnt/ttsbit.c
index ff5fd93..46e0f31 100644
--- a/src/sfnt/ttsbit.c
+++ b/src/sfnt/ttsbit.c
@@ -18,11 +18,12 @@
 
 #include <ft2build.h>
 #include FT_INTERNAL_DEBUG_H
-#include FT_INTERNAL_TRUETYPE_ERRORS_H
 #include FT_INTERNAL_STREAM_H
 #include FT_TRUETYPE_TAGS_H
 #include "ttsbit.h"
 
+#include "sferrors.h"
+
 
   /*************************************************************************/
   /*                                                                       */
@@ -363,7 +364,7 @@
       break;
 
     default:
-      error = TT_Err_Invalid_File_Format;
+      error = SFNT_Err_Invalid_File_Format;
     }
 
   Exit:
@@ -469,7 +470,7 @@
          num_strikes >= 0x10000L    )
     {
       FT_ERROR(( "TT_Load_SBit_Strikes: invalid table version!\n" ));
-      error = TT_Err_Invalid_File_Format;
+      error = SFNT_Err_Invalid_File_Format;
 
       goto Exit;
     }
@@ -630,7 +631,7 @@
 
     if ( x_ppem < 0 || x_ppem > 255 ||
          y_ppem < 1 || y_ppem > 255 )
-      return TT_Err_Invalid_PPem;
+      return SFNT_Err_Invalid_PPem;
 
     for ( i = 0; i < face->num_sbit_strikes; i++ )
     {
@@ -639,11 +640,11 @@
              ( face->sbit_strikes[i].x_ppem == x_ppem ) ) )
       {
         *astrike_index = i;
-        return TT_Err_Ok;
+        return SFNT_Err_Ok;
       }
     }
 
-    return TT_Err_Invalid_PPem;
+    return SFNT_Err_Invalid_PPem;
   }
 
 
@@ -746,7 +747,7 @@
     *arange        = 0;
     *aglyph_offset = 0;
 
-    return TT_Err_Invalid_Argument;
+    return SFNT_Err_Invalid_Argument;
   }
 
 
@@ -775,7 +776,7 @@
   /*                                                                       */
   /* <Return>                                                              */
   /*    FreeType error code.  0 means success.  Returns                    */
-  /*    TT_Err_Invalid_Argument if no sbit exists for the requested glyph. */
+  /*    SFNT_Err_Invalid_Argument if no sbit exists for the requested glyph. */
   /*                                                                       */
   static
   FT_Error  Find_SBit_Image( TT_Face           face,
@@ -802,7 +803,7 @@
 
     *astrike = strike;
 
-    return TT_Err_Ok;
+    return SFNT_Err_Ok;
 
   Fail:
     /* no embedded bitmap for this glyph in face */
@@ -810,7 +811,7 @@
     *astrike       = 0;
     *aglyph_offset = 0;
 
-    return TT_Err_Invalid_Argument;
+    return SFNT_Err_Invalid_Argument;
   }
 
 
@@ -846,7 +847,7 @@
                                TT_SBit_Range*    range,
                                TT_SBit_Metrics*  metrics )
   {
-    FT_Error  error = TT_Err_Ok;
+    FT_Error  error = SFNT_Err_Ok;
 
 
     switch ( range->image_format )
@@ -905,7 +906,7 @@
       if ( range->index_format == 2 || range->index_format == 5 )
         *metrics = range->metrics;
       else
-        return TT_Err_Invalid_File_Format;
+        return SFNT_Err_Invalid_File_Format;
    }
 
   Exit:
@@ -1134,7 +1135,7 @@
     if ( x_offset < 0 || x_offset + metrics->width  > map->width ||
          y_offset < 0 || y_offset + metrics->height > map->rows  )
     {
-      error = TT_Err_Invalid_Argument;
+      error = SFNT_Err_Invalid_Argument;
 
       goto Exit;
     }
@@ -1177,7 +1178,7 @@
         break;
 
       default:  /* invalid format */
-        return TT_Err_Invalid_File_Format;
+        return SFNT_Err_Invalid_File_Format;
       }
 
       /* Now read data and draw glyph into target pixmap       */
@@ -1256,7 +1257,7 @@
         break;
 
       default:
-        return TT_Err_Invalid_File_Format;
+        return SFNT_Err_Invalid_File_Format;
       }
 
       size = map->rows * map->pitch;
@@ -1287,7 +1288,7 @@
       break;
 
     default: /* invalid image format */
-      return TT_Err_Invalid_File_Format;
+      return SFNT_Err_Invalid_File_Format;
     }
 
     /* All right, we have a compound format.  First of all, read */
diff --git a/src/smooth/ftgrays.c b/src/smooth/ftgrays.c
index fa2ef77..584d767 100644
--- a/src/smooth/ftgrays.c
+++ b/src/smooth/ftgrays.c
@@ -122,14 +122,17 @@
 
 #else /* _STANDALONE_ */
 
+
 #include <ft2build.h>
 #include "ftgrays.h"
 #include FT_INTERNAL_OBJECTS_H
 #include FT_INTERNAL_DEBUG_H
 #include FT_OUTLINE_H
 
-#define ErrRaster_Invalid_Mode     FT_Err_Cannot_Render_Glyph
-#define ErrRaster_Invalid_Outline  FT_Err_Invalid_Outline
+#include "ftsmerrs.h"
+
+#define ErrRaster_Invalid_Mode     Smooth_Err_Cannot_Render_Glyph
+#define ErrRaster_Invalid_Outline  Smooth_Err_Invalid_Outline
 
 
 #endif /* _STANDALONE_ */
diff --git a/src/smooth/ftsmerrs.h b/src/smooth/ftsmerrs.h
new file mode 100644
index 0000000..a319c9e
--- /dev/null
+++ b/src/smooth/ftsmerrs.h
@@ -0,0 +1,44 @@
+/***************************************************************************/
+/*                                                                         */
+/*  ftsmerrs.h                                                             */
+/*                                                                         */
+/*    smooth renderer error codes (specification only).                    */
+/*                                                                         */
+/*  Copyright 2001 by                                                      */
+/*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
+/*                                                                         */
+/*  This file is part of the FreeType project, and may only be used,       */
+/*  modified, and distributed under the terms of the FreeType project      */
+/*  license, LICENSE.TXT.  By continuing to use, modify, or distribute     */
+/*  this file you indicate that you have read the license and              */
+/*  understand and accept it fully.                                        */
+/*                                                                         */
+/***************************************************************************/
+
+
+  /*************************************************************************/
+  /*                                                                       */
+  /* This file is used to define the smooth renderer error enumeration     */
+  /* constants.                                                            */
+  /*                                                                       */
+  /*************************************************************************/
+
+#ifndef __FTSMERRS_H__
+#define __FTSMERRS_H__
+
+#include FT_MODULE_ERRORS_H
+
+#undef __FTERRORS_H__
+
+#define FT_ERRORDEF( e, v, s )    Smooth_Err_ ## e = v + FT_Mod_Err_Smooth,
+#define FT_NOERRORDEF( e, v, s )  Smooth_Err_ ## e = v,
+
+#define FT_ERROR_START_LIST       enum {
+#define FT_ERROR_END_LIST         Smooth_Err_Max };
+
+#include FT_ERRORS_H
+
+#endif /* __FTSMERRS_H__ */
+
+
+/* END */
diff --git a/src/smooth/ftsmooth.c b/src/smooth/ftsmooth.c
index cc2985d..9dd460c 100644
--- a/src/smooth/ftsmooth.c
+++ b/src/smooth/ftsmooth.c
@@ -22,6 +22,8 @@
 #include "ftsmooth.h"
 #include "ftgrays.h"
 
+#include "ftsmerrs.h"
+
 
   /* initialize renderer -- init its raster */
   static
@@ -57,12 +59,12 @@
                                  FT_Matrix*    matrix,
                                  FT_Vector*    delta )
   {
-    FT_Error  error = FT_Err_Ok;
+    FT_Error  error = Smooth_Err_Ok;
 
 
     if ( slot->format != render->glyph_format )
     {
-      error = FT_Err_Invalid_Argument;
+      error = Smooth_Err_Invalid_Argument;
       goto Exit;
     }
 
@@ -110,13 +112,13 @@
     /* check glyph image format */
     if ( slot->format != render->glyph_format )
     {
-      error = FT_Err_Invalid_Argument;
+      error = Smooth_Err_Invalid_Argument;
       goto Exit;
     }
 
     /* check mode */
     if ( mode != ft_render_mode_normal )
-      return FT_Err_Cannot_Render_Glyph;
+      return Smooth_Err_Cannot_Render_Glyph;
 
     outline = &slot->outline;
 
diff --git a/src/smooth/rules.mk b/src/smooth/rules.mk
index cf751f5..4458823 100644
--- a/src/smooth/rules.mk
+++ b/src/smooth/rules.mk
@@ -31,7 +31,8 @@ SMOOTH_DRV_SRC := $(SMOOTH_DIR_)ftgrays.c  \
 
 # smooth driver headers
 #
-SMOOTH_DRV_H := $(SMOOTH_DRV_SRC:%c=%h)
+SMOOTH_DRV_H := $(SMOOTH_DRV_SRC:%c=%h)  \
+                $(SMOOTH_DIR_)ftsmerrs.h
 
 
 # smooth driver object(s)
diff --git a/src/truetype/rules.mk b/src/truetype/rules.mk
index a9f6c36..4ef3678 100644
--- a/src/truetype/rules.mk
+++ b/src/truetype/rules.mk
@@ -34,7 +34,8 @@ TT_DRV_SRC := $(TT_DIR_)ttobjs.c   \
 
 # TrueType driver headers
 #
-TT_DRV_H := $(TT_DRV_SRC:%.c=%.h)
+TT_DRV_H := $(TT_DRV_SRC:%.c=%.h) \
+            $(TT_DIR_)tterrors.h
 
 
 # TrueType driver object(s)
diff --git a/src/truetype/ttdriver.c b/src/truetype/ttdriver.c
index d21d02f..16c1ac2 100644
--- a/src/truetype/ttdriver.c
+++ b/src/truetype/ttdriver.c
@@ -21,9 +21,12 @@
 #include FT_INTERNAL_STREAM_H
 #include FT_INTERNAL_SFNT_H
 #include FT_TRUETYPE_IDS_H
+
 #include "ttdriver.h"
 #include "ttgload.h"
 
+#include "tterrors.h"
+
 
   /*************************************************************************/
   /*                                                                       */
@@ -298,7 +301,7 @@
 
 
     if ( !slot )
-      return TT_Err_Invalid_Glyph_Handle;
+      return TT_Err_Invalid_Slot_Handle;
 
     /* check whether we want a scaled outline or bitmap */
     if ( !size )
diff --git a/src/truetype/tterrors.h b/src/truetype/tterrors.h
new file mode 100644
index 0000000..ace9f78
--- /dev/null
+++ b/src/truetype/tterrors.h
@@ -0,0 +1,43 @@
+/***************************************************************************/
+/*                                                                         */
+/*  tterrors.h                                                             */
+/*                                                                         */
+/*    TrueType error codes (specification only).                           */
+/*                                                                         */
+/*  Copyright 2001 by                                                      */
+/*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
+/*                                                                         */
+/*  This file is part of the FreeType project, and may only be used,       */
+/*  modified, and distributed under the terms of the FreeType project      */
+/*  license, LICENSE.TXT.  By continuing to use, modify, or distribute     */
+/*  this file you indicate that you have read the license and              */
+/*  understand and accept it fully.                                        */
+/*                                                                         */
+/***************************************************************************/
+
+
+  /*************************************************************************/
+  /*                                                                       */
+  /* This file is used to define the TrueType error enumeration            */
+  /* constants.                                                            */
+  /*                                                                       */
+  /*************************************************************************/
+
+#ifndef __TTERRORS_H__
+#define __TTERRORS_H__
+
+#include FT_MODULE_ERRORS_H
+
+#undef __FTERRORS_H__
+
+#define FT_ERRORDEF( e, v, s )    TT_Err_ ## e = v + FT_Mod_Err_TrueType,
+#define FT_NOERRORDEF( e, v, s )  TT_Err_ ## e = v,
+
+#define FT_ERROR_START_LIST       enum {
+#define FT_ERROR_END_LIST         TT_Err_Max };
+
+#include FT_ERRORS_H
+
+#endif /* __TTERRORS_H__ */
+
+/* END */
diff --git a/src/truetype/ttgload.c b/src/truetype/ttgload.c
index ec81e1e..63bf703 100644
--- a/src/truetype/ttgload.c
+++ b/src/truetype/ttgload.c
@@ -26,6 +26,8 @@
 
 #include "ttgload.h"
 
+#include "tterrors.h"
+
 
   /*************************************************************************/
   /*                                                                       */
@@ -300,14 +302,14 @@
     if ( n_ins > face->max_profile.maxSizeOfInstructions )
     {
       FT_TRACE0(( "ERROR: Too many instructions!\n" ));
-      error = TT_Err_Too_Many_Ins;
+      error = TT_Err_Too_Many_Hints;
       goto Fail;
     }
 
     if ( stream->cursor + n_ins > stream->limit )
     {
       FT_TRACE0(( "ERROR: Instruction count mismatch!\n" ));
-      error = TT_Err_Too_Many_Ins;
+      error = TT_Err_Too_Many_Hints;
       goto Fail;
     }
 
@@ -1019,7 +1021,7 @@
           {
             FT_TRACE0(( "Too many instructions (%d) in composite glyph %ld\n",
                         n_ins, subglyph->index ));
-            return TT_Err_Too_Many_Ins;
+            return TT_Err_Too_Many_Hints;
           }
 
           /* read the instructions */
diff --git a/src/truetype/ttinterp.c b/src/truetype/ttinterp.c
index 320c783..1f5b6c7 100644
--- a/src/truetype/ttinterp.c
+++ b/src/truetype/ttinterp.c
@@ -20,8 +20,10 @@
 #include FT_INTERNAL_DEBUG_H
 #include FT_INTERNAL_CALC_H
 #include FT_SYSTEM_H
+
 #include "ttinterp.h"
-#include FT_INTERNAL_TRUETYPE_ERRORS_H
+
+#include "tterrors.h"
 
 
 #ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER
diff --git a/src/truetype/ttobjs.c b/src/truetype/ttobjs.c
index af15bf8..6dcce38 100644
--- a/src/truetype/ttobjs.c
+++ b/src/truetype/ttobjs.c
@@ -24,11 +24,12 @@
 #include FT_TRUETYPE_TAGS_H
 #include FT_INTERNAL_SFNT_H
 #include FT_INTERNAL_POSTSCRIPT_NAMES_H
-#include FT_INTERNAL_TRUETYPE_ERRORS_H
 
 #include "ttgload.h"
 #include "ttpload.h"
 
+#include "tterrors.h"
+
 #ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER
 #include "ttinterp.h"
 #endif
diff --git a/src/truetype/ttobjs.h b/src/truetype/ttobjs.h
index 67d2940..51df3c7 100644
--- a/src/truetype/ttobjs.h
+++ b/src/truetype/ttobjs.h
@@ -23,7 +23,6 @@
 #include <ft2build.h>
 #include FT_INTERNAL_OBJECTS_H
 #include FT_INTERNAL_TRUETYPE_TYPES_H
-#include FT_INTERNAL_TRUETYPE_ERRORS_H
 
 
 FT_BEGIN_HEADER
diff --git a/src/truetype/ttpload.c b/src/truetype/ttpload.c
index aecd3c2..6ca3cbd 100644
--- a/src/truetype/ttpload.c
+++ b/src/truetype/ttpload.c
@@ -21,8 +21,10 @@
 #include FT_INTERNAL_OBJECTS_H
 #include FT_INTERNAL_STREAM_H
 #include FT_TRUETYPE_TAGS_H
+
 #include "ttpload.h"
-#include FT_INTERNAL_TRUETYPE_ERRORS_H
+
+#include "tterrors.h"
 
 
   /*************************************************************************/
diff --git a/src/type1/rules.mk b/src/type1/rules.mk
index aff446f..5f4ce9f 100644
--- a/src/type1/rules.mk
+++ b/src/type1/rules.mk
@@ -36,7 +36,8 @@ T1_DRV_SRC := $(T1_DIR_)t1parse.c  \
 # Type1 driver headers
 #
 T1_DRV_H := $(T1_DRV_SRC:%.c=%.h) \
-             $(T1_DIR_)t1tokens.h
+            $(T1_DIR_)t1tokens.h  \
+            $(T1_DIR_)t1errors.h
 
 
 # Type1 driver object(s)
diff --git a/src/type1/t1driver.c b/src/type1/t1driver.c
index 5146192..c83a501 100644
--- a/src/type1/t1driver.c
+++ b/src/type1/t1driver.c
@@ -21,6 +21,8 @@
 #include "t1gload.h"
 #include "t1load.h"
 
+#include "t1errors.h"
+
 #ifndef T1_CONFIG_OPTION_NO_AFM
 #include "t1afm.h"
 #endif
diff --git a/src/type1/t1errors.h b/src/type1/t1errors.h
new file mode 100644
index 0000000..ebd0a81
--- /dev/null
+++ b/src/type1/t1errors.h
@@ -0,0 +1,43 @@
+/***************************************************************************/
+/*                                                                         */
+/*  t1errors.h                                                             */
+/*                                                                         */
+/*    Type 1 error codes (specification only).                             */
+/*                                                                         */
+/*  Copyright 2001 by                                                      */
+/*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
+/*                                                                         */
+/*  This file is part of the FreeType project, and may only be used,       */
+/*  modified, and distributed under the terms of the FreeType project      */
+/*  license, LICENSE.TXT.  By continuing to use, modify, or distribute     */
+/*  this file you indicate that you have read the license and              */
+/*  understand and accept it fully.                                        */
+/*                                                                         */
+/***************************************************************************/
+
+
+  /*************************************************************************/
+  /*                                                                       */
+  /* This file is used to define the Type 1 error enumeration constants.   */
+  /*                                                                       */
+  /*************************************************************************/
+
+#ifndef __T1ERRORS_H__
+#define __T1ERRORS_H__
+
+#include FT_MODULE_ERRORS_H
+
+#undef __FTERRORS_H__
+
+#define FT_ERRORDEF( e, v, s )    T1_Err_ ## e = v + FT_Mod_Err_Type1,
+#define FT_NOERRORDEF( e, v, s )  T1_Err_ ## e = v,
+
+#define FT_ERROR_START_LIST       enum {
+#define FT_ERROR_END_LIST         T1_Err_Max };
+
+#include FT_ERRORS_H
+
+#endif /* __T1ERRORS_H__ */
+
+
+/* END */
diff --git a/src/type1/t1gload.c b/src/type1/t1gload.c
index 881c998..695897f 100644
--- a/src/type1/t1gload.c
+++ b/src/type1/t1gload.c
@@ -23,6 +23,8 @@
 #include FT_OUTLINE_H
 #include FT_INTERNAL_POSTSCRIPT_AUX_H
 
+#include "t1errors.h"
+
 #include <string.h>     /* for strcmp() */
 
 
diff --git a/src/type1/t1load.c b/src/type1/t1load.c
index b848c97..faff552 100644
--- a/src/type1/t1load.c
+++ b/src/type1/t1load.c
@@ -66,10 +66,11 @@
 #include FT_CONFIG_CONFIG_H
 #include FT_MULTIPLE_MASTERS_H
 #include FT_INTERNAL_TYPE1_TYPES_H
-#include FT_INTERNAL_TYPE1_ERRORS_H
 
 #include "t1load.h"
 
+#include "t1errors.h"
+
 #include <string.h>     /* for strncmp(), strcmp() */
 #include <ctype.h>      /* for isalnum()           */
 
diff --git a/src/type1/t1objs.c b/src/type1/t1objs.c
index b830092..1c9f45b 100644
--- a/src/type1/t1objs.c
+++ b/src/type1/t1objs.c
@@ -25,6 +25,8 @@
 #include "t1gload.h"
 #include "t1load.h"
 
+#include "t1errors.h"
+
 #ifndef T1_CONFIG_OPTION_NO_AFM
 #include "t1afm.h"
 #endif
diff --git a/src/type1/t1objs.h b/src/type1/t1objs.h
index 8c83fa7..810380a 100644
--- a/src/type1/t1objs.h
+++ b/src/type1/t1objs.h
@@ -23,7 +23,6 @@
 #include <ft2build.h>
 #include FT_INTERNAL_OBJECTS_H
 #include FT_CONFIG_CONFIG_H
-#include FT_INTERNAL_TYPE1_ERRORS_H
 #include FT_INTERNAL_TYPE1_TYPES_H
 
 
diff --git a/src/type1/t1parse.c b/src/type1/t1parse.c
index 2ec6ba3..fee1b38 100644
--- a/src/type1/t1parse.c
+++ b/src/type1/t1parse.c
@@ -37,10 +37,12 @@
 #include FT_INTERNAL_DEBUG_H
 #include FT_INTERNAL_CALC_H
 #include FT_INTERNAL_STREAM_H
-#include FT_INTERNAL_TYPE1_ERRORS_H
 #include FT_INTERNAL_POSTSCRIPT_AUX_H
+
 #include "t1parse.h"
 
+#include "t1errors.h"
+
 #include <string.h>     /* for strncmp() */
 
 
diff --git a/src/winfonts/fnterrs.h b/src/winfonts/fnterrs.h
new file mode 100644
index 0000000..8d8cf33
--- /dev/null
+++ b/src/winfonts/fnterrs.h
@@ -0,0 +1,44 @@
+/***************************************************************************/
+/*                                                                         */
+/*  fnterrs.h                                                              */
+/*                                                                         */
+/*    Win FNT/FON error codes (specification only).                        */
+/*                                                                         */
+/*  Copyright 2001 by                                                      */
+/*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
+/*                                                                         */
+/*  This file is part of the FreeType project, and may only be used,       */
+/*  modified, and distributed under the terms of the FreeType project      */
+/*  license, LICENSE.TXT.  By continuing to use, modify, or distribute     */
+/*  this file you indicate that you have read the license and              */
+/*  understand and accept it fully.                                        */
+/*                                                                         */
+/***************************************************************************/
+
+
+  /*************************************************************************/
+  /*                                                                       */
+  /* This file is used to define the Windows FNT/FON error enumeration     */
+  /* constants.                                                            */
+  /*                                                                       */
+  /*************************************************************************/
+
+#ifndef __FNTERRS_H__
+#define __FNTERRS_H__
+
+#include FT_MODULE_ERRORS_H
+
+#undef __FTERRORS_H__
+
+#define FT_ERRORDEF( e, v, s )    FNT_Err_ ## e = v + FT_Mod_Err_Winfonts,
+#define FT_NOERRORDEF( e, v, s )  FNT_Err_ ## e = v,
+
+#define FT_ERROR_START_LIST       enum {
+#define FT_ERROR_END_LIST         FNT_Err_Max };
+
+#include FT_ERRORS_H
+
+#endif /* __FNTERRS_H__ */
+
+
+/* END */
diff --git a/src/winfonts/rules.mk b/src/winfonts/rules.mk
index aa015f4..3574ad8 100644
--- a/src/winfonts/rules.mk
+++ b/src/winfonts/rules.mk
@@ -28,7 +28,8 @@ FNT_DRV_SRC := $(FNT_DIR_)winfnt.c
 
 # Windows driver headers
 #
-FNT_DRV_H := $(FNT_DRV_SRC:%.c=%.h)
+FNT_DRV_H := $(FNT_DRV_SRC:%.c=%.h) \
+             $(FNT_DIR_)fnterrs.h
 
 
 # Windows driver object(s)
diff --git a/src/winfonts/winfnt.c b/src/winfonts/winfnt.c
index 1fa47d7..423b484 100644
--- a/src/winfonts/winfnt.c
+++ b/src/winfonts/winfnt.c
@@ -17,13 +17,15 @@
 
 
 #include <ft2build.h>
-#include FT_ERRORS_H
 #include FT_INTERNAL_DEBUG_H
 #include FT_INTERNAL_STREAM_H
 #include FT_INTERNAL_OBJECTS_H
 #include FT_INTERNAL_FNT_TYPES_H
+
 #include "winfnt.h"
 
+#include "fnterrs.h"
+
 
   /*************************************************************************/
   /*                                                                       */
@@ -139,14 +141,14 @@
          header->version != 0x300 )
     {
       FT_TRACE2(( "[not a valid FNT file]\n" ));
-      error = FT_Err_Unknown_File_Format;
+      error = FNT_Err_Unknown_File_Format;
       goto Exit;
     }
 
     if ( header->file_type & 1 )
     {
       FT_TRACE2(( "[can't handle vector FNT fonts]\n" ));
-      error = FT_Err_Unknown_File_Format;
+      error = FNT_Err_Unknown_File_Format;
       goto Exit;
     }
 
@@ -198,7 +200,7 @@
          READ_Fields( winmz_header_fields, &mz_header ) )
       goto Exit;
 
-    error = FT_Err_Unknown_File_Format;
+    error = FNT_Err_Unknown_File_Format;
     if ( mz_header.magic == WINFNT_MZ_MAGIC )
     {
       /* yes, now look for a NE header in the file */
@@ -209,7 +211,7 @@
            READ_Fields( winne_header_fields, &ne_header ) )
         goto Exit;
 
-      error = FT_Err_Unknown_File_Format;
+      error = FNT_Err_Unknown_File_Format;
       if ( ne_header.magic == WINFNT_NE_MAGIC )
       {
         /* good, now look in the resource table for each FNT resource */
@@ -254,7 +256,7 @@
         if ( !font_count || !font_offset )
         {
           FT_TRACE2(( "this file doesn't contain any FNT resources!\n" ));
-          error = FT_Err_Unknown_File_Format;
+          error = FNT_Err_Unknown_File_Format;
           goto Exit;
         }
 
@@ -464,7 +466,7 @@
       }
     }
 
-    return ( size->font ? FT_Err_Ok : FT_Err_Invalid_Pixel_Size );
+    return ( size->font ? FNT_Err_Ok : FNT_Err_Invalid_Pixel_Size );
   }
 
 
@@ -513,7 +515,7 @@
 
     if ( !font )
     {
-      error = FT_Err_Invalid_Argument;
+      error = FNT_Err_Invalid_Argument;
       goto Exit;
     }