Commit 8edbcabce1b3756fb1921f85901dcce944bdf1e7

David Turner 2001-06-19T08:28:24

- updated doc for FT_New_Memory_Face - removed lots of compiler warnings in lint-style warning modes (/W4 with Visual C++)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
diff --git a/include/freetype/freetype.h b/include/freetype/freetype.h
index 3b64b0b..29195ac 100644
--- a/include/freetype/freetype.h
+++ b/include/freetype/freetype.h
@@ -1458,14 +1458,14 @@ FT_BEGIN_HEADER
   /*                                                                       */
   typedef struct  FT_Open_Args_
   {
-    FT_Open_Flags  flags;
-    FT_Byte*       memory_base;
-    FT_Long        memory_size;
-    FT_String*     pathname;
-    FT_Stream      stream;
-    FT_Module      driver;
-    FT_Int         num_params;
-    FT_Parameter*  params;
+    FT_Open_Flags   flags;
+    const FT_Byte*  memory_base;
+    FT_Long         memory_size;
+    FT_String*      pathname;
+    FT_Stream       stream;
+    FT_Module       driver;
+    FT_Int          num_params;
+    FT_Parameter*   params;
 
   } FT_Open_Args;
 
@@ -1536,6 +1536,11 @@ FT_BEGIN_HEADER
   /*    FreeType error code.  0 means success.                             */
   /*                                                                       */
   /* <Note>                                                                */
+  /*    the font data bytes are used _directly_ by the @FT_Face object.    */
+  /*    this means that they're not copied, and that the client is         */
+  /*    responsible for releasing/destroying them _after_ the              */
+  /*    corresponding call to @FT_Done_Face                                */
+  /*                                                                       */
   /*    Unlike FreeType 1.x, this function automatically creates a glyph   */
   /*    slot for the face object which can be accessed directly through    */
   /*    `face->glyph'.                                                     */
@@ -1546,11 +1551,11 @@ FT_BEGIN_HEADER
   /*    `aface'.  Its return value should be 0 if the font format is       */
   /*    recognized, or non-zero if not.                                    */
   /*                                                                       */
-  FT_EXPORT( FT_Error )  FT_New_Memory_Face( FT_Library  library,
-                                             FT_Byte*    file_base,
-                                             FT_Long     file_size,
-                                             FT_Long     face_index,
-                                             FT_Face    *aface );
+  FT_EXPORT( FT_Error )  FT_New_Memory_Face( FT_Library      library,
+                                             const FT_Byte*  file_base,
+                                             FT_Long         file_size,
+                                             FT_Long         face_index,
+                                             FT_Face        *aface );
 
 
   /*************************************************************************/
diff --git a/include/freetype/fterrors.h b/include/freetype/fterrors.h
index ee2b82f..bdfc8b0 100644
--- a/include/freetype/fterrors.h
+++ b/include/freetype/fterrors.h
@@ -13,91 +13,128 @@
 /*  this file you indicate that you have read the license and              */
 /*  understand and accept it fully.                                        */
 /*                                                                         */
+/*                                                                         */
+/*  This special header file is used to define the FT2 enumeration         */
+/*  constants. It can also be used to generate error message strings       */
+/*  with a small macro trick explained below.                              */
+/*                                                                         */
+/*  I - Error Formats:                                                     */
+/*  ------------------                                                     */
+/*                                                                         */
+/*    Since release 2.1, the error constants have changed. The lower byte  */
+/*    of the error value gives the "generic" error code, while the higher  */
+/*    bytes indicates in which module the error occured.                   */
+/*                                                                         */
+/*    You can use the macro FT_ERROR_BASE(x) macro to extract the          */
+/*    generic error code from a FT_Error                                   */
+/*                                                                         */
+/*    The configuration macro FT_CONFIG_OPTION_USE_MODULE_ERRORS can       */
+/*    be undefined in ftoption.h in order to make the higher byte always   */
+/*    zero, in case you'd need to be compatible with previous versions     */
+/*    of FT2.                                                              */
+/*                                                                         */
+/*                                                                         */
+/*  II - Error Message strings:                                            */
+/*  ---------------------------                                            */
+/*                                                                         */
+/*    The error definitions below are made through special macros that     */
+/*    allow client applications to build a table of error message strings  */
+/*    if they need it. The strings are not included in a normal build of   */
+/*    FT2 to save space (most client apps do not use them)                 */
+/*                                                                         */
+/*    To do so, you'll need to define the following macros before          */
+/*    including this file:                                                 */
+/*                                                                         */
+/*    FT_ERROR_START_LIST ::                                               */
+/*       this macro is called before anything else to define the           */
+/*       start of the error list. It is followed by several                */
+/*       FT_ERROR_DEF calls (see below)                                    */
+/*                                                                         */
+/*    FT_ERROR_DEF( e, v, s ) ::                                           */
+/*        this macro is called to define one single error.                 */
+/*        'e' is the error code identifier (e.g. FT_Err_Invalid_Argument)  */
+/*        'v' is the error numerical value                                 */
+/*        's' is the corresponding error string                            */
+/*                                                                         */
+/*    FT_ERROR_END_LIST ::                                                 */
+/*        this macro is used to end the list.                              */
+/*                                                                         */
+/*    Additionally, you'll need to undefine __FTERRORS_H__ before          */
+/*    #including this file.                                                */
+/*                                                                         */
+/*    Here's a simple example:                                             */
+/*                                                                         */
+/*     {                                                                   */
+/*       #undef __FTERRORS_H__                                             */
+/*       #define FT_ERRORDEF( e, v, s )   { e, s },                        */
+/*       #define FT_ERROR_START_LIST      {                                */
+/*       #define FT_ERROR_END_LIST        { 0, 0 } };                      */
+/*                                                                         */
+/*       const struct                                                      */
+/*       {                                                                 */
+/*         int          err_code;                                          */
+/*         const char*  err_msg                                            */
+/*       } ft_errors[] =                                                   */
+/*                                                                         */
+/*       #include FT_ERRORS_H                                              */
+/*     }                                                                   */
+/*                                                                         */
+/*                                                                         */
 /***************************************************************************/
 
-
-  /*************************************************************************/
-  /*                                                                       */
-  /* This file is used to define the FreeType error enumeration constants. */
-  /*                                                                       */
-  /* The lower byte gives the error code, the higher byte gives the        */
-  /* module.  The base module has error offset 0.  For example, the error  */
-  /* `FT_Err_Invalid_File_Format' has value 0x003, the error               */
-  /* `TT_Err_Invalid_File_Format' has value 0xB03, the error               */
-  /* `T1_Err_Invalid_File_Format' has value 0xC03, etc.                    */
-  /*                                                                       */
-  /* Undefine the macro FT_CONFIG_OPTION_USE_MODULE_ERRORS (in ftoption.h) */
-  /* to make the higher byte always zero.                                  */
-  /*                                                                       */
-  /* It can also be used to create an error message table easily with      */
-  /* something like                                                        */
-  /*                                                                       */
-  /*   {                                                                   */
-  /*     #undef __FTERRORS_H__                                             */
-  /*     #define FT_ERRORDEF( e, v, s )   { e, s },                        */
-  /*     #define FT_ERROR_START_LIST      {                                */
-  /*     #define FT_ERROR_END_LIST        { 0, 0 } };                      */
-  /*                                                                       */
-  /*     const struct                                                      */
-  /*     {                                                                 */
-  /*       int          err_code;                                          */
-  /*       const char*  err_msg                                            */
-  /*     } ft_errors[] =                                                   */
-  /*                                                                       */
-  /*     #include FT_ERRORS_H                                              */
-  /*   }                                                                   */
-  /*                                                                       */
-  /* To use such a table, all errors must be ANDed with 0x00FF to remove   */
-  /* the module error offset.                                              */
-  /*                                                                       */
-  /*************************************************************************/
-
-
 #ifndef __FTERRORS_H__
 #define __FTERRORS_H__
 
-#include FT_MODULE_ERRORS_H
-
-#undef FT_NEED_EXTERN_C
 
+  /*******************************************************************/
+  /*******************************************************************/
+  /*****                                                         *****/
+  /*****                       SETUP MACROS                      *****/
+  /*****                                                         *****/
+  /*******************************************************************/
+  /*******************************************************************/
 
-  /* public interface */
+#include FT_MODULE_ERRORS_H
 
+#undef FT_NEED_EXTERN_C
 #ifndef FT_ERRORDEF
 
