Commit c56216283418771f42842efa72a334f2fc762e63

David Turner 2005-06-30T11:46:46

* src/sfnt/ftbitmap.c, src/truetype/ttgload.c, src/sfnt/ttcmap.c: removing compiler warnings (Visual C++ /W4) * Jamfile, src/otvalid/{otvcommn.h,otvgdef.c,otvgpos.c,otvgsub.c, otvjstf.c}: modified the code to use a different pre-processor trick to implement the OTV_NEST1, OTV_NEST2 and OTV_NEST3 macros. The code now compiles neatly with Visual C++. The 'otvalid' module has been put in the Jamfile build again.

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
diff --git a/ChangeLog b/ChangeLog
index 99ac8d7..285d73c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2005-06-30  David Turner  <david@freetype.org>
+
+        * src/sfnt/ftbitmap.c, src/truetype/ttgload.c, src/sfnt/ttcmap.c:
+        removing compiler warnings (Visual C++ /W4)
+
+        * Jamfile, src/otvalid/{otvcommn.h,otvgdef.c,otvgpos.c,otvgsub.c,
+        otvjstf.c}: modified the code to use a different pre-processor trick
+        to implement the OTV_NEST1, OTV_NEST2 and OTV_NEST3 macros. The code
+        now compiles neatly with Visual C++. The 'otvalid' module has been
+        put in the Jamfile build again.
+
 2005-06-20  Chia I Wu  <b90201047@ntu.edu.tw>
 
 	* include/freetype/internal/ftobjs.h, src/base/ftobjs.c: New function
@@ -5,7 +16,7 @@
 
 	* src/truetype/ttgload.c (compute_glyph_metrics): Use
 	ft_glyphslot_grid_fit_metrics.
-	
+
 	* src/cff/cffgload.c (cff_slot_load), src/cid/cidgload.c
 	(cid_slot_load_glyph), src/type1/t1gload.c (T1_Load_Glyph): Use
 	ft_glyphslot_grid_fit_metrics.
diff --git a/Jamfile b/Jamfile
index 74e9f6c..5b4614b 100644
--- a/Jamfile
+++ b/Jamfile
@@ -78,7 +78,7 @@ FT2_COMPONENTS ?= autofit    # auto-fitter
                   cid        # PostScript CID-keyed font driver
                   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/src/base/ftbitmap.c b/src/base/ftbitmap.c
