Commit 222cec8c201dfb93aae9e167ead620ea5065cd7b

David Turner 2002-02-21T11:48:48

* include/freetype/internal/ftdebug.h, src/base/ftdebug.c: modified the debug sub-system initialization. trace levels can now be specified within the "FT2_DEBUG" environment variable. See the comments within "ftdebug.c" for more details * include/freetype/internal/fttrace.h: new file to define the trace levels used for debugging. it is used both to define enums and toggle names for FT2_DEBUG * src/base/ftobjs.c, src/base/ftstream.c: FT_Assert renamed to FT_ASSERT * include/freetype/internal/ftextend.h, src/base/ftextend.c, src/base/Jamfile, src/base/rules.mk: removing "ftextend" from the library, since it is now completely obsolete..

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
diff --git a/ChangeLog b/ChangeLog
index 5d1407d..e96f5ac 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,8 +1,39 @@
+2002-02-21  David Turner  <david@freetype.org>
+
+        * include/freetype/internal/ftdebug.h, src/base/ftdebug.c: modified
+        the debug sub-system initialization. trace levels can now be specified
+        within the "FT2_DEBUG" environment variable. See the comments within
+        "ftdebug.c" for more details
+
+        * include/freetype/internal/fttrace.h: new file to define the trace
+        levels used for debugging. it is used both to define enums and
+        toggle names for FT2_DEBUG
+
+        * src/base/ftobjs.c, src/base/ftstream.c: FT_Assert renamed to
+        FT_ASSERT
+
+        * include/freetype/internal/ftextend.h, src/base/ftextend.c,
+        src/base/Jamfile, src/base/rules.mk: removing "ftextend" from the
+        library, since it is now completely obsolete..
+
+        * include/freetype/fterrors.h: adding "#undef FT_ERR_CAT" to avoid
+        warnings with certain compilers (like LCC)
+
+        * src/pshinter/pshalgo2.c: renaming 'print_zone' to 'psh2_print_zone'
+        to avoid errors during compilation of debug library
+
+
+2002-02-20  David Turner  <david@freetype.org>
+
+        * README: adding "devel@freetype.org" address for bug reports..
+
+
 2002-02-20  Werner Lemberg  <wl@gnu.org>
 
 	* builds/unix/install.mk (check): New dummy target.
 	(.PHONY): Add it.
 
+
 2002-02-19  Werner Lemberg  <wl@gnu.org>
 
 	* builds/freetype.mk (FT_CFLAGS): Use $(INCLUDE_FLAGS) first.
diff --git a/include/freetype/config/ftoption.h b/include/freetype/config/ftoption.h
index 506663b..d163677 100644
--- a/include/freetype/config/ftoption.h
+++ b/include/freetype/config/ftoption.h
@@ -250,7 +250,7 @@ FT_BEGIN_HEADER
   /*   Don't define any of these macros to compile in `release' mode!      */
   /*                                                                       */
 #undef  FT_DEBUG_LEVEL_ERROR
-#undef  FT_DEBUG_LEVEL_TRACE
+#define FT_DEBUG_LEVEL_TRACE
 
 
   /*************************************************************************/
diff --git a/include/freetype/fterrors.h b/include/freetype/fterrors.h
index 89e0cf3..85dd658 100644
--- a/include/freetype/fterrors.h
+++ b/include/freetype/fterrors.h
@@ -105,6 +105,10 @@
 
 
 #undef  FT_NEED_EXTERN_C
+
+#undef  FT_ERR_XCAT
+#undef  FT_ERR_CAT
+
 #define FT_ERR_XCAT( x, y )  x ## y
 #define FT_ERR_CAT( x, y )   FT_ERR_XCAT( x, y )
 
@@ -192,6 +196,11 @@
                "invalid argument" )
   FT_ERRORDEF_( Unimplemented_Feature,                       0x07, \
                "unimplemented feature" )
+  FT_ERRORDEF_( Invalid_Table,                               0x08, \
+                "broken table" )
+  FT_ERRORDEF_( Invalid_Offset,                              0x09, \
+                "broken offset within table" )
+
 
   /* glyph/character errors */
 
diff --git a/include/freetype/internal/ftdebug.h b/include/freetype/internal/ftdebug.h
index e18acbb..b13aa78 100644
--- a/include/freetype/internal/ftdebug.h
+++ b/include/freetype/internal/ftdebug.h
@@ -27,99 +27,48 @@
 FT_BEGIN_HEADER
 
 
+/* force the definition of FT_DEBUG_LEVEL_ERROR if FT_DEBUG_LEVEL_TRACE */
+/* is already defined.. this simplifies the following #ifdefs..         */
+/*                                                                      */
 #ifdef FT_DEBUG_LEVEL_TRACE
+#  undef  FT_DEBUG_LEVEL_ERROR
+#  define FT_DEBUG_LEVEL_ERROR
+#endif
 
 
-  /* note that not all levels are used currently */
+  /*************************************************************************/
+  /*                                                                       */
+  /*  Define the trace enums as well as the trace levels array when        */
+  /*  they're needed                                                       */
+  /*                                                                       */
+  /*************************************************************************/
 
-  typedef enum  FT_Trace_
+#ifdef FT_DEBUG_LEVEL_TRACE
+
+#  define FT_TRACE_DEF(x)   trace_ ## x ,
+
+ /* defining the enums */ 
+  typedef enum
   {
-    /* the first level must always be `trace_any' */
-    trace_any = 0,
-
-    /* base components */
-    trace_aaraster,  /* anti-aliasing raster    (ftgrays.c)  */
-    trace_calc,      /* calculations            (ftcalc.c)   */
-    trace_extend,    /* extension manager       (ftextend.c) */
-    trace_glyph,     /* glyph manager           (ftglyph.c)  */
-    trace_io,        /* i/o monitoring          (ftsystem.c) */
-    trace_init,      /* initialization          (ftinit.c)   */
-    trace_list,      /* list manager            (ftlist.c)   */
-    trace_memory,    /* memory manager          (ftobjs.c)   */
-    trace_mm,        /* MM interface            (ftmm.c)     */
-    trace_objs,      /* base objects            (ftobjs.c)   */
-    trace_outline,   /* outline management      (ftoutln.c)  */
-    trace_raster,    /* rasterizer              (ftraster.c) */
-    trace_stream,    /* stream manager          (ftstream.c) */
-
-    /* Cache sub-system */
-    trace_cache,
-
-    /* SFNT driver components */
-    trace_sfobjs,    /* SFNT object handler     (sfobjs.c)   */
-    trace_ttcmap,    /* charmap handler         (ttcmap.c)   */
-    trace_ttload,    /* basic TrueType tables   (ttload.c)   */
-    trace_ttpost,    /* PS table processing     (ttpost.c)   */
-    trace_ttsbit,    /* TrueType sbit handling  (ttsbit.c)   */
-
-    /* TrueType driver components */
-    trace_ttdriver,  /* TT font driver          (ttdriver.c) */
-    trace_ttgload,   /* TT glyph loader         (ttgload.c)  */
-    trace_ttinterp,  /* bytecode interpreter    (ttinterp.c) */
-    trace_ttobjs,    /* TT objects manager      (ttobjs.c)   */
-    trace_ttpload,   /* TT data/program loader  (ttpload.c)  */
-
-    /* Type 1 driver components */
-    trace_t1driver,
-    trace_t1gload,
-    trace_t1hint,
-    trace_t1load,
-    trace_t1objs,
-    trace_t1parse,
-
-    /* PostScript helper module `psaux' */
-    trace_t1decode,
-    trace_psobjs,
-
-    /* PostScript hinting module `pshinter' */
-    trace_pshrec,
-    trace_pshalgo1,
-    trace_pshalgo2,
-
-    /* Type 2 driver components */
-    trace_cffdriver,
-    trace_cffgload,
-    trace_cffload,
-    trace_cffobjs,
-    trace_cffparse,
-
-    /* CID driver components */
-    trace_cidafm,
-    trace_ciddriver,
-    trace_cidgload,
-    trace_cidload,
-    trace_cidobjs,
-    trace_cidparse,
-
-    /* Windows fonts component */
-    trace_winfnt,
-
-    /* PCF fonts component */
-    trace_pcfdriver,
-    trace_pcfread,
-
-    /* the last level must always be `trace_max' */
-    trace_max
+#  include FT_INTERNAL_TRACE_H  
+    trace_count,
 
   } FT_Trace;
 
 