-#define FT_ERRORDEF( e, v, s )  e = v,
+#  define FT_ERRORDEF( e, v, s )  e = v,
 
-#ifdef __cplusplus
-#define FT_NEED_EXTERN_C
-  extern "C" {
-#endif
+#  ifdef __cplusplus
+#  define FT_NEED_EXTERN_C
+      extern "C" {
+#  endif
 
 #endif /* !FT_ERRORDEF */
 
 
 #ifndef FT_ERROR_START_LIST
+#  define FT_ERROR_START_LIST  enum {
+#endif
 
-#define FT_ERROR_START_LIST  enum {
-#define FT_ERROR_END_LIST    FT_Err_Max };
-
-#endif /* !FT_ERROR_START_LIST */
-
+#ifndef FT_ERROR_END_LIST
+#  define FT_ERROR_END_LIST    FT_Err_Max };
+#endif
 
-  /* internal interface */
 
-#ifndef FT_ERRORDEF_
 
 #define FT_ERRORDEF_( e, v, s )   \
-          FT_ERRORDEF( FT_Err_ ## e, v + FT_Mod_Err_Base, s )
+        FT_ERRORDEF( FT_Err_ ## e, v + FT_Mod_Err_Base, s )
+          
 #define FT_NOERRORDEF_( e, v, s ) \
-          FT_ERRORDEF( FT_Err_ ## e, v, s )
+        FT_ERRORDEF( FT_Err_ ## e, v, s )
 
-#endif /* !FT_ERRORDEF_ */
 
+  /*******************************************************************/
+  /*******************************************************************/
+  /*****                                                         *****/
+  /*****                   LIST ERROR CODES/MESSAGES             *****/
+  /*****                                                         *****/
+  /*******************************************************************/
+  /*******************************************************************/
 
-#ifdef FT_ERROR_START_LIST
   FT_ERROR_START_LIST
-#endif
 
 
   /* generic errors */
@@ -276,11 +313,17 @@
                "argument stack underflow" )
 
 
-#ifdef FT_ERROR_END_LIST
   FT_ERROR_END_LIST
-#endif
 
 
+  /*******************************************************************/
+  /*******************************************************************/
+  /*****                                                         *****/
+  /*****                      SIMPLE CLEANUPP                    *****/
+  /*****                                                         *****/
+  /*******************************************************************/
+  /*******************************************************************/
+
 #undef FT_ERROR_START_LIST
 #undef FT_ERROR_END_LIST
 #undef FT_ERRORDEF
@@ -292,7 +335,6 @@
   }
 #endif
 
-#endif /* __FTERRORS_H__ */
-
+#endif /* __FT_ERRORS_H__ */
 
 /* END */
diff --git a/include/freetype/fttypes.h b/include/freetype/fttypes.h
index 6444e72..4a7ce5c 100644
--- a/include/freetype/fttypes.h
+++ b/include/freetype/fttypes.h
@@ -512,6 +512,7 @@ FT_BEGIN_HEADER
   /* return base error code (without module-specific prefix) */
 #define FT_ERROR_BASE( x )     ( (x) & 255 )
 
+#define FT_BOOL(x)             ((FT_Bool)(x))
 
 FT_END_HEADER
 
diff --git a/include/freetype/internal/ftdebug.h b/include/freetype/internal/ftdebug.h
index db905ed..d49d163 100644
--- a/include/freetype/internal/ftdebug.h
+++ b/include/freetype/internal/ftdebug.h
@@ -221,6 +221,14 @@ FT_BEGIN_HEADER
 #define FT_TRACE6( varformat )  FT_TRACE( 6, varformat )
 #define FT_TRACE7( varformat )  FT_TRACE( 7, varformat )
 
+#if defined( _MSC_VER )      /* Visual C++ (and Intel C++) */
+
+/* we disable the warnings "conditional expression is constant" here */
+/* in order to compile cleanly with the maximum level of warnings    */
+#pragma warning( disable : 4127 )
+
+#endif /* _MSC_VER */
+
 
 FT_END_HEADER
 
diff --git a/include/freetype/internal/ftstream.h b/include/freetype/internal/ftstream.h
index e590f4e..4789693 100644
--- a/include/freetype/internal/ftstream.h
+++ b/include/freetype/internal/ftstream.h
@@ -143,63 +143,77 @@ FT_BEGIN_HEADER
   /* integer extraction macros -- the `buffer' parameter must ALWAYS be of */
   /* type `char*' or equivalent (1-byte elements).                         */
   /*                                                                       */
+
+#define FT_GET_SHORT_BE(p)                         \
+          ((short)( ((signed char)(p)[0] <<  8) |  \
+                                  (p)[1]        ))
+
+#define FT_GET_OFF3_BE(p)                          \
+          ((long) ( ((signed char)(p)[0] << 16) |  \
+                                 ((p)[1] <<  8) |  \
+                                  (p)[2]        ))
+
+#define FT_GET_LONG_BE(p)                          \
+          ((long) ( ((signed char)(p)[0] << 24) |  \
+                                 ((p)[1] << 16) |  \
+                                 ((p)[2] <<  8) |  \
+                                  (p)[3]        ))
+
+#define FT_GET_SHORT_LE(p)                         \
+          ((short)( ((signed char)(p)[1] <<  8) |  \
+                                  (p)[0]        ))
+
+#define FT_GET_OFF3_LE(p)                          \
+          ((long) ( ((signed char)(p)[2] << 16) |  \
+                                 ((p)[1] <<  8) |  \
+                                  (p)[0]        ))
+
+#define FT_GET_LONG_LE(p)                          \
+          ((long) ( ((signed char)(p)[3] << 24) |  \
+                                 ((p)[2] << 16) |  \
+                                 ((p)[1] <<  8) |  \
+                                  (p)[0]        ))
+
 #define NEXT_Char( buffer )            \
           ( (signed char)*buffer++ )
+
 #define NEXT_Byte( buffer )            \
           ( (unsigned char)*buffer++ )
 
 #define NEXT_Short( buffer )                              \
-          ( buffer += 2,                                  \
-            ( (short)( (signed   char)buffer[-2] << 8 ) | \
-                       (unsigned char)buffer[-1]        ) )
+          ( (short)( buffer += 2, FT_GET_SHORT_BE(buffer-2) ) )
 
 #define NEXT_UShort( buffer )                      \
           ( (unsigned short)NEXT_Short( buffer ) )
 
-#define NEXT_Offset( buffer )                             \
-          ( buffer += 3,                                  \
-            ( ( (long)(signed   char)buffer[-3] << 16 ) | \
-              ( (long)(unsigned char)buffer[-2] <<  8 ) | \
-                (long)(unsigned char)buffer[-1]         ) )
+#define NEXT_Offset( buffer )                                     \
+          ( (long)( buffer += 3, FT_GET_OFF3_BE(buffer-3) ) )
 
 #define NEXT_UOffset( buffer )                     \
           ( (unsigned long)NEXT_Offset( buffer ) )
 
-#define NEXT_Long( buffer )                               \
-          ( buffer += 4,                                  \
-            ( ( (long)(signed   char)buffer[-4] << 24 ) | \
-              ( (long)(unsigned char)buffer[-3] << 16 ) | \
-              ( (long)(unsigned char)buffer[-2] <<  8 ) | \
-                (long)(unsigned char)buffer[-1]         ) )
+#define NEXT_Long( buffer )                                       \
+          ( (long)( buffer += 4, FT_GET_LONG_BE(buffer-4) ) )
 
 #define NEXT_ULong( buffer )                     \
           ( (unsigned long)NEXT_Long( buffer ) )
 
 
 #define NEXT_ShortLE( buffer )                            \
-          ( buffer += 2,                                  \
-            ( (short)( (signed   char)buffer[-1] << 8 ) | \
-                       (unsigned char)buffer[-2]        ) )
+          ( (short)( buffer += 2, FT_GET_SHORT_LE(buffer-2) ) )
 
 #define NEXT_UShortLE( buffer )                      \
           ( (unsigned short)NEXT_ShortLE( buffer ) )
 
 #define NEXT_OffsetLE( buffer )                           \
-          ( buffer += 3,                                  \
-            ( ( (long)(signed   char)buffer[-1] << 16 ) | \
-              ( (long)(unsigned char)buffer[-2] <<  8 ) | \
-                (long)(unsigned char)buffer[-3]         ) )
+          ( (long)( buffer += 3, FT_GET_OFF3_LE(buffer-3) ) )
 
 #define NEXT_UOffsetLE( buffer )                     \
-          ( (unsigned long)NEXT_OffsetLE( buffer ) )
+         ( (unsigned long)NEXT_OffsetLE( buffer ) )
 
 
 #define NEXT_LongLE( buffer )                             \
-          ( buffer += 4,                                  \
-            ( ( (long)(signed   char)buffer[-1] << 24 ) | \
-              ( (long)(unsigned char)buffer[-2] << 16 ) | \
-              ( (long)(unsigned char)buffer[-3] <<  8 ) | \
-                (long)(unsigned char)buffer[-4]         ) )
+          ( (long)( buffer += 4, FT_GET_LONG_LE(buffer-4) ) )
 
 #define NEXT_ULongLE( buffer )                     \
           ( (unsigned long)NEXT_LongLE( buffer ) )
diff --git a/src/autohint/ahglobal.c b/src/autohint/ahglobal.c
index f2ebc6e..7eaf9d3 100644
--- a/src/autohint/ahglobal.c
+++ b/src/autohint/ahglobal.c
@@ -20,6 +20,7 @@
 
 
 #include <ft2build.h>
+#include FT_INTERNAL_DEBUG_H
 #include "ahglobal.h"
 #include "ahglyph.h"
 
@@ -214,9 +215,9 @@
           } while ( next != index );
 
           /* now, set the `round' flag depending on the segment's kind */
-          round =
+          round = FT_BOOL(
             FT_CURVE_TAG( glyph->outline.tags[prev] ) != FT_Curve_Tag_On ||
-            FT_CURVE_TAG( glyph->outline.tags[next] ) != FT_Curve_Tag_On ;
+            FT_CURVE_TAG( glyph->outline.tags[next] ) != FT_Curve_Tag_On );
 
           AH_LOG(( "%c ", round ? 'r' : 'f' ));
         }
@@ -265,7 +266,7 @@
       {
         FT_Pos   ref      = *blue_ref;
         FT_Pos   shoot    = *blue_shoot;
-        FT_Bool  over_ref = ( shoot > ref );
+        FT_Bool  over_ref = FT_BOOL( shoot > ref );
 
 
         if ( AH_IS_TOP_BLUE( blue ) ^ over_ref )
diff --git a/src/autohint/ahglyph.c b/src/autohint/ahglyph.c
index d3affc1..688e782 100644
--- a/src/autohint/ahglyph.c
+++ b/src/autohint/ahglyph.c
@@ -558,7 +558,7 @@
         for ( ; contour < contour_limit; contour++, end++ )
         {
           contour[0] = points + index;
-          index      = end[0] + 1;
+          index      = (short)(end[0] + 1);
         }
       }
 
@@ -959,9 +959,9 @@
             /* check that the segments are correctly oriented and */
             /* positioned to form a black distance                */
 
-            is_dir = ( seg1->dir == outline->horz_major_dir ||
-                       seg1->dir == outline->vert_major_dir );
-            is_pos = pos1 > pos2;
+            is_dir = (FT_Bool)( seg1->dir == outline->horz_major_dir ||
+                                seg1->dir == outline->vert_major_dir );
+            is_pos = (FT_Bool)(pos1 > pos2);
 
             if ( pos1 == pos2 || !(is_dir ^ is_pos) )
               continue;
@@ -1199,7 +1199,7 @@
 
           /* check for links -- if seg->serif is set, then seg->link must */
           /* be ignored                                                   */
-          is_serif = seg->serif && seg->serif->edge != edge;
+          is_serif = (FT_Bool)(seg->serif && seg->serif->edge != edge);
 
           if ( seg->link || is_serif )
           {
@@ -1371,8 +1371,8 @@
         /* zone, check for left edges                                      */
         /*                                                                 */
         /* of course, that's for TrueType XXX                              */
-        FT_Bool  is_top_blue  = AH_IS_TOP_BLUE( blue );
-        FT_Bool  is_major_dir = edge->dir == outline->horz_major_dir;
+        FT_Bool  is_top_blue  = FT_BOOL(AH_IS_TOP_BLUE( blue ));
+        FT_Bool  is_major_dir = FT_BOOL(edge->dir == outline->horz_major_dir);
 
         if ( !blue_active[blue] )
           continue;
@@ -1403,7 +1403,7 @@
           /* top zone, or under the reference position of a bottom zone   */
           if ( edge->flags & ah_edge_round && dist != 0 )
           {
-            FT_Bool  is_under_ref = edge->fpos < *blue_pos;
+            FT_Bool  is_under_ref = FT_BOOL( edge->fpos < *blue_pos );
 
 
             if ( is_top_blue ^ is_under_ref )
diff --git a/src/autohint/ahhint.c b/src/autohint/ahhint.c
index 2b339c5..505949b 100644
--- a/src/autohint/ahhint.c
+++ b/src/autohint/ahhint.c
@@ -1004,10 +1004,10 @@
     FT_Error          error;
     AH_Outline*       outline  = hinter->glyph;
     AH_Loader*        gloader  = hinter->loader;
-    FT_Bool           no_horz_hints =
-                        ( load_flags & AH_HINT_NO_HORZ_EDGES ) != 0;
-    FT_Bool           no_vert_hints =
-                        ( load_flags & AH_HINT_NO_VERT_EDGES ) != 0;
+    FT_Bool           no_horz_hints = FT_BOOL(
+                        ( load_flags & AH_HINT_NO_HORZ_EDGES ) != 0 );
+    FT_Bool           no_vert_hints = FT_BOOL(
+                        ( load_flags & AH_HINT_NO_VERT_EDGES ) != 0 );
 
 
     /* load the glyph */
@@ -1251,7 +1251,7 @@
 
 
             dummy.points  += num_base_points;
-            dummy.n_points = num_new_points;
+            dummy.n_points = (short)num_new_points;
 
             FT_Outline_Translate( &dummy, x, y );
           }
diff --git a/src/base/ftobjs.c b/src/base/ftobjs.c
index 1fa50ce..19ff545 100644
--- a/src/base/ftobjs.c
+++ b/src/base/ftobjs.c
@@ -187,7 +187,7 @@
     {
       error = 0;
       FT_New_Memory_Stream( library,
-                            args->memory_base,
+                            (FT_Byte*)args->memory_base,
                             args->memory_size,
                             stream );
     }
@@ -529,13 +529,13 @@
     FT_UInt        n;
 
 
-    base->outline.n_points   += current->outline.n_points;
-    base->outline.n_contours += current->outline.n_contours;
+    base->outline.n_points   = (short)( base->outline.n_points   + current->outline.n_points );
+    base->outline.n_contours = (short)( base->outline.n_contours + current->outline.n_contours );
     base->num_subglyphs      += current->num_subglyphs;
 
     /* adjust contours count in newest outline */
     for ( n = 0; n < n_curr_contours; n++ )
-      current->outline.contours[n] += n_base_points;
+      current->outline.contours[n] = (short)( current->outline.contours[n] + n_base_points );
 
     /* prepare for another new glyph image */
     FT_GlyphLoader_Prepare( loader );
@@ -570,8 +570,8 @@
         MEM_Copy( target->base.extra_points, source->base.extra_points,
                   num_points * sizeof ( FT_Vector ) );
 
-      out->n_points   = num_points;
-      out->n_contours = num_contours;
+      out->n_points   = (short)num_points;
+      out->n_contours = (short)num_contours;
 
       FT_GlyphLoader_Adjust_Points( target );
     }
@@ -844,10 +844,10 @@
     /* do we need to load the glyph through the auto-hinter? */
     library  = driver->root.library;
     hinter   = library->auto_hinter;
-    autohint = hinter                                                      &&
+    autohint = FT_BOOL( hinter                                             &&
                !( load_flags & ( FT_LOAD_NO_SCALE | FT_LOAD_NO_HINTING ) ) &&
                FT_DRIVER_IS_SCALABLE(driver) &&
-               FT_DRIVER_USES_OUTLINES(driver);
+               FT_DRIVER_USES_OUTLINES(driver) );
     if ( autohint )
     {
       if ( FT_DRIVER_HAS_HINTER( driver ) &&
@@ -1127,11 +1127,11 @@
 
   /* documentation is in freetype.h */
 
-  FT_EXPORT_DEF( FT_Error )  FT_New_Memory_Face( FT_Library  library,
-                                                 FT_Byte*    file_base,
-                                                 FT_Long     file_size,
-                                                 FT_Long     face_index,
-                                                 FT_Face    *aface )
+  FT_EXPORT_DEF( FT_Error )  FT_New_Memory_Face( FT_Library      library,
+                                                 const FT_Byte*  file_base,
+                                                 FT_Long         file_size,
+                                                 FT_Long         face_index,
+                                                 FT_Face        *aface )
   {
     FT_Open_Args  args;
 
@@ -1172,7 +1172,7 @@
 
     *aface = 0;
 
-    external_stream = ( ( args->flags & ft_open_stream ) && args->stream );
+    external_stream = FT_BOOL(( args->flags & ft_open_stream ) && args->stream);
 
     /* create input stream */
     error = ft_new_input_stream( library, args, &stream );
@@ -1648,8 +1648,8 @@
     if ( pixel_height < 1 )
       pixel_height = 1;
 
-    metrics->x_ppem = pixel_width;
-    metrics->y_ppem = pixel_height;
+    metrics->x_ppem = (FT_UShort)pixel_width;
+    metrics->y_ppem = (FT_UShort)pixel_height;
 
     if ( face->face_flags & FT_FACE_FLAG_SCALABLE )
     {
diff --git a/src/base/ftoutln.c b/src/base/ftoutln.c
index 342ee28..6e585e8 100644
--- a/src/base/ftoutln.c
+++ b/src/base/ftoutln.c
@@ -64,7 +64,7 @@
 
     FT_Int   n;         /* index of contour in outline     */
     FT_UInt  first;     /* index of first point in contour */
-    char     tag;       /* current point's state           */
+    FT_Int   tag;       /* current point's state           */
 
     FT_Int   shift;
     FT_Pos   delta;
diff --git a/src/base/ftstream.c b/src/base/ftstream.c
index 1ada68c..3c18497 100644
--- a/src/base/ftstream.c
+++ b/src/base/ftstream.c
@@ -31,10 +31,10 @@
 #define FT_COMPONENT  trace_stream
 
 
-  FT_BASE_DEF( void )  FT_New_Memory_Stream( FT_Library  library,
-                                             FT_Byte*    base,
-                                             FT_ULong    size,
-                                             FT_Stream   stream )
+  FT_BASE_DEF( void )  FT_New_Memory_Stream( FT_Library      library,
+                                             FT_Byte*  base,
+                                             FT_ULong        size,
+                                             FT_Stream       stream )
   {
     stream->memory = library->memory;
     stream->base   = base;
diff --git a/src/cache/ftcchunk.c b/src/cache/ftcchunk.c
index 788098d..316ffc3 100644
--- a/src/cache/ftcchunk.c
+++ b/src/cache/ftcchunk.c
@@ -50,9 +50,9 @@
     data->ref_count    = (FT_Short) 0;
     node->cset         = cset;
     node->cset_index   = (FT_UShort)index;
-    node->num_elements = ( index + 1 < cset->num_chunks )
+    node->num_elements = (unsigned short)(( index + 1 < cset->num_chunks )
                          ? cset->element_count
-                         : cset->element_max - cset->element_count*index;
+                         : cset->element_max - cset->element_count*index );
     if ( alloc )
     {
       /* allocate elements array */
diff --git a/src/cache/ftcimage.c b/src/cache/ftcimage.c
index 1ad044f..693403f 100644
--- a/src/cache/ftcimage.c
+++ b/src/cache/ftcimage.c
@@ -225,7 +225,7 @@
   FT_Bool  ftc_image_set_compare( FTC_ImageSet     iset,
                                   FTC_Image_Desc*  type )
   {
-    return !memcmp( &iset->description, type, sizeof ( *type ) );
+    return FT_BOOL(!memcmp( &iset->description, type, sizeof ( *type ) ));
   }
 
 
diff --git a/src/cache/ftcmanag.c b/src/cache/ftcmanag.c
index dad724a..76c02ce 100644
--- a/src/cache/ftcmanag.c
+++ b/src/cache/ftcmanag.c
@@ -74,7 +74,7 @@
   {
     FT_UNUSED( lru );
 
-    return ((FT_Size)node->root.data)->face == (FT_Face)data;
+    return FT_BOOL(((FT_Size)node->root.data)->face == (FT_Face)data);
   }
 
 
@@ -184,9 +184,9 @@
     FT_UNUSED( node );
 
 
-    return ( size->face           == req->face   &&
-             size->metrics.x_ppem == req->width  &&
-             size->metrics.y_ppem == req->height );
+    return FT_BOOL( size->face           == req->face   &&
+                    size->metrics.x_ppem == req->width  &&
+                    size->metrics.y_ppem == req->height );
   }
 
 
diff --git a/src/cache/ftcsbits.c b/src/cache/ftcsbits.c
index 7d22b6e..4d236c6 100644
--- a/src/cache/ftcsbits.c
+++ b/src/cache/ftcsbits.c
@@ -317,7 +317,7 @@
   FT_Bool  ftc_sbit_chunk_set_compare( FTC_SBitSet      sset,
                                        FTC_Image_Desc*  type )
   {
-    return !memcmp( &sset->desc, type, sizeof ( *type ) );
+    return FT_BOOL(!memcmp( &sset->desc, type, sizeof ( *type ) ));
   }
 
 
diff --git a/src/cff/cffgload.c b/src/cff/cffgload.c
index 8b71542..048e5a2 100644
--- a/src/cff/cffgload.c
+++ b/src/cff/cffgload.c
@@ -409,7 +409,7 @@
 
       point->x = x >> 16;
       point->y = y >> 16;
-      *control = flag ? FT_Curve_Tag_On : FT_Curve_Tag_Cubic;
+      *control = (FT_Byte)(flag ? FT_Curve_Tag_On : FT_Curve_Tag_Cubic);
 
       builder->last = *point;
     }
@@ -452,7 +452,7 @@
     if ( !error )
     {
       if ( outline->n_contours > 0 )
-        outline->contours[outline->n_contours - 1] = outline->n_points - 1;
+        outline->contours[outline->n_contours - 1] = (short)(outline->n_points - 1);
 
       outline->n_contours++;
     }
@@ -512,7 +512,7 @@
     }
 
     if ( outline->n_contours > 0 )
-      outline->contours[outline->n_contours - 1] = outline->n_points - 1;
+      outline->contours[outline->n_contours - 1] = (short)(outline->n_points - 1);
   }
 
 
@@ -655,7 +655,7 @@
       FT_Outline  dummy;
 
 
-      dummy.n_points = base->n_points - n_base_points;
+      dummy.n_points = (short)(base->n_points - n_base_points);
       dummy.points   = base->points   + n_base_points;
 
       FT_Outline_Translate( &dummy, adx, ady );
@@ -2142,8 +2142,8 @@
     glyph->root.outline.n_points   = 0;
     glyph->root.outline.n_contours = 0;
 
-    hinting = ( load_flags & FT_LOAD_NO_SCALE   ) == 0 &&
-              ( load_flags & FT_LOAD_NO_HINTING ) == 0;
+    hinting = FT_BOOL( ( load_flags & FT_LOAD_NO_SCALE   ) == 0 &&
+                       ( load_flags & FT_LOAD_NO_HINTING ) == 0 );
 
     glyph->root.format = ft_glyph_format_outline;  /* by default */
 
diff --git a/src/cff/cffload.c b/src/cff/cffload.c
index 78a93fb..9fc6ca5 100644
--- a/src/cff/cffload.c
+++ b/src/cff/cffload.c
@@ -1753,7 +1753,7 @@
             goto Exit;
 
           /* Assign code to GID mapping. */
-          encoding->codes[glyph_code] = j;
+          encoding->codes[glyph_code] = (FT_UShort)j;
 
           /* Assign code to SID mapping. */
           encoding->sids[glyph_code] = charset->sids[j];
@@ -1764,8 +1764,8 @@
       case 1:
         {
           FT_Byte  nleft;
-          FT_Byte  i = 1;
-          FT_Byte  k;
+          FT_UInt  i = 1;
+          FT_UInt  k;
 
 
           /* Parse the Format1 ranges. */
@@ -1786,11 +1786,11 @@
             for ( k = i; k < nleft + i; k++, glyph_code++ )
             {
               /* Make sure k is not too big. */
-              if ( (FT_UInt)k > num_glyphs )
+              if ( k > num_glyphs )
                 goto Exit;
 
               /* Assign code to GID mapping. */
-              encoding->codes[glyph_code] = k;
+              encoding->codes[glyph_code] = (FT_UShort)k;
 
               /* Assign code to SID mapping. */
               encoding->sids[glyph_code] = charset->sids[k];
@@ -1837,7 +1837,7 @@
           }
 
           /* Now, make the assignment. */
-          encoding->codes[glyph_code] = glyph_id;
+          encoding->codes[glyph_code] = (FT_UShort)glyph_id;
         }
       }
     }
@@ -1879,7 +1879,7 @@
               encoding->sids [j] = 0;
             }
             else
-              encoding->codes[j] = i;
+              encoding->codes[j] = (FT_UShort)i;
           }
         }
         break;
