Commit 6a681fa84a0ba1164726cedfc3623d84f1e3d60a

David Turner 2006-01-27T12:11:22

* src/autofit/afwarp.c: simple #ifdef to prevent compilation when the warp hinter isn't active (it shouldn't, still experimental) * Jamfile, include/freetype/config/ftmodule.h: removed "gxvalid" and "otvalid" from the list of modules that are linked statically to a given FreeType library. Functionality has been moved to the "ftvalid" CVS module. note also that current Make-based build system still compiles the modules though... * include/freetype/config/ftoption.h: added FT_STRICT_ALIASING, which controls the definitions of the memory management functions to avoid warnings with recent versions of GCC. this macro is only here to be disabled, in case we detect problems with the new scheme. NOTE: disable macro to use the memory debugger. this will be fixed later !!

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
diff --git a/ChangeLog b/ChangeLog
index 4fd5017..6c50dc3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,29 @@
 2006-01-27  David Turner  <david@freetype.org>
 
+    * src/autofit/afwarp.c: simple #ifdef to prevent compilation when
+    the warp hinter isn't active (it shouldn't, still experimental)
+
+    * Jamfile, include/freetype/config/ftmodule.h: removed "gxvalid"
+    and "otvalid" from the list of modules that are linked statically
+    to a given FreeType library. Functionality has been moved to the
+    "ftvalid" CVS module.
+    
+    note also that current Make-based build system still compiles the
+    modules though...
+
+    * include/freetype/config/ftoption.h: added FT_STRICT_ALIASING,
+    which controls the definitions of the memory management functions
+    to avoid warnings with recent versions of GCC. this macro is
+    only here to be disabled, in case we detect problems with the
+    new scheme.
+    
+    NOTE: disable macro to use the memory debugger. this will be fixed
+          later !!
+
+    * builds/win32/visualc/freetype.dsp: updating project file to
+    define FT2_BUILD_LIBRARY, and remove gxvalid+otvalid from
+    compilation
+
     * builds/freetype.mk, Jamfile: define the macro FT2_BUILD_LIBRARY
     when compiling the library.
     
diff --git a/Jamfile b/Jamfile
index 81103b0..471c298 100644
--- a/Jamfile
+++ b/Jamfile
@@ -76,10 +76,10 @@ FT2_COMPONENTS ?= autofit    # auto-fitter
                   cache      # cache sub-system
                   cff        # CFF/CEF font driver
                   cid        # PostScript CID-keyed font driver
-                  gxvalid    # validation of TrueTypeGX/AAT tables
+                  #gxvalid    # validation of TrueTypeGX/AAT tables
                   gzip       # support for gzip-compressed files
                   lzw        # support for LZW-compressed files
-                  otvalid    # validation of OpenType tables
+                  #otvalid    # validation of OpenType tables
                   pcf        # PCF font driver
                   pfr        # PFR/TrueDoc font driver
                   psaux      # common PostScript routines module
diff --git a/include/freetype/config/ftmodule.h b/include/freetype/config/ftmodule.h
index 6248a18..f9694b8 100644
--- a/include/freetype/config/ftmodule.h
+++ b/include/freetype/config/ftmodule.h
@@ -15,6 +15,4 @@ FT_USE_MODULE(sfnt_module_class)
 FT_USE_MODULE(ft_smooth_renderer_class)
 FT_USE_MODULE(ft_smooth_lcd_renderer_class)
 FT_USE_MODULE(ft_smooth_lcdv_renderer_class)
-FT_USE_MODULE(otv_module_class)
 FT_USE_MODULE(bdf_driver_class)
-FT_USE_MODULE(gxv_module_class)
diff --git a/include/freetype/config/ftoption.h b/include/freetype/config/ftoption.h
index 74b6b66..ab5d156 100644
--- a/include/freetype/config/ftoption.h
+++ b/include/freetype/config/ftoption.h
@@ -561,7 +561,14 @@ FT_BEGIN_HEADER
  * reducing the heap footprint of memory-mapped TrueType files.
  *
  */
-/* #define  FT_OPTIMIZE_MEMORY */
+#define  FT_OPTIMIZE_MEMORY
+
+/* this temporary macro is used to control wether we're going to
+ * compile certain functions like FT_Alloc in a way that prevent recent
+ * GCC releases from spouting horrible "strict aliasing" warning
+ * messages each time a memory-management function is called
+ */
+#define  FT_STRICT_ALIASING
 
 FT_END_HEADER
 
diff --git a/include/freetype/internal/ftmemory.h b/include/freetype/internal/ftmemory.h
index f8ceaf7..30e77e3 100644
--- a/include/freetype/internal/ftmemory.h
+++ b/include/freetype/internal/ftmemory.h
@@ -56,7 +56,140 @@ FT_BEGIN_HEADER
   /*************************************************************************/
   /*************************************************************************/
 
