Commit ac39ecdca8db98fcca49f56a615cd84d796bd9bc

Werner Lemberg 2000-06-30T22:24:36

Formatting... Fixing incorrect scaling of vertical advance width.

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
diff --git a/src/cff/t2gload.c b/src/cff/t2gload.c
index 47f9794..dfde78b 100644
--- a/src/cff/t2gload.c
+++ b/src/cff/t2gload.c
@@ -1659,7 +1659,7 @@
         T2_Forget_Element( &cff->charstrings_index, &charstring );
       }
 
-      /* ignore the error if one has occured - skip to next glyph */
+      /* ignore the error if one has occurred -- skip to next glyph */
       error = 0;
     }
 
@@ -1800,10 +1800,10 @@
 
           /* Then scale the metrics */
           metrics->horiAdvance  = FT_MulFix( metrics->horiAdvance,  x_scale );
+          metrics->vertAdvance  = FT_MulFix( metrics->vertAdvance,  y_scale );
 
           metrics->vertBearingX = FT_MulFix( metrics->vertBearingX, x_scale );
           metrics->vertBearingY = FT_MulFix( metrics->vertBearingY, y_scale );
-          metrics->vertAdvance  = FT_MulFix( metrics->vertAdvance,  x_scale );
         }
 
 #if 0
diff --git a/src/cid/cidafm.c b/src/cid/cidafm.c
index 3b1bd26..ce2739b 100644
--- a/src/cid/cidafm.c
+++ b/src/cid/cidafm.c
@@ -36,8 +36,6 @@
 #define FT_COMPONENT  trace_cidafm
 
 
-#if 1
-
   LOCAL_FUNC
   void  CID_Done_AFM( FT_Memory  memory,
                       CID_AFM*   afm )
@@ -120,7 +118,7 @@
     while ( p < limit && !isdigit( *p ) )
     {
       sign = 1;
-      if (*p == '-')
+      if ( *p == '-' )
         sign = -1;
 
       p++;
@@ -138,7 +136,7 @@
 
 
 #undef  KERN_INDEX
-#define KERN_INDEX( g1, g2 ) ( ( (FT_ULong)g1 << 16 ) | g2 )
+#define KERN_INDEX( g1, g2 )  ( ( (FT_ULong)g1 << 16 ) | g2 )
 
 
   /* compare two kerning pairs */
@@ -157,7 +155,7 @@
   }
 
 
-  /* parse an AFM file - for now, only read the kerning pairs */
+  /* parse an AFM file -- for now, only read the kerning pairs */
   LOCAL_FUNC
   FT_Error  CID_Read_AFM( FT_Face    cid_face,
                           FT_Stream  stream )
@@ -180,8 +178,8 @@
     limit = (FT_Byte*)stream->limit;
     p     = start;
 
-    /* we are now going to count the occurences of `KP' or `KPX' in */
-    /* the AFM file.                                                */
+    /* we are now going to count the occurrences of `KP' or `KPX' in */
+    /* the AFM file.                                                 */
     count = 0;
     for ( p = start; p < limit - 3; p++ )
     {
@@ -212,7 +210,7 @@
         FT_Byte*  q;
 
 
-        /* skip keyword (KP or KPX) */
+        /* skip keyword (`KP' or `KPX') */
         q = p + 2;
         if ( *q == 'X' )
           q++;
@@ -281,7 +279,5 @@
     kerning->y = 0;
   }
 
-#endif /* 1 */
-
 
 /* END */
diff --git a/src/cid/cidafm.h b/src/cid/cidafm.h
index 61c5ad7..93e8b97 100644
--- a/src/cid/cidafm.h
+++ b/src/cid/cidafm.h
@@ -38,8 +38,6 @@
   } CID_AFM;
 
 
-#if 1
-
   LOCAL_DEF
   FT_Error  CID_Read_AFM( FT_Face    cid_face,
                           FT_Stream  stream );
@@ -54,8 +52,6 @@
                          FT_UInt     glyph2,
                          FT_Vector*  kerning );
 
-#endif /* 1 */
-
 
 #endif /* CIDAFM_H */
 
diff --git a/src/cid/cidgload.c b/src/cid/cidgload.c
index 9945082..3a38545 100644
--- a/src/cid/cidgload.c
+++ b/src/cid/cidgload.c
@@ -76,7 +76,8 @@
 
   } CID_Operator;
 