@@ -1910,7 +1910,7 @@
               encoding->sids [j] = 0;
             }
             else
-              encoding->codes[j] = i;
+              encoding->codes[j] = (FT_UShort)i;
           }
         }
         break;
diff --git a/src/cff/cffobjs.c b/src/cff/cffobjs.c
index cf2386e..d9f4e6d 100644
--- a/src/cff/cffobjs.c
+++ b/src/cff/cffobjs.c
@@ -388,7 +388,7 @@
         root->bbox         = dict->font_bbox;
         root->ascender     = (FT_Short)( root->bbox.yMax >> 16 );
         root->descender    = (FT_Short)( root->bbox.yMin >> 16 );
-        root->height       = ( ( root->ascender - root->descender ) * 12 ) / 10;
+        root->height       = (FT_Short)(( ( root->ascender - root->descender ) * 12 ) / 10);
 
         if ( dict->units_per_em )
           root->units_per_EM = dict->units_per_em;
@@ -474,8 +474,8 @@
 
 
             charmap->root.face        = (FT_Face)face;
-            charmap->root.platform_id = platform;
-            charmap->root.encoding_id = encoding;
+            charmap->root.platform_id = (FT_UShort)platform;
+            charmap->root.encoding_id = (FT_UShort)encoding;
             charmap->root.encoding    = find_encoding( platform, encoding );
 
             /* now, set root->charmap with a unicode charmap */