-#ifdef FT_DEBUG_MEMORY
+#ifdef FT_STRICT_ALIASING
+
+ /* the allocation functions return a pointer, and the error code
+  * is written to through the 'p_error' parameter
+  */
+
+  FT_BASE( FT_Pointer )
+  FT_Alloc( FT_Memory  memory,
+            FT_Long    size,
+            FT_Error  *p_error );
+
+  FT_BASE( FT_Pointer )
+  FT_QAlloc( FT_Memory  memory,
+             FT_Long    size,
+             FT_Error  *p_error );
+
+  FT_BASE( FT_Pointer )
+  FT_Realloc( FT_Memory  memory,
+              FT_Long    current,
+              FT_Long    size,
+              void*      block,
+              FT_Error  *p_error );
+
+  FT_BASE( FT_Pointer )
+  FT_QRealloc( FT_Memory  memory,
+               FT_Long    current,
+               FT_Long    size,
+               void*      block,
+               FT_Error  *p_error );
+
+  FT_BASE( void )
+  FT_Free( FT_Memory    memory,
+           const void*  P );
+
+
+#  ifdef FT_DEBUG_MEMORY
+
+  FT_BASE( FT_Pointer )
+  FT_Alloc_Debug( FT_Memory    memory,
+                  FT_Long      size,
+                  FT_Error    *p_error,
+                  const char*  file_name,
+                  FT_Long      line_no );
+
+  FT_BASE( FT_Pointer )
+  FT_QAlloc_Debug( FT_Memory    memory,
+                   FT_Long      size,
+                   void*        P,
+                   FT_Error    *p_error,
+                   const char*  file_name,
+                   FT_Long      line_no );
+
+  FT_BASE( FT_Pointer )
+  FT_Realloc_Debug( FT_Memory    memory,
+                    FT_Long      current,
+                    FT_Long      size,
+                    void*        P,
+                    FT_Error    *p_error,
+                    const char*  file_name,
+                    FT_Long      line_no );
+
+  FT_BASE( FT_Pointer )
+  FT_QRealloc_Debug( FT_Memory    memory,
+                     FT_Long      current,
+                     FT_Long      size,
+                     void*        P,
+                     FT_Error    *p_error,
+                     const char*  file_name,
+                     FT_Long      line_no );
+
+  FT_BASE( void )
+  FT_Free_Debug( FT_Memory    memory,
+                 FT_Pointer   block,
+                 const char*  file_name,
+                 FT_Long      line_no );
+
+#    define FT_MEM_ALLOC( _pointer_, _size_ )                   \
+          (_pointer_) = FT_Alloc_Debug( memory, _size_, &error, \
+                        __FILE__, __LINE__ )
+
+#    define FT_MEM_REALLOC( _pointer_, _current_, _size_ )             \
+          (_pointer_) = FT_Realloc_Debug( memory, _current_, _size_,   \
+                            (_pointer_), &error,                       \
+                            __FILE__, __LINE__ )
+
+#    define FT_MEM_QALLOC( _pointer_, _size_ )                   \
+          (_pointer_) = FT_QAlloc_Debug( memory, _size_, &error, \
+                           __FILE__, __LINE__ )
+
+#    define FT_MEM_QREALLOC( _pointer_, _current_, _size_ )            \
+          (_pointer_) = FT_QRealloc_Debug( memory, _current_, _size_,  \
+                             (_pointer_), &error,                      \
+                             __FILE__, __LINE__ )
+
+#    define FT_MEM_FREE( _pointer_ )                                \
+    FT_BEGIN_STMNT                                                  \
+      if ( _pointer_ ) {                                            \
+        FT_Free_Debug( memory, (_pointer_), __FILE__, __LINE__ );   \
+        (_pointer_) = NULL;                                         \
+      }                                                             \
+    FT_END_STMNT
+
+
+#  else  /* !FT_DEBUG_MEMORY */
+
+#    define FT_MEM_ALLOC( _pointer_, _size_ )         \
+          (_pointer_) = FT_Alloc( memory, _size_, &error )
+
+#    define FT_MEM_FREE( _pointer_ )             \
+    FT_BEGIN_STMNT                               \
+      if ( (_pointer_) ) {                       \
+        FT_Free( memory, (_pointer_) );          \
+        (_pointer_) = NULL;                      \
+      }                                          \
+    FT_END_STMNT
+
+#  define FT_MEM_REALLOC( _pointer_, _current_, _size_ )        \
+          (_pointer_) = FT_Realloc( memory, _current_, _size_,  \
+                                    (_pointer_), &error )
+
+#  define FT_MEM_QALLOC( _pointer_, _size_ )              \
+          (_pointer_) = FT_QAlloc( memory, _size_, &error )
+
+#  define FT_MEM_QREALLOC( _pointer_, _current_, _size_ )        \
+          (_pointer_) = FT_QRealloc( memory, _current_, _size_,  \
+                                     (_pointer_), &error )
+
+#  endif /* !FT_DEBUG_MEMORY */
+
+#  define  FT_MEM_SET_ERROR(cond)  ( (cond), error != 0 )
+
+#else /* !FT_STRICT_ALIASING */
+
+#  ifdef FT_DEBUG_MEMORY
 
   FT_BASE( FT_Error )
   FT_Alloc_Debug( FT_Memory    memory,
@@ -94,7 +227,8 @@ FT_BEGIN_HEADER
                  const char*  file_name,
                  FT_Long      line_no );
 
-#endif
+#  endif /* FT_DEBUG_MEMORY */
+
 
 
   /*************************************************************************/
@@ -249,45 +383,6 @@ FT_BEGIN_HEADER
   FT_Free( FT_Memory  memory,
            void*     *P );
 
-
-#define FT_MEM_SET( dest, byte, count )     ft_memset( dest, byte, count )
-
-#define FT_MEM_COPY( dest, source, count )  ft_memcpy( dest, source, count )
-
-#define FT_MEM_MOVE( dest, source, count )  ft_memmove( dest, source, count )
-
-
-#define FT_MEM_ZERO( dest, count )  FT_MEM_SET( dest, 0, count )
-
-#define FT_ZERO( p )                FT_MEM_ZERO( p, sizeof ( *(p) ) )
-
-#define FT_ARRAY_ZERO( dest, count )                        \
-          FT_MEM_ZERO( dest, (count) * sizeof ( *(dest) ) )
-
-#define FT_ARRAY_COPY( dest, source, count )                        \
-          FT_MEM_COPY( dest, source, (count) * sizeof ( *(dest) ) )
-
-#define FT_ARRAY_MOVE( dest, source, count )                        \
-          FT_MEM_MOVE( dest, source, (count) * sizeof ( *(dest) ) )
-
-
-  /*
-   *  Return the maximum number of adressable elements in an array.
-   *  We limit ourselves to INT_MAX, rather than UINT_MAX, to avoid
-   *  any problems.
-   */
-#define FT_ARRAY_MAX( ptr )           ( FT_INT_MAX / sizeof ( *(ptr) ) )
-
-#define FT_ARRAY_CHECK( ptr, count )  ( (count) <= FT_ARRAY_MAX( ptr ) )
-
-
-  /*************************************************************************/
-  /*                                                                       */
-  /* We first define FT_MEM_ALLOC, FT_MEM_REALLOC, and FT_MEM_FREE.  All   */
-  /* macros use an _implicit_ `memory' parameter to access the current     */
-  /* memory allocator.                                                     */
-  /*                                                                       */
-
 #ifdef FT_DEBUG_MEMORY
 
 #define FT_MEM_ALLOC( _pointer_, _size_ )              \
@@ -340,6 +435,43 @@ FT_BEGIN_HEADER
 
 #endif /* !FT_DEBUG_MEMORY */
 