-  /* declared in ftdebug.c */
-  extern char  ft_trace_levels[trace_max];
+ /* defining the array of trace levels, provided by 'src/base/ftdebug.c' */
+  extern  int  ft_trace_levels [ trace_count ];
+
+#  undef FT_TRACE_DEF
+
+#endif /* FT_DEBUG_LEVEL_TRACE */
+
 
 
   /*************************************************************************/
   /*                                                                       */
+  /*  Define the FT_TRACE macro                                            */
+  /*                                                                       */
   /* IMPORTANT!                                                            */
   /*                                                                       */
   /* Each component must define the macro FT_COMPONENT to a valid FT_Trace */
@@ -127,70 +76,66 @@ FT_BEGIN_HEADER
   /*                                                                       */
   /*************************************************************************/
 
+#ifdef FT_DEBUG_LEVEL_TRACE
 
-#define FT_TRACE( level, varformat )                      \
+#  define FT_TRACE( level, varformat )                    \
           do                                              \
           {                                               \
             if ( ft_trace_levels[FT_COMPONENT] >= level ) \
               FT_Message varformat;                       \
           } while ( 0 )
 
+#else /* !FT_DEBUG_LEVEL_TRACE */
+
+#  define FT_TRACE( level, varformat )  do ; while ( 0 )      /* nothing */
+
+#endif /* !FT_DEBUG_LEVEL_TRACE */
 
   /*************************************************************************/
   /*                                                                       */
-  /* <Function>                                                            */
-  /*    FT_SetTraceLevel                                                   */
-  /*                                                                       */
-  /* <Description>                                                         */
-  /*    Sets the trace level for debugging.                                */
-  /*                                                                       */
-  /* <Input>                                                               */
-  /*    component :: The component which should be traced.  See above for  */
-  /*                 a complete list.  If set to `trace_any', all          */
-  /*                 components will be traced.                            */
+  /* You need two opening resp. closing parentheses!                       */
   /*                                                                       */
-  /*    level     :: The tracing level.                                    */
+  /* Example: FT_TRACE0(( "Value is %i", foo ))                            */
   /*                                                                       */
-  FT_EXPORT( void )
-  FT_SetTraceLevel( FT_Trace  component,
-                    char      level );
-
-
-#elif defined( FT_DEBUG_LEVEL_ERROR )
+  /*************************************************************************/
 
+#define FT_TRACE0( varformat )  FT_TRACE( 0, varformat )
+#define FT_TRACE1( varformat )  FT_TRACE( 1, varformat )
+#define FT_TRACE2( varformat )  FT_TRACE( 2, varformat )
+#define FT_TRACE3( varformat )  FT_TRACE( 3, varformat )
+#define FT_TRACE4( varformat )  FT_TRACE( 4, varformat )
+#define FT_TRACE5( varformat )  FT_TRACE( 5, varformat )
+#define FT_TRACE6( varformat )  FT_TRACE( 6, varformat )
+#define FT_TRACE7( varformat )  FT_TRACE( 7, varformat )
 
-#define FT_TRACE( level, varformat )  do ; while ( 0 )      /* nothing */
 
 
-#else  /* release mode */
+  /*************************************************************************/
+  /*                                                                       */
+  /*  Define the FT_ERROR macro                                            */
+  /*                                                                       */
+  /*************************************************************************/
 
+#ifdef FT_DEBUG_LEVEL_ERROR
 
-#define FT_Assert( condition )        do ; while ( 0 )      /* nothing */
+#  define FT_ERROR( varformat )  FT_Message  varformat
 
-#define FT_TRACE( level, varformat )  do ; while ( 0 )      /* nothing */
-#define FT_ERROR( varformat )         do ; while ( 0 )      /* nothing */
+#else  /* !FT_DEBUG_LEVEL_ERROR */
 
+#  define FT_ERROR( varformat )  do ; while ( 0 )      /* nothing */
 
-#endif /* FT_DEBUG_LEVEL_TRACE, FT_DEBUG_LEVEL_ERROR */
+#endif /* !FT_DEBUG_LEVEL_ERROR */
 
 
   /*************************************************************************/
   /*                                                                       */
-  /* Define macros and functions that are common to the debug and trace    */
-  /* modes.                                                                */
-  /*                                                                       */
-  /* You need vprintf() to be able to compile ftdebug.c.                   */
+  /*  Define the FT_ASSERT macro                                           */
   /*                                                                       */
   /*************************************************************************/
 
+#ifdef FT_DEBUG_LEVEL_ERROR
 
-#if defined( FT_DEBUG_LEVEL_TRACE ) || defined( FT_DEBUG_LEVEL_ERROR )
-
-
-#include "stdio.h"  /* for vprintf() */
-
-
-#define FT_Assert( condition )                                      \
+#define FT_ASSERT( condition )                                      \
           do                                                        \
           {                                                         \
             if ( !( condition ) )                                   \
@@ -198,6 +143,23 @@ FT_BEGIN_HEADER
                         __LINE__, __FILE__ );                       \
           } while ( 0 )
 
+#else /* !FT_DEBUG_LEVEL_ERROR */
+
+#  define  FT_ASSERT( condition )      do ; while ( 0 )
+
+#endif /* !FT_DEBUG_LEVEL_ERROR */
+
+
+  /*************************************************************************/
+  /*                                                                       */
+  /*  Define 'FT_Message' and 'FT_Panic' when needed                       */
+  /*                                                                       */
+  /*************************************************************************/
+
+#ifdef FT_DEBUG_LEVEL_ERROR
+
+#include "stdio.h"  /* for vprintf() */
+
   /* print a message */
   FT_EXPORT( void )
   FT_Message( const char*  fmt, ... );