diff --git a/src/cff/cffparse.c b/src/cff/cffparse.c
index 5121b23..362c70a 100644
--- a/src/cff/cffparse.c
+++ b/src/cff/cffparse.c
@@ -144,8 +144,8 @@
     FT_Byte*  p    = start;
     FT_Long   num, divider, result, exp;
     FT_Int    sign = 0, exp_sign = 0;
-    FT_Byte   nib;
-    FT_Byte   phase;
+    FT_UInt   nib;
+    FT_UInt   phase;
 
 
     result  = 0;
@@ -495,7 +495,7 @@
 
     while ( p < limit )
     {
-      FT_Byte  v = *p;
+      FT_UInt  v = *p;
 
 
       if ( v >= 27 && v != 31 )
diff --git a/src/cid/cidgload.c b/src/cid/cidgload.c
index 73187f0..05abd9c 100644
--- a/src/cid/cidgload.c
+++ b/src/cid/cidgload.c
@@ -225,8 +225,8 @@
     glyph->root.outline.n_points   = 0;
     glyph->root.outline.n_contours = 0;
 
-    hinting = ( load_flags & FT_LOAD_NO_SCALE   ) == 0 &&
-              ( load_flags & FT_LOAD_NO_HINTING ) == 0;
+    hinting = FT_BOOL( ( load_flags & FT_LOAD_NO_SCALE   ) == 0 &&
+                       ( load_flags & FT_LOAD_NO_HINTING ) == 0 );
 
     glyph->root.format = ft_glyph_format_outline;
 
@@ -240,8 +240,8 @@
                                              cid_load_glyph );
 
       /* set up the decoder */