+#  define  FT_MEM_SET_ERROR(cond)   ( (error = (cond)) != 0 )
+
+#endif /* !FT_STRICT_ALIASING */
+
+
+
+#define FT_MEM_SET( dest, byte, count )     ft_memset( dest, byte, count )
+
+#define FT_MEM_COPY( dest, source, count )  ft_memcpy( dest, source, count )
+
+#define FT_MEM_MOVE( dest, source, count )  ft_memmove( dest, source, count )
+
+
+#define FT_MEM_ZERO( dest, count )  FT_MEM_SET( dest, 0, count )
+
+#define FT_ZERO( p )                FT_MEM_ZERO( p, sizeof ( *(p) ) )
+
+#define FT_ARRAY_ZERO( dest, count )                        \
+          FT_MEM_ZERO( dest, (count) * sizeof ( *(dest) ) )
+
+#define FT_ARRAY_COPY( dest, source, count )                        \
+          FT_MEM_COPY( dest, source, (count) * sizeof ( *(dest) ) )
+
+#define FT_ARRAY_MOVE( dest, source, count )                        \
+          FT_MEM_MOVE( dest, source, (count) * sizeof ( *(dest) ) )
+
+
+  /*
+   *  Return the maximum number of adressable elements in an array.
+   *  We limit ourselves to INT_MAX, rather than UINT_MAX, to avoid
+   *  any problems.
+   */
+#define FT_ARRAY_MAX( ptr )           ( FT_INT_MAX / sizeof ( *(ptr) ) )
+
+#define FT_ARRAY_CHECK( ptr, count )  ( (count) <= FT_ARRAY_MAX( ptr ) )
+
+
 
   /*************************************************************************/
   /*                                                                       */
@@ -388,17 +520,19 @@ FT_BEGIN_HEADER
   /* if an error occured (i.e. if 'error != 0').                           */
   /*                                                                       */
 
+
+
 #define FT_ALLOC( _pointer_, _size_ )                       \
-          FT_SET_ERROR( FT_MEM_ALLOC( _pointer_, _size_ ) )
+          FT_MEM_SET_ERROR( FT_MEM_ALLOC( _pointer_, _size_ ) )
 
 #define FT_REALLOC( _pointer_, _current_, _size_ )                       \
-          FT_SET_ERROR( FT_MEM_REALLOC( _pointer_, _current_, _size_ ) )
+          FT_MEM_SET_ERROR( FT_MEM_REALLOC( _pointer_, _current_, _size_ ) )
 
 #define FT_QALLOC( _pointer_, _size_ )                       \
-          FT_SET_ERROR( FT_MEM_QALLOC( _pointer_, _size_ ) )
+          FT_MEM_SET_ERROR( FT_MEM_QALLOC( _pointer_, _size_ ) )
 
 #define FT_QREALLOC( _pointer_, _current_, _size_ )                       \
-          FT_SET_ERROR( FT_MEM_QREALLOC( _pointer_, _current_, _size_ ) )
+          FT_MEM_SET_ERROR( FT_MEM_QREALLOC( _pointer_, _current_, _size_ ) )
 
 
 #define FT_FREE( _pointer_ )       \
diff --git a/include/freetype/internal/psaux.h b/include/freetype/internal/psaux.h
index 49c53d0..7ca47d8 100644
--- a/include/freetype/internal/psaux.h
+++ b/include/freetype/internal/psaux.h
@@ -695,35 +695,6 @@ FT_BEGIN_HEADER
 
   typedef struct AFM_ParserRec_*  AFM_Parser;
 
-  typedef struct  AFM_TrackKernRec_
-  {
-    FT_Int    degree;
-    FT_Fixed  min_ptsize;
-    FT_Fixed  min_kern;
-    FT_Fixed  max_ptsize;
-    FT_Fixed  max_kern;
-
-  } AFM_TrackKernRec, *AFM_TrackKern;
-
-  typedef struct  AFM_KernPairRec_
-  {
-    FT_Int  index1;
-    FT_Int  index2;
-    FT_Int  x;
-    FT_Int  y;
-
-  } AFM_KernPairRec, *AFM_KernPair;
-
-  typedef struct  AFM_FontInfoRec_
-  {
-    FT_Bool        IsCIDFont;
-    AFM_TrackKern  TrackKerns;   /* free if non-NULL */
-    FT_Int         NumTrackKern;
-    AFM_KernPair   KernPairs;    /* free if non-NULL */
-    FT_Int         NumKernPair;
-
-  } AFM_FontInfoRec, *AFM_FontInfo;
-
   typedef struct  AFM_Parser_FuncsRec_
   {
     FT_Error
@@ -742,7 +713,6 @@ FT_BEGIN_HEADER
 
   typedef struct AFM_StreamRec_*  AFM_Stream;
 
-
   /*************************************************************************/
   /*                                                                       */
   /* <Struct>                                                              */
diff --git a/include/freetype/internal/t1types.h b/include/freetype/internal/t1types.h
index 75f737b..0a16453 100644
--- a/include/freetype/internal/t1types.h
+++ b/include/freetype/internal/t1types.h
@@ -134,6 +134,48 @@ FT_BEGIN_HEADER
   /*************************************************************************/
   /***                                                                   ***/
   /***                                                                   ***/
+  /***                AFM FONT INFORMATION STRUCTURES                    ***/
+  /***                                                                   ***/
+  /***                                                                   ***/
+  /*************************************************************************/
+  /*************************************************************************/
+  /*************************************************************************/
+
+  typedef struct  AFM_TrackKernRec_
+  {
+    FT_Int    degree;
+    FT_Fixed  min_ptsize;
+    FT_Fixed  min_kern;
+    FT_Fixed  max_ptsize;
+    FT_Fixed  max_kern;
+
+  } AFM_TrackKernRec, *AFM_TrackKern;
+
+  typedef struct  AFM_KernPairRec_
+  {
+    FT_Int  index1;
+    FT_Int  index2;
+    FT_Int  x;
+    FT_Int  y;
+
+  } AFM_KernPairRec, *AFM_KernPair;
+
+  typedef struct  AFM_FontInfoRec_
+  {
+    FT_Bool        IsCIDFont;
+    AFM_TrackKern  TrackKerns;   /* free if non-NULL */
+    FT_Int         NumTrackKern;
+    AFM_KernPair   KernPairs;    /* free if non-NULL */
+    FT_Int         NumKernPair;
+
+  } AFM_FontInfoRec, *AFM_FontInfo;
+
+
+  /*************************************************************************/
+  /*************************************************************************/
+  /*************************************************************************/
+  /***                                                                   ***/
+  /***                                                                   ***/
   /***                ORIGINAL T1_FACE CLASS DEFINITION                  ***/
   /***                                                                   ***/
   /***                                                                   ***/
diff --git a/src/autofit/afwarp.c b/src/autofit/afwarp.c
index ac39942..c8f86c7 100644
--- a/src/autofit/afwarp.c
+++ b/src/autofit/afwarp.c
@@ -18,6 +18,7 @@
 
 #include "afwarp.h"
 
+#ifdef AF_USE_WARPER
 
 #if 1
   static const AF_WarpScore
@@ -303,5 +304,10 @@
     *a_delta = warper->best_delta;
   }
 