@@ -206,28 +168,11 @@ FT_BEGIN_HEADER
   FT_EXPORT( void )
   FT_Panic( const char*  fmt, ... );
 
-#define FT_ERROR( varformat )  FT_Message varformat
+#endif /* FT_DEBUG_LEVEL_ERROR */
 
 
-#endif /* FT_DEBUG_LEVEL_TRACE || FT_DEBUG_LEVEL_ERROR */
 
-
-  /*************************************************************************/
-  /*                                                                       */
-  /* You need two opening resp. closing parentheses!                       */
-  /*                                                                       */
-  /* Example: FT_TRACE0(( "Value is %i", foo ))                            */
-  /*                                                                       */
-  /*************************************************************************/
-
-#define FT_TRACE0( varformat )  FT_TRACE( 0, varformat )
-#define FT_TRACE1( varformat )  FT_TRACE( 1, varformat )
-#define FT_TRACE2( varformat )  FT_TRACE( 2, varformat )
-#define FT_TRACE3( varformat )  FT_TRACE( 3, varformat )
-#define FT_TRACE4( varformat )  FT_TRACE( 4, varformat )
-#define FT_TRACE5( varformat )  FT_TRACE( 5, varformat )
-#define FT_TRACE6( varformat )  FT_TRACE( 6, varformat )
-#define FT_TRACE7( varformat )  FT_TRACE( 7, varformat )
+  FT_BASE( void )   ft_debug_init( void );
 
 
 #if defined( _MSC_VER )      /* Visual C++ (and Intel C++) */
diff --git a/include/freetype/internal/ftextend.h b/include/freetype/internal/ftextend.h
deleted file mode 100644
index 8257a2a..0000000
--- a/include/freetype/internal/ftextend.h
+++ /dev/null
@@ -1,211 +0,0 @@
-/***************************************************************************/
-/*                                                                         */
-/*  ftextend.h                                                             */
-/*                                                                         */
-/*    FreeType extensions implementation (specification).                  */
-/*                                                                         */
-/*  Copyright 1996-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.                                        */
-/*                                                                         */
-/***************************************************************************/
-
-
-#ifndef __FTEXTEND_H__
-#define __FTEXTEND_H__
-
-
-#include <ft2build.h>
-#include FT_INTERNAL_OBJECTS_H
-
-
-FT_BEGIN_HEADER
-
-
-  /*************************************************************************/
-  /*                                                                       */
-  /* The extensions don't need to be integrated at compile time into the   */
-  /* engine, only at link time.                                            */
-  /*                                                                       */
-  /*************************************************************************/
-
-
-  /*************************************************************************/
-  /*                                                                       */
-  /* <FuncType>                                                            */
-  /*    FT_Extension_Initializer                                           */
-  /*                                                                       */
-  /* <Description>                                                         */
-  /*    Each new face object can have several extensions associated with   */
-  /*    it at creation time.  This function is used to initialize given    */
-  /*    extension data for a given face.                                   */
-  /*                                                                       */
-  /* <InOut>                                                               */
-  /*    ext  :: A typeless pointer to the extension data.                  */
-  /*                                                                       */
-  /*    face :: A handle to the source face object the extension is        */
-  /*            associated with.                                           */
-  /*                                                                       */
-  /* <Return>                                                              */
-  /*    FreeType error code.  0 means success.                             */
-  /*                                                                       */
-  /* <Note>                                                                */
-  /*    In case of error, the initializer should not destroy the extension */
-  /*    data, as the finalizer will get called later by the function's     */
-  /*    caller.                                                            */
-  /*                                                                       */
-  typedef FT_Error
-  (*FT_Extension_Initializer)( void*    ext,
-                               FT_Face  face );
-
-
-  /*************************************************************************/
-  /*                                                                       */
-  /* <FuncType>                                                            */
-  /*    FT_Extension_Finalizer                                             */
-  /*                                                                       */
-  /* <Description>                                                         */
-  /*    Each new face object can have several extensions associated with   */
-  /*    it at creation time.  This function is used to finalize given      */
-  /*    extension data for a given face; it occurs before the face object  */
-  /*    itself is finalized.                                               */
-  /*                                                                       */
-  /* <InOut>                                                               */
-  /*    ext  :: A typeless pointer to the extension data.                  */
-  /*                                                                       */
-  /*    face :: A handle to the source face object the extension is        */
-  /*            associated with.                                           */
-  /*                                                                       */
-  typedef void
-  (*FT_Extension_Finalizer)( void*    ext,
-                             FT_Face  face );
-
-
-  /*************************************************************************/
-  /*                                                                       */
-  /* <Struct>                                                              */
-  /*    FT_Extension_Class                                                 */
-  /*                                                                       */
-  /* <Description>                                                         */
-  /*    A simple structure used to describe a given extension to the       */
-  /*    FreeType base layer.  An FT_Extension_Class is used as a parameter */
-  /*    for FT_Register_Extension().                                       */
-  /*                                                                       */
-  /* <Fields>                                                              */
-  /*    id        :: The extension's ID.  This is a normal C string that   */
-  /*                 is used to uniquely reference the extension's         */
-  /*                 interface.                                            */
-  /*                                                                       */
-  /*    size      :: The size in bytes of the extension data that must be  */
-  /*                 associated with each face object.                     */
-  /*                                                                       */
-  /*    init      :: A pointer to the extension data's initializer.        */
-  /*                                                                       */
-  /*    finalize  :: A pointer to the extension data's finalizer.          */
-  /*                                                                       */
-  /*    interface :: This pointer can be anything, but should usually      */
-  /*                 point to a table of function pointers which implement */
-  /*                 the extension's interface.                            */
-  /*                                                                       */
-  /*    offset    :: This field is set and used within the base layer and  */
-  /*                 should be set to 0 when registering an extension      */
-  /*                 through FT_Register_Extension().  It contains an      */
-  /*                 offset within the face's extension block for the      */
-  /*                 current extension's data.                             */
-  /*                                                                       */
-  typedef struct  FT_Extension_Class_
-  {
-    const char*               id;
-    FT_ULong                  size;
-    FT_Extension_Initializer  init;
-    FT_Extension_Finalizer    finalize;
-    void*                     interface;
-
-    FT_ULong                  offset;
-
-  } FT_Extension_Class;
-
-
-  /*************************************************************************/
-  /*                                                                       */
-  /* <Function>                                                            */
-  /*    FT_Register_Extension                                              */
-  /*                                                                       */
-  /* <Description>                                                         */
-  /*    Registers a new extension.                                         */
-  /*                                                                       */
-  /* <InOut>                                                               */
-  /*    driver :: A handle to the driver object.                           */
-  /*                                                                       */
-  /*    class  :: A pointer to a class describing the extension.           */
-  /*                                                                       */
-  /* <Return>                                                              */
-  /*    FreeType error code.  0 means success.                             */
-  /*                                                                       */
-  FT_EXPORT( FT_Error )
-  FT_Register_Extension( FT_Driver            driver,
-                         FT_Extension_Class*  clazz );
-
-
-#ifdef FT_CONFIG_OPTION_EXTEND_ENGINE
-
-
-  /* Initialize the extension component */
-  FT_LOCAL FT_Error
-  FT_Init_Extensions( FT_Library  library );
-
-  /* Finalize the extension component */
-  FT_LOCAL FT_Error
-  FT_Done_Extensions( FT_Library  library );
-
-  /* Create an extension within a face object.  Called by the */
-  /* face object constructor.                                 */
-  FT_LOCAL FT_Error
-  FT_Create_Extensions( FT_Face  face );
-
-  /* Destroy all extensions within a face object.  Called by the */
-  /* face object destructor.                                     */
-  FT_LOCAL FT_Error
-  FT_Destroy_Extensions( FT_Face  face );
-
-
-#endif
-
-
-  /*************************************************************************/
-  /*                                                                       */
-  /* <Function>                                                            */
-  /*    FT_Get_Extension                                                   */
-  /*                                                                       */
-  /* <Description>                                                         */
-  /*    Queries an extension block by an extension ID string.              */
-  /*                                                                       */
-  /* <Input>                                                               */
-  /*    face                :: A handle to the face object.                */
-  /*    extension_id        :: An ID string identifying the extension.     */
-  /*                                                                       */
-  /* <Output>                                                              */
-  /*    extension_interface :: A generic pointer, usually pointing to a    */
-  /*                           table of functions implementing the         */
-  /*                           extension interface.                        */
-  /*                                                                       */
-  /* <Return>                                                              */
-  /*    A generic pointer to the extension block.                          */
-  /*                                                                       */
-  FT_EXPORT( void* )
-  FT_Get_Extension( FT_Face      face,
-                    const char*  extension_id,
-                    void**       extension_interface );
-
-
-FT_END_HEADER
-
-#endif /* __FTEXTEND_H__ */
-
-
-/* END */
diff --git a/include/freetype/internal/ftobjs.h b/include/freetype/internal/ftobjs.h
index 755faf8..43a44d0 100644
--- a/include/freetype/internal/ftobjs.h
+++ b/include/freetype/internal/ftobjs.h
@@ -26,7 +26,7 @@
 #ifndef __FTOBJS_H__
 #define __FTOBJS_H__
 
