Commit d15bc0d13a163995e1ca11925349bd64d1c33617

David Turner 2002-04-12T09:31:48

* README.UNX: updated the Unix-specific quick-compilation guide to warn about the GNU Make requirement at compile time.. * include/freetype/config/ftstdlib.h, include/freetype/config/ftconfig.h, include/freetype/config/ftheader.h, include/freetype/internal/ftmemory.h, include/freetype/internal/ftobjs.h, src/autohint/ahoptim.c, src/base/ftdbgmem.c, src/base/ftdebug.c, src/base/ftmac.c, src/base/ftobjs.c, src/base/ftsystem.c, src/cache/ftcimage.c, src/cache/ftcsbits.c, src/cff/cffdriver.c, src/cff/cffload.c, src/cff/cffobjs.c, src/cid/cidload.c, src/cid/cidparse.c, src/cid/cidriver.c, src/pcf/pcfdriver.c, src/pcf/pcfread.c, src/psaux/t1cmap.c, src/psaux/t1decode.c, src/pshinter/pshalgo1.c, src/pshinter/pshalgo2.c, src/pshinter/pshrec.c, src/psnames/psmodule.c, src/raster/ftraster.c, src/sfnt/sfdriver.c, src/sfnt/ttload.c, src/sfnt/ttpost.c, src/smooth/ftgrays.c, src/type1/t1afm.c, src/type1/t1driver.c, src/type1/t1gload.c, src/type1/t1load.c, src/type1/t1objs.c, src/type1/t1parse.c: added the new configuration file "ftstdlib.h" used to define aliases for all ISO C library functions used by the engine (e.g. strlen, qsort, setjmp, etc...) this eases the porting of FreeType 2 to exotic environments like XFree86 modules/extensions.. also removed many #include <string.h>, #include <stdlib.h>, etc... from the engine's sources where they're not needed..

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
diff --git a/ChangeLog b/ChangeLog
index d7916ff..1c1ddbd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,72 @@
+2002-04-12  David Turner  <david@freetype.org>
+
+        * README.UNX: updated the Unix-specific quick-compilation guide to
+          warn about the GNU Make requirement at compile time..
+
+        * include/freetype/config/ftstdlib.h,
+          include/freetype/config/ftconfig.h,
+          include/freetype/config/ftheader.h,
+          include/freetype/internal/ftmemory.h,
+          include/freetype/internal/ftobjs.h,
+          
+          src/autohint/ahoptim.c,
+          
+          src/base/ftdbgmem.c, src/base/ftdebug.c,
+          src/base/ftmac.c,    src/base/ftobjs.c,
+          src/base/ftsystem.c,
+
+          src/cache/ftcimage.c, src/cache/ftcsbits.c,
+          
+          src/cff/cffdriver.c, src/cff/cffload.c, src/cff/cffobjs.c,
+          
+          src/cid/cidload.c, src/cid/cidparse.c, src/cid/cidriver.c,
+          
+          src/pcf/pcfdriver.c, src/pcf/pcfread.c,
+          
+          src/psaux/t1cmap.c, src/psaux/t1decode.c,
+          
+          src/pshinter/pshalgo1.c, src/pshinter/pshalgo2.c,
+          src/pshinter/pshrec.c,
+          
+          src/psnames/psmodule.c,
+          
+          src/raster/ftraster.c,
+          
+          src/sfnt/sfdriver.c, src/sfnt/ttload.c, src/sfnt/ttpost.c,
+          
+          src/smooth/ftgrays.c,
+          
+          src/type1/t1afm.c,  src/type1/t1driver.c, src/type1/t1gload.c,
+          src/type1/t1load.c, src/type1/t1objs.c,   src/type1/t1parse.c:
+          
+            added the new configuration file "ftstdlib.h" used to define
+            aliases for all ISO C library functions used by the engine
+            (e.g. strlen, qsort, setjmp, etc...)
+            
+            this eases the porting of FreeType 2 to exotic environments like
+            XFree86 modules/extensions..
+
+            also removed many #include <string.h>, #include <stdlib.h>, etc...
+            from the engine's sources where they're not needed..
+
+
+2002-04-12  Vincent Caron  <v.caron@zerodeux.net>
+
+        * configure, builds/detect.mk: updated the build system to print
+          a warning message in case GNU Make isn't used to build the library.
+          Very nice !
+
+
 2002-04-11  David Turner  <david@freetype.org>
 
-	* README, docs/CHANGES: Updates for the 2.1.0 release.
+        * README, docs/CHANGES, Jamfile.in: updating for the 2.1.0 release
+
+        * docs/FTL.txt: updated license text to provide a preffered disclaimer
+          and adjust copyright dates/extents
+
+        * include/freetype/cache/ftcglyph.h: removing obsolete (and confusing
+          comment)
+
 	* Jamfile.in: New file.
 
 2002-04-11  Maxim Shemanarev  <mcseemagg@yahoo.com>
diff --git a/README.UNX b/README.UNX
index 838ee8a..2ca23fe 100644
--- a/README.UNX
+++ b/README.UNX
@@ -8,8 +8,8 @@ SPECIAL NOTE FOR UNIX USERS
 
 
 