-  static const FT_Int  t1_args_count[op_max] =
+  static
+  const FT_Int  t1_args_count[op_max] =
   {
     0, /* none */
     0, /* endchar */
@@ -220,7 +221,7 @@
   /*    decoder :: A pointer to the glyph builder to initialize.           */
   /*                                                                       */
   LOCAL_FUNC
-  void  CID_Init_Decoder( CID_Decoder* decoder )
+  void  CID_Init_Decoder( CID_Decoder*  decoder )
   {
     MEM_Set( decoder, 0, sizeof ( *decoder ) );
 
@@ -229,7 +230,7 @@
   }
 
 
-  /* check that there is enough room for `count' more points */
+  /* check that there is enough space for `count' more points */
   static
   FT_Error  check_points( CID_Builder*  builder,
                           FT_Int        count )
@@ -238,7 +239,7 @@
   }
 
 
-  /* add a new point, do not check space */
+  /* add a new point, but do not check space */
   static
   void  add_point( CID_Builder*  builder,
                    FT_Pos        x,
@@ -265,7 +266,7 @@
   }
 
 
-  /* check room for a new on-curve point, then add it */
+  /* check space for a new on-curve point, then add it */
   static
   FT_Error  add_point1( CID_Builder*  builder,
                         FT_Pos        x,
@@ -273,6 +274,7 @@
   {
     FT_Error  error;
 
+
     error = check_points( builder, 1 );
     if ( !error )
       add_point( builder, x, y, 1 );
@@ -307,7 +309,7 @@
   }
 
 
-  /* if a path was begun, add its first on-curve point */
+  /* if a path has been started, add its first on-curve point */
   static
   FT_Error  start_point( CID_Builder*  builder,
                          FT_Pos        x,
@@ -335,8 +337,9 @@
   {
     FT_Outline*  outline = builder->current;
 
-    /* XXXX: We must not include the last point in the path if it */
-    /*       is located on the first point.                       */
+
+    /* XXX: We must not include the last point in the path if it */
+    /*      is located on the first point.                       */
     if ( outline->n_points > 1 )
     {
       FT_Int      first = 0;
@@ -456,7 +459,8 @@
 
     if ( bchar_index < 0 || achar_index < 0 )
     {
-      FT_ERROR(( "t1operator_seac: invalid seac character code arguments\n" ));
+      FT_ERROR(( "t1operator_seac: ));
+      FT_ERROR(( " invalid seac character code arguments\n" ));
       return T1_Err_Syntax_Error;
     }
 
@@ -542,14 +546,18 @@
         FT_Outline_Translate( &dummy, adx - asb, ady );
       }
     }
+
   Exit:
     return error;
   }
 
 
-#define USE_ARGS( n )  top -= n;                   \
-                       if ( top < decoder->stack ) \
-                         goto Stack_Underflow
+#define USE_ARGS( n )  do                            \
+                       {                             \
+                         top -= n;                   \
+                         if ( top < decoder->stack ) \
+                           goto Stack_Underflow;     \
+                       } while ( 0 )
 
 
   /*************************************************************************/
@@ -561,12 +569,12 @@
   /*    Parses a given CID charstrings program.                            */
   /*                                                                       */
   /* <InOut>                                                               */
-  /*    decoder          :: The current CID decoder.                       */
+  /*    decoder         :: The current CID decoder.                        */
   /*                                                                       */
   /* <Input>                                                               */
-  /*    charstring_base  :: The base of the charstring stream.             */
+  /*    charstring_base :: The base of the charstring stream.              */
   /*                                                                       */
-  /*    charstring_len   :: The length in bytes of the charstring stream.  */
+  /*    charstring_len  :: The length in bytes of the charstring stream.   */
   /*                                                                       */
   /* <Return>                                                              */
   /*    FreeType error code.  0 means success.                             */
@@ -738,7 +746,8 @@
           {
             if ( ++ip > limit )
             {
-              FT_ERROR(( "CID_Parse_CharStrings: unexpected EOF in integer\n" ));
+              FT_ERROR(( "CID_Parse_CharStrings:" ));
+              FT_ERROR(( " unexpected EOF in integer\n" ));
               goto Syntax_Error;
             }
 
@@ -775,6 +784,7 @@
       else if ( op == op_callothersubr )  /* callothersubr */
       {
         FT_TRACE4(( " callothersubr" ));
+
         if ( top - decoder->stack < 2 )
           goto Stack_Underflow;
 
@@ -819,7 +829,7 @@
           if ( decoder->flex_state       == 0 ||
                decoder->num_flex_vectors != 7 )
           {
-            FT_ERROR(( "CID)Parse_CharStrings: unexpected flex end\n" ));
+            FT_ERROR(( "CID_Parse_CharStrings: unexpected flex end\n" ));
             goto Syntax_Error;
           }
 
@@ -851,7 +861,8 @@
 
           if ( ip[0] != 12 || ip[1] != 17 )
           {
-            FT_ERROR(( "CID_Parse_CharStrings: `pop' expected, found (%d %d)\n",
+            FT_ERROR(( "CID_Parse_CharStrings:" ));
+            FT_ERROR(( " `pop' expected, found (%d %d)\n",
                        ip[0], ip[1] ));
             goto Syntax_Error;
           }
@@ -877,16 +888,19 @@
             FT_Int*    delta;
             FT_Int*    values;
 
+
             if ( !blend )
             {
-              FT_ERROR(( "CID_Parse_CharStrings: unexpected multiple masters operator!\n" ));
+              FT_ERROR(( "CID_Parse_CharStrings:" ));
+              FT_ERROR(( " unexpected multiple masters operator!\n" ));
               goto Syntax_Error;
             }
 
             num_points = top[1] - 13 + ( top[1] == 18 );
             if ( top[0] != num_points * blend->num_designs )
             {
-              FT_ERROR(( "CID_Parse_CharStrings: incorrect number of mm arguments\n" ));
+              FT_ERROR(( "CID_Parse_CharStrings:" ));
+              FT_ERROR(( " incorrect number of mm arguments\n" ));
               goto Syntax_Error;
             }
 
@@ -894,12 +908,12 @@
             if ( top < decoder->stack )
               goto Stack_Underflow;
 
-            /* we want to compute:                                   */
+            /* We want to compute:                                   */
             /*                                                       */
             /*  a0*w0 + a1*w1 + ... + ak*wk                          */
             /*                                                       */
-            /* but we only have the a0, a1-a0, a2-a0, .. ak-a0       */
-            /* however, given that w0 + w1 + ... + wk == 1, we can   */
+            /* but we only have the a0, a1-a0, a2-a0, .. ak-a0.      */
+            /* However, given that w0 + w1 + ... + wk == 1, we can   */
             /* rewrite it easily as:                                 */
             /*                                                       */
             /*  a0 + (a1-a0)*w1 + (a2-a0)*w2 + .. + (ak-a0)*wk       */
@@ -909,7 +923,6 @@
             /* I guess that's why it's written in this `compact'     */
             /* form...                                               */
             /*                                                       */
-            /*                                                       */
             delta  = top + num_points;
             values = top;
             for ( nn = 0; nn < num_points; nn++ )
@@ -970,7 +983,7 @@
           builder->last.x = x = top[0];
           builder->last.y = y = 0;
 
-          /* the `metrics_only' indicates that we only want to compute */
+          /* The `metrics_only' indicates that we only want to compute */
           /* the glyph's metrics (lsb + advance width), not load the   */
           /* rest of it.  So exit immediately.                         */
           if ( builder->metrics_only )
@@ -979,7 +992,7 @@
           break;
 
         case op_seac:
-          /* return immediately after the processing */
+          /* return immediately after processing */
           return t1operator_seac( decoder, top[0], top[1],
                                            top[2], top[3], top[4] );
 
@@ -994,7 +1007,7 @@
           builder->last.x = x = top[0];
           builder->last.y = y = top[1];
 
-          /* the `metrics_only' indicates that we only want to compute */
+          /* The `metrics_only' indicates that we only want to compute */
           /* the glyph's metrics (lsb + advance width), not load the   */
           /* rest of it.  So exit immediately.                         */
           if ( builder->metrics_only )
@@ -1087,6 +1100,7 @@
 
         case op_vhcurveto:
           FT_TRACE4(( " vhcurveto" ));
+
           if ( start_point( builder, x, y ) ||
                check_points( builder, 3 )   )
             goto Memory_Error;
@@ -1175,7 +1189,7 @@
         case op_pop:
           FT_TRACE4(( " pop" ));
 
-          /* theorically, the arguments are already on the stack */
+          /* theoretically, the arguments are already on the stack */
           top++;
           break;
 
@@ -1223,7 +1237,8 @@
         case op_setcurrentpoint:
           FT_TRACE4(( " setcurrentpoint" ));
 
-          FT_ERROR(( "CID_Parse_CharStrings: unexpected `setcurrentpoint'\n" ));
+          FT_ERROR(( "CID_Parse_CharStrings:" ));
+          FT_ERROR(( " unexpected `setcurrentpoint'\n" ));
           goto Syntax_Error;
 
         default:
@@ -1252,6 +1267,9 @@
   }
 
 
+#if 0
+
+
   /*************************************************************************/
   /*************************************************************************/
   /*************************************************************************/
@@ -1270,9 +1288,6 @@
   /*************************************************************************/
 
 
-#if 0
-
-
   LOCAL_FUNC
   FT_Error  CID_Compute_Max_Advance( CID_Face  face,
                                      FT_Int*   max_advance )
@@ -1291,14 +1306,14 @@
     decoder.builder.metrics_only = 1;
     decoder.builder.load_points  = 0;
 
-    /* For each glyph, parse the glyph charstring and extract */
-    /* the advance width.                                     */
+    /* for each glyph, parse the glyph charstring and extract */
+    /* the advance width                                      */
     for ( glyph_index = 0; glyph_index < face->root.num_glyphs;
           glyph_index++ )
     {
       /* now get load the unscaled outline */
       error = cid_load_glyph( &decoder, glyph_index );
-      /* ignore the error if one occured - skip to next glyph */
+      /* ignore the error if one occurred - skip to next glyph */
     }
 
     *max_advance = decoder.builder.advance.x;
@@ -1395,7 +1410,6 @@
   }
 
 
-
   LOCAL_FUNC
   FT_Error  CID_Load_Glyph( CID_GlyphSlot  glyph,
                             CID_Size       size,
@@ -1442,7 +1456,7 @@
     if ( !error )
     {
       /* for composite glyphs, return only the left side bearing and the */
-      /* advance width..                                                 */
+      /* advance width                                                   */
       if ( load_flags & FT_LOAD_NO_RECURSE )
       {
         glyph->root.metrics.horiBearingX = decoder.builder.left_bearing.x;
@@ -1455,7 +1469,7 @@
 
 
         /* copy the _unscaled_ advance width */
-        metrics->horiAdvance  = decoder.builder.advance.x;
+        metrics->horiAdvance = decoder.builder.advance.x;
 
         /* make up vertical metrics */
         metrics->vertBearingX = 0;
@@ -1497,10 +1511,10 @@
 
           /* Then scale the metrics */
           metrics->horiAdvance  = FT_MulFix( metrics->horiAdvance,  x_scale );
+          metrics->vertAdvance  = FT_MulFix( metrics->vertAdvance,  y_scale );
 
           metrics->vertBearingX = FT_MulFix( metrics->vertBearingX, x_scale );
           metrics->vertBearingY = FT_MulFix( metrics->vertBearingY, y_scale );
-          metrics->vertAdvance  = FT_MulFix( metrics->vertAdvance,  x_scale );
         }
 
         /* apply the font matrix */
@@ -1514,8 +1528,8 @@
         {
           cbox.xMin &= -64;
           cbox.yMin &= -64;
-          cbox.xMax = ( cbox.xMax + 63 ) & -64;
-          cbox.yMax = ( cbox.yMax + 63 ) & -64;
+          cbox.xMax  = ( cbox.xMax + 63 ) & -64;
+          cbox.yMax  = ( cbox.yMax + 63 ) & -64;
         }
 
         metrics->width  = cbox.xMax - cbox.xMin;
diff --git a/src/cid/cidload.c b/src/cid/cidload.c
index 1a0b538..c66496d 100644
--- a/src/cid/cidload.c
+++ b/src/cid/cidload.c
@@ -38,7 +38,7 @@
 #define FT_COMPONENT  trace_cidload
 
 
- /* read a single offset */
+  /* read a single offset */
   LOCAL_FUNC
   FT_Long  cid_get_offset( FT_Byte**  start,
                            FT_Byte    offsize )
@@ -48,7 +48,10 @@
 
 
     for ( result = 0; offsize > 0; offsize-- )
-      result = ( result << 8 ) | *p++;
+    {
+      result <<= 8;
+      result  |= *p++;
+    }
 
     *start = p;
     return result;
@@ -87,10 +90,10 @@
                               CID_Loader*           loader,
                               const CID_Field_Rec*  keyword )
   {
-    FT_Error    error;
-    CID_Parser* parser = &loader->parser;
-    FT_Byte*    object;
-    CID_Info*   cid = &face->cid;
+    FT_Error     error;
+    CID_Parser*  parser = &loader->parser;
+    FT_Byte*     object;
+    CID_Info*    cid = &face->cid;
 
 
     /* if the keyword has a dedicated callback, call it */
@@ -309,7 +312,7 @@
           len = cur2 - cur;
           if ( len > 0 && len < 22 )
           {
-            /* now, compare the immediate name to the keyword table */
+            /* now compare the immediate name to the keyword table */
             const CID_Field_Rec*  keyword = t1_field_records;
 
 
@@ -408,8 +411,8 @@
       /* allocate, and read them                     */
       data_len = offsets[num_subrs] - offsets[0];
 
-      if ( ALLOC_ARRAY( subr->code, num_subrs+1, FT_Byte* ) ||
-           ALLOC( subr->code[0], data_len )                 )
+      if ( ALLOC_ARRAY( subr->code, num_subrs + 1, FT_Byte* ) ||
+           ALLOC( subr->code[0], data_len )                   )
         goto Fail;
 
       if ( FILE_Seek( cid->data_offset + offsets[0] ) ||
@@ -463,7 +466,7 @@
   void t1_init_loader( CID_Loader*  loader,
                        CID_Face     face )
   {
-    UNUSED(face);
+    UNUSED( face );
 
     MEM_Set( loader, 0, sizeof ( *loader ) );
   }
diff --git a/src/cid/cidobjs.c b/src/cid/cidobjs.c
index 21490b4..5b0af14 100644
--- a/src/cid/cidobjs.c
+++ b/src/cid/cidobjs.c
@@ -177,10 +177,10 @@
         if ( face->cid.font_info.is_fixed_pitch )
           root->face_flags |= FT_FACE_FLAG_FIXED_WIDTH;
 
-        /* XXX: TO DO - add kerning with .afm support */
+        /* XXX: TODO: add kerning with .afm support */
 
-        /* get style name - be careful, some broken fonts only */
-        /* have a /FontName dictionary entry!                  */
+        /* get style name -- be careful, some broken fonts only */
+        /* have a /FontName dictionary entry!                   */
         root->family_name = face->cid.font_info.family_name;
         if ( root->family_name )
         {
@@ -259,7 +259,7 @@
       FT_CharMap   charmap = face->charmaprecs;
 
 
-      /* synthesize a Unicode charmap if there is support in the "psnames" */
+      /* synthesize a Unicode charmap if there is support in the `psnames' */
       /* module                                                            */
       if ( face->psnames )
       {
diff --git a/src/cid/cidobjs.h b/src/cid/cidobjs.h
index aec06c8..c28c59b 100644
--- a/src/cid/cidobjs.h
+++ b/src/cid/cidobjs.h
@@ -86,20 +86,20 @@
 
   /*************************************************************************/
   /*                                                                       */
-  /* HERE BEGINS THE TYPE1 SPECIFIC STUFF                                  */
+  /* HERE BEGINS THE TYPE 1 SPECIFIC STUFF                                 */
   /*                                                                       */
   /*************************************************************************/
 
 
-  typedef struct CID_SizeRec_
+  typedef struct  CID_SizeRec_
   {
-    FT_SizeRec      root;
-    FT_Bool         valid;
+    FT_SizeRec  root;
+    FT_Bool     valid;
 
   } CID_SizeRec;
 
 
-  typedef struct CID_GlyphSlotRec_
+  typedef struct  CID_GlyphSlotRec_
   {
     FT_GlyphSlotRec  root;
 
@@ -113,11 +113,11 @@
 
 
   LOCAL_DEF
-  FT_Error  CID_Init_Face( FT_Stream     stream,
-                           CID_Face      face,
-                           FT_Int        face_index,
-                           FT_Int        num_params,
-                           FT_Parameter* params );
+  FT_Error  CID_Init_Face( FT_Stream      stream,
+                           CID_Face       face,
+                           FT_Int         face_index,
+                           FT_Int         num_params,
+                           FT_Parameter*  params );
 
   LOCAL_DEF
   void  CID_Done_Face( CID_Face  face );
diff --git a/src/cid/cidparse.c b/src/cid/cidparse.c
index d4ec6bc..279d4b9 100644
--- a/src/cid/cidparse.c
+++ b/src/cid/cidparse.c
@@ -354,7 +354,7 @@
         }
         break;
 
-        /* **************** otherwise, it's any token **********/
+        /* **************** otherwise, it is any token **********/
       default:
         token->start = cur++;
         token->type  = t1_token_any;
@@ -504,7 +504,8 @@
       for (;;)
       {
         d = (FT_Byte)( *cur - '0' );
-        if ( d >= 10 ) break;
+        if ( d >= 10 )
+          break;
 
         if ( divider < 10000000L )
         {
@@ -706,7 +707,6 @@
   }
 
 
-
   /* Loads a simple field (i.e. non-table) into the current */
   /* list of objects                                        */
   LOCAL_FUNC
@@ -761,6 +761,12 @@
             *(FT_UShort*)q = (FT_UShort)val;
             break;
 
+#if SIZEOF_INT == 4
+          case 4:
+            *(FT_Int*)q = (FT_Int)val;
+            break;
+#endif
+
           default:
             *(FT_Long*)q = val;
         }
@@ -783,7 +789,7 @@
         break;
 
       default:
-        /* an error occured */
+        /* an error occurred */
         goto Fail;
       }
     }
@@ -958,12 +964,12 @@
 
       buff_len = 256 + 10;
 
-      /* look for "StartData" */
+      /* look for `StartData' */
       for ( p = buffer; p < limit; p++ )
       {
         if ( p[0] == 'S' && strncmp( (char*)p, "StartData", 9 ) == 0 )
         {
-          /* save offset of binary data after "StartData" */
+          /* save offset of binary data after `StartData' */
           offset = FILE_Pos() - ( limit - p ) + 10;
           goto Found;
         }
@@ -971,7 +977,7 @@
     }
 
   Found:
-    /* all right, we found the start of the binary data.  We will now  */
+    /* we have found the start of the binary data.  We will now        */
     /* rewind and extract the frame of corresponding to the Postscript */
     /* section                                                         */
 
diff --git a/src/type1/t1gload.c b/src/type1/t1gload.c
index d27e8f2..aa728a5 100644
--- a/src/type1/t1gload.c
+++ b/src/type1/t1gload.c
@@ -1783,11 +1783,12 @@
 
           metrics->horiBearingX = FT_MulFix( metrics->horiBearingX, x_scale );
           metrics->horiBearingY = FT_MulFix( metrics->horiBearingY, y_scale );
-          metrics->horiAdvance  = FT_MulFix( metrics->horiAdvance,  x_scale );
 
           metrics->vertBearingX = FT_MulFix( metrics->vertBearingX, x_scale );
           metrics->vertBearingY = FT_MulFix( metrics->vertBearingY, y_scale );
-          metrics->vertAdvance  = FT_MulFix( metrics->vertAdvance,  x_scale );
+
+          metrics->horiAdvance  = FT_MulFix( metrics->horiAdvance,  x_scale );
+          metrics->vertAdvance  = FT_MulFix( metrics->vertAdvance,  y_scale );
         }
       }
     }
diff --git a/src/type1z/z1gload.c b/src/type1z/z1gload.c
index 25c1264..44d7d2b 100644
--- a/src/type1z/z1gload.c
+++ b/src/type1z/z1gload.c
@@ -1368,10 +1368,10 @@
 
           /* Then scale the metrics */
           metrics->horiAdvance  = FT_MulFix( metrics->horiAdvance,  x_scale );
+          metrics->vertAdvance  = FT_MulFix( metrics->vertAdvance,  y_scale );
 
           metrics->vertBearingX = FT_MulFix( metrics->vertBearingX, x_scale );
           metrics->vertBearingY = FT_MulFix( metrics->vertBearingY, y_scale );
-          metrics->vertAdvance  = FT_MulFix( metrics->vertAdvance,  x_scale );
         }
 
         /* apply the font matrix */