-
+#include <setjmp.h>
 #include <ft2build.h>
 #include FT_RENDER_H
 #include FT_SIZES_H
@@ -450,6 +450,171 @@ FT_BEGIN_HEADER
   /*************************************************************************/
   /****                                                                 ****/
   /****                                                                 ****/
+  /****                         V A L I D A T O R                       ****/
+  /****                                                                 ****/
+  /****                                                                 ****/
+  /*************************************************************************/
+  /*************************************************************************/
+  /*************************************************************************/
+
+  typedef struct FT_ValidatorRec_*   FT_Validator;
+
+/*********************************************************************
+ *
+ * there are three distinct validation levels here:
+ *
+ *  DEFAULT ::
+ *    used to perform normal checks. A table validated with this setting
+ *    is sufficiently correct to be used reliably by FreeType
+ *
+ *  TIGHT ::
+ *    this is more strict than default. A table validated with this setting
+ *    is sufficiently correct to be used reliablity by FreeType and to not
+ *    contain invalid data (that will not crash FreeType or produce bogus
+ *    warnings). This is used to spot font converter/generation tool
+ *    bugs..
+ *
+ *    for example, a CharMap table could map a given character code to
+ *    a glyph index that is larger than the number of available glyphs
+ *    in the font. Such a table would not pass the "TIGHT" validation
+ *    even though it can be used safely with FreeType (which will later
+ *    report errors when trying to load the glyph, for example..)
+ *
+ *
+ *  PARANOID ::
+ *    in this mode, everything is checked to the maximum, and according
+ *    to the specification(s) defining the tables being checked. Really
+ *    useful for font fascists and to spot really weird font artefacts.
+ *
+ *    Beware that most fonts will simply not pass this validation level
+ *    though !!
+ */
+ typedef enum
+ {
+   FT_VALIDATE_DEFAULT = 0,
+   FT_VALIDATE_TIGHT,
+   FT_VALIDATE_PARANOID
+
+ } FT_ValidationLevel;
+
+
+/**********************************************************************
+ *
+ * to use it, you need something like:
+ *
+ *   valid->error = 0;
+ *
+ *   if ( setjmp( valid->jump_buffer ) == 0 )
+ *     validate_table( table_data, .... );
+ *
+ *   return valid->error;
+ *
+ */
+ typedef struct FT_ValidatorRec_
+ {
+   FT_Byte*            base;        /* address of table in memory    */
+   FT_Byte*            limit;       /* base + size of table in bytes */
+
+   FT_Error            error;       /* error code. 0 in case of success   */
+   FT_ValidationLevel  level;       /* validation level..                 */
+   FT_UInt             num_glyphs;  /* if level >= FT_VALIDATE_TIGHT only */
+
+   jmp_buf             jump_buffer;
+
+ } FT_ValidatorRec;
+
+
+ /* call this function when an error is detected during validation. this */
+ /* will set the error and call 'longjmp' to return to the top-level     */
+ /* caller of the validation routine..                                   */
+ /*                                                                      */
+  FT_BASE( void )
+  ft_validator_error( FT_Validator  valid,
+                      FT_Error      error );  
+
+ /* this macro assumes that the local variable 'valid' points to the */
+ /* current validator structure..                                    */
+#define  FT_INVALID(e)   ft_validator_error( valid, e )
+
+ /* a few "common" errors in font tables */
+#define  FT_INVALID_TOO_SHORT   FT_INVALID( FT_Err_Invalid_Table )
+#define  FT_INVALID_OFFSET      FT_INVALID( FT_Err_Invalid_Offset )
+#define  FT_INVALID_GLYPH_ID    FT_INVALID( FT_Err_Invalid_Table )
+
+
+  /*************************************************************************/
+  /*************************************************************************/
+  /*************************************************************************/
+  /****                                                                 ****/
+  /****                                                                 ****/
+  /****                         C H A R M A P S                         ****/
+  /****                                                                 ****/
+  /****                                                                 ****/
+  /*************************************************************************/
+  /*************************************************************************/
+  /*************************************************************************/
+
+ /* handle to internal charmap object */
+  typedef struct FT_CMapRec_*   FT_CMap;
+  
+ /* handle to charmap class structure */
+  typedef const struct FT_CMap_ClassRec_*   FT_CMap_Class;
+
+
+ /* internal charmap object structure, sub-class of 'FT_CharMapRec' */
+  typedef struct FT_CMapRec_
+  {
+    FT_CharMapRec  charmap;
+    FT_CMap_Class  clazz;
+    FT_Pointer     data;   /* passed to validate/index/next methods */
+
+  } FT_CMapRec;
+
+ /* useful macros */
+#define  FT_CMAP(x)               ((FT_CMap)(x))
+#define  FT_CMAP_FACE(x)          (FT_CMAP(x)->charmap.face)
+#define  FT_CMAP_PLATFORM_ID(x)   (FT_CMAP(x)->charmap.platform_id)
+#define  FT_CMAP_ENCODING_ID(x)   (FT_CMAP(x)->charmap.encoding_id)
+#define  FT_CMAP_ENCODING(x)      (FT_CMAP(x)->charmap.encoding)
+
+
+ /* charmap initializer */
+  typedef FT_Error  (*FT_CMap_InitFunc)( FT_CMap  cmap );
+
+ /* charmap finalizer */
+  typedef void      (*FT_CMap_DoneFunc)( FT_CMap  cmap );
+
+ /* charmap validation routine */
+  typedef FT_Error  (*FT_CMap_ValidateFunc)( FT_Pointer    cmap_data,
+                                             FT_Validator  valid );
+
+ /* charmap charcode to glyph index mapping function */
+  typedef FT_UInt   (*FT_CMap_CharIndexFunc)( FT_Pointer   cmap_data,
+                                              FT_ULong     char_code );
+
+ /* charmap charcode increment function */
+  typedef FT_ULong  (*FT_CMap_CharNextFunc)( FT_Pointer   cmap_data,
+                                             FT_ULong     char_code,
+                                             FT_UInt     *agindex );
+
+ /* charmap class */
+  typedef struct FT_CMap_ClassRec_
+  {
+    FT_ULong               size;   /* size in bytes */
+    FT_CMap_InitFunc       init;
+    FT_CMap_DoneFunc       done;
+    FT_CMap_ValidateFunc   validate;
+    FT_CMap_CharIndexFunc  char_index;
+    FT_CMap_CharNextFunc   char_next;
+  
+  } FT_CMap_ClassRec;
+
+
+  /*************************************************************************/
+  /*************************************************************************/
+  /*************************************************************************/
+  /****                                                                 ****/
+  /****                                                                 ****/
   /****                        R E N D E R E R S                        ****/
   /****                                                                 ****/
   /****                                                                 ****/