index 7c95af7..dc5911d 100644
--- a/src/base/ftbitmap.c
+++ b/src/base/ftbitmap.c
@@ -277,7 +277,7 @@
     /* for each row */
     for ( y = 0; y < bitmap->rows ; y++ )
     {
-      /* 
+      /*
        * Horizontally:
        *
        * From the last pixel on, make each pixel or'ed with the
@@ -310,12 +310,12 @@
             {
               if ( p[x] + p[x - i] > bitmap->num_grays - 1 )
               {
-                p[x] = bitmap->num_grays - 1;
+                p[x] = (unsigned char)(bitmap->num_grays - 1);
                 break;
               }
               else
               {
-                p[x] += p[x - i];
+                p[x] = (unsigned char)(p[x] + p[x-i]);
                 if ( p[x] == bitmap->num_grays - 1 )
                   break;
               }
@@ -326,7 +326,7 @@
         }
       }
 
-      /* 
+      /*
        * Vertically:
        *
        * Make the above `ystr' rows or'ed with it.
diff --git a/src/otvalid/otvcommn.h b/src/otvalid/otvcommn.h
index f0c6945..7808798 100644
--- a/src/otvalid/otvcommn.h
+++ b/src/otvalid/otvcommn.h
@@ -109,39 +109,42 @@ FT_BEGIN_HEADER
           FT_END_STMNT
 
 
+#define  OTV_NAME_(x)  #x
+#define  OTV_NAME(x)   OTV_NAME_(x)
+
+#define  OTV_FUNC_(x)  x##Func
+#define  OTV_FUNC(x)   OTV_FUNC_(x)
+
 #ifdef FT_DEBUG_LEVEL_TRACE
 
   /* use preprocessor's argument prescan to expand one argument into two */
-#define OTV_NEST1( x )  OTV_NEST1_( x )
-#define OTV_NEST1_( func0, name0 )                 \
-          FT_BEGIN_STMNT                           \
-            valid->nesting_level          = 0;     \
-            valid->func[0]                = func0; \
-            valid->debug_function_name[0] = name0; \
+#define OTV_NEST1( x )                                     \
+          FT_BEGIN_STMNT                                   \
+            valid->nesting_level          = 0;             \
+            valid->func[0]                = OTV_FUNC(x);   \
+            valid->debug_function_name[0] = OTV_NAME(x);   \
           FT_END_STMNT
 
   /* use preprocessor's argument prescan to expand two arguments into four */
-#define OTV_NEST2( x, y )  OTV_NEST2_( x, y )
-#define OTV_NEST2_( func0, name0, func1, name1 )   \
-          FT_BEGIN_STMNT                           \
-            valid->nesting_level          = 0;     \
-            valid->func[0]                = func0; \
-            valid->func[1]                = func1; \
-            valid->debug_function_name[0] = name0; \
-            valid->debug_function_name[1] = name1; \
+#define OTV_NEST2( x, y )                                   \
+          FT_BEGIN_STMNT                                    \
+            valid->nesting_level          = 0;              \
+            valid->func[0]                = OTV_FUNC(x);    \
+            valid->func[1]                = OTV_FUNC(y);    \
+            valid->debug_function_name[0] = OTV_NAME(x);    \
+            valid->debug_function_name[1] = OTV_NAME(y);    \
           FT_END_STMNT
 
   /* use preprocessor's argument prescan to expand three arguments into six */
-#define OTV_NEST3( x, y, z )  OTV_NEST3_( x, y, z )
-#define OTV_NEST3_( func0, name0, func1, name1, func2, name2 ) \
-          FT_BEGIN_STMNT                                       \
-            valid->nesting_level          = 0;                 \
-            valid->func[0]                = func0;             \
-            valid->func[1]                = func1;             \
-            valid->func[2]                = func2;             \
-            valid->debug_function_name[0] = name0;             \
-            valid->debug_function_name[1] = name1;             \
-            valid->debug_function_name[2] = name2;             \
+#define OTV_NEST3( x, y, z )                                \
+          FT_BEGIN_STMNT                                    \
+            valid->nesting_level          = 0;              \
+            valid->func[0]                = OTV_FUNC(x);    \
+            valid->func[1]                = OTV_FUNC(y);    \
+            valid->func[2]                = OTV_FUNC(z);    \
+            valid->debug_function_name[0] = OTV_NAME(x);    \
+            valid->debug_function_name[1] = OTV_NAME(y);    \
+            valid->debug_function_name[2] = OTV_NAME(z);    \
           FT_END_STMNT
 
 #define OTV_INIT  valid->debug_indent = 0
@@ -172,30 +175,27 @@ FT_BEGIN_HEADER
 #else   /* !FT_DEBUG_LEVEL_TRACE */
 
   /* use preprocessor's argument prescan to expand one argument into two */
-#define OTV_NEST1( x )  OTV_NEST1_( x )
-#define OTV_NEST1_( func0, name0 )        \
-          FT_BEGIN_STMNT                  \
-            valid->nesting_level = 0;     \
-            valid->func[0]       = func0; \
+#define OTV_NEST1( x )                          \
+          FT_BEGIN_STMNT                        \
+            valid->nesting_level = 0;           \
+            valid->func[0]       = OTV_FUNC(x); \
           FT_END_STMNT
 
   /* use preprocessor's argument prescan to expand two arguments into four */
-#define OTV_NEST2( x, y )  OTV_NEST2_( x, y )
-#define OTV_NEST2_( func0, name0, func1, name1 ) \
+#define OTV_NEST2( x, y )                        \
           FT_BEGIN_STMNT                         \
             valid->nesting_level = 0;            \
-            valid->func[0]       = func0;        \
-            valid->func[1]       = func1;        \
+            valid->func[0]       = OTV_FUNC(x);  \
+            valid->func[1]       = OTV_FUNC(y);  \
           FT_END_STMNT
 
   /* use preprocessor's argument prescan to expand three arguments into six */
-#define OTV_NEST3( x, y, z )  OTV_NEST3_( x, y, z )
-#define OTV_NEST3_( func0, name0, func1, name1, func2, name2 ) \
-          FT_BEGIN_STMNT                                       \
-            valid->nesting_level = 0;                          \
-            valid->func[0]       = func0;                      \
-            valid->func[1]       = func1;                      \
-            valid->func[2]       = func2;                      \
+#define OTV_NEST3( x, y, z )                     \
+          FT_BEGIN_STMNT                         \
+            valid->nesting_level = 0;            \
+            valid->func[0]       = OTV_FUNC(x);  \
+            valid->func[1]       = OTV_FUNC(y);  \
+            valid->func[2]       = OTV_FUNC(z);  \
           FT_END_STMNT
 
 #define OTV_INIT                do ; while ( 0 )
@@ -338,6 +338,7 @@ FT_BEGIN_HEADER
   /*************************************************************************/
   /*************************************************************************/
 
+#if 0
 #define ChainPosClassSet  otv_x_Ox, "ChainPosClassSet"
 #define ChainPosRuleSet   otv_x_Ox, "ChainPosRuleSet"
 #define ChainSubClassSet  otv_x_Ox, "ChainSubClassSet"
@@ -351,11 +352,27 @@ FT_BEGIN_HEADER
 #define PosRuleSet        otv_x_Ox, "PosRuleSet"
 #define SubClassSet       otv_x_Ox, "SubClassSet"
 #define SubRuleSet        otv_x_Ox, "SubRuleSet"
+#endif
+
+#define ChainPosClassSetFunc  otv_x_Ox
+#define ChainPosRuleSetFunc   otv_x_Ox
+#define ChainSubClassSetFunc  otv_x_Ox
+#define ChainSubRuleSetFunc   otv_x_Ox
+#define JstfLangSysFunc       otv_x_Ox
+#define JstfMaxFunc           otv_x_Ox
+#define LigGlyphFunc          otv_x_Ox
+#define LigatureArrayFunc     otv_x_Ox
+#define LigatureSetFunc       otv_x_Ox
+#define PosClassSetFunc       otv_x_Ox
+#define PosRuleSetFunc        otv_x_Ox
+#define SubClassSetFunc       otv_x_Ox
+#define SubRuleSetFunc        otv_x_Ox
 
   FT_LOCAL( void )
   otv_x_Ox ( FT_Bytes       table,
              OTV_Validator  valid );
 
+#if 0
 #define AlternateSubstFormat1     otv_u_C_x_Ox, "AlternateSubstFormat1"
 #define ChainContextPosFormat1    otv_u_C_x_Ox, "ChainContextPosFormat1"
 #define ChainContextSubstFormat1  otv_u_C_x_Ox, "ChainContextSubstFormat1"
@@ -363,63 +380,115 @@ FT_BEGIN_HEADER
 #define ContextSubstFormat1       otv_u_C_x_Ox, "ContextSubstFormat1"
 #define LigatureSubstFormat1      otv_u_C_x_Ox, "LigatureSubstFormat1"
 #define MultipleSubstFormat1      otv_u_C_x_Ox, "MultipleSubstFormat1"
+#endif
+
+#define AlternateSubstFormat1Func     otv_u_C_x_Ox
+#define ChainContextPosFormat1Func    otv_u_C_x_Ox
+#define ChainContextSubstFormat1Func  otv_u_C_x_Ox
+#define ContextPosFormat1Func         otv_u_C_x_Ox
+#define ContextSubstFormat1Func       otv_u_C_x_Ox
+#define LigatureSubstFormat1Func      otv_u_C_x_Ox
+#define MultipleSubstFormat1Func      otv_u_C_x_Ox
+
 
   FT_LOCAL( void )
   otv_u_C_x_Ox( FT_Bytes       table,
                 OTV_Validator  valid );
 
+#if 0
 #define AlternateSet     otv_x_ux, "AlternateSet"
 #define AttachPoint      otv_x_ux, "AttachPoint"
 #define ExtenderGlyph    otv_x_ux, "ExtenderGlyph"
 #define JstfGPOSModList  otv_x_ux, "JstfGPOSModList"
 #define JstfGSUBModList  otv_x_ux, "JstfGSUBModList"
 #define Sequence         otv_x_ux, "Sequence"
+#endif
+#define AlternateSetFunc     otv_x_ux
+#define AttachPointFunc      otv_x_ux
+#define ExtenderGlyphFunc    otv_x_ux
+#define JstfGPOSModListFunc  otv_x_ux
+#define JstfGSUBModListFunc  otv_x_ux
+#define SequenceFunc         otv_x_ux
 
   FT_LOCAL( void )
   otv_x_ux( FT_Bytes       table,
             OTV_Validator  valid );
 
+#if 0
 #define PosClassRule  otv_x_y_ux_sy, "PosClassRule"
 #define PosRule       otv_x_y_ux_sy, "PosRule"
 #define SubClassRule  otv_x_y_ux_sy, "SubClassRule"
 #define SubRule       otv_x_y_ux_sy, "SubRule"
+#endif
+
+#define PosClassRuleFunc  otv_x_y_ux_sy
+#define PosRuleFunc       otv_x_y_ux_sy
+#define SubClassRuleFunc  otv_x_y_ux_sy
+#define SubRuleFunc       otv_x_y_ux_sy
 
   FT_LOCAL( void )
   otv_x_y_ux_sy( FT_Bytes       table,
                  OTV_Validator  valid );
 
+#if 0
 #define ChainPosClassRule  otv_x_ux_y_uy_z_uz_p_sp, "ChainPosClassRule"
 #define ChainPosRule       otv_x_ux_y_uy_z_uz_p_sp, "ChainPosRule"
 #define ChainSubClassRule  otv_x_ux_y_uy_z_uz_p_sp, "ChainSubClassRule"
 #define ChainSubRule       otv_x_ux_y_uy_z_uz_p_sp, "ChainSubRule"
+#endif
+
+#define ChainPosClassRuleFunc  otv_x_ux_y_uy_z_uz_p_sp
+#define ChainPosRuleFunc       otv_x_ux_y_uy_z_uz_p_sp
+#define ChainSubClassRuleFunc  otv_x_ux_y_uy_z_uz_p_sp
+#define ChainSubRuleFunc       otv_x_ux_y_uy_z_uz_p_sp
 
   FT_LOCAL( void )
   otv_x_ux_y_uy_z_uz_p_sp( FT_Bytes       table,
                            OTV_Validator  valid );
 
+#if 0
 #define ContextPosFormat2    otv_u_O_O_x_Onx, "ContextPosFormat2"
 #define ContextSubstFormat2  otv_u_O_O_x_Onx, "ContextSubstFormat2"
+#endif
+
+#define ContextPosFormat2Func    otv_u_O_O_x_Onx
+#define ContextSubstFormat2Func  otv_u_O_O_x_Onx
 
   FT_LOCAL( void )
   otv_u_O_O_x_Onx( FT_Bytes       table,
                    OTV_Validator  valid );
 
+#if 0
 #define ContextPosFormat3    otv_u_x_y_Ox_sy, "ContextPosFormat3"
 #define ContextSubstFormat3  otv_u_x_y_Ox_sy, "ContextSubstFormat3"
+#endif
+
+#define ContextPosFormat3Func    otv_u_x_y_Ox_sy
+#define ContextSubstFormat3Func  otv_u_x_y_Ox_sy
 
   FT_LOCAL( void )
   otv_u_x_y_Ox_sy( FT_Bytes       table,
                    OTV_Validator  valid );
 
-#define ChainContextPosFormat2    otv_u_O_O_O_O_x_Onx, "ChainContextPosFormat2"
-#define ChainContextSubstFormat2  otv_u_O_O_O_O_x_Onx, "ChainContextSubstFormat2"
+#if 0
+#define ChainContextPosFormat2        otv_u_O_O_O_O_x_Onx, "ChainContextPosFormat2"
+#define ChainContextSubstFormat2      otv_u_O_O_O_O_x_Onx, "ChainContextSubstFormat2"
+#endif
+
+#define ChainContextPosFormat2Func    otv_u_O_O_O_O_x_Onx
+#define ChainContextSubstFormat2Func  otv_u_O_O_O_O_x_Onx
 
   FT_LOCAL( void )
   otv_u_O_O_O_O_x_Onx( FT_Bytes       table,
                        OTV_Validator  valid );
 
-#define ChainContextPosFormat3    otv_u_x_Ox_y_Oy_z_Oz_p_sp, "ChainContextPosFormat3"
-#define ChainContextSubstFormat3  otv_u_x_Ox_y_Oy_z_Oz_p_sp, "ChainContextSubstFormat3"
+#if 0
+#define ChainContextPosFormat3        otv_u_x_Ox_y_Oy_z_Oz_p_sp, "ChainContextPosFormat3"
+#define ChainContextSubstFormat3      otv_u_x_Ox_y_Oy_z_Oz_p_sp, "ChainContextSubstFormat3"
+#endif
+
+#define ChainContextPosFormat3Func    otv_u_x_Ox_y_Oy_z_Oz_p_sp
+#define ChainContextSubstFormat3Func  otv_u_x_Ox_y_Oy_z_Oz_p_sp
 
   FT_LOCAL( void )
   otv_u_x_Ox_y_Oy_z_Oz_p_sp( FT_Bytes       table,
diff --git a/src/otvalid/otvgdef.c b/src/otvalid/otvgdef.c
index e408c70..60f75f5 100644
--- a/src/otvalid/otvgdef.c
+++ b/src/otvalid/otvgdef.c
@@ -38,8 +38,8 @@
   /*************************************************************************/
   /*************************************************************************/
 
-#define AttachList    otv_O_x_Ox, "AttachList"
-#define LigCaretList  otv_O_x_Ox, "LigCaretList"
+#define AttachListFunc    otv_O_x_Ox
+#define LigCaretListFunc  otv_O_x_Ox
 
   /* sets valid->extra1 (0)           */
 
@@ -88,7 +88,7 @@
   /*************************************************************************/
   /*************************************************************************/
 
-#define  CaretValue  otv_CaretValue_validate, "CaretValue"
+#define  CaretValueFunc  otv_CaretValue_validate
 
   static void
   otv_CaretValue_validate( FT_Bytes       table,
diff --git a/src/otvalid/otvgpos.c b/src/otvalid/otvgpos.c
index ceffd2f..a93a007 100644
--- a/src/otvalid/otvgpos.c
+++ b/src/otvalid/otvgpos.c
@@ -48,9 +48,9 @@
   /*************************************************************************/
   /*************************************************************************/
 
-#define BaseArray       otv_x_sxy, "BaseArray"
-#define LigatureAttach  otv_x_sxy, "LigatureAttach"
-#define Mark2Array      otv_x_sxy, "Mark2Array"
+#define BaseArrayFunc       otv_x_sxy
+#define LigatureAttachFunc  otv_x_sxy
+#define Mark2ArrayFunc      otv_x_sxy
 
   /* uses valid->extra1 (counter)                             */
   /* uses valid->extra2 (boolean to handle NULL anchor field) */
@@ -88,8 +88,8 @@
           OTV_SIZE_CHECK( anchor_offset );
           if ( anchor_offset )
             otv_Anchor_validate( table + anchor_offset, valid );
-        }        
-        else  
+        }
+        else
           otv_Anchor_validate( table + anchor_offset, valid );
       }
 