-      decoder.builder.no_recurse =
-        ( ( load_flags & FT_LOAD_NO_RECURSE ) != 0 );
+      decoder.builder.no_recurse = FT_BOOL(
+        ( ( load_flags & FT_LOAD_NO_RECURSE ) != 0 ) );
 
       error = cid_load_glyph( &decoder, glyph_index );
 
diff --git a/src/cid/cidload.c b/src/cid/cidload.c
index fe4867b..8addfae 100644
--- a/src/cid/cidload.c
+++ b/src/cid/cidload.c
@@ -70,8 +70,8 @@
       FT_Byte  plain;
 
 
-      plain     = ( *buffer ^ ( seed >> 8 ) );
-      seed      = ( *buffer + seed ) * 52845U + 22719;
+      plain     = (FT_Byte)( *buffer ^ ( seed >> 8 ) );
+      seed      = (FT_UShort)(( *buffer + seed ) * 52845 + 22719);
       *buffer++ = plain;
       length--;
     }
diff --git a/src/cid/cidobjs.c b/src/cid/cidobjs.c
index df5395e..f2c7377 100644
--- a/src/cid/cidobjs.c
+++ b/src/cid/cidobjs.c
@@ -229,8 +229,8 @@
 
         root->ascender     = (FT_Short)( face->cid.font_bbox.yMax >> 16 );
         root->descender    = (FT_Short)( face->cid.font_bbox.yMin >> 16 );
-        root->height       = ( ( root->ascender + root->descender ) * 12 )
-                             / 10;
+        root->height       = (FT_Short)( (( root->ascender + root->descender ) * 12 )
+                             / 10 );
 
 
 #if 0
diff --git a/src/pcf/pcfread.c b/src/pcf/pcfread.c
index b261515..d60f723 100644
--- a/src/pcf/pcfread.c
+++ b/src/pcf/pcfread.c
@@ -224,11 +224,11 @@ THE SOFTWARE.
     if ( READ_Fields( pcf_compressed_metric_header, &compr_metric ) )
       return error;
 
-    metric->leftSideBearing  = (FT_Short)compr_metric.leftSideBearing - 0x80;
-    metric->rightSideBearing = (FT_Short)compr_metric.rightSideBearing - 0x80;
-    metric->characterWidth   = (FT_Short)compr_metric.characterWidth - 0x80;
-    metric->ascent           = (FT_Short)compr_metric.ascent - 0x80;
-    metric->descent          = (FT_Short)compr_metric.descent - 0x80;
+    metric->leftSideBearing  = (FT_Short)(compr_metric.leftSideBearing - 0x80);
+    metric->rightSideBearing = (FT_Short)(compr_metric.rightSideBearing - 0x80);
+    metric->characterWidth   = (FT_Short)(compr_metric.characterWidth - 0x80);
+    metric->ascent           = (FT_Short)(compr_metric.ascent - 0x80);
+    metric->descent          = (FT_Short)(compr_metric.descent - 0x80);
     metric->attributes       = 0;
   
     return PCF_Err_Ok;
@@ -719,7 +719,7 @@ THE SOFTWARE.
                                ( ( i % ( lastCol - firstCol + 1 ) ) +
                                  firstCol );
 
-        tmpEncoding[j].glyph = encodingOffset;
+        tmpEncoding[j].glyph = (FT_Short)encodingOffset;
         j++;
       }
 
diff --git a/src/psaux/psobjs.c b/src/psaux/psobjs.c
index 075d5e9..c35c688 100644
--- a/src/psaux/psobjs.c
+++ b/src/psaux/psobjs.c
@@ -925,7 +925,7 @@
     old_limit  = parser->limit;
 
     /* we store the elements count */
-    *(FT_Byte*)( (FT_Byte*)objects[0] + field->count_offset ) = num_elements;
+    *(FT_Byte*)( (FT_Byte*)objects[0] + field->count_offset ) = (FT_Byte)num_elements;
 
     /* we now load each element, adjusting the field.offset on each one */
     token = elements;
@@ -1156,7 +1156,7 @@
       }
       point->x = x;
       point->y = y;
-      *control = flag ? FT_Curve_Tag_On : FT_Curve_Tag_Cubic;
+      *control = (FT_Byte)(flag ? FT_Curve_Tag_On : FT_Curve_Tag_Cubic);
 
       builder->last = *point;
     }
@@ -1199,7 +1199,7 @@
     if ( !error )
     {
       if ( outline->n_contours > 0 )
-        outline->contours[outline->n_contours - 1] = outline->n_points - 1;
+        outline->contours[outline->n_contours - 1] = (short)(outline->n_points - 1);
 
       outline->n_contours++;
     }
@@ -1260,7 +1260,7 @@
     }
 
     if ( outline->n_contours > 0 )
-      outline->contours[outline->n_contours - 1] = outline->n_points - 1;
+      outline->contours[outline->n_contours - 1] = (short)(outline->n_points - 1);
   }
 
 
@@ -1282,8 +1282,8 @@
       FT_Byte  plain;
 
 