diff --git a/include/freetype/internal/fttrace.h b/include/freetype/internal/fttrace.h
new file mode 100644
index 0000000..f1e9d6e
--- /dev/null
+++ b/include/freetype/internal/fttrace.h
@@ -0,0 +1,75 @@
+/* definitions of trace levels for FreeType 2 */
+
+/* the first level must always be `trace_any' */
+FT_TRACE_DEF( any )
+
+/* base components */
+FT_TRACE_DEF( calc )      /* calculations            (ftcalc.c)   */
+FT_TRACE_DEF( memory )    /* memory manager          (ftobjs.c)   */
+FT_TRACE_DEF( stream )    /* stream manager          (ftstream.c) */
+FT_TRACE_DEF( io )        /* i/o interface           (ftsystem.c) */
+FT_TRACE_DEF( list )      /* list management         (ftlist.c)   */
+FT_TRACE_DEF( init )      /* initialization          (ftinit.c)   */
+FT_TRACE_DEF( objs )      /* base objects            (ftobjs.c)   */
+FT_TRACE_DEF( outline )   /* outline management      (ftoutln.c)  */
+FT_TRACE_DEF( glyph )     /* glyph management        (ftglyph.c)  */
+
+FT_TRACE_DEF( raster )    /* monochrome rasterizer   (ftraster.c) */
+FT_TRACE_DEF( smooth )    /* anti-aliasing raster    (ftgrays.c)  */
+FT_TRACE_DEF( mm )        /* MM interface            (ftmm.c)     */
+
+/* Cache sub-system */
+FT_TRACE_DEF( cache )     /* cache sub-system        (ftcache.c, etc..) */
+
+/* SFNT driver components */
+FT_TRACE_DEF( sfobjs )    /*  SFNT object handler     (sfobjs.c)   */
+FT_TRACE_DEF( ttcmap )    /* charmap handler         (ttcmap.c)    */
+FT_TRACE_DEF( ttload )    /* basic TrueType tables   (ttload.c)    */
+FT_TRACE_DEF( ttpost )    /* PS table processing     (ttpost.c)   */
+FT_TRACE_DEF( ttsbit )    /* TrueType sbit handling  (ttsbit.c)   */
+
+/* TrueType driver components */
+FT_TRACE_DEF( ttdriver )  /* TT font driver          (ttdriver.c) */
+FT_TRACE_DEF( ttgload )   /* TT glyph loader         (ttgload.c)  */
+FT_TRACE_DEF( ttinterp )  /* bytecode interpreter    (ttinterp.c) */
+FT_TRACE_DEF( ttobjs )    /* TT objects manager      (ttobjs.c)   */
+FT_TRACE_DEF( ttpload )   /* TT data/program loader  (ttpload.c)  */
+
+/* Type 1 driver components */
+FT_TRACE_DEF( t1driver )
+FT_TRACE_DEF( t1gload )
+FT_TRACE_DEF( t1hint )
+FT_TRACE_DEF( t1load )
+FT_TRACE_DEF( t1objs )
+FT_TRACE_DEF( t1parse )
+
+/* PostScript helper module `psaux' */
+FT_TRACE_DEF( t1decode )
+FT_TRACE_DEF( psobjs )
+
+/* PostScript hinting module `pshinter' */
+FT_TRACE_DEF( pshrec )
+FT_TRACE_DEF( pshalgo1 )
+FT_TRACE_DEF( pshalgo2 )
+
+/* Type 2 driver components */
+FT_TRACE_DEF( cffdriver )
+FT_TRACE_DEF( cffgload )
+FT_TRACE_DEF( cffload )
+FT_TRACE_DEF( cffobjs )
+FT_TRACE_DEF( cffparse )
+
+/* CID driver components */
+FT_TRACE_DEF( cidafm )
+FT_TRACE_DEF( ciddriver )
+FT_TRACE_DEF( cidgload )
+FT_TRACE_DEF( cidload )
+FT_TRACE_DEF( cidobjs )
+FT_TRACE_DEF( cidparse )
+
+/* Windows fonts component */
+FT_TRACE_DEF( winfnt )
+
+/* PCF fonts component */
+FT_TRACE_DEF( pcfdriver )
+FT_TRACE_DEF( pcfread )
diff --git a/include/freetype/internal/internal.h b/include/freetype/internal/internal.h
index cad39bb..32a06f9 100644
--- a/include/freetype/internal/internal.h
+++ b/include/freetype/internal/internal.h
@@ -32,6 +32,7 @@
 #define FT_INTERNAL_CALC_H                <freetype/internal/ftcalc.h>
 #define FT_INTERNAL_DRIVER_H              <freetype/internal/ftdriver.h>
 #define FT_INTERNAL_EXTEND_H              <freetype/internal/ftextend.h>
+#define FT_INTERNAL_TRACE_H               <freetype/internal/fttrace.h>
 
 #define FT_INTERNAL_SFNT_H                <freetype/internal/sfnt.h>
 