+#else /* !AF_USE_WARPER */
+
+char  af_warper_dummy = 0;  /* make compiler happy */
+
+#endif /* !AF_USE_WARPER */
 
 /* END */
diff --git a/src/base/ftbitmap.c b/src/base/ftbitmap.c
index dc5911d..f856de1 100644
--- a/src/base/ftbitmap.c
+++ b/src/base/ftbitmap.c
@@ -73,10 +73,10 @@
       target_size = (FT_ULong)( target_pitch * target->rows );
 
       if ( target_size != size )
-        FT_QREALLOC( target->buffer, target_size, size );
+        (void)FT_QREALLOC( target->buffer, target_size, size );
     }
     else
-      FT_QALLOC( target->buffer, size );
+      (void)FT_QALLOC( target->buffer, size );
 
     if ( !error )
     {
diff --git a/src/base/ftobjs.c b/src/base/ftobjs.c
index a01afcb..4ba53c7 100644
--- a/src/base/ftobjs.c
+++ b/src/base/ftobjs.c
@@ -267,7 +267,8 @@
   ft_glyphslot_alloc_bitmap( FT_GlyphSlot  slot,
                              FT_ULong      size )
   {
-    FT_Memory  memory = FT_FACE_MEMORY( slot->face );
+    FT_Memory   memory = FT_FACE_MEMORY( slot->face );
+    FT_Error    error;
 
 
     if ( slot->internal->flags & FT_GLYPH_OWN_BITMAP )
@@ -275,7 +276,8 @@
     else
       slot->internal->flags |= FT_GLYPH_OWN_BITMAP;
 
-    return FT_MEM_ALLOC( slot->bitmap.buffer, size );
+    (void)FT_ALLOC( slot->bitmap.buffer, size );
+    return error;
   }
 
 
@@ -895,7 +897,7 @@
     FT_Driver_Class   clazz;
     FT_Face           face = 0;
     FT_Error          error, error2;
-    FT_Face_Internal  internal;
+    FT_Face_Internal  internal = NULL;
 
 
     clazz  = driver->clazz;
@@ -1722,10 +1724,10 @@
     if ( FT_IS_SCALABLE( face ) )
     {
       if ( face->height < 0 )
-        face->height = -face->height;
+        face->height = (short)-face->height;
 
       if ( !FT_HAS_VERTICAL( face ) )
-        face->max_advance_height = face->height;
+        face->max_advance_height = (short)face->height;
     }
 
     if ( FT_HAS_FIXED_SIZES( face ) )
@@ -1739,9 +1741,9 @@
 
 
         if ( bsize->height < 0 )
-          bsize->height = -bsize->height;
+          bsize->height = (FT_Short) -bsize->height;
         if ( bsize->x_ppem < 0 )
-          bsize->x_ppem = -bsize->x_ppem;
+          bsize->x_ppem = (FT_Short) -bsize->x_ppem;
         if ( bsize->y_ppem < 0 )
           bsize->y_ppem = -bsize->y_ppem;
       }
@@ -2085,8 +2087,8 @@
     metrics = &face->size->metrics;
     bsize   = face->available_sizes + strike_index;
 
-    metrics->x_ppem = ( bsize->x_ppem + 32 ) >> 6;
-    metrics->y_ppem = ( bsize->y_ppem + 32 ) >> 6;
+    metrics->x_ppem = (FT_UShort)(( bsize->x_ppem + 32 ) >> 6);
+    metrics->y_ppem = (FT_UShort)(( bsize->y_ppem + 32 ) >> 6);
 
     if ( FT_IS_SCALABLE( face ) )
     {
@@ -2197,8 +2199,8 @@
         scaled_h = FT_MulFix( face->units_per_EM, metrics->y_scale );
       }
 
-      metrics->x_ppem = ( scaled_w + 32 ) >> 6;
-      metrics->y_ppem = ( scaled_h + 32 ) >> 6;
+      metrics->x_ppem = (FT_UShort)(( scaled_w + 32 ) >> 6);
+      metrics->y_ppem = (FT_UShort)(( scaled_h + 32 ) >> 6);
 
       ft_recompute_scaled_metrics( face, metrics );
     }
diff --git a/src/base/ftrfork.c b/src/base/ftrfork.c
index 50dcf85..3b92247 100644
--- a/src/base/ftrfork.c
+++ b/src/base/ftrfork.c
@@ -657,7 +657,7 @@
     char*        tmp;
     const char*  slash;
     unsigned     new_length;
-    FT_ULong     error = FT_Err_Ok;
+    FT_Error     error = FT_Err_Ok;
 
     FT_UNUSED( error );
 
diff --git a/src/base/ftutil.c b/src/base/ftutil.c
index 765252d..6ed1db2 100644
--- a/src/base/ftutil.c
+++ b/src/base/ftutil.c
@@ -45,6 +45,133 @@
   /*************************************************************************/
   /*************************************************************************/
 