-      plain     = ( *buffer ^ ( seed >> 8 ) );
-      seed      = ( *buffer + seed ) * 52845U + 22719;
+      plain     = (FT_Byte)   ( *buffer ^ ( seed >> 8 ) );
+      seed      = (FT_UShort)(( *buffer + seed ) * 52845 + 22719 );
       *buffer++ = plain;
       length--;
     }
diff --git a/src/psaux/t1decode.c b/src/psaux/t1decode.c
index dd1c97a..dfd4b00 100644
--- a/src/psaux/t1decode.c
+++ b/src/psaux/t1decode.c
@@ -284,7 +284,7 @@
       FT_Outline  dummy;
 
 
-      dummy.n_points = base->n_points - n_base_points;
+      dummy.n_points = (short)(base->n_points - n_base_points);
       dummy.points   = base->points   + n_base_points;
 
       FT_Outline_Translate( &dummy, adx - asb, ady );
diff --git a/src/psnames/psmodule.c b/src/psnames/psmodule.c
index f5c5437..ec6f5dc 100644
--- a/src/psnames/psmodule.c
+++ b/src/psnames/psmodule.c
@@ -67,7 +67,7 @@
       for ( count = 4; count > 0; count--, p++ )
       {
         char           c = *p;
-        unsigned char  d;
+        unsigned int   d;
 
 
         d = (unsigned char)c - '0';
diff --git a/src/raster/ftraster.c b/src/raster/ftraster.c
index de4b28b..c819622 100644
--- a/src/raster/ftraster.c
+++ b/src/raster/ftraster.c
@@ -282,11 +282,11 @@
     FT_F26Dot6  X;           /* current coordinate during sweep        */
     PProfile    link;        /* link to next profile - various purpose */
     PLong       offset;      /* start of profile's data in render pool */
-    Int         flow;        /* Profile orientation: Asc/Descending    */
-    Long        height;      /* profile's height in scanlines          */
-    Long        start;       /* profile's starting scanline            */
+    int         flow;        /* Profile orientation: Asc/Descending    */
+    long        height;      /* profile's height in scanlines          */
+    long        start;       /* profile's starting scanline            */
 
-    UShort      countL;      /* number of lines to step before this    */
+    unsigned    countL;      /* number of lines to step before this    */
                              /* profile becomes drawable               */
 
     PProfile    next;        /* next profile in same contour, used     */
@@ -947,7 +947,7 @@
         ras.joint = FALSE;
       }
 
-    ras.joint = ( f2 == 0 );
+    ras.joint = (char)( f2 == 0 );
 
     if ( ras.fresh )
     {
@@ -1603,7 +1603,7 @@
     FT_Vector*  limit;
     char*       tags;
 
-    char        tag;       /* current point's state           */
+    unsigned    tag;       /* current point's state           */
 
 
     points = ras.outline.points;
@@ -1808,8 +1808,8 @@
   static
   Bool  Convert_Glyph( RAS_ARGS int  flipped )
   {
-    Short     i;
-    UShort    start;
+    int       i;
+    unsigned  start;
 
     PProfile  lastProfile;
 
@@ -1833,7 +1833,7 @@
       ras.state    = Unknown;
       ras.gProfile = NULL;
 
-      if ( Decompose_Curve( RAS_VARS start, ras.outline.contours[i], flipped ) )
+      if ( Decompose_Curve( RAS_VARS (unsigned short)start, ras.outline.contours[i], flipped ) )
         return FAILURE;
 
       start = ras.outline.contours[i] + 1;
@@ -1859,7 +1859,7 @@
     if ( Finalize_Profile_Table( RAS_VAR ) )
       return FAILURE;
 
-    return ( ras.top < ras.maxBuff ? SUCCESS : FAILURE );
+    return (Bool)( ras.top < ras.maxBuff ? SUCCESS : FAILURE );
   }
 
 
@@ -2058,7 +2058,7 @@
                                       PProfile    right )
   {
     Long   e1, e2;
-    Short  c1, c2;
+    int    c1, c2;
     Byte   f1, f2;
     Byte*  target;
 
@@ -2086,11 +2086,11 @@
       c1 = (Short)( e1 >> 3 );
       c2 = (Short)( e2 >> 3 );
 
-      f1 =    (unsigned char)0xFF >> ( e1 & 7 );
-      f2 = ~( (unsigned char)0x7F >> ( e2 & 7 ) );
+      f1 = (Byte)  ( 0xFF >> ( e1 & 7 ) );
+      f2 = (Byte) ~( 0x7F >> ( e2 & 7 ) );
 
-      if ( ras.gray_min_x > c1 ) ras.gray_min_x = c1;
-      if ( ras.gray_max_x < c2 ) ras.gray_max_x = c2;
+      if ( ras.gray_min_x > c1 ) ras.gray_min_x = (short)c1;
+      if ( ras.gray_max_x < c2 ) ras.gray_max_x = (short)c2;
 
       target = ras.bTarget + ras.traceOfs + c1;
       c2 -= c1;
@@ -2755,7 +2755,7 @@
       Sort( &draw_right );
 
       y_change = (Short)ras.sizeBuff[-ras.numTurns--];
-      y_height = y_change - y;
+      y_height = (Short)(y_change - y);
 
       while ( y < y_change )
       {
@@ -2929,7 +2929,7 @@
         i = ras.band_stack[ras.band_top].y_min;
         j = ras.band_stack[ras.band_top].y_max;
 
-        k = ( i + j ) / 2;
+        k = (Short)(( i + j ) / 2);
 
         if ( ras.band_top >= 7 || k < i )
         {
@@ -2942,7 +2942,7 @@
         ras.band_stack[ras.band_top + 1].y_min = k;
         ras.band_stack[ras.band_top + 1].y_max = j;
 
-        ras.band_stack[ras.band_top].y_max = k - 1;
+        ras.band_stack[ras.band_top].y_max = (Short)(k - 1);
 
         ras.band_top++;
       }
@@ -2980,7 +2980,7 @@
                         ft_outline_high_precision );
     ras.scale_shift    = ras.precision_shift;
     ras.dropOutControl = 2;
-    ras.second_pass    = !( ras.outline.flags & ft_outline_single_pass );
+    ras.second_pass    = (FT_Byte)(!( ras.outline.flags & ft_outline_single_pass ));
 
     /* Vertical Sweep */
     ras.Proc_Sweep_Init = Vertical_Sweep_Init;
@@ -2990,9 +2990,9 @@
 
     ras.band_top            = 0;
     ras.band_stack[0].y_min = 0;
-    ras.band_stack[0].y_max = ras.target.rows - 1;
+    ras.band_stack[0].y_max = (short)(ras.target.rows - 1);
 
-    ras.bWidth  = ras.target.width;
+    ras.bWidth  = (unsigned short)ras.target.width;
     ras.bTarget = (Byte*)ras.target.buffer;
 
     if ( ( error = Render_Single_Pass( RAS_VARS 0 ) ) != 0 )
@@ -3008,7 +3008,7 @@
 
       ras.band_top            = 0;
       ras.band_stack[0].y_min = 0;
-      ras.band_stack[0].y_max = ras.target.width - 1;
+      ras.band_stack[0].y_max = (short)(ras.target.width - 1);
 
       if ( ( error = Render_Single_Pass( RAS_VARS 1 ) ) != 0 )
         return error;
diff --git a/src/sfnt/sfobjs.c b/src/sfnt/sfobjs.c
index 438e47a..2392fd8 100644
--- a/src/sfnt/sfobjs.c
+++ b/src/sfnt/sfobjs.c
@@ -277,8 +277,8 @@
     /*                                                             */
 
     /* do we have outlines in there? */
-    has_outline   = ( ( TT_LookUp_Table( face, TTAG_glyf ) != 0 ) ||
-                      ( TT_LookUp_Table( face, TTAG_CFF  ) != 0 ) );
+    has_outline   = FT_BOOL( ( TT_LookUp_Table( face, TTAG_glyf ) != 0 ) ||
+                             ( TT_LookUp_Table( face, TTAG_CFF  ) != 0 ) );
     is_apple_sbit = 0;
     
 #ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS
@@ -286,7 +286,7 @@
     /* if this font doesn't contain outlines, we try to load */
     /* a `bhed' table                                        */
     if ( !has_outline )
-      is_apple_sbit = !LOAD_( bitmap_header );
+      is_apple_sbit = FT_BOOL(!LOAD_( bitmap_header ));
 
 #endif /* TT_CONFIG_OPTION_EMBEDDED_BITMAPS */
 
@@ -437,8 +437,8 @@
 
 
         charmap->root.face        = (FT_Face)face;
-        charmap->root.platform_id = platform;
-        charmap->root.encoding_id = encoding;
+        charmap->root.platform_id = (FT_UShort)platform;
+        charmap->root.encoding_id = (FT_UShort)encoding;
         charmap->root.encoding    = find_encoding( platform, encoding );
 
         /* now, set root->charmap with a unicode charmap */
@@ -538,13 +538,13 @@
         root->ascender  = face->horizontal.Ascender;
         root->descender = face->horizontal.Descender;
 
-        root->height    = root->ascender - root->descender +
-                          face->horizontal.Line_Gap;
+        root->height    = (FT_Short)( root->ascender - root->descender +
+                                      face->horizontal.Line_Gap );
 
         /* if the line_gap is 0, we add an extra 15% to the text height --  */
         /* this computation is based on various versions of Times New Roman */
         if ( face->horizontal.Line_Gap == 0 )
-          root->height = ( root->height * 115 + 50 ) / 100;
+          root->height = (FT_Short)(( root->height * 115 + 50 ) / 100 );
 
 #if 0
 
@@ -567,9 +567,9 @@
 
         root->max_advance_width   = face->horizontal.advance_Width_Max;
 
-        root->max_advance_height  = face->vertical_info
+        root->max_advance_height  = (FT_Short)( face->vertical_info
                                       ? face->vertical.advance_Height_Max
-                                      : root->height;
+                                      : root->height );
 
         root->underline_position  = face->postscript.underlinePosition;
         root->underline_thickness = face->postscript.underlineThickness;
diff --git a/src/sfnt/ttcmap.c b/src/sfnt/ttcmap.c
index 37f1034..e2584f2 100644
--- a/src/sfnt/ttcmap.c
+++ b/src/sfnt/ttcmap.c
@@ -123,7 +123,7 @@
 
       for ( i = 0; i < 256; i++ )
       {
-        u = GET_UShort() / 8;
+        u = (FT_UShort)(GET_UShort() / 8);
         cmap2->subHeaderKeys[i] = u;
 
         if ( num_SH < u )
@@ -134,8 +134,8 @@
 
       /* load subheaders */
 
-      cmap2->numGlyphId = l =
-        ( ( cmap->length - 2L * ( 256 + 3 ) - num_SH * 8L ) & 0xFFFF ) / 2;
+      cmap2->numGlyphId = l = (FT_UShort)(
+        ( ( cmap->length - 2L * ( 256 + 3 ) - num_SH * 8L ) & 0xFFFF ) / 2 );
 
       if ( ALLOC_ARRAY( cmap2->subHeaders,
                         num_SH + 1,
@@ -151,7 +151,7 @@
         cmap2sub->entryCount    = GET_UShort();
         cmap2sub->idDelta       = GET_Short();
         /* we apply the location offset immediately */
-        cmap2sub->idRangeOffset = GET_UShort() - ( num_SH - i ) * 8 - 2;
+        cmap2sub->idRangeOffset = (FT_UShort)( GET_UShort() - ( num_SH - i ) * 8 - 2 );
 
         cmap2sub++;
       }
@@ -185,7 +185,7 @@
       cmap4->entrySelector = GET_UShort();
       cmap4->rangeShift    = GET_UShort();
 
-      num_Seg = cmap4->segCountX2 / 2;
+      num_Seg = (FT_UShort)(cmap4->segCountX2 / 2);
 
       FORGET_Frame();
 
@@ -215,8 +215,8 @@
 
       FORGET_Frame();
 
-      cmap4->numGlyphId = l =
-        ( ( cmap->length - ( 16L + 8L * num_Seg ) ) & 0xFFFF ) / 2;
+      cmap4->numGlyphId = l = (FT_UShort)(
+        ( ( cmap->length - ( 16L + 8L * num_Seg ) ) & 0xFFFF ) / 2 );
 
       /* load IDs */
 
diff --git a/src/sfnt/ttload.c b/src/sfnt/ttload.c
index 38d1247..7a7486c 100644
--- a/src/sfnt/ttload.c
+++ b/src/sfnt/ttload.c
@@ -604,11 +604,11 @@
 
     face->root.num_glyphs = maxProfile->numGlyphs;
 
-    face->root.internal->max_points = MAX( maxProfile->maxCompositePoints,
-                                           maxProfile->maxPoints );
+    face->root.internal->max_points = (FT_UShort)MAX( maxProfile->maxCompositePoints,
+                                                      maxProfile->maxPoints );
 
-    face->root.internal->max_contours = MAX( maxProfile->maxCompositeContours,
-                                             maxProfile->maxContours );
+    face->root.internal->max_contours = (FT_Short)MAX( maxProfile->maxCompositeContours,
+                                                       maxProfile->maxContours );
 
     face->max_components = (FT_ULong)maxProfile->maxComponentElements +
                            maxProfile->maxComponentDepth;
diff --git a/src/sfnt/ttpost.c b/src/sfnt/ttpost.c
index 8a9df12..959f3f3 100644
--- a/src/sfnt/ttpost.c
+++ b/src/sfnt/ttpost.c
@@ -212,7 +212,7 @@
         {
           index -= 257;
           if ( index > num_names )
-            num_names = index;
+            num_names = (FT_UShort)index;
         }
       }
     }
@@ -244,8 +244,8 @@
       TT_Post_20*  table = &face->postscript_names.names.format_20;
 
 
-      table->num_glyphs    = num_glyphs;
-      table->num_names     = num_names;
+      table->num_glyphs    = (FT_UShort)num_glyphs;
+      table->num_names     = (FT_UShort)num_names;
       table->glyph_indices = glyph_indices;
       table->glyph_names   = name_strings;
     }