diff --git a/src/base/Jamfile b/src/base/Jamfile
index a310914..5c2f5a6 100644
--- a/src/base/Jamfile
+++ b/src/base/Jamfile
@@ -10,7 +10,7 @@ SubDirHdrs  [ FT2_SubDir  src base ] ;
 
   if $(FT2_MULTI)
   {
-    _sources = ftcalc ftextend ftlist ftobjs ftstream ftoutln ftnames fttrigon
+    _sources = ftcalc ftlist ftobjs ftstream ftoutln ftnames fttrigon
                ftdbgmem ;
   }
   else
diff --git a/src/base/ftdebug.c b/src/base/ftdebug.c
index 6a3fc49..ea4033a 100644
--- a/src/base/ftdebug.c
+++ b/src/base/ftdebug.c
@@ -45,12 +45,7 @@
 #include FT_INTERNAL_DEBUG_H
 
 
-#ifdef FT_DEBUG_LEVEL_TRACE
-  char  ft_trace_levels[trace_max];
-#endif
-
-
-#if defined( FT_DEBUG_LEVEL_ERROR ) || defined( FT_DEBUG_LEVEL_TRACE )
+#if defined( FT_DEBUG_LEVEL_ERROR )
 
 
 #include <stdarg.h>
@@ -83,36 +78,123 @@
     exit( EXIT_FAILURE );
   }
 
+#endif /* FT_DEBUG_LEVEL_ERROR */
+
+
 
 #ifdef FT_DEBUG_LEVEL_TRACE
 
-  FT_EXPORT_DEF( void )
-  FT_SetTraceLevel( FT_Trace  component,
-                    char      level )
+  /* array of trace levels, initialized to 0 */
+  int  ft_trace_levels[ trace_count ];
+
+ /* define array of trace toggle names */
+#define  FT_TRACE_DEF(x)   #x ,
+
+  static const char*  ft_trace_toggles[ trace_count+1 ] =
+  { 
+#include FT_INTERNAL_TRACE_H
+    NULL
+  };
+
+#undef FT_TRACE_DEF
+
+
+
+ /************************************************************************
+  *
+  *  initialize the tracing sub-system, this is done by retrieving the
+  *  value of the "FT2_DEBUG" environment variable. It must be a list of
+  *  toggles, separated by spaces, ';' or ':' for example:
+  *
+  *    "any=3 memory=6 stream=5"
+  *
+  *  will request that all levels be set to 3, except the trace level for
+  *  the memory and stream components which are respectively set to 6 and 5
+  *
+  *  see the file <freetype/internal/fttrace.h> for details of the available
+  *  toggle names.
+  *
+  *  the level is between 0 and 6, where 0 is quiet (except in important
+  *  runtime errors), and 6 is _very_ verbose
+  */
+
+  FT_BASE_DEF( void )
+  ft_debug_init( void )
   {
-    if ( component >= trace_max )
-      return;
-
-    /* if component is `trace_any', change _all_ levels at once */
-    if ( component == trace_any )
+    const char*  ft2_debug = getenv( "FT2_DEBUG" );
+    
+    if ( ft2_debug )
     {
-      int  n;
-
-
-      for ( n = trace_any; n < trace_max; n++ )
-        ft_trace_levels[n] = level;
+      const char*  p = ft2_debug;
+      const char*  q;
+      
+      for ( ; *p; p++ )
+      {
+        /* skip leading whitespace and separators */
+        if ( *p == ' ' || *p == '\t' || *p == ':' || *p == ';' || *p == '=' )
+          continue;
+          
+        /* read toggle name, followed by '=' */
+        q = p;
+        while ( *p && *p != '=' )
+          p++;
+          
+        if ( *p == '=' && p > q )
+        {
+          int  n, i, len = p - q;
+          int  level = -1, found = -1;
+          
+          for ( n = 0; n < trace_count; n++ )
+          {
+            const char*  toggle = ft_trace_toggles[n];
+            
+            for ( i = 0; i < len; i++ )
+            {
+              if ( toggle[i] != q[i] )
+                break;
+            }
+            
+            if ( i == len && toggle[i] == 0 )
+            {
+              found = n;
+              break;
+            }
+          }
+          
+          /* read level */
+          p++;
+          if ( *p )
+          {
+            level = *p++ - '0';
+            if ( level < 0 || level > 6 )
+              level = -1;
+          }
+          
+          if ( found >= 0 && level >= 0 )
+          {
+            if ( found == trace_any )
+            {
+              /* special case for "any" */
+              for ( n = 0; n < trace_count; n++ )
+                ft_trace_levels[n] = level;
+            }
+            else
+              ft_trace_levels[ found ] = level;
+          }
+        }
+      }
     }
-    else        /* otherwise, only change individual component */
-      ft_trace_levels[component] = level;
   }
 
-#endif /* FT_DEBUG_LEVEL_TRACE */
-
-#endif /* FT_DEBUG_LEVEL_TRACE || FT_DEBUG_LEVEL_ERROR */
+#else  /* !FT_DEBUG_LEVEL_TRACE */
 
+  FT_BASE_DEF( void )
+  ft_debut_init( void )
+  {
+    /* nothing */
+  }
 
-  /* ANSI C doesn't allow empty files, so we insert a dummy symbol */
-  extern const int  ft_debug_dummy;
+#endif /* !FT_DEBUG_LEVEL_TRACE */
 
 
 /* END */