+#ifdef FT_STRICT_ALIASING
+
+
+  FT_BASE_DEF( FT_Pointer )
+  FT_Alloc( FT_Memory  memory,
+            FT_Long    size,
+            FT_Error  *p_error )
+  {
+    FT_Error    error = 0;
+    FT_Pointer  block = NULL;
+    
+    if ( size > 0 )
+    {
+      block = memory->alloc( memory, size );
+      if ( block == NULL )
+        error = FT_Err_Out_Of_Memory;
+      else
+        FT_MEM_ZERO( block, size );
+    }
+    *p_error = error;
+    return block;
+  }
+              
+
+  FT_BASE_DEF( FT_Pointer )
+  FT_QAlloc( FT_Memory  memory,
+             FT_Long    size,
+             FT_Error  *p_error )
+  {
+    FT_Error    error = 0;
+    FT_Pointer  block = NULL;
+    
+    if ( size > 0 )
+    {
+      block = memory->alloc( memory, size );
+      if ( block == NULL )
+        error = FT_Err_Out_Of_Memory;
+    }
+    *p_error = error;
+    return block;
+  }
+               
+
+  FT_BASE_DEF( FT_Pointer )
+  FT_Realloc( FT_Memory  memory,
+              FT_Long    current,
+              FT_Long    size,
+              void*      block,
+              FT_Error  *p_error )
+  {
+    FT_Error    error = 0;
+    
+    if ( size <= 0 )
+    {
+      FT_Free( memory, block );
+      block = NULL;
+    }
+    else if ( current <= 0 )
+    {
+      FT_ASSERT( block == NULL );
+      
+      block = FT_Alloc( memory, size, &error );
+    }
+    else
+    {
+      FT_Pointer  block2;
+
+      block2 = memory->realloc( memory, current, size, block );
+      if ( block2 == NULL )
+        error = FT_Err_Out_Of_Memory;
+      else
+      {
+        block = block2;
+        if ( size > current )
+          FT_MEM_ZERO( (char*)block + current, size-current );
+      }
+    }
+    *p_error = error;
+    return block;
+  }
+                
+
+  FT_BASE_DEF( FT_Pointer )
+  FT_QRealloc( FT_Memory  memory,
+               FT_Long    current,
+               FT_Long    size,
+               void*      block,
+               FT_Error  *p_error )
+  {
+    FT_Error  error = 0;
+    
+    if ( size <= 0 )
+    {
+      FT_Free( memory, block );
+      block = NULL;
+    }
+    else if ( current <= 0 )
+    {
+      FT_ASSERT( block == NULL );
+      
+      block = FT_QAlloc( memory, size, &error );
+    }
+    else
+    {
+      FT_Pointer  block2;
+
+      block2 = memory->realloc( memory, current, size, block );
+      if ( block2 == NULL )
+        error = FT_Err_Out_Of_Memory;
+      else
+        block = block2;
+    }
+    *p_error = error;
+    return block;
+
+  }               
+
+  FT_BASE_DEF( void )
+  FT_Free( FT_Memory   memory,
+           const void *P )
+  {
+    if ( P )
+      memory->free( memory, (void*)P );
+  }           
+
+#else /* !FT_STRICT_ALIASING */
+
   /* documentation is in ftmemory.h */
 
   FT_BASE_DEF( FT_Error )
@@ -208,6 +335,8 @@
     }
   }
 
+#endif /* !FT_STRICT_ALIASING */
+
 
   /*************************************************************************/
   /*************************************************************************/
diff --git a/src/bdf/bdfdrivr.c b/src/bdf/bdfdrivr.c
index dcb16c9..93592f5 100644
--- a/src/bdf/bdfdrivr.c
+++ b/src/bdf/bdfdrivr.c
@@ -249,7 +249,9 @@ THE SOFTWARE.
 
     if ( !parts || !len )
     {
-      FT_ALLOC( face->style_name, ft_strlen( "Regular" ) + 1 );
+      if ( FT_ALLOC( face->style_name, ft_strlen( "Regular" ) + 1 ) )
+        return error;
+        
       ft_strcpy( face->style_name, "Regular" );
     }
     else
diff --git a/src/cache/ftccache.c b/src/cache/ftccache.c
index 3470794..a4e6b1d 100644
--- a/src/cache/ftccache.c
+++ b/src/cache/ftccache.c
@@ -100,10 +100,11 @@
         if ( p >= mask )
         {
           FT_Memory  memory = cache->memory;
+          FT_Error   error;
 
 
           /* if we can't expand the array, leave immediately */
-          if ( FT_MEM_RENEW_ARRAY( cache->buckets, (mask+1)*2, (mask+1)*4 ) )
+          if ( FT_RENEW_ARRAY( cache->buckets, (mask+1)*2, (mask+1)*4 ) )
             break;
         }
 
@@ -152,11 +153,12 @@
         if ( p == 0 )
         {
           FT_Memory  memory = cache->memory;
+          FT_Error   error;
 
 
           /* if we can't shrink the array, leave immediately */
-          if ( FT_MEM_RENEW_ARRAY( cache->buckets,
-                                   ( mask + 1 ) * 2, mask + 1 ) )
+          if ( FT_RENEW_ARRAY( cache->buckets,
+                               ( mask + 1 ) * 2, mask + 1 ) )
             break;
 
           cache->mask >>= 1;
@@ -320,13 +322,15 @@
   ftc_cache_init( FTC_Cache  cache )
   {
     FT_Memory  memory = cache->memory;
+    FT_Error   error;
 
 
     cache->p     = 0;
     cache->mask  = FTC_HASH_INITIAL_SIZE - 1;
     cache->slack = FTC_HASH_INITIAL_SIZE * FTC_HASH_MAX_LOAD;
 
-    return ( FT_MEM_NEW_ARRAY( cache->buckets, FTC_HASH_INITIAL_SIZE * 2 ) );
+    (void)FT_NEW_ARRAY( cache->buckets, FTC_HASH_INITIAL_SIZE * 2 );
+    return error;
   }
 
 
diff --git a/src/cff/cffgload.c b/src/cff/cffgload.c
index 13cdfa7..3b848e3 100644
--- a/src/cff/cffgload.c
+++ b/src/cff/cffgload.c
@@ -2610,9 +2610,9 @@
         glyph->root.linearHoriAdvance           = decoder.glyph_width;
         glyph->root.internal->glyph_transformed = 0;
 
-        has_vertical_info = face->vertical_info                   &&
-                            face->vertical.number_Of_VMetrics > 0 &&
-                            face->vertical.long_metrics != 0;
+        has_vertical_info = FT_BOOL( face->vertical_info                   &&
+                                     face->vertical.number_Of_VMetrics > 0 &&
+                                     face->vertical.long_metrics != 0 );
 
         /* get the vertical metrics from the vtmx table if we have one */
         if ( has_vertical_info )
diff --git a/src/cff/cffload.c b/src/cff/cffload.c
index b14976f..5556565 100644
--- a/src/cff/cffload.c
+++ b/src/cff/cffload.c
@@ -2294,7 +2294,7 @@
       for ( idx = 0; idx < font->num_subfonts; idx++ )
         cff_subfont_done( memory, font->subfonts[idx] );
 
-      FT_FREE( font->subfonts );
+      /* FT_FREE( font->subfonts ); -- bug this is a static array !! */
     }
 
     cff_encoding_done( &font->encoding );