-  I. Enable the TrueType bytecode hinter if you need it
-  -----------------------------------------------------
+  I. Enable the TrueType bytecode hinter if you need it:
+  ------------------------------------------------------
 
     The  TrueType  bytecode  interpreter  is disabled  in  all  public
     releases  of  the  FreeType  packages  for  patents  reasons  (see
@@ -34,8 +34,8 @@ SPECIAL NOTE FOR UNIX USERS
 
 
 
-  II. Determine the correct installation path
-  -------------------------------------------
+  II. Determine the correct installation path:
+  --------------------------------------------
   
     By  default,  the  source  package  will install  the  library  in
     "/usr/local".   However, many Unix  distributions now  install the
@@ -48,10 +48,33 @@ SPECIAL NOTE FOR UNIX USERS
        
     on the command line.  This  should return the installation path to
     use below  (e.g. "/usr"  or "/usr/local").  Otherwise,  simply use
-    "/usr".
+    "/usr" (or what you think is adequate for your installation).
 
-    Then, to build and install the library, type:
+
+
+  III. Ensure that you're using GNU Make:
+  ---------------------------------------
+
+    The FreeType build system _exclusively_ works with GNU Make. You will
+    not be able to compile the library with the following instructions with
+    any other alternative (including BSD Make !!).
+
+    Trying to compile the library with a different Make tool will print a
+    message like:
     
+      "Sorry, GNU make is required to build FreeType2."
+      
+    and the build will be aborted. If this happens, install GNU Make on your
+    system, and use the GNUMAKE environment variable to name it.
+    
+
+
+  IV. Build and install the library:
+  ----------------------------------
+  
+    The following should work on all Unix systems where the 'make' command
+    invokes GNU Make:
+  
       ./configure --prefix=<yourprefix>
       make
       make install           (as root)
@@ -60,9 +83,21 @@ SPECIAL NOTE FOR UNIX USERS
     the "freetype-config" command.
 
 
+    When using a different command to invoke GNU Make, use the GNUMAKE
+    variable. For example, if 'gmake' is the command to use on your system,
+    do something like:
+    
+       GNUMAKE=gmake  ./configure  --prefix=<yourprefix>
+       gmake
+       gmake install  (as root)
+
+
+    If this still doesn't work, read the detailed compilation procedure
+    available in the file "docs/BUILD" for troubleshooting..
+
 
-  III. Take care of XFree86 version 4
-  -----------------------------------
+  V. Take care of XFree86 version 4:
+  ----------------------------------
   
     Certain recent Linux distributions will install _several_ versions
     of FreeType on your system.   For example, on a fresh Mandrake 8.1
diff --git a/builds/amiga/src/base/ftdebug.c b/builds/amiga/src/base/ftdebug.c
index 3e16337..80fec06 100644
--- a/builds/amiga/src/base/ftdebug.c
+++ b/builds/amiga/src/base/ftdebug.c
@@ -38,7 +38,7 @@ extern void __stdargs KVPrintF( const char *formatString, const void *values );
   /*                                                                       */
   /* - release mode:                                                       */
   /*                                                                       */
-  /*   No error message is sent or generated.  The code is free from any   */
+  /*   No error message is sent or generated.  The code is ft_free from any   */
   /*   debugging parts.                                                    */
   /*                                                                       */
   /*************************************************************************/
@@ -58,7 +58,6 @@ extern void __stdargs KVPrintF( const char *formatString, const void *values );
 
 #include <stdarg.h>
 #include <stdlib.h>
-#include <string.h>
 
 
   FT_EXPORT_DEF( void )
diff --git a/builds/detect.mk b/builds/detect.mk
index fbdbee5..99467a9 100644
--- a/builds/detect.mk
+++ b/builds/detect.mk
@@ -127,7 +127,7 @@ std_setup:
 	@echo "If this does not correspond to your system or settings please remove the file"
 	@echo "\`$(CONFIG_MK)' from this directory then read the INSTALL file for help."
 	@echo ""
-	@echo "Otherwise, simply type \`make' again to build the library."
+	@echo "Otherwise, simply type \`$(MAKE)' again to build the library."
 	@echo ""
 	@$(COPY) $(CONFIG_RULES) $(CONFIG_MK)
 
diff --git a/configure b/configure
index 366c8bd..bd4c523 100644
--- a/configure
+++ b/configure
@@ -8,4 +8,15 @@
 #   Jamfile
 #   install
 #
-CFG="$@" make setup unix
+
+if [ "x$GNUMAKE" = x ]; then
+  GNUMAKE=make
+fi
+
+if [ `$GNUMAKE -v 2>/dev/null|grep -ic gnu` -eq 0 ]; then
+  echo "Sorry, GNU make is required to build FreeType2." >&2
+  echo "Please try \`GNUMAKE=<GNU make command name> $0'." >&2
+  exit 1
+fi
+
+CFG="$@" $GNUMAKE setup unix
diff --git a/include/freetype/config/ftconfig.h b/include/freetype/config/ftconfig.h
index c1c2f29..3e76bc9 100644
--- a/include/freetype/config/ftconfig.h
+++ b/include/freetype/config/ftconfig.h
@@ -41,7 +41,7 @@
 
 #include <ft2build.h>
 #include FT_CONFIG_OPTIONS_H
-
+#include FT_CONFIG_STANDARD_LIBRARY_H
 
 FT_BEGIN_HEADER
 
@@ -58,24 +58,21 @@ FT_BEGIN_HEADER
   /*************************************************************************/
 
 
-  /* We use <limits.h> values to know the sizes of the types.  */
-#include <limits.h>
-
   /* The number of bytes in an `int' type.  */
-#if   UINT_MAX == 0xFFFFFFFFUL
+#if   FT_UINT_MAX == 0xFFFFFFFFUL
 #define FT_SIZEOF_INT  4
-#elif UINT_MAX == 0xFFFFU
+#elif FT_UINT_MAX == 0xFFFFU
 #define FT_SIZEOF_INT  2
-#elif UINT_MAX > 0xFFFFFFFFU && UINT_MAX == 0xFFFFFFFFFFFFFFFFU
+#elif FT_UINT_MAX > 0xFFFFFFFFU && FT_UINT_MAX == 0xFFFFFFFFFFFFFFFFU
 #define FT_SIZEOF_INT  8
 #else
 #error "Unsupported number of bytes in `int' type!"
 #endif
 
   /* The number of bytes in a `long' type.  */
-#if   ULONG_MAX == 0xFFFFFFFFUL
+#if   FT_ULONG_MAX == 0xFFFFFFFFUL
 #define FT_SIZEOF_LONG  4
-#elif ULONG_MAX > 0xFFFFFFFFU && ULONG_MAX == 0xFFFFFFFFFFFFFFFFU
+#elif FT_ULONG_MAX > 0xFFFFFFFFU && FT_ULONG_MAX == 0xFFFFFFFFFFFFFFFFU
 #define FT_SIZEOF_LONG  8
 #else
 #error "Unsupported number of bytes in `long' type!"
diff --git a/include/freetype/config/ftheader.h b/include/freetype/config/ftheader.h
index 71f9a51..e43a9e6 100644
--- a/include/freetype/config/ftheader.h
+++ b/include/freetype/config/ftheader.h
@@ -111,6 +111,21 @@
   /*************************************************************************/
   /*                                                                       */
   /* @macro:                                                               */
+  /*    FT_CONFIG_STANDARD_LIBRARY_H                                       */
+  /*                                                                       */
+  /* @description:                                                         */
+  /*    A macro used in #include statements to name the file containing    */
+  /*    FreeType 2 configuration data.                                     */
+  /*                                                                       */
+#ifndef FT_CONFIG_STANDARD_LIBRARY_H
+#define FT_CONFIG_STANDARD_LIBRARY_H  <freetype/config/ftstdlib.h>
+#endif
+
+
+
+  /*************************************************************************/
+  /*                                                                       */
+  /* @macro:                                                               */
   /*    FT_CONFIG_OPTIONS_H                                                */
   /*                                                                       */
   /* @description:                                                         */
diff --git a/include/freetype/config/ftstdlib.h b/include/freetype/config/ftstdlib.h
new file mode 100644
index 0000000..28db872
--- /dev/null
+++ b/include/freetype/config/ftstdlib.h
@@ -0,0 +1,116 @@
+/***************************************************************************/
+/*                                                                         */
+/*  ftstdlib.h                                                             */
+/*                                                                         */
+/*    ANSI-specific configuration file                                     */
+/*                                                                         */
+/*  Copyright 1996-2001, 2002 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 group all #includes to the ANSI C library         */
+/*  that FreeType normally requires. It also defines macros to rename      */
+/*  the standard functions within the FT source code                       */
+/*                                                                         */
+/*  (You're free to provide alternative when working in exotic             */
+/*   runtime environments :-)                                              */
+/*                                                                         */
+/***************************************************************************/
+
+#ifndef __FT_STANDARD_LIBRARY_H__
+#define __FT_STANDARD_LIBRARY_H__
+
+
+/************************************************************************/
+/*                                                                      */
+/*                            integer limits                            */
+/*                                                                      */
+/*  UINT_MAX and ULONG_MAX are used to automatically compute the size   */
+/*  of 'int' and 'long' in bytes at compile-time. So far, this works    */
+/*  for all platforms the library has been tested on.                   */
+/*                                                                      */
+/*  Note that on the extremely rare platforms that do not provide       */
+/*  integer types that are _exactly_ 16 and 32 bits wide (e.g. some     */
+/*  old Crays where 'int' is 36 bits !!), we do not make any guarantee  */
+/*  about the correct behaviour of FT2 with all fonts..                 */
+/*                                                                      */
+/*  in these case, "ftconfig.h" will refuse to compile anyway with a    */
+/*  message like "couldn't find 32-bit type" or something similar       */
+/*  anyway..                                                            */
+/*                                                                      */
+/*                                                                      */
+/*  IMPORTANT NOTE: We do not define aliases for heap management and    */
+/*                  i/o routines (i.e. malloc/free/fopen/fread/...)     */
+/*                  since these functions should all be encapsulated    */
+/*                  by platform-specific implementations of             */
+/*                  "ftsystem.c" anyway !!                              */
+/*                                                                      */
+/************************************************************************/
+
+#include <limits.h>
+#define  FT_UINT_MAX   UINT_MAX
+#define  FT_ULONG_MAX  ULONG_MAX
+
+
+/************************************************************************/
+/*                                                                      */
+/*                   character and string processing                    */
+/*                                                                      */
+/************************************************************************/
+
+#include <ctype.h>
+#define  ft_isalnum    isalnum
+#define  ft_isupper    isupper
+#define  ft_islower    islower
+
+
+#include <string.h>
+#define  ft_strlen     strlen
+#define  ft_strcmp     strcmp
+#define  ft_strncmp    strncmp
+#define  ft_memcpy     memcpy
+#define  ft_strcpy     strcpy
+#define  ft_strncpy    strncpy
+#define  ft_memset     memset
+#define  ft_memmove    memmove
+
+
+/************************************************************************/
+/*                                                                      */
+/*                               sorting                                */
+/*                                                                      */
+/************************************************************************/
+
+#include <stdlib.h>   /* for qsort() */
+#define  ft_qsort      qsort
+
+
+/************************************************************************/
+/*                                                                      */
+/*                           execution control                          */
+/*                                                                      */
+/************************************************************************/
+
+#include <setjmp.h>
+
+#define  ft_jmp_buf   jmp_buf   /* note: this cannot be a typedef since */
+                                /*       jmp_buf is defined as a macro  */
+                                /*       on certain platforms..         */
+
+#define  ft_setjmp   setjmp     /* same thing here */
+#define  ft_longjmp  longjmp    /*   "             */
+
+
+/* the following is only used for debugging purposes, i.e. when */
+/* FT_DEBUG_LEVEL_ERROR or FT_DEBUG_LEVEL_TRACE are defined     */
+/*                                                              */
+#include <stdarg.h>
+
+
+#endif /* __FT_STANDARD_LIBRARY_H__ */
diff --git a/include/freetype/internal/ftmemory.h b/include/freetype/internal/ftmemory.h
index 821d8c4..597b64d 100644
--- a/include/freetype/internal/ftmemory.h
+++ b/include/freetype/internal/ftmemory.h
@@ -172,15 +172,11 @@ FT_BEGIN_HEADER
            void**     P );
 
 