@@ -97,9 +97,9 @@
   }
 
 
-#define MarkBasePosFormat1  otv_u_O_O_u_O_O, "MarkBasePosFormat1"
-#define MarkLigPosFormat1   otv_u_O_O_u_O_O, "MarkLigPosFormat1"
-#define MarkMarkPosFormat1  otv_u_O_O_u_O_O, "MarkMarkPosFormat1"
+#define MarkBasePosFormat1Func  otv_u_O_O_u_O_O
+#define MarkLigPosFormat1Func   otv_u_O_O_u_O_O
+#define MarkMarkPosFormat1Func  otv_u_O_O_u_O_O
 
   /* sets valid->extra1 (class count) */
 
@@ -130,7 +130,7 @@
     otv_MarkArray_validate( table + Array1, valid );
 
     valid->nesting_level++;
-    func          = valid->func[valid->nesting_level];    
+    func          = valid->func[valid->nesting_level];
     valid->extra1 = ClassCount;
 
     func( table + Array2, valid );
@@ -861,8 +861,7 @@
       /* context rules since even invalid glyph indices/classes return  */
       /* meaningful results                                             */
 
-      OTV_NEST3( ChainContextPosFormat2,
-                 ChainPosClassSet, ChainPosClassRule );
+      OTV_NEST3( ChainContextPosFormat2,ChainPosClassSet, ChainPosClassRule );
       OTV_RUN( table, valid );
       break;
 