diff --git a/src/base/ftextend.c b/src/base/ftextend.c
deleted file mode 100644
index cafb284..0000000
--- a/src/base/ftextend.c
+++ /dev/null
@@ -1,302 +0,0 @@
-/***************************************************************************/
-/*                                                                         */
-/*  ftextend.c                                                             */
-/*                                                                         */
-/*    FreeType extensions implementation (body).                           */
-/*                                                                         */
-/*  Copyright 1996-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 is an updated version of the extension component, now located   */
-  /*  in the main library's source directory.  It allows the dynamic       */
-  /*  registration/use of various face object extensions through a simple  */
-  /*  API.                                                                 */
-  /*                                                                       */
-  /*************************************************************************/
-
-
-#include <ft2build.h>
-#include FT_INTERNAL_EXTEND_H
-#include FT_INTERNAL_DEBUG_H
-
-
-  /*************************************************************************/
-  /*                                                                       */
-  /* The macro FT_COMPONENT is used in trace mode.  It is an implicit      */
-  /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log  */
-  /* messages during execution.                                            */
-  /*                                                                       */
-#undef  FT_COMPONENT
-#define FT_COMPONENT  trace_extend
-
-
-  typedef struct  FT_Extension_Registry_
-  {
-    FT_Int              num_extensions;
-    FT_Long             cur_offset;
-    FT_Extension_Class  classes[FT_MAX_EXTENSIONS];
-
-  } FT_Extension_Registry;
-
-
-  /*************************************************************************/
-  /*                                                                       */
-  /* <Function>                                                            */
-  /*    FT_Init_Extensions                                                 */
-  /*                                                                       */
-  /* <Description>                                                         */
-  /*    Initializes the extension component.                               */
-  /*                                                                       */
-  /* <InOut>                                                               */
-  /*    driver :: A handle to the driver object.                           */
-  /*                                                                       */
-  /* <Return>                                                              */
-  /*    FreeType error code.  0 means success.                             */
-  /*                                                                       */
-  FT_LOCAL_DEF FT_Error
-  FT_Init_Extensions( FT_Driver  driver )
-  {
-    FT_Error                error;
-    FT_Memory               memory;
-    FT_Extension_Registry*  registry;
-
-
-    memory = driver->root.library->memory;
-    if ( ALLOC( registry, sizeof ( *registry ) ) )
-      return error;
-
-    registry->num_extensions = 0;
-    registry->cur_offset     = 0;
-    driver->extensions       = registry;
-
-    FT_TRACE2(( "FT_Init_Extensions: success\n" ));
-
-    return FT_Err_Ok;
-  }
-
-
-  /*************************************************************************/
-  /*                                                                       */
-  /* <Function>                                                            */
-  /*    FT_Done_Extensions                                                 */
-  /*                                                                       */
-  /* <Description>                                                         */
-  /*    Finalizes the extension component.                                 */
-  /*                                                                       */
-  /* <InOut>                                                               */
-  /*    driver :: A handle to the driver object.                           */
-  /*                                                                       */
-  /* <Return>                                                              */
-  /*    FreeType error code.  0 means success.                             */
-  /*                                                                       */
-  FT_LOCAL_DEF FT_Error
-  FT_Done_Extensions( FT_Driver  driver )
-  {
-    FT_Memory  memory = driver->root.memory;
-
-
-    FREE( driver->extensions );
-    return FT_Err_Ok;
-  }
-
-
-  /* documentation is in ftextend.h */
-
-  FT_EXPORT_DEF( FT_Error )
-  FT_Register_Extension( FT_Driver            driver,
-                         FT_Extension_Class*  clazz )
-  {
-    FT_Extension_Registry*  registry;
-
-
-    if ( !driver )
-      return FT_Err_Invalid_Driver_Handle;
-
-    if ( !clazz )
-      return FT_Err_Invalid_Argument;
-
-    registry = (FT_Extension_Registry*)driver->extensions;
-    if ( registry )
-    {
-      FT_Int               n   = registry->num_extensions;
-      FT_Extension_Class*  cur = registry->classes + n;
-
-
-      if ( n >= FT_MAX_EXTENSIONS )
-        return FT_Err_Too_Many_Extensions;
-
-      *cur = *clazz;
-
-      cur->offset  = registry->cur_offset;
-
-      registry->num_extensions++;
-      registry->cur_offset +=
-        ( cur->size + FT_ALIGNMENT - 1 ) & -FT_ALIGNMENT;
-
-      FT_TRACE1(( "FT_Register_Extension: `%s' successfully registered\n",
-                  cur->id ));
-    }
-
-    return FT_Err_Ok;
-  }
-
-
-  /* documentation is in ftextend.h */
-
-  FT_EXPORT_DEF( void* )
-  FT_Get_Extension( FT_Face      face,
-                    const char*  extension_id,
-                    void**       extension_interface )
-  {
-    FT_Extension_Registry*  registry;
-
-
-    if ( !face || !extension_id || !extension_interface )
-      return 0;
-
-    registry = (FT_Extension_Registry*)face->driver->extensions;
-    if ( registry && face->extensions )
-    {
-      FT_Extension_Class*  cur   = registry->classes;
-      FT_Extension_Class*  limit = cur + registry->num_extensions;
-
-
-      for ( ; cur < limit; cur++ )
-        if ( strcmp( cur->id, extension_id ) == 0 )
-        {
-          *extension_interface = cur->interface;
-
-          FT_TRACE1(( "FT_Get_Extension: got `%s'\n", extension_id ));
-
-          return (void*)((char*)face->extensions + cur->offset);
-        }
-    }
-
-    /* could not find the extension id */
-
-    FT_ERROR(( "FT_Get_Extension: couldn't find `%s'\n", extension_id ));
-
-    *extension_interface = 0;
-
-    return 0;
-  }
-
-
-  /*************************************************************************/
-  /*                                                                       */
-  /* <Function>                                                            */
-  /*    FT_Destroy_Extensions                                              */
-  /*                                                                       */
-  /* <Description>                                                         */
-  /*    Destroys all extensions within a face object.                      */
-  /*                                                                       */
-  /* <InOut>                                                               */
-  /*    face :: A handle to the face object.                               */
-  /*                                                                       */
-  /* <Return>                                                              */
-  /*    FreeType error code.  0 means success.                             */
-  /*                                                                       */
-  /* <Note>                                                                */
-  /*    Called by the face object destructor.                              */
-  /*                                                                       */
-  FT_LOCAL_DEF FT_Error
-  FT_Destroy_Extensions( FT_Face  face )
-  {
-    FT_Extension_Registry*  registry;
-    FT_Memory               memory;
-
-
-    registry = (FT_Extension_Registry*)face->driver->extensions;
-    if ( registry && face->extensions )
-    {
-      FT_Extension_Class*  cur   = registry->classes;
-      FT_Extension_Class*  limit = cur + registry->num_extensions;
-
-
-      for ( ; cur < limit; cur++ )
-      {
-        char*  ext = (char*)face->extensions + cur->offset;
-
-        if ( cur->finalize )
-          cur->finalize( ext, face );
-      }
-
-      memory = face->driver->root.memory;
-      FREE( face->extensions );
-    }
-
-    return FT_Err_Ok;
-  }
-
-
-  /*************************************************************************/
-  /*                                                                       */
-  /* <Function>                                                            */
-  /*    FT_Create_Extensions                                               */
-  /*                                                                       */
-  /* <Description>                                                         */
-  /*    Creates an extension object within a face object for all           */
-  /*    registered extensions.                                             */
-  /*                                                                       */
-  /* <InOut>                                                               */
-  /*    face :: A handle to the face object.                               */
-  /*                                                                       */
-  /* <Return>                                                              */
-  /*    FreeType error code.  0 means success.                             */
-  /*                                                                       */
-  /* <Note>                                                                */
-  /*    Called by the face object constructor.                             */
-  /*                                                                       */
-  FT_LOCAL_DEF FT_Error
-  FT_Create_Extensions( FT_Face  face )
-  {
-    FT_Extension_Registry*  registry;
-    FT_Memory               memory;
-    FT_Error                error;
-
-
-    face->extensions = 0;
-
-    /* load extensions registry; exit successfully if none is there */
-
-    registry = (FT_Extension_Registry*)face->driver->extensions;
-    if ( !registry )
-      return FT_Err_Ok;
-
-    memory = face->driver->root.memory;
-    if ( ALLOC( face->extensions, registry->cur_offset ) )
-      return error;
-
-    {
-      FT_Extension_Class*  cur   = registry->classes;
-      FT_Extension_Class*  limit = cur + registry->num_extensions;
-
-
-      for ( ; cur < limit; cur++ )
-      {
-        char*  ext = (char*)face->extensions + cur->offset;
-
-        if ( cur->init )
-        {
-          error = cur->init( ext, face );
-          if ( error )
-            break;
-        }
-      }
-    }
-
-    return error;
-  }
-
-
-/* END */
diff --git a/src/base/ftobjs.c b/src/base/ftobjs.c
index 21a6be0..1b78c9d 100644
--- a/src/base/ftobjs.c
+++ b/src/base/ftobjs.c
@@ -57,7 +57,7 @@
             FT_Long    size,
             void*     *P )
   {
-    FT_Assert( P != 0 );
+    FT_ASSERT( P != 0 );
 
     if ( size > 0 )
     {
@@ -94,7 +94,7 @@
     void*  Q;
 
 
-    FT_Assert( P != 0 );
+    FT_ASSERT( P != 0 );
 
     /* if the original pointer is NULL, call FT_Alloc() */
     if ( !*P )
diff --git a/src/base/ftstream.c b/src/base/ftstream.c
index 96683a2..3fc40f9 100644
--- a/src/base/ftstream.c
+++ b/src/base/ftstream.c
@@ -201,7 +201,7 @@
 
 
     /* check for nested frame access */
-    FT_Assert( stream && stream->cursor == 0 );
+    FT_ASSERT( stream && stream->cursor == 0 );
 
     if ( stream->read )
     {
@@ -265,7 +265,7 @@
     /*  gracefully; however, stream.cursor is really set to 0 by the      */
     /*  FT_Access_Frame() call, and this is not an error.                 */
     /*                                                                    */
-    FT_Assert( stream );
+    FT_ASSERT( stream );
 
     if ( stream->read )
     {
@@ -285,7 +285,7 @@
     FT_Char  result;
 
 
-    FT_Assert( stream && stream->cursor );
+    FT_ASSERT( stream && stream->cursor );
 
     result = 0;
     if ( stream->cursor < stream->limit )
@@ -302,7 +302,7 @@
     FT_Short  result;
 
 
-    FT_Assert( stream && stream->cursor );
+    FT_ASSERT( stream && stream->cursor );
 
     result         = 0;
     p              = stream->cursor;
@@ -321,7 +321,7 @@
     FT_Short  result;
 
 
-    FT_Assert( stream && stream->cursor );
+    FT_ASSERT( stream && stream->cursor );
 
     result         = 0;
     p              = stream->cursor;
@@ -340,7 +340,7 @@
     FT_Long   result;
 
 
-    FT_Assert( stream && stream->cursor );
+    FT_ASSERT( stream && stream->cursor );
 
     result         = 0;
     p              = stream->cursor;
@@ -358,7 +358,7 @@
     FT_Long   result;
 
 
-    FT_Assert( stream && stream->cursor );
+    FT_ASSERT( stream && stream->cursor );
 
     result         = 0;
     p              = stream->cursor;
@@ -376,7 +376,7 @@
     FT_Long   result;
 
 
-    FT_Assert( stream && stream->cursor );
+    FT_ASSERT( stream && stream->cursor );
 
     result         = 0;
     p              = stream->cursor;
@@ -394,7 +394,7 @@
     FT_Byte  result = 0;
 
 
-    FT_Assert( stream );
+    FT_ASSERT( stream );
 
     *error = FT_Err_Ok;
 
@@ -433,7 +433,7 @@
     FT_Short  result = 0;
 
 
-    FT_Assert( stream );
+    FT_ASSERT( stream );
 
     *error = FT_Err_Ok;
 
@@ -480,7 +480,7 @@
     FT_Short  result = 0;
 
 
-    FT_Assert( stream );
+    FT_ASSERT( stream );
 
     *error = FT_Err_Ok;
 
@@ -527,7 +527,7 @@
     FT_Long   result = 0;
 
 
-    FT_Assert( stream );
+    FT_ASSERT( stream );
 
     *error = FT_Err_Ok;
 
@@ -574,7 +574,7 @@
     FT_Long   result = 0;
 
 
-    FT_Assert( stream );
+    FT_ASSERT( stream );
 
     *error = FT_Err_Ok;
 
@@ -621,7 +621,7 @@
     FT_Long   result = 0;
 
 
-    FT_Assert( stream );
+    FT_ASSERT( stream );
 
     *error = FT_Err_Ok;
 
diff --git a/src/base/rules.mk b/src/base/rules.mk
index 8c3bbd4..2c6df87 100644
--- a/src/base/rules.mk
+++ b/src/base/rules.mk
@@ -34,7 +34,6 @@ BASE_COMPILE := $(FT_COMPILE) $I$(SRC_)base
 #
 BASE_SRC := $(BASE_)ftcalc.c   \
             $(BASE_)fttrigon.c \
-            $(BASE_)ftextend.c \
             $(BASE_)ftlist.c   \
             $(BASE_)ftobjs.c   \
             $(BASE_)ftstream.c \
diff --git a/src/pshinter/pshalgo2.c b/src/pshinter/pshalgo2.c
index a1d874c..bbc5265 100644
--- a/src/pshinter/pshalgo2.c
+++ b/src/pshinter/pshalgo2.c
@@ -523,7 +523,7 @@
 #include <stdio.h>
 
   static void
-  print_zone( PSH2_Zone  zone )
+  psh2_print_zone( PSH2_Zone  zone )
   {
     printf( "zone [scale,delta,min,max] = [%.3f,%.3f,%d,%d]\n",
              zone->scale/65536.0,
@@ -534,7 +534,7 @@
 
 #else
 
-#define print_zone( x )   do { } while ( 0 )
+#define psh2_print_zone( x )   do { } while ( 0 )
 
 #endif
 
@@ -576,7 +576,7 @@
     zone->min   = PSH2_ZONE_MIN;
     zone->max   = hint->org_pos;
 
-    print_zone( zone );
+    psh2_print_zone( zone );
 
     zone++;
 
@@ -597,7 +597,7 @@
         zone->max   = hint->org_pos + hint->org_len;
         zone->delta = hint->cur_pos - FT_MulFix( zone->min, scale2 );
 
-        print_zone( zone );
+        psh2_print_zone( zone );
 
         zone++;
       }
@@ -620,7 +620,7 @@
       zone->delta = hint->cur_pos + hint->cur_len -
                     FT_MulFix( zone->min, scale2 );
 
-      print_zone( zone );
+      psh2_print_zone( zone );
 
       zone++;
 
@@ -634,7 +634,7 @@
     zone->delta = hint->cur_pos + hint->cur_len -
                   FT_MulFix( zone->min, scale );
 
-    print_zone( zone );
+    psh2_print_zone( zone );
 
     zone++;
 
diff --git a/src/smooth/ftgrays.c b/src/smooth/ftgrays.c
index e6d361b..cc47c18 100644
--- a/src/smooth/ftgrays.c
+++ b/src/smooth/ftgrays.c
@@ -96,7 +96,7 @@
   /* messages during execution.                                            */
   /*                                                                       */
 #undef  FT_COMPONENT
-#define FT_COMPONENT  trace_aaraster
+#define FT_COMPONENT  trace_smooth
 
 
 #define ErrRaster_MemoryOverflow   -4