-  /* This `#include' is needed by the MEM_xxx() macros; it should be */
-  /* available on all platforms we know of.                          */
-#include <string.h>
+#define FT_MEM_SET( dest, byte, count )     ft_memset( dest, byte, count )
 
-#define FT_MEM_SET( dest, byte, count )     memset( dest, byte, count )
+#define FT_MEM_COPY( dest, source, count )  ft_memcpy( dest, source, count )
 
-#define FT_MEM_COPY( dest, source, count )  memcpy( dest, source, count )
-
-#define FT_MEM_MOVE( dest, source, count )  memmove( dest, source, count )
+#define FT_MEM_MOVE( dest, source, count )  ft_memmove( dest, source, count )
 
 
   /*************************************************************************/
diff --git a/include/freetype/internal/ftobjs.h b/include/freetype/internal/ftobjs.h
index 4f2cbad..796513d 100644
--- a/include/freetype/internal/ftobjs.h
+++ b/include/freetype/internal/ftobjs.h
@@ -132,7 +132,7 @@ FT_BEGIN_HEADER
     FT_ValidationLevel  level;  /* validation level                 */
     FT_Error            error;  /* error returned. 0 means success  */
 
-    jmp_buf             jump_buffer;  /* used for exception handling */
+    ft_jmp_buf             jump_buffer;  /* used for exception handling */
 
   } FT_ValidatorRec;
 
diff --git a/src/autohint/ahoptim.c b/src/autohint/ahoptim.c
index e99cd1d..6b4cdf0 100644
--- a/src/autohint/ahoptim.c
+++ b/src/autohint/ahoptim.c
@@ -61,7 +61,6 @@
 
 #include <stdarg.h>
 #include <stdlib.h>
-#include <string.h>
 
 #define FLOAT( x )  ( (float)( (x) / 64.0 ) )
 
diff --git a/src/base/ftdbgmem.c b/src/base/ftdbgmem.c
index 3768234..6ca02da 100644
--- a/src/base/ftdbgmem.c
+++ b/src/base/ftdbgmem.c
@@ -30,7 +30,6 @@
 
 #include <stdio.h>
 #include <stdlib.h>
-#include <string.h>
 
 
   typedef struct FT_MemNodeRec_*   FT_MemNode;
@@ -122,8 +121,6 @@
   };
 
 
-#include <stdarg.h>
-
 
   extern void
   ft_mem_debug_panic( const char*  fmt, ... )
@@ -547,7 +544,7 @@
         block, file_name, line_no );
 
     if ( node->size != cur_size )
-      ft_mem_debug_panic( "invalid realloc request for %p. cur_size is "
+      ft_mem_debug_panic( "invalid ft_realloc request for %p. cur_size is "
                           "%ld instead of %ld in (%s:%ld)",
                           block, cur_size, node->size, file_name, line_no );
 
@@ -555,7 +552,7 @@
     if ( new_block == NULL )
       return NULL;
 
-    memcpy( new_block, block, cur_size < new_size ? cur_size : new_size );
+    ft_memcpy( new_block, block, cur_size < new_size ? cur_size : new_size );
 
     table->file_name = file_name;
     table->line_no   = line_no;
diff --git a/src/base/ftdebug.c b/src/base/ftdebug.c
index 4263c67..f622e77 100644
--- a/src/base/ftdebug.c
+++ b/src/base/ftdebug.c
@@ -47,12 +47,6 @@
 
 #if defined( FT_DEBUG_LEVEL_ERROR )
 
-
-#include <stdarg.h>
-#include <stdlib.h>
-#include <string.h>
-
-
   FT_EXPORT_DEF( void )
   FT_Message( const char*  fmt, ... )
   {
diff --git a/src/base/ftmac.c b/src/base/ftmac.c
index 9d76b38..462220d 100644
--- a/src/base/ftmac.c
+++ b/src/base/ftmac.c
@@ -69,7 +69,6 @@
 #include <Files.h>
 #include <TextUtils.h>
 
-#include <ctype.h>  /* for isupper() and isalnum() */
 
 #include FT_MAC_H
 
@@ -90,7 +89,7 @@
     static char  cstr[256];
 
 
-    strncpy( cstr, (char*)pstr + 1, pstr[0] );
+    ft_strncpy( cstr, (char*)pstr + 1, pstr[0] );
     cstr[pstr[0]] = '\0';
     return cstr;
   }
@@ -106,11 +105,11 @@
 
 
     /* convert path to a pascal string */
-    path_len = strlen( pathname );
+    path_len = ft_strlen( pathname );
     if ( path_len > 255 )
       return -1;
     p_path[0] = (unsigned char)path_len;
-    strncpy( (char*)p_path + 1, pathname, path_len );
+    ft_strncpy( (char*)p_path + 1, pathname, path_len );
 
     if ( FSMakeFSSpec( 0, 0, p_path, spec ) != noErr )
       return -1;
@@ -172,7 +171,7 @@
           max = 3;
         count = 0;
       }
-      if ( count < max && ( isalnum( *q ) || *q == '_' ) )
+      if ( count < max && ( ft_isalnum( *q ) || *q == '_' ) )
       {
         *++p = *q;
         lwfn_file_name[0]++;
@@ -299,7 +298,7 @@
         p += names[i][0];
         p++;
       }
-      strcpy( ps_name, p2c_str( names[0] ) );  /* Family name */
+      ft_strcpy( ps_name, p2c_str( names[0] ) );  /* Family name */
 
       if ( style->indexes[0] > 1 )
       {
@@ -410,7 +409,7 @@
         }
       }
 
-      memcpy( p, *post_data + 2, post_size );
+      ft_memcpy( p, *post_data + 2, post_size );
       pfb_chunk_size += post_size;
       p += post_size;
       last_code = code;