diff --git a/src/otvalid/otvgsub.c b/src/otvalid/otvgsub.c
index 022fa46..91dae0b 100644
--- a/src/otvalid/otvgsub.c
+++ b/src/otvalid/otvgsub.c
@@ -200,7 +200,7 @@
   /*************************************************************************/
   /*************************************************************************/
 
-#define Ligature  otv_Ligature_validate, "Ligature"
+#define LigatureFunc  otv_Ligature_validate
 
   /* uses valid->glyph_count */
 
diff --git a/src/otvalid/otvjstf.c b/src/otvalid/otvjstf.c
index a230b36..80b8dd6 100644
--- a/src/otvalid/otvjstf.c
+++ b/src/otvalid/otvjstf.c
@@ -31,8 +31,8 @@
 #define FT_COMPONENT  trace_otvjstf
 
 
-#define JstfPriority  otv_JstfPriority_validate, "JstfPriority"
-#define JstfLookup    otv_GPOS_subtable_validate, ""
+#define JstfPriorityFunc  otv_JstfPriority_validate
+#define JstfLookupFunc    otv_GPOS_subtable_validate
 
   /* uses valid->extra1 (GSUB lookup count) */
   /* uses valid->extra2 (GPOS lookup count) */
@@ -69,7 +69,7 @@
     table_size = 20;
 
     valid->extra1 = gsub_lookup_count;