@@ -319,7 +319,7 @@
       TT_Post_25*  table = &face->postscript_names.names.format_25;
 
 
-      table->num_glyphs = num_glyphs;
+      table->num_glyphs = (FT_UShort)num_glyphs;
       table->offsets    = offset_table;
     }
 
diff --git a/src/sfnt/ttsbit.c b/src/sfnt/ttsbit.c
index 18f2dac..8850c6a 100644
--- a/src/sfnt/ttsbit.c
+++ b/src/sfnt/ttsbit.c
@@ -76,7 +76,7 @@
     FT_Int     height;
 
     FT_UShort  acc;
-    FT_Byte    loaded;
+    FT_UInt    loaded;
 
 
     /* first of all, compute starting write position */
@@ -104,10 +104,10 @@
 
     for ( height = target->rows; height > 0; height-- )
     {
-      FT_Byte*  cur   = line_buff;    /* current write cursor          */
-      FT_Int    count = line_bits;    /* # of bits to extract per line */
-      FT_Byte   shift = x_offset & 7; /* current write shift           */
-      FT_Byte   space = 8 - shift;
+      FT_Byte*  cur   = line_buff;      /* current write cursor          */
+      FT_UInt   count = line_bits;      /* # of bits to extract per line */
+      FT_Byte   shift = (FT_Byte)(x_offset & 7); /* current write shift  */
+      FT_Byte   space = (FT_Byte)(8 - shift);
 
 
       /* first of all, read individual source bytes */
@@ -163,7 +163,7 @@
         }
 
         /* now write remaining bits */
-        val     = ( (FT_Byte)( acc >> 8 ) ) & ~( 0xFF >> count );
+        val     = (FT_Byte)(( (FT_Byte)( acc >> 8 ) ) & ~( 0xFF >> count ));
         cur[0] |= val >> shift;
 
         if ( count > space )
@@ -175,7 +175,10 @@
 
       /* now, skip to next line */
       if ( byte_padded )
-        acc = loaded = 0;   /* clear accumulator on byte-padded lines */
+      {
+        acc    = 0;
+        loaded = 0;   /* clear accumulator on byte-padded lines */
+      }
 
       line_buff += line_incr;
     }