@@ -595,7 +594,7 @@
     }
 
     HLock( sfnt );
-    memcpy( sfnt_data, *sfnt, sfnt_size );
+    ft_memcpy( sfnt_data, *sfnt, sfnt_size );
     HUnlock( sfnt );
     ReleaseResource( sfnt );
 
@@ -797,14 +796,14 @@
 
 
             /* build up a complete face name */
-            strcpy( fullName, famName );
+            ft_strcpy( fullName, famName );
             if ( style & bold )
               strcat( fullName, " Bold" );
             if ( style & italic )
               strcat( fullName, " Italic" );
 
             /* compare with the name we are looking for */
-            if ( strcmp( fullName, fontName ) == 0 )
+            if ( ft_strcmp( fullName, fontName ) == 0 )
             {
               /* found it! */
               the_font = font;
diff --git a/src/base/ftobjs.c b/src/base/ftobjs.c
index a12c13d..4e4a70b 100644
--- a/src/base/ftobjs.c
+++ b/src/base/ftobjs.c
@@ -25,9 +25,6 @@
 #include FT_TRUETYPE_TABLES_H
 #include FT_OUTLINE_H
 
-#include <string.h>     /* for strcmp() */
-#include <setjmp.h>     /* for setjmp() and longjmp() */
-
 
   FT_BASE_DEF( void )
   ft_validator_init( FT_Validator        valid,
@@ -2167,7 +2164,7 @@
     for ( nn = 0; nn < library->num_modules; nn++ )
     {
       module = library->modules[nn];
-      if ( strcmp( module->clazz->module_name, clazz->module_name ) == 0 )
+      if ( ft_strcmp( module->clazz->module_name, clazz->module_name ) == 0 )
       {
         /* this installed module has the same name, compare their versions */
         if ( clazz->module_version <= module->clazz->module_version )
@@ -2283,7 +2280,7 @@
     limit = cur + library->num_modules;
 
     for ( ; cur < limit; cur++ )
-      if ( strcmp( cur[0]->clazz->module_name, module_name ) == 0 )
+      if ( ft_strcmp( cur[0]->clazz->module_name, module_name ) == 0 )
       {
         result = cur[0];
         break;
diff --git a/src/base/ftsystem.c b/src/base/ftsystem.c
index 32d8172..2365de2 100644
--- a/src/base/ftsystem.c
+++ b/src/base/ftsystem.c
@@ -34,7 +34,6 @@
 
 #include <stdio.h>
 #include <stdlib.h>
-#include <string.h>
 
 
   /*************************************************************************/
diff --git a/src/cache/ftcimage.c b/src/cache/ftcimage.c
index 39f0aa0..86ecd09 100644
--- a/src/cache/ftcimage.c
+++ b/src/cache/ftcimage.c
@@ -24,9 +24,6 @@
 
 #include "ftcerror.h"
 
-#include <string.h>     /* memcmp() */
-#include <stdlib.h>     /* labs()   */
-
 
   /* the FT_Glyph image node type */
   typedef struct  FTC_ImageNodeRec_
diff --git a/src/cache/ftcsbits.c b/src/cache/ftcsbits.c
index 5d18ee1..82ab84c 100644
--- a/src/cache/ftcsbits.c
+++ b/src/cache/ftcsbits.c
@@ -26,8 +26,6 @@
 
 #include "ftcerror.h"
 
-#include <string.h>         /* memcmp() */
-
 
 #define FTC_SBIT_ITEMS_PER_NODE  16
 
diff --git a/src/cff/cffdrivr.c b/src/cff/cffdrivr.c
index 14aa245..7db9a69 100644
--- a/src/cff/cffdrivr.c
+++ b/src/cff/cffdrivr.c
@@ -257,7 +257,7 @@
 
     if ( buffer_max > 0 )
     {
-      FT_UInt  len = strlen( gname );
+      FT_UInt  len = ft_strlen( gname );
 
 
       if ( len >= buffer_max )
@@ -410,7 +410,7 @@
       else
         name = (FT_String *)psnames->adobe_std_strings( sid );
 
-      result = strcmp( glyph_name, name );
+      result = ft_strcmp( glyph_name, name );
 
       if ( sid > 390 )
         FT_FREE( name );
@@ -444,10 +444,10 @@
 
 #ifndef FT_CONFIG_OPTION_NO_GLYPH_NAMES
 
-    if ( strcmp( (const char*)interface, "glyph_name" ) == 0 )
+    if ( ft_strcmp( (const char*)interface, "glyph_name" ) == 0 )
       return (FT_Module_Interface)cff_get_glyph_name;
 
-    if ( strcmp( (const char*)interface, "name_index" ) == 0 )
+    if ( ft_strcmp( (const char*)interface, "name_index" ) == 0 )
       return (FT_Module_Interface)cff_get_name_index;
 
 #endif
diff --git a/src/cff/cffload.c b/src/cff/cffload.c
index 1e00789..2b81ebb 100644
--- a/src/cff/cffload.c
+++ b/src/cff/cffload.c
@@ -1332,7 +1332,7 @@
         FT_Error   error;
 
 
-        len = (FT_UInt)strlen( adobe_name );
+        len = (FT_UInt)ft_strlen( adobe_name );
         if ( !FT_ALLOC( name, len + 1 ) )
         {
           FT_MEM_COPY( name, adobe_name, len );
diff --git a/src/cff/cffobjs.c b/src/cff/cffobjs.c
index 5aabfbc..49b6736 100644
--- a/src/cff/cffobjs.c
+++ b/src/cff/cffobjs.c
@@ -31,8 +31,6 @@
 
 #include "cfferrs.h"
 
-#include <string.h>         /* for strlen() */
-
 
   /*************************************************************************/
   /*                                                                       */
@@ -231,7 +229,7 @@
   {
     FT_Error    error;
     FT_String*  result = 0;
-    FT_Int      len = (FT_Int)strlen( source );
+    FT_Int      len = (FT_Int)ft_strlen( source );
 
 
     if ( !FT_ALLOC( result, len + 1 ) )
diff --git a/src/cid/cidload.c b/src/cid/cidload.c
index 0a67a8a..3afdd16 100644
--- a/src/cid/cidload.c
+++ b/src/cid/cidload.c
@@ -26,9 +26,6 @@
 
 #include "ciderrs.h"
 
-#include <stdio.h>
-#include <ctype.h>  /* for isspace(), isalnum() */
-
 
   /*************************************************************************/
   /*                                                                       */
@@ -285,7 +282,7 @@
   static int
   is_alpha( char  c )
   {
-    return ( isalnum( (int)c ) ||
+    return ( ft_isalnum( (int)c ) ||
              c == '.'          ||
              c == '_'          );
   }
@@ -313,7 +310,7 @@
       {
         /* look for `%ADOBeginFontDict' */
         if ( *cur == '%' && cur + 20 < limit &&
-             strncmp( (char*)cur, "%ADOBeginFontDict", 17 ) == 0 )
+             ft_strncmp( (char*)cur, "%ADOBeginFontDict", 17 ) == 0 )
         {
           cur += 17;
 
@@ -352,7 +349,7 @@
                 break;
 
               if ( cur[0] == name[0]                          &&
-                   len == (FT_Int)strlen( (const char*)name ) )
+                   len == (FT_Int)ft_strlen( (const char*)name ) )
               {
                 FT_Int  n;
 
diff --git a/src/cid/cidparse.c b/src/cid/cidparse.c
index fde0041..821f2fe 100644
--- a/src/cid/cidparse.c
+++ b/src/cid/cidparse.c
@@ -26,8 +26,6 @@
 
 #include "ciderrs.h"
 
-#include <string.h>     /* for strncmp() */
-
 
   /*************************************************************************/
   /*                                                                       */
@@ -73,7 +71,7 @@
     if ( FT_FRAME_ENTER( 31 ) )
       goto Exit;
 
-    if ( strncmp( (char *)stream->cursor,
+    if ( ft_strncmp( (char *)stream->cursor,
                   "%!PS-Adobe-3.0 Resource-CIDFont", 31 ) )
     {
       FT_TRACE2(( "[not a valid CID-keyed font]\n" ));
@@ -108,7 +106,7 @@
       /* look for `StartData' */
       for ( p = buffer; p < limit; p++ )
       {
-        if ( p[0] == 'S' && strncmp( (char*)p, "StartData", 9 ) == 0 )
+        if ( p[0] == 'S' && ft_strncmp( (char*)p, "StartData", 9 ) == 0 )
         {
           /* save offset of binary data after `StartData' */
           offset = (FT_ULong)( top_position - ( limit - p ) + 10 );
diff --git a/src/cid/cidriver.c b/src/cid/cidriver.c
index a798a77..594c7a4 100644
--- a/src/cid/cidriver.c
+++ b/src/cid/cidriver.c
@@ -25,8 +25,6 @@
 
 #include "ciderrs.h"
 
-#include <string.h>         /* for strcmp() */
-
 
   /*************************************************************************/
   /*                                                                       */
@@ -58,7 +56,7 @@
     FT_UNUSED( driver );
     FT_UNUSED( interface );
 
-    if ( strcmp( (const char*)interface, "postscript_name" ) == 0 )
+    if ( ft_strcmp( (const char*)interface, "postscript_name" ) == 0 )
       return (FT_Module_Interface)cid_get_postscript_name;
 
     return 0;
@@ -175,7 +173,7 @@
 
 
             if ( gname && gname[0] == glyph_name[0] &&
-                 strcmp( gname, glyph_name ) == 0   )
+                 ft_strcmp( gname, glyph_name ) == 0   )
             {
               result = n;
               break;
@@ -275,7 +273,7 @@
 
 
             if ( gname && gname[0] == glyph_name[0] &&
-                 strcmp( gname, glyph_name ) == 0   )
+                 ft_strcmp( gname, glyph_name ) == 0   )
             {
               return charcode;
             }
diff --git a/src/pcf/pcfdriver.c b/src/pcf/pcfdriver.c
index 899d034..9fc0930 100644
--- a/src/pcf/pcfdriver.c
+++ b/src/pcf/pcfdriver.c
@@ -315,9 +315,9 @@ THE SOFTWARE.
       if ( ( charset_registry != NULL ) &&
            ( charset_encoding != NULL ) )
       {
-        if ( !strcmp( face->charset_registry, "ISO10646" ) ||
-           ( !strcmp( face->charset_registry, "ISO8859" ) &&
-             !strcmp( face->charset_encoding, "1" ) ) )
+        if ( !ft_strcmp( face->charset_registry, "ISO10646" ) ||
+           ( !ft_strcmp( face->charset_registry, "ISO8859" ) &&
+             !ft_strcmp( face->charset_encoding, "1" ) ) )
           unicode_charmap = 1;
       }
 
diff --git a/src/pcf/pcfread.c b/src/pcf/pcfread.c
index 923eb08..4c05233 100644
--- a/src/pcf/pcfread.c
+++ b/src/pcf/pcfread.c
@@ -36,8 +36,6 @@ THE SOFTWARE.
 
 #include "pcferror.h"
 
-#include <string.h>     /* strlen(), strcpy() */
-
 
   /*************************************************************************/
   /*                                                                       */
@@ -331,7 +329,7 @@ THE SOFTWARE.
 
     for ( i = 0 ; i < face->nprops && !found; i++ )
     {
-      if ( !strcmp( properties[i].name, prop ) )
+      if ( !ft_strcmp( properties[i].name, prop ) )
         found = 1;
     }
 
@@ -433,18 +431,18 @@ THE SOFTWARE.
     {
       /* XXX: make atom */
       if ( FT_NEW_ARRAY( properties[i].name,
-                         strlen( strings + props[i].name ) + 1 ) )
+                         ft_strlen( strings + props[i].name ) + 1 ) )
         goto Bail;
-      strcpy( properties[i].name,strings + props[i].name );
+      ft_strcpy( properties[i].name,strings + props[i].name );
 
       properties[i].isString = props[i].isString;
 
       if ( props[i].isString )
       {
         if ( FT_NEW_ARRAY( properties[i].value.atom,
-                           strlen( strings + props[i].value ) + 1 ) )
+                           ft_strlen( strings + props[i].value ) + 1 ) )
           goto Bail;
-        strcpy( properties[i].value.atom, strings + props[i].value );
+        ft_strcpy( properties[i].value.atom, strings + props[i].value );
       }
       else
         properties[i].value.integer = props[i].value;
@@ -952,12 +950,12 @@ THE SOFTWARE.
       {
         if ( prop->isString )
         {
-          int  l = strlen( prop->value.atom ) + 1;
+          int  l = ft_strlen( prop->value.atom ) + 1;
 
 
           if ( FT_NEW_ARRAY( root->family_name, l ) )
             goto Exit;
-          strcpy( root->family_name, prop->value.atom );
+          ft_strcpy( root->family_name, prop->value.atom );
         }
       }
       else
@@ -1025,15 +1023,15 @@ THE SOFTWARE.
                ( charset_encoding->isString ) )
           {
             if ( FT_NEW_ARRAY( face->charset_encoding,
-                               strlen( charset_encoding->value.atom ) + 1 ) )
+                               ft_strlen( charset_encoding->value.atom ) + 1 ) )
               goto Exit;
 
             if ( FT_NEW_ARRAY( face->charset_registry,
-                               strlen( charset_registry->value.atom ) + 1 ) )
+                               ft_strlen( charset_registry->value.atom ) + 1 ) )
               goto Exit;
 
-            strcpy( face->charset_registry, charset_registry->value.atom );
-            strcpy( face->charset_encoding, charset_encoding->value.atom );
+            ft_strcpy( face->charset_registry, charset_registry->value.atom );
+            ft_strcpy( face->charset_encoding, charset_encoding->value.atom );
           }
         }
       }
diff --git a/src/psaux/t1cmap.c b/src/psaux/t1cmap.c
index 5fd8b9f..7757f7f 100644
--- a/src/psaux/t1cmap.c
+++ b/src/psaux/t1cmap.c
@@ -17,7 +17,6 @@
 
 
 #include "t1cmap.h"
-#include <stdlib.h>     /* for qsort() */
 
 #include FT_INTERNAL_DEBUG_H
 
@@ -82,7 +81,7 @@
 
 
         if ( gname && gname[0] == glyph_name[0] &&
-             strcmp( gname, glyph_name ) == 0   )
+             ft_strcmp( gname, glyph_name ) == 0   )
         {
           result = n;
           break;
@@ -337,7 +336,7 @@
         }
 
         /* sort the pairs table to allow efficient binary searches */
-        qsort( cmap->pairs,
+        ft_qsort( cmap->pairs,
                new_count,
                sizeof ( T1_CMapUniPairRec ),
                t1_cmap_uni_pair_compare );
diff --git a/src/psaux/t1decode.c b/src/psaux/t1decode.c
index cac5cfe..c8e0709 100644
--- a/src/psaux/t1decode.c
+++ b/src/psaux/t1decode.c
@@ -143,7 +143,7 @@
 
 
       if ( name && name[0] == glyph_name[0] &&
-           strcmp( name,glyph_name ) == 0 )
+           ft_strcmp( name,glyph_name ) == 0 )
         return n;
     }
 
diff --git a/src/pshinter/pshalgo1.c b/src/pshinter/pshalgo1.c
index 67c159e..8fa0325 100644
--- a/src/pshinter/pshalgo1.c
+++ b/src/pshinter/pshalgo1.c
@@ -757,7 +757,7 @@
 
 
       /* initialize hints table */
-      memset( &hints, 0, sizeof ( hints ) );
+      ft_memset( &hints, 0, sizeof ( hints ) );
       error = psh1_hint_table_init( &hints,
                                     &dim->hints,
                                     &dim->masks,
diff --git a/src/pshinter/pshalgo2.c b/src/pshinter/pshalgo2.c
index 8509d87..2cd3911 100644
--- a/src/pshinter/pshalgo2.c
+++ b/src/pshinter/pshalgo2.c
@@ -861,7 +861,7 @@
 
 
     /* clear all fields */
-    memset( glyph, 0, sizeof ( *glyph ) );
+    ft_memset( glyph, 0, sizeof ( *glyph ) );
 
     memory = globals->memory;
 
diff --git a/src/pshinter/pshrec.c b/src/pshinter/pshrec.c
index ad0485e..208cf78 100644
--- a/src/pshinter/pshrec.c
+++ b/src/pshinter/pshrec.c
@@ -472,7 +472,7 @@
         PS_MaskRec  dummy = *mask2;
 
 
-        memmove( mask2, mask2 + 1, delta * sizeof ( PS_MaskRec ) );
+        ft_memmove( mask2, mask2 + 1, delta * sizeof ( PS_MaskRec ) );
 
         mask2[delta] = dummy;
       }
@@ -797,7 +797,7 @@
   ps_hints_init( PS_Hints   hints,
                  FT_Memory  memory )
   {
-    memset( hints, 0, sizeof ( *hints ) );
+    ft_memset( hints, 0, sizeof ( *hints ) );
     hints->memory = memory;
     return 0;
   }
@@ -1132,7 +1132,7 @@
   FT_LOCAL_DEF( void )
   t1_hints_funcs_init( T1_Hints_FuncsRec*  funcs )
   {
-    memset( (char*)funcs, 0, sizeof ( *funcs ) );
+    ft_memset( (char*)funcs, 0, sizeof ( *funcs ) );
 
     funcs->open  = (T1_Hints_OpenFunc)    t1_hints_open;
     funcs->close = (T1_Hints_CloseFunc)   ps_hints_close;
@@ -1197,7 +1197,7 @@
   FT_LOCAL_DEF( void )
   t2_hints_funcs_init( T2_Hints_FuncsRec*  funcs )
   {
-    memset( funcs, 0, sizeof ( *funcs ) );
+    ft_memset( funcs, 0, sizeof ( *funcs ) );
 
     funcs->open    = (T2_Hints_OpenFunc)   t2_hints_open;
     funcs->close   = (T2_Hints_CloseFunc)  ps_hints_close;
diff --git a/src/psnames/psmodule.c b/src/psnames/psmodule.c
index 58b7de6..a0e0386 100644
--- a/src/psnames/psmodule.c
+++ b/src/psnames/psmodule.c
@@ -25,9 +25,6 @@
 
 #include "psnamerr.h"
 
-#include <stdlib.h>     /* for qsort()             */
-#include <string.h>     /* for strcmp(), strncpy() */
-
 
 #ifndef FT_CONFIG_OPTION_NO_POSTSCRIPT_NAMES
 
@@ -106,7 +103,7 @@
 
       if ( *p && len < 64 )
       {
-        strncpy( temp, glyph_name, len );
+        ft_strncpy( temp, glyph_name, len );
         temp[len]  = 0;
         glyph_name = temp;
       }
@@ -118,7 +115,7 @@
       const char*  name = sid_standard_names[n];
 
 
-      if ( first == name[0] && strcmp( glyph_name, name ) == 0 )
+      if ( first == name[0] && ft_strcmp( glyph_name, name ) == 0 )
         return ps_names_to_unicode[n];
     }
 
@@ -127,7 +124,7 @@
   }
 
 
-  /* qsort callback to sort the unicode map */
+  /* ft_qsort callback to sort the unicode map */
   FT_CALLBACK_DEF( int )
   compare_uni_maps( const void*  a,
                     const void*  b )
@@ -198,7 +195,7 @@
       }
       else
         /* sort the table in increasing order of unicode values */
-        qsort( table->maps, count, sizeof ( PS_UniMap ), compare_uni_maps );
+        ft_qsort( table->maps, count, sizeof ( PS_UniMap ), compare_uni_maps );
 
       table->num_maps = count;
     }