-    
+
     OTV_OPTIONAL_OFFSET( ShrinkageEnableGSUB );
     OTV_SIZE_CHECK( ShrinkageEnableGSUB );
     if ( ShrinkageEnableGSUB )
diff --git a/src/sfnt/ttcmap.c b/src/sfnt/ttcmap.c
index 0f3a324..2dbb342 100644
--- a/src/sfnt/ttcmap.c
+++ b/src/sfnt/ttcmap.c
@@ -2160,7 +2160,7 @@
           if ( clazz->format == format )
           {
             volatile TT_ValidatorRec  valid;
-            FT_Error                  error = SFNT_Err_Ok;
+            volatile FT_Error         error = SFNT_Err_Ok;
 
 
             ft_validator_init( FT_VALIDATOR( &valid ), cmap, limit,
diff --git a/src/truetype/ttgload.c b/src/truetype/ttgload.c
index a975aa4..1c4bd2e 100644
--- a/src/truetype/ttgload.c
+++ b/src/truetype/ttgload.c
@@ -124,9 +124,9 @@
       p      = face->horz_metrics;
       limit  = p + face->horz_metrics_size;
     }
-    
+
     k = header->number_Of_HMetrics;
-    
+
     if ( k > 0 )
     {
       if ( idx < (FT_UInt)k )
@@ -134,7 +134,7 @@
         p += 4 * idx;
         if ( p + 4 > limit )
           goto NoData;
-          
+
         *aadvance = FT_NEXT_USHORT( p );
         *abearing = FT_NEXT_SHORT( p );
       }
@@ -143,7 +143,7 @@
         p += 4 * ( k - 1 );
         if ( p + 4 > limit )
           goto NoData;
-          
+
         *aadvance = FT_NEXT_USHORT( p );
         p += 2 + 2 * ( idx - k );
         if ( p + 2 > limit )
@@ -233,7 +233,7 @@
     FT_Byte*  result      = NULL;
     FT_ULong  record_size = face->hdmx_record_size;
     FT_Byte*  record      = face->hdmx_table + 8;
-    
+
 
     for ( nn = 0; nn < face->hdmx_record_count; nn++ )
       if ( face->hdmx_record_sizes[nn] == ppem )
@@ -1774,18 +1774,20 @@
         /*       table in the font.  Otherwise, we use the     */
         /*       values defined in the horizontal header.      */
 
-        height = FT_DivFix( bbox.yMax - bbox.yMin, y_scale );
+        height = (FT_Short)FT_DivFix( bbox.yMax - bbox.yMin, y_scale );
         if ( face->os2.version != 0xFFFFU )
         {
           /* sTypoDescender is negative */
-          max_height = face->os2.sTypoAscender - face->os2.sTypoDescender;
+          max_height     = (FT_Short)(face->os2.sTypoAscender -
+                                      face->os2.sTypoDescender);
 
           top_bearing    = (FT_Short)( ( max_height - height ) / 2 );
           advance_height = (FT_UShort)( max_height + face->os2.sTypoLineGap );
         }
         else
         {
-          max_height = face->horizontal.Ascender + face->horizontal.Descender;
+          max_height = (FT_Short)(face->horizontal.Ascender +
+                                  face->horizontal.Descender);
 
           top_bearing    = (FT_Short)( ( max_height - height ) / 2 );
           advance_height = (FT_UShort)( max_height +