diff --git a/src/gzip/ftgzip.c b/src/gzip/ftgzip.c
index 67e7bb8..bfbcbf9 100644
--- a/src/gzip/ftgzip.c
+++ b/src/gzip/ftgzip.c
@@ -99,12 +99,12 @@
                  uInt       size )
   {
     FT_ULong    sz = (FT_ULong)size * items;
+    FT_Error    error;
     FT_Pointer  p;
 
 
-    FT_MEM_ALLOC( p, sz );
-
-    return (voidpf) p;
+    (void)FT_ALLOC( p, sz );
+    return p;
   }
 
 
diff --git a/src/otvalid/otvcommn.c b/src/otvalid/otvcommn.c
index 1b9d77c..293960f 100644
--- a/src/otvalid/otvcommn.c
+++ b/src/otvalid/otvcommn.c
@@ -222,10 +222,10 @@
 
         OTV_LIMIT_CHECK( 2 );
 
-        OTV_TRACE(( " (GlyphCount = %d)\n", GlyphCount ));
-
         GlyphCount = FT_NEXT_USHORT( p );
 
+        OTV_TRACE(( " (GlyphCount = %d)\n", GlyphCount ));
+
         OTV_LIMIT_CHECK( GlyphCount * 2 );    /* ClassValueArray */
       }
       break;
diff --git a/src/otvalid/otvgpos.c b/src/otvalid/otvgpos.c
index b6bd6ed..d21d8ea 100644
--- a/src/otvalid/otvgpos.c
+++ b/src/otvalid/otvgpos.c
@@ -67,10 +67,10 @@
 
     OTV_LIMIT_CHECK( 2 );
 
-    OTV_TRACE(( " (Count = %d)\n", Count ));
-
     Count = FT_NEXT_USHORT( p );
 
+    OTV_TRACE(( " (Count = %d)\n", Count ));
+
     OTV_LIMIT_CHECK( Count * valid->extra1 * 2 );
 
     table_size = Count * valid->extra1 * 2 + 2;
diff --git a/src/pcf/pcfdrivr.c b/src/pcf/pcfdrivr.c
index 3aaeb47..719e58f 100644
--- a/src/pcf/pcfdrivr.c
+++ b/src/pcf/pcfdrivr.c
@@ -213,7 +213,7 @@ THE SOFTWARE.
 
         FT_FREE( prop->name );
         if ( prop->isString )
-          FT_FREE( prop->value );
+          FT_FREE( prop->value.atom );
       }
 
       FT_FREE( face->properties );
diff --git a/src/pfr/pfrobjs.c b/src/pfr/pfrobjs.c
index b4b89e5..1270400 100644
--- a/src/pfr/pfrobjs.c
+++ b/src/pfr/pfrobjs.c
@@ -480,7 +480,7 @@
         FT_UInt    probe    = power * size;
         FT_UInt    extra    = count - power;
         FT_Byte*   base     = stream->cursor;
-        FT_Bool    twobytes = item->flags & 1;
+        FT_Bool    twobytes = FT_BOOL(item->flags & 1);
         FT_Byte*   p;
         FT_UInt32  cpair;
 
diff --git a/src/psaux/Jamfile b/src/psaux/Jamfile
index a8c199c..07c653d 100644
--- a/src/psaux/Jamfile
+++ b/src/psaux/Jamfile
@@ -16,7 +16,9 @@ SubDir  FT2_TOP $(FT2_SRC_DIR) psaux ;
 
   if $(FT2_MULTI)
   {
-    _sources = psauxmod psobjs t1decode t1cmap ;
+    _sources = psauxmod psobjs   t1decode t1cmap
+               psconv   afmparse 
+               ;
   }
   else
   {
diff --git a/src/psaux/afmparse.c b/src/psaux/afmparse.c
index fa33fba..27d0c13 100644
--- a/src/psaux/afmparse.c
+++ b/src/psaux/afmparse.c
@@ -15,7 +15,8 @@
 /*                                                                         */
 /***************************************************************************/
 
-
+#include <ft2build.h>
+#include FT_FREETYPE_H
 #include FT_INTERNAL_POSTSCRIPT_AUX_H
 #include FT_INTERNAL_DEBUG_H
 
@@ -90,7 +91,7 @@
   static int
   afm_stream_skip_spaces( AFM_Stream  stream )
   {
-    int  ch;
+    int  ch = 0;  /* make stupid compiler happy */
 
 
     if ( AFM_STATUS_EOC( stream ) )
@@ -277,7 +278,7 @@
   } AFM_Token;
 
 
-  static const char*  afm_key_table[N_AFM_TOKENS] =
+  static const char*  const afm_key_table[N_AFM_TOKENS] =
   {
     "Ascender",
     "AxisLabel",
@@ -356,11 +357,6 @@
   };
 
 
-#define AFM_MAX_ARGUMENTS  5
-
-  static AFM_ValueRec  shared_vals[AFM_MAX_ARGUMENTS];
-
-
   /*
    * `afm_parser_read_vals' and `afm_parser_next_key' provide
    * high-level operations to an AFM_Stream.  The rest of the
@@ -401,12 +397,16 @@
       {
       case AFM_VALUE_TYPE_STRING:
       case AFM_VALUE_TYPE_NAME:
-        if ( !FT_QAlloc( parser->memory, len + 1,
-                         (void**)&(val->u.s)  ) )
-        {
-          ft_memcpy( val->u.s, str, len );
-          val->u.s[len] = '\0';
-        }
+		  {
+            FT_Memory  memory = parser->memory;
+			FT_Error   error;
+        
+			if ( !FT_QALLOC( val->u.s, len + 1 ) )
+			{
+              ft_memcpy( val->u.s, str, len );
+              val->u.s[len] = '\0';
+			}
+		  }
         break;
 
       case AFM_VALUE_TYPE_FIXED:
@@ -420,8 +420,8 @@
         break;
 
       case AFM_VALUE_TYPE_BOOL:
-        val->u.b = ( len == 4                          &&
-                     ft_strncmp( str, "true", 4 ) == 0 );
+        val->u.b = FT_BOOL( len == 4                      &&
+                            !ft_strncmp( str, "true", 4 ) );
         break;
 
       case AFM_VALUE_TYPE_INDEX:
@@ -443,7 +443,7 @@
                        FT_UInt*    len )
   {
     AFM_Stream  stream = parser->stream;
-    char*       key;
+    char*       key    = 0;  /* make stupid compiler happy */
 
 
     if ( line )
@@ -598,13 +598,14 @@
       FT_Error   error;
 
 
-      FT_QNEW_ARRAY( fi->TrackKerns, fi->NumTrackKern );
-      if ( error )
+      if ( FT_QNEW_ARRAY( fi->TrackKerns, fi->NumTrackKern ) )
         return error;
     }
 