diff --git a/src/raster/ftraster.c b/src/raster/ftraster.c
index 28475f7..32f813c 100644
--- a/src/raster/ftraster.c
+++ b/src/raster/ftraster.c
@@ -187,7 +187,7 @@
 
 
 #ifndef FT_MEM_SET
-#define FT_MEM_SET( d, s, c )  memset( d, s, c )
+#define FT_MEM_SET( d, s, c )  ft_memset( d, s, c )
 #endif
 
 
@@ -2094,7 +2094,7 @@
       {
         target[0] |= f1;
 
-        /* memset() is slower than the following code on many platforms. */
+        /* ft_memset() is slower than the following code on many platforms. */
         /* This is due to the fact that, in the vast majority of cases,  */
         /* the span length in bytes is relatively small.                 */
         c2--;
diff --git a/src/sfnt/sfdriver.c b/src/sfnt/sfdriver.c
index 303498a..bbc8822 100644
--- a/src/sfnt/sfdriver.c
+++ b/src/sfnt/sfdriver.c
@@ -33,8 +33,6 @@
 #include "ttpost.h"
 #endif
 
-#include <string.h>     /* for strcmp() */
-
 
   static void*
   get_sfnt_table( TT_Face      face,
@@ -97,7 +95,7 @@
     error = TT_Get_PS_Name( face, glyph_index, &gname );
     if ( !error && buffer_max > 0 )
     {
-      FT_UInt  len = (FT_UInt)( strlen( gname ) );
+      FT_UInt  len = (FT_UInt)( ft_strlen( gname ) );
 
 
       if ( len >= buffer_max )
@@ -201,15 +199,15 @@
   {
     FT_UNUSED( module );
 
-    if ( strcmp( interface, "get_sfnt" ) == 0 )
+    if ( ft_strcmp( interface, "get_sfnt" ) == 0 )
       return (FT_Module_Interface)get_sfnt_table;
 
 #ifdef TT_CONFIG_OPTION_POSTSCRIPT_NAMES
-    if ( strcmp( interface, "glyph_name" ) == 0 )
+    if ( ft_strcmp( interface, "glyph_name" ) == 0 )
       return (FT_Module_Interface)get_sfnt_glyph_name;
 #endif
 
-    if ( strcmp( interface, "postscript_name" ) == 0 )
+    if ( ft_strcmp( interface, "postscript_name" ) == 0 )
       return (FT_Module_Interface)get_sfnt_postscript_name;
 
     return 0;
diff --git a/src/sfnt/ttload.c b/src/sfnt/ttload.c
index dfa2948..5de5769 100644
--- a/src/sfnt/ttload.c
+++ b/src/sfnt/ttload.c
@@ -26,8 +26,6 @@
 
 #include "sferrors.h"
 
-#include <stdlib.h>  /* for qsort */
-
 
   /*************************************************************************/
   /*                                                                       */
@@ -1720,7 +1718,7 @@
           {
             if ( tt_kern_pair_compare( pair0, pair0 + 1 ) != -1 )
             {
-              qsort( (void*)face->kern_pairs, (int)num_pairs,
+              ft_qsort( (void*)face->kern_pairs, (int)num_pairs,
                      sizeof ( TT_Kern0_PairRec ), tt_kern_pair_compare );
               break;
             }
diff --git a/src/sfnt/ttpost.c b/src/sfnt/ttpost.c
index f6e2434..686a987 100644
--- a/src/sfnt/ttpost.c
+++ b/src/sfnt/ttpost.c
@@ -50,7 +50,7 @@
 #ifdef FT_CONFIG_OPTION_POSTSCRIPT_NAMES
 
 
-#include <freetype/internal/psnames.h>
+#include FT_INTERNAL_POSTSCRIPT_NAMES_H
 
 #define MAC_NAME( x )  ( (FT_String*)psnames->macintosh_name( x ) )
 
diff --git a/src/smooth/ftgrays.c b/src/smooth/ftgrays.c
index c12c57a..a3025cc 100644
--- a/src/smooth/ftgrays.c
+++ b/src/smooth/ftgrays.c
@@ -81,9 +81,6 @@
   /*************************************************************************/
 
 
-#include <string.h>             /* for memcpy() */
-#include <setjmp.h>
-
 
 /* experimental support for gamma correction within the rasterizer */
 #define xxxGRAYS_USE_GAMMA
@@ -101,8 +98,18 @@
 
 #define ErrRaster_MemoryOverflow   -4
 
+
+
+
+
+
+
 #ifdef _STANDALONE_
 
+#include <string.h>             /* for ft_memcpy() */
+#include <setjmp.h>
+#include <limits.h>
+#define  FT_UINT_MAX  UINT_MAX
 
 #define ErrRaster_Invalid_Mode     -2
 #define ErrRaster_Invalid_Outline  -1
@@ -146,7 +153,7 @@
 
 
 #ifndef FT_MEM_SET
-#define FT_MEM_SET( d, s, c )  memset( d, s, c )
+#define FT_MEM_SET( d, s, c )  ft_memset( d, s, c )
 #endif
 
   /* define this to dump debugging information */
@@ -203,7 +210,7 @@
   /* increases the number of cells available in the render pool but slows  */
   /* down the rendering a bit.  It is useful if you have a really tiny     */
   /* render pool.                                                          */
-#define xxxGRAYS_COMPACT
+#undef  GRAYS_COMPACT
 
 
   /*************************************************************************/
@@ -229,9 +236,7 @@
 #else /* PIXEL_BITS >= 8 */
 
   /* approximately determine the size of integers using an ANSI-C header */
-#include <limits.h>
-
-#if UINT_MAX == 0xFFFFU
+#if FT_UINT_MAX == 0xFFFFU
   typedef long  TArea;
 #else
   typedef int  TArea;
@@ -308,7 +313,7 @@
     int  cubic_level;
 
     void*    memory;
-    jmp_buf  jump_buffer;
+    ft_jmp_buf  jump_buffer;
 
 #ifdef GRAYS_USE_GAMMA
     FT_Byte  gamma[257];
@@ -1083,7 +1088,7 @@
 #ifdef QUICK_SORT
 
   /* This is a non-recursive quicksort that directly process our cells     */
-  /* array.  It should be faster than calling the stdlib qsort(), and we   */
+  /* array.  It should be faster than calling the stdlib ft_qsort(), and we   */
   /* can even tailor our insertion threshold...                            */
 
 #define QSORT_THRESHOLD  9  /* below this size, a sub-array will be sorted */
diff --git a/src/type1/t1afm.c b/src/type1/t1afm.c
index df78088..36df559 100644
--- a/src/type1/t1afm.c
+++ b/src/type1/t1afm.c
@@ -20,9 +20,6 @@
 #include "t1afm.h"
 #include FT_INTERNAL_STREAM_H
 #include FT_INTERNAL_TYPE1_TYPES_H
-#include <stdlib.h>  /* for qsort()   */
-#include <string.h>  /* for strcmp()  */
-#include <ctype.h>   /* for isalnum() */
 
 
   /*************************************************************************/
@@ -48,7 +45,7 @@
 #undef  IS_KERN_PAIR
 #define IS_KERN_PAIR( p )  ( p[0] == 'K' && p[1] == 'P' )
 
-#define IS_ALPHANUM( c )  ( isalnum( c ) || \
+#define IS_ALPHANUM( c )  ( ft_isalnum( c ) || \
                             c == '_'     || \
                             c == '.'     )
 
@@ -92,7 +89,7 @@
         char*  gname = (char*)type1->glyph_names[n];
 
 
-        if ( gname && gname[0] == temp[0] && strcmp( gname, temp ) == 0 )
+        if ( gname && gname[0] == temp[0] && ft_strcmp( gname, temp ) == 0 )
         {
           result = n;
           break;
@@ -229,7 +226,7 @@
     }
 
     /* now, sort the kern pairs according to their glyph indices */
-    qsort( afm->kern_pairs, count, sizeof ( T1_Kern_Pair ),
+    ft_qsort( afm->kern_pairs, count, sizeof ( T1_Kern_Pair ),
            compare_kern_pairs );
 
   Exit:
diff --git a/src/type1/t1driver.c b/src/type1/t1driver.c
index 1951891..8fdce53 100644
--- a/src/type1/t1driver.c
+++ b/src/type1/t1driver.c
@@ -31,8 +31,6 @@
 #include FT_INTERNAL_STREAM_H
 #include FT_INTERNAL_POSTSCRIPT_NAMES_H
 
-#include <string.h>     /* for strcmp() */
-
 
   /*************************************************************************/
   /*                                                                       */
@@ -57,7 +55,7 @@
 
     if ( buffer_max > 0 )
     {
-      FT_UInt  len = (FT_UInt)( strlen( gname ) );
+      FT_UInt  len = (FT_UInt)( ft_strlen( gname ) );
 
 
       if (len >= buffer_max)
@@ -100,7 +98,7 @@
     {
       gname = face->type1.glyph_names[i];
 
-      if ( !strcmp( glyph_name, gname ) )
+      if ( !ft_strcmp( glyph_name, gname ) )
         return (FT_UInt)i;
     }
 
@@ -149,23 +147,23 @@
     FT_UNUSED( driver );
     FT_UNUSED( interface );
 
-    if ( strcmp( (const char*)interface, "glyph_name" ) == 0 )
+    if ( ft_strcmp( (const char*)interface, "glyph_name" ) == 0 )
       return (FT_Module_Interface)t1_get_glyph_name;
 
-    if ( strcmp( (const char*)interface, "name_index" ) == 0 )
+    if ( ft_strcmp( (const char*)interface, "name_index" ) == 0 )
       return (FT_Module_Interface)t1_get_name_index;
 
-    if ( strcmp( (const char*)interface, "postscript_name" ) == 0 )
+    if ( ft_strcmp( (const char*)interface, "postscript_name" ) == 0 )
       return (FT_Module_Interface)t1_get_ps_name;
 
 #ifndef T1_CONFIG_OPTION_NO_MM_SUPPORT
-    if ( strcmp( (const char*)interface, "get_mm" ) == 0 )
+    if ( ft_strcmp( (const char*)interface, "get_mm" ) == 0 )
       return (FT_Module_Interface)T1_Get_Multi_Master;
 
-    if ( strcmp( (const char*)interface, "set_mm_design") == 0 )
+    if ( ft_strcmp( (const char*)interface, "set_mm_design") == 0 )
       return (FT_Module_Interface)T1_Set_MM_Design;
 
-    if ( strcmp( (const char*)interface, "set_mm_blend") == 0 )
+    if ( ft_strcmp( (const char*)interface, "set_mm_blend") == 0 )
       return (FT_Module_Interface)T1_Set_MM_Blend;
 #endif
     return 0;
@@ -333,7 +331,7 @@
 
 
             if ( gname && gname[0] == glyph_name[0] &&
-                 strcmp( gname, glyph_name ) == 0   )
+                 ft_strcmp( gname, glyph_name ) == 0   )
             {
               result = n;
               break;
@@ -448,7 +446,7 @@
 
 
             if ( gname && gname[0] == glyph_name[0] &&
-                 strcmp( gname, glyph_name ) == 0   )
+                 ft_strcmp( gname, glyph_name ) == 0   )
               return charcode;
           }
         }
diff --git a/src/type1/t1gload.c b/src/type1/t1gload.c
index 4ee9beb..7617b00 100644
--- a/src/type1/t1gload.c
+++ b/src/type1/t1gload.c
@@ -25,8 +25,6 @@
 
 #include "t1errors.h"
 
-#include <string.h>     /* for strcmp() */
-
 
   /*************************************************************************/
   /*                                                                       */
diff --git a/src/type1/t1load.c b/src/type1/t1load.c
index 2b87e51..c4b538a 100644
--- a/src/type1/t1load.c
+++ b/src/type1/t1load.c
@@ -68,11 +68,8 @@
 #include FT_INTERNAL_TYPE1_TYPES_H
 
 #include "t1load.h"
-
 #include "t1errors.h"
 
-#include <string.h>     /* for strncmp(), strcmp() */
-#include <ctype.h>      /* for isalnum()           */
 
 
   /*************************************************************************/
@@ -770,7 +767,7 @@
     /* Note: we must accept "+" as a valid character, as it is used in */
     /*       embedded type1 fonts in PDF documents.                    */
     /*                                                                 */
-    return ( isalnum( c ) || c == '.' || c == '_' || c == '-' || c == '+' );
+    return ( ft_isalnum( c ) || c == '.' || c == '_' || c == '-' || c == '+' );
   }
 
 
@@ -1076,15 +1073,15 @@
     else
     {
       if ( cur + 17 < limit &&
-           strncmp( (const char*)cur, "StandardEncoding", 16 ) == 0 )
+           ft_strncmp( (const char*)cur, "StandardEncoding", 16 ) == 0 )
         face->type1.encoding_type = T1_ENCODING_TYPE_STANDARD;
 
       else if ( cur + 15 < limit &&
-                strncmp( (const char*)cur, "ExpertEncoding", 14 ) == 0 )
+                ft_strncmp( (const char*)cur, "ExpertEncoding", 14 ) == 0 )
         face->type1.encoding_type = T1_ENCODING_TYPE_EXPORT;
 
       else if ( cur + 18 < limit &&
-                strncmp( (const char*)cur, "ISOLatin1Encoding", 17 ) == 0 )
+                ft_strncmp( (const char*)cur, "ISOLatin1Encoding", 17 ) == 0 )
         face->type1.encoding_type = T1_ENCODING_TYPE_ISOLATIN1;
 
       else
@@ -1139,7 +1136,7 @@
 
       /* If the next token isn't `dup', we are also done.  This */
       /* happens when there are `holes' in the Subrs array.     */
-      if ( strncmp( (char*)parser->root.cursor, "dup", 3 ) != 0 )
+      if ( ft_strncmp( (char*)parser->root.cursor, "dup", 3 ) != 0 )
         break;
 
       idx = T1_ToInt( parser );
@@ -1155,7 +1152,7 @@
       T1_Skip_Alpha( parser );    /* `NP' or `I' or `noaccess' */
       T1_Skip_Spaces( parser );
 
-      if ( strncmp( (char*)parser->root.cursor, "put", 3 ) == 0 )
+      if ( ft_strncmp( (char*)parser->root.cursor, "put", 3 ) == 0 )
       {
         T1_Skip_Alpha( parser );  /* skip `put' */
         T1_Skip_Spaces( parser );
@@ -1296,7 +1293,7 @@
         name_table->elements[n][len] = '\0';
 
         /* record index of /.notdef              */
-        if ( strcmp( (const char*)".notdef",
+        if ( ft_strcmp( (const char*)".notdef",
                      (const char*)(name_table->elements[n]) ) == 0 )
         {
           notdef_index = n;
@@ -1336,7 +1333,7 @@
     loader->num_glyphs = n;
 
     /* if /.notdef is found but does not occupy index 0, do our magic.      */
-    if ( strcmp( (const char*)".notdef",
+    if ( ft_strcmp( (const char*)".notdef",
                  (const char*)name_table->elements[0] ) &&
          notdef_found                                      )
     {
@@ -1503,7 +1500,7 @@
       {
         /* look for `FontDirectory', which causes problems on some fonts */
         if ( *cur == 'F' && cur + 25 < limit                 &&
-             strncmp( (char*)cur, "FontDirectory", 13 ) == 0 )
+             ft_strncmp( (char*)cur, "FontDirectory", 13 ) == 0 )
         {
           FT_Byte*  cur2;
 
@@ -1514,7 +1511,7 @@
 
           /* lookup the `known' keyword */
           while ( cur < limit && *cur != 'k'        &&
-                  strncmp( (char*)cur, "known", 5 ) )
+                  ft_strncmp( (char*)cur, "known", 5 ) )
             cur++;
 
           if ( cur < limit )
@@ -1563,7 +1560,7 @@
                   break;
 
                 if ( cur[0] == name[0]                          &&
-                     len == (FT_Int)strlen( (const char*)name ) )
+                     len == (FT_Int)ft_strlen( (const char*)name ) )
                 {
                   FT_Int  n;
 
@@ -1732,7 +1729,7 @@
           for ( idx = 0; idx < type1->num_glyphs; idx++ )
           {
             glyph_name = (FT_Byte*)type1->glyph_names[idx];
-            if ( strcmp( (const char*)char_name,
+            if ( ft_strcmp( (const char*)char_name,
                          (const char*)glyph_name ) == 0 )
             {
               type1->encoding.char_index[charcode] = (FT_UShort)idx;
@@ -1740,7 +1737,7 @@
 
               /* Change min/max encoded char only if glyph name is */
               /* not /.notdef                                      */
-              if ( strcmp( (const char*)".notdef",
+              if ( ft_strcmp( (const char*)".notdef",
                            (const char*)glyph_name ) != 0 )
               {
                 if (charcode < min_char) min_char = charcode;
diff --git a/src/type1/t1objs.c b/src/type1/t1objs.c
index b75dace..18d0b1e 100644
--- a/src/type1/t1objs.c
+++ b/src/type1/t1objs.c
@@ -20,8 +20,6 @@
 #include FT_INTERNAL_DEBUG_H
 #include FT_INTERNAL_STREAM_H
 
-#include <string.h>         /* strcmp() */
-
 #include "t1gload.h"
 #include "t1load.h"
 
@@ -382,8 +380,8 @@
         root->style_flags |= FT_STYLE_FLAG_ITALIC;
       if ( face->type1.font_info.weight )
       {
-        if ( !strcmp( face->type1.font_info.weight, "Bold"  ) ||
-             !strcmp( face->type1.font_info.weight, "Black" ) )
+        if ( !ft_strcmp( face->type1.font_info.weight, "Bold"  ) ||
+             !ft_strcmp( face->type1.font_info.weight, "Black" ) )
           root->style_flags |= FT_STYLE_FLAG_BOLD;
       }
 
diff --git a/src/type1/t1parse.c b/src/type1/t1parse.c
index 7a366ee..e21e57d 100644
--- a/src/type1/t1parse.c
+++ b/src/type1/t1parse.c
@@ -43,8 +43,6 @@
 
 #include "t1errors.h"
 
-#include <string.h>     /* for strncmp() */
-
 
   /*************************************************************************/
   /*                                                                       */
@@ -203,9 +201,9 @@
     /* or `%!FontType'                                       */
     {
       if ( size <= 16                                    ||
-           ( strncmp( (const char*)parser->base_dict,
+           ( ft_strncmp( (const char*)parser->base_dict,
                       "%!PS-AdobeFont-1", 16 )        &&
-             strncmp( (const char*)parser->base_dict,
+             ft_strncmp( (const char*)parser->base_dict,
                       "%!FontType", 10 )              )  )
       {
         FT_TRACE2(( "[not a Type1 font]\n" ));