@@ -328,7 +331,7 @@
       {
         FT_ULong  num_glyphs, n;
         FT_Int    size_elem;
-        FT_Bool   large = ( range->index_format == 1 );
+        FT_Bool   large = FT_BOOL( range->index_format == 1 );
 
 
         num_glyphs        = range->last_glyph - range->first_glyph + 1L;
@@ -696,7 +699,7 @@
       if ( glyph_index >= (FT_UInt)range->first_glyph &&
            glyph_index <= (FT_UInt)range->last_glyph  )
       {
-        FT_UShort  delta = glyph_index - range->first_glyph;
+        FT_UShort  delta = (FT_UShort)(glyph_index - range->first_glyph);
 
 
         switch ( range->index_format )
@@ -992,9 +995,9 @@
         MEM_Move( line, line + count * line_len,
                   ( rows - count ) * line_len );
 
-        metrics->height       -= count;
-        metrics->horiBearingY -= count;
-        metrics->vertBearingY -= count;
+        metrics->height       = (FT_Byte)( metrics->height - count );
+        metrics->horiBearingY = (FT_Char)( metrics->horiBearingY - count );
+        metrics->vertBearingY = (FT_Char)( metrics->vertBearingY - count );
 
         map->rows -= count;
         rows      -= count;
@@ -1025,7 +1028,7 @@
     Found_Bottom:
       if ( count > 0 )
       {
-        metrics->height -= count;
+        metrics->height  = (FT_Byte)( metrics->height - count );
         rows            -= count;
         map->rows       -= count;
       }
@@ -1058,15 +1061,15 @@
         FT_Byte*  cur = line;
 
 
-        old = cur[0] << 1;
+        old = (FT_Byte)(cur[0] << 1);
         for ( n = 8; n < width; n += 8 )
         {
           FT_Byte  val;
 
 
           val    = cur[1];
-          cur[0] = old | ( val >> 7 );
-          old    = val << 1;
+          cur[0] = (FT_Byte)(old | ( val >> 7 ));
+          old    = (FT_Byte)(val << 1);
           cur++;
         }
         cur[0] = old;
@@ -1095,7 +1098,7 @@
 
       line  = (FT_Byte*)map->buffer + ( right >> 3 );
       limit = line + rows * line_len;
-      mask  = 0x80 >> ( right & 7 );
+      mask  = (FT_Byte)(0x80 >> ( right & 7 ));
 
       for ( ; line < limit; line += line_len )
         if ( line[0] & mask )
@@ -1449,9 +1452,9 @@
 
       /* some heuristic values */
 
-      metrics->vertBearingX = -metrics->width / 2;
-      metrics->vertBearingY =  advance / 10;
-      metrics->vertAdvance  =  advance * 12 / 10;
+      metrics->vertBearingX = (FT_Char)(-metrics->width / 2);
+      metrics->vertBearingY = (FT_Char)( advance / 10 );
+      metrics->vertAdvance  = (FT_Char)( advance * 12 / 10 );
     }
 
     /* Crop the bitmap now, unless specified otherwise */
diff --git a/src/smooth/ftgrays.c b/src/smooth/ftgrays.c
index cb6ee2b..03205bb 100644
--- a/src/smooth/ftgrays.c
+++ b/src/smooth/ftgrays.c
@@ -1308,7 +1308,7 @@
            (int)span->x + span->len == (int)x &&
            span->coverage == coverage )
       {
-        span->len += acount;
+        span->len = (unsigned short)(span->len + acount);
         return;
       }
 
diff --git a/src/truetype/ttgload.c b/src/truetype/ttgload.c
index 05c1d48..f2155c4 100644
--- a/src/truetype/ttgload.c
+++ b/src/truetype/ttgload.c
@@ -180,8 +180,8 @@
                          FT_UInt        start_point,
                          FT_UInt        start_contour )
   {
-    zone->n_points   = load->outline.n_points - start_point;
-    zone->n_contours = load->outline.n_contours - start_contour;
+    zone->n_points   = (FT_UShort)(load->outline.n_points - start_point);
+    zone->n_contours = (FT_Short) (load->outline.n_contours - start_contour);
     zone->org        = load->extra_points + start_point;
     zone->cur        = load->outline.points + start_point;
     zone->tags       = (FT_Byte*)load->outline.tags + start_point;
@@ -408,8 +408,8 @@
     for ( n = 0; n < n_points; n++ )
       outline->tags[n] &= FT_Curve_Tag_On;
 
-    outline->n_points   = n_points;
-    outline->n_contours = n_contours;
+    outline->n_points   = (FT_UShort)n_points;
+    outline->n_contours = (FT_Short) n_contours;
 
   Fail:
     return error;
@@ -1215,14 +1215,14 @@
         /*                                                     */
         if ( face->os2.version != 0xFFFF )
         {
-          top_bearing    = face->os2.sTypoLineGap / 2;
+          top_bearing    = (FT_Short)(face->os2.sTypoLineGap / 2);
           advance_height = (FT_UShort)( face->os2.sTypoAscender -
                                         face->os2.sTypoDescender +
                                         face->os2.sTypoLineGap );
         }
         else
         {
-          top_bearing    = face->horizontal.Line_Gap / 2;
+          top_bearing    = (FT_Short)(face->horizontal.Line_Gap / 2);
           advance_height = (FT_UShort)( face->horizontal.Ascender  +
                                         face->horizontal.Descender +
                                         face->horizontal.Line_Gap );
diff --git a/src/type1/t1gload.c b/src/type1/t1gload.c
index 695897f..01f82ea 100644
--- a/src/type1/t1gload.c
+++ b/src/type1/t1gload.c
@@ -161,8 +161,8 @@
     glyph->root.outline.n_points   = 0;
     glyph->root.outline.n_contours = 0;
 
-    hinting = ( load_flags & FT_LOAD_NO_SCALE   ) == 0 &&
-              ( load_flags & FT_LOAD_NO_HINTING ) == 0;
+    hinting = FT_BOOL( ( load_flags & FT_LOAD_NO_SCALE   ) == 0 &&
+                       ( load_flags & FT_LOAD_NO_HINTING ) == 0 );
 
     glyph->root.format = ft_glyph_format_outline;
 
@@ -176,7 +176,7 @@
     if ( error )
       goto Exit;
 
-    decoder.builder.no_recurse = ( ( load_flags & FT_LOAD_NO_RECURSE ) != 0 );
+    decoder.builder.no_recurse = FT_BOOL( ( load_flags & FT_LOAD_NO_RECURSE ) != 0 );
 
     decoder.num_subrs = type1->num_subrs;
     decoder.subrs     = type1->subrs;
diff --git a/src/type1/t1load.c b/src/type1/t1load.c
index faff552..4934242 100644
--- a/src/type1/t1load.c
+++ b/src/type1/t1load.c
@@ -1702,7 +1702,7 @@
             if ( strcmp( (const char*)char_name,
                          (const char*)glyph_name ) == 0 )
             {
-              type1->encoding.char_index[charcode] = index;
+              type1->encoding.char_index[charcode] = (FT_UShort)index;
               type1->encoding.char_name [charcode] = (char*)glyph_name;
 
               /* Change min/max encoded char only if glyph name is */
diff --git a/src/type1/t1objs.c b/src/type1/t1objs.c
index 1c9f45b..c5d1cc7 100644
--- a/src/type1/t1objs.c
+++ b/src/type1/t1objs.c
@@ -278,7 +278,7 @@
 
       root->ascender  = (FT_Short)( face->type1.font_bbox.yMax >> 16 );
       root->descender = (FT_Short)( face->type1.font_bbox.yMin >> 16 );
-      root->height    = ( ( root->ascender - root->descender ) * 12 ) / 10;
+      root->height    = (FT_Short)(( ( root->ascender - root->descender ) * 12 ) / 10 );
 
       /* now compute the maximum advance width */
       root->max_advance_width =
@@ -291,7 +291,7 @@
 
         /* in case of error, keep the standard width */
         if ( !error )
-          root->max_advance_width = max_advance;
+          root->max_advance_width = (FT_Short)max_advance;
         else
           error = 0;   /* clear error */
       }
diff --git a/src/type1/t1parse.c b/src/type1/t1parse.c
index fee1b38..a31f248 100644
--- a/src/type1/t1parse.c
+++ b/src/type1/t1parse.c
@@ -436,7 +436,7 @@
             break;
 
           /* otherwise, store byte */
-          *write++ = ( hex1 << 4 ) | hexa_value( cur[1] );
+          *write++ = (FT_Byte)(( hex1 << 4 ) | hexa_value( cur[1] ));
           count++;
           cur++;
         }
diff --git a/src/winfonts/winfnt.c b/src/winfonts/winfnt.c
index 423b484..c5e7750 100644
--- a/src/winfonts/winfnt.c
+++ b/src/winfonts/winfnt.c
@@ -524,7 +524,7 @@
     else
       glyph_index = font->header.default_char - font->header.first_char;
 
-    new_format = font->header.version == 0x300;
+    new_format = FT_BOOL( font->header.version == 0x300 );
     len        = new_format ? 6 : 4;
 
     /* jump to glyph entry */