-    while ( ( key = afm_parser_next_key( parser, 1, &len ) ) )
+    while ( ( key = afm_parser_next_key( parser, 1, &len ) ) != 0 )
     {
+      AFM_ValueRec  shared_vals[5];
+      
       switch ( afm_tokenize( key, len ) )
       {
       case AFM_TOKEN_TRACKKERN:
@@ -694,12 +695,11 @@
       FT_Error   error;
 
 
-      FT_QNEW_ARRAY( fi->KernPairs, fi->NumKernPair );
-      if ( error )
+      if ( FT_QNEW_ARRAY( fi->KernPairs, fi->NumKernPair ) )
         return error;
     }
 
-    while ( ( key = afm_parser_next_key( parser, 1, &len ) ) )
+    while ( ( key = afm_parser_next_key( parser, 1, &len ) ) != 0 )
     {
       AFM_Token  token = afm_tokenize( key, len );
 
@@ -710,7 +710,8 @@
       case AFM_TOKEN_KPX:
       case AFM_TOKEN_KPY:
         {
-          FT_Int  r;
+          FT_Int        r;
+          AFM_ValueRec  shared_vals[4];
 
 
           n++;
@@ -775,7 +776,7 @@
     FT_UInt   len;
 
 
-    while ( ( key = afm_parser_next_key( parser, 1, &len ) ) )
+    while ( ( key = afm_parser_next_key( parser, 1, &len ) ) != 0 )
     {
       switch ( afm_tokenize( key, len ) )
       {
@@ -826,7 +827,7 @@
         goto Fail;
     }
 
-    while ( ( key = afm_parser_next_key( parser, 1, &len ) ) )
+    while ( ( key = afm_parser_next_key( parser, 1, &len ) ) != 0 )
     {
       AFM_Token  token = afm_tokenize( key, len );
 
@@ -859,7 +860,7 @@
          ft_strncmp( key, "StartFontMetrics", 16 ) != 0 )
       return PSaux_Err_Unknown_File_Format;
 
-    while ( ( key = afm_parser_next_key( parser, 1, &len ) ) )
+    while ( ( key = afm_parser_next_key( parser, 1, &len ) ) != 0 )
     {
       switch ( afm_tokenize( key, len ) )
       {
@@ -876,11 +877,15 @@
         break;
 
       case AFM_TOKEN_ISCIDFONT:
-        shared_vals[0].type = AFM_VALUE_TYPE_BOOL;
-        if ( afm_parser_read_vals( parser, shared_vals, 1 ) != 1 )
-          goto Fail;
+        {
+          AFM_ValueRec  shared_vals[1];
+          
+          shared_vals[0].type = AFM_VALUE_TYPE_BOOL;
+          if ( afm_parser_read_vals( parser, shared_vals, 1 ) != 1 )
+            goto Fail;
 
-        fi->IsCIDFont = shared_vals[0].u.b;
+          fi->IsCIDFont = shared_vals[0].u.b;
+        }
         break;
 
       case AFM_TOKEN_STARTCHARMETRICS:
diff --git a/src/psaux/afmparse.h b/src/psaux/afmparse.h
index 192727a..c2fce75 100644
--- a/src/psaux/afmparse.h
+++ b/src/psaux/afmparse.h
@@ -66,13 +66,13 @@ FT_BEGIN_HEADER
 
   } AFM_ValueRec, *AFM_Value;
 
+#define  AFM_MAX_ARGUMENTS  5
 
   FT_LOCAL( FT_Int )
   afm_parser_read_vals( AFM_Parser  parser,
                         AFM_Value   vals,
                         FT_Int      n );
 
-
   /* read the next key from the next line or column */
   FT_LOCAL( char* )
   afm_parser_next_key( AFM_Parser  parser,
diff --git a/src/psaux/psconv.c b/src/psaux/psconv.c
index 40c22dc..0fb19ee 100644
--- a/src/psaux/psconv.c
+++ b/src/psaux/psconv.c
@@ -20,6 +20,7 @@
 #include FT_INTERNAL_POSTSCRIPT_AUX_H
 #include FT_INTERNAL_DEBUG_H
 
+#include "psconv.h"
 #include "psobjs.h"
 #include "psauxerr.h"
 
@@ -85,7 +86,7 @@
 
     if ( *p == '-' || *p == '+' )
     {
-      sign = ( *p == '-' );
+      sign = FT_BOOL( *p == '-' );
 
       p++;
       if ( p == limit )
@@ -156,7 +157,7 @@
 
     if ( *p == '-' || *p == '+' )
     {
-      sign = ( *p == '-' );
+      sign = FT_BOOL( *p == '-' );
 
       p++;
       if ( p == limit )
@@ -351,9 +352,12 @@
         break;
 
       if ( r % 2 )
-        *buffer++ += c;
+	  {
+        *buffer = (FT_Byte)(*buffer + c);
+		buffer++;
+	  }
       else
-        *buffer = c << 4;
+        *buffer = (FT_Byte)(c << 4);
 
       r++;
     }
@@ -378,7 +382,7 @@
 
     for ( r = 0, p = *cursor; r < n && p < limit; r++, p++ )
     {
-      FT_Byte  b = ( *p ^ ( s >> 8 ) );
+      FT_Byte  b = (FT_Byte)( *p ^ ( s >> 8 ) );
 
 
       s = (FT_UShort)( ( *p + s ) * 52845U + 22719 );
diff --git a/src/sfnt/sfobjs.c b/src/sfnt/sfobjs.c
index 6ffc5a2..2d5f79a 100644
--- a/src/sfnt/sfobjs.c
+++ b/src/sfnt/sfobjs.c
@@ -51,11 +51,12 @@
     FT_String*  string;
     FT_UInt     len, code, n;
     FT_Byte*    read = (FT_Byte*)entry->string;
+	FT_Error    error;
 
 
     len = (FT_UInt)entry->stringLength / 2;
 
-    if ( FT_MEM_NEW_ARRAY( string, len + 1 ) )
+    if ( FT_NEW_ARRAY( string, len + 1 ) )
       return NULL;
 
     for ( n = 0; n < len; n++ )
@@ -81,11 +82,12 @@
     FT_String*  string;
     FT_UInt     len, code, n;
     FT_Byte*    read = (FT_Byte*)entry->string;
+	FT_Error    error;
 
 
     len = (FT_UInt)entry->stringLength / 4;
 
-    if ( FT_MEM_NEW_ARRAY( string, len + 1 ) )
+    if ( FT_NEW_ARRAY( string, len + 1 ) )
       return NULL;
 
     for ( n = 0; n < len; n++ )
@@ -111,11 +113,12 @@
     FT_String*  string;
     FT_UInt     len, code, n;
     FT_Byte*    read = (FT_Byte*)entry->string;
+	FT_Error    error;
 
 
     len = (FT_UInt)entry->stringLength;
 
-    if ( FT_MEM_NEW_ARRAY( string, len + 1 ) )
+    if ( FT_NEW_ARRAY( string, len + 1 ) )
       return NULL;
 
     for ( n = 0; n < len; n++ )
diff --git a/src/sfnt/ttsbit0.c b/src/sfnt/ttsbit0.c
index 6e63fe2..d1e8b96 100644
--- a/src/sfnt/ttsbit0.c
+++ b/src/sfnt/ttsbit0.c
@@ -172,9 +172,9 @@
         bsize->y_ppem = (FT_Pos)(y_ppem << 6);
 
         /* XXX: Is this correct? */
-        bsize->height = ascender - descender;
-        bsize->width  = (FT_Short)( avgwidth * y_ppem + em_size / 2 ) /
-                          em_size;
+        bsize->height = (FT_Short)(ascender - descender);
+        bsize->width  = (FT_Short)( ( avgwidth * y_ppem + em_size / 2 ) /
+                                     em_size );
 
         /* assume 72dpi */
         bsize->size   = bsize->y_ppem;
@@ -232,9 +232,9 @@
     bsize  = ( (FT_Face)face )->available_sizes + strike_index;
     strike = face->sbit_table + 8 + strike_index * 48;
 
-    metrics->x_ppem = bsize->x_ppem >> 6;
-    metrics->y_ppem = bsize->y_ppem >> 6;
-    metrics->height = bsize->height << 6;
+    metrics->x_ppem = (FT_UShort)(bsize->x_ppem >> 6);
+    metrics->y_ppem = (FT_UShort)(bsize->y_ppem >> 6);
+    metrics->height = (FT_UShort)(bsize->height << 6);
 
     metrics->ascender  = (FT_Char)strike[16] << 6;  /* hori.ascender  */
     metrics->descender = (FT_Char)strike[17] << 6;  /* hori.descender */
diff --git a/src/tools/apinames.c b/src/tools/apinames.c
index e4383cf..51668a0 100644
--- a/src/tools/apinames.c
+++ b/src/tools/apinames.c
@@ -1,6 +1,6 @@
 /*
  * This little program is used to parse the FreeType headers and
- * find the declaration of all public API.  This is easy, because
+ * find the declaration of all public APIs.  This is easy, because
  * they all look like the following:
  *
  *   FT_EXPORT( return_type )
@@ -19,6 +19,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <ctype.h>
 
 #define  PROGRAM_NAME     "apinames"
 #define  PROGRAM_VERSION  "0.1"
@@ -75,7 +76,7 @@ names_add( const char*  name,
   {
     nm = the_names + nn;
 
-    if ( nm->hash                      == h &&
+    if ( (int)nm->hash                 == h &&
          memcmp( name, nm->name, len ) == 0 &&
          nm->name[len]                 == 0 )
       return;
@@ -164,7 +165,7 @@ names_dump( FILE*         out,
         if ( dot != NULL )
         {
           int  len = (dot - dll_name);
-          if ( len > sizeof(temp)-1 )
+          if ( len > (int)(sizeof(temp)-1) )
             len = sizeof(temp)-1;
 
           memcpy( temp, dll_name, len );
@@ -257,7 +258,6 @@ read_header_file( FILE*  file, int  verbose )
       case STATE_TYPE:
         {
           char*   name = p;
-          size_t  func_len;
 
           while ( isalnum(*p) || *p == '_' )
             p++;
diff --git a/src/type1/t1afm.c b/src/type1/t1afm.c
index bdf2f42..e1c98ec 100644
--- a/src/type1/t1afm.c
+++ b/src/type1/t1afm.c
@@ -20,7 +20,7 @@
 #include "t1afm.h"
 #include "t1errors.h"
 #include FT_INTERNAL_STREAM_H
-#include FT_INTERNAL_TYPE1_TYPES_H
+#include FT_INTERNAL_POSTSCRIPT_AUX_H
 
 
   /*************************************************************************/
@@ -232,12 +232,14 @@
     FT_Error       error = T1_Err_Unknown_File_Format;
 
 
-    if ( FT_FRAME_ENTER( stream->size ) )
+    if ( FT_NEW( fi ) )
       return error;
 
-    FT_NEW( fi );
-    if ( error )
+    if ( FT_FRAME_ENTER( stream->size ) )
+    {
+      FT_FREE( fi );
       return error;
+    }
 
     psaux = (PSAux_Service)( (T1_Face)t1_face )->psaux;
     if ( psaux && psaux->afm_parser_funcs )
diff --git a/src/type1/t1afm.h b/src/type1/t1afm.h
index 7f9957e..8eb1764 100644
--- a/src/type1/t1afm.h
+++ b/src/type1/t1afm.h
@@ -21,7 +21,7 @@
 
 #include <ft2build.h>
 #include "t1objs.h"
-
+#include FT_INTERNAL_TYPE1_TYPES_H
 
 FT_BEGIN_HEADER