Commit eacb9306c03ad97053865eadb07fb9ae709951c0

Werner Lemberg 2002-10-07T10:12:43

Formatting; adding file headers.

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
diff --git a/ChangeLog b/ChangeLog
index 3e577e8..a841b9b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -7,21 +7,38 @@
 
 2002-10-05  David Turner  <david@freetype.org>
 
-        * src/pfr/pfrsbit.h, src/pfr/pfrsbit.c, src/pfr/pfrload.c,
-        src/pfr/pfrgload.c, src/pfr/pfrobjs.c, src/pfr/pfrtypes.h,
-        Jamfile, src/base/ftobjs.c: adding support for embedded bitmaps to
-        the PFR driver, and rewriting its kerning loader / handler to use all
-        kerning pairs in a physical font (and not just the first item).
-
-        * src/tools/docmaker/content.py, src/tools/docmaker/sources.py,
-        src/tools/docmaker/tohtml.py: fixing a few nasty bugs
-
-        * src/sfnt/ttcmap0.c: the validator for format 4 sub-tables is
-        now capable of dealing with invalid "length" fields at the start
-        of the sub-table. This allows fonts like "mg______.ttf" (i.e.
-        Marriage) to return accurate charmaps.
-
-        * docs/CHANGES: updating
+	Adding support for embedded bitmaps to the PFR driver, and rewriting
+	its kerning loader/handler to use all kerning pairs in a physical
+	font (and not just the first item).
+
+	* src/pfr/pfr.c: Include `pfrsbit.c'.
+	* src/pfr/pfrgload.c: Include `pfrsbit.h'.
+	* src/pfr/pfrload.c (pfr_extra_item_load_kerning_pairs): Rewritten.
+	(pfr_phy_font_done, pfr_phy_font_load): Updated.
+	* src/pfr/pfrobks.c: Include `pfrsbit.h'.
+	(pfr_face_init): Handle kerning and embedded bitmaps.
+	(pfr_slot_load): Load embedded bitmaps.
+	(PFR_KERN_INDEX): Removed.
+	(pfr_face_get_kerning): Rewritten.
+	* src/pfr/pfrsbit.c, src/pfr/pfrsbit.h: New files.
+	* src/pfr/pfrtypes.h (PFR_KernItemRec): New structure.
+	(PFR_KERN_INDEX): New macro.
+	(PFR_PhyFontRec): Add items for kerning and embedded bitmaps.
+	* src/pfr/Jamfile (_sources) [FT2_MULTI]: Add `pfrsbit'.
+
+	* src/base/ftobjs.c (FT_Load_Glyph): Don't load bitmap fonts if
+	FT_LOAD_NO_RECURSE is set.
+	Load embedded bitmaps only if FT_LOAD_NO_BITMAP isn't set.
+
+	* src/tools/docmaker/content.py, src/tools/docmaker/sources.py,
+	src/tools/docmaker/tohtml.py: Fixing a few nasty bugs.
+
+	* src/sfnt/ttcmap0.c (tt_cmap4_validate): The validator for format 4
+	sub-tables is now capable of dealing with invalid "length" fields at
+	the start of the sub-table.  This allows fonts like "mg______.ttf"
+	(i.e.  Marriage) to return accurate charmaps.
+
+	* docs/CHANGES: Updated.
 
 2002-10-05  Werner Lemberg  <wl@gnu.org>
 
diff --git a/docs/CHANGES b/docs/CHANGES
index a91ff04..94b6f15 100644
--- a/docs/CHANGES
+++ b/docs/CHANGES
@@ -72,9 +72,9 @@ LATEST CHANGES BETWEEN 2.1.3 and 2.1.2
       has been updated to support LCD-optimized display on non-paletted
       displays (under Win32 and X11)
 
-    - the PFR driver now supports embedded bitmaps (all formats supported)
+    - The PFR driver now supports embedded bitmaps (all formats supported).
 
-    - the TrueType charmap loader now supports certain "broken" fonts that
+    - The TrueType charmap loader now supports certain "broken" fonts that
       load under Windows without problems.
 
     - The cache API has been slightly modified (it's still a beta!):
diff --git a/src/base/ftobjs.c b/src/base/ftobjs.c
index a139a88..05e74f5 100644
--- a/src/base/ftobjs.c
+++ b/src/base/ftobjs.c
@@ -467,7 +467,7 @@
       /* XXX: This is really a temporary hack that should disappear */
       /*      promptly with FreeType 2.1!                           */
       /*                                                            */
-      if ( FT_HAS_FIXED_SIZES( face ) &&
+      if ( FT_HAS_FIXED_SIZES( face )             &&
           ( load_flags & FT_LOAD_NO_BITMAP ) == 0 )
       {
         error = driver->clazz->load_glyph( slot, face->size,
diff --git a/src/pfr/pfrgload.h b/src/pfr/pfrgload.h
index 76916e5..7cc7a87 100644
--- a/src/pfr/pfrgload.h
+++ b/src/pfr/pfrgload.h
@@ -44,3 +44,6 @@ FT_END_HEADER
 
 
 #endif /* __PFRGLOAD_H__ */
+
+
+/* END */
diff --git a/src/pfr/pfrload.c b/src/pfr/pfrload.c
index a165b6f..bd4d2a9 100644
--- a/src/pfr/pfrload.c
+++ b/src/pfr/pfrload.c
@@ -501,8 +501,8 @@
   }
 
 
-
 #if 0
+
   /* load kerning pair data */
   FT_CALLBACK_DEF( FT_Error )
   pfr_extra_item_load_kerning_pairs( FT_Byte*     p,
@@ -582,7 +582,9 @@
                "invalid kerning pairs table\n" ));
     goto Exit;
   }
-#else
+
+#else /* 0 */
+
   /* load kerning pair data */
   FT_CALLBACK_DEF( FT_Error )
   pfr_extra_item_load_kerning_pairs( FT_Byte*     p,
@@ -593,6 +595,7 @@
     FT_Error      error  = 0;
     FT_Memory     memory = phy_font->memory;
 
+
     FT_TRACE2(( "pfr_extra_item_load_kerning_pairs()\n" ));
 
     if ( FT_NEW( item ) )
@@ -624,33 +627,34 @@
       FT_UInt   char1, char2;
       FT_Byte*  q;
 
+
       if ( item->flags & PFR_KERN_2BYTE_CHAR )
       {
         q     = p;
-        char1 = PFR_NEXT_USHORT(q);
-        char2 = PFR_NEXT_USHORT(q);
+        char1 = PFR_NEXT_USHORT( q );
+        char2 = PFR_NEXT_USHORT( q );
 
-        item->pair1 = PFR_KERN_INDEX(char1,char2);
+        item->pair1 = PFR_KERN_INDEX( char1, char2 );
 
-        q = p + item->pair_size*(item->pair_count-1);
-        char1 = PFR_NEXT_USHORT(q);
-        char2 = PFR_NEXT_USHORT(q);
+        q = p + item->pair_size * ( item->pair_count - 1 );
+        char1 = PFR_NEXT_USHORT( q );
+        char2 = PFR_NEXT_USHORT( q );
 
-        item->pair2 = PFR_KERN_INDEX(char1,char2);
+        item->pair2 = PFR_KERN_INDEX( char1, char2 );
       }
       else
       {
         q     = p;
-        char1 = PFR_NEXT_BYTE(q);
-        char2 = PFR_NEXT_BYTE(q);
+        char1 = PFR_NEXT_BYTE( q );
+        char2 = PFR_NEXT_BYTE( q );
 
-        item->pair1 = PFR_KERN_INDEX(char1,char2);
+        item->pair1 = PFR_KERN_INDEX( char1, char2 );
 
-        q = p + item->pair_size*(item->pair_count-1);
-        char1 = PFR_NEXT_BYTE(q);
-        char2 = PFR_NEXT_BYTE(q);
+        q = p + item->pair_size * ( item->pair_count - 1 );
+        char1 = PFR_NEXT_BYTE( q );
+        char2 = PFR_NEXT_BYTE( q );
 
-        item->pair2 = PFR_KERN_INDEX(char1,char2);
+        item->pair2 = PFR_KERN_INDEX( char1, char2 );
       }
 
       /* add new item to the current list */
@@ -661,7 +665,7 @@
     }
     else
     {
-      /* empty item !! */
+      /* empty item! */
       FT_FREE( item );
     }
 
@@ -676,7 +680,8 @@
                "invalid kerning pairs table\n" ));
     goto Exit;
   }
-#endif
+#endif /* 0 */
+
 
   static const PFR_ExtraItemRec  pfr_phy_font_extra_items[] =
   {
@@ -715,8 +720,9 @@
     {
       PFR_KernItem  item, next;
 
+
       item = phy_font->kern_items;
-      while (item)
+      while ( item )
       {
         next = item->next;
         FT_FREE( item );
@@ -725,6 +731,7 @@
       phy_font->kern_items      = NULL;
       phy_font->kern_items_tail = NULL;
     }
+
     phy_font->num_kern_pairs = 0;
   }
 
diff --git a/src/pfr/pfrobjs.c b/src/pfr/pfrobjs.c
index af123e9..c0438fc 100644
--- a/src/pfr/pfrobjs.c
+++ b/src/pfr/pfrobjs.c
@@ -248,7 +248,7 @@
     FT_ASSERT( gindex < face->phy_font.num_chars );
 
     /* try to load an embedded bitmap */
-    if ( (load_flags & (FT_LOAD_NO_SCALE | FT_LOAD_NO_BITMAP)) == 0 )
+    if ( ( load_flags & ( FT_LOAD_NO_SCALE | FT_LOAD_NO_BITMAP ) ) == 0 )
     {
       error = pfr_slot_load_bitmap( slot, size, gindex );
       if ( error == 0 )
@@ -356,6 +356,7 @@
           sure */
 
 #if 0
+
   /* find the kerning for a given glyph pair */
   FT_LOCAL_DEF( FT_Error )
   pfr_face_get_kerning( PFR_Face    face,
@@ -398,7 +399,9 @@
   Exit:
     return 0;
   }
-#else
+
+#else /* 0 */
+
   /* find the kerning for a given glyph pair */
   FT_LOCAL_DEF( FT_Error )
   pfr_face_get_kerning( PFR_Face    face,
@@ -411,6 +414,7 @@
     PFR_KernItem  item     = phy_font->kern_items;
     FT_UInt32     idx      = PFR_KERN_INDEX( glyph1, glyph2 );
 
+
     kerning->x = 0;
     kerning->y = 0;
 
@@ -433,6 +437,7 @@
       FT_Stream  stream = face->root.stream;
       FT_Byte*   p;
 
+
       if ( FT_STREAM_SEEK( item->offset )                       ||
            FT_FRAME_ENTER( item->pair_count * item->pair_size ) )
         goto Exit;
@@ -443,32 +448,33 @@
       {
         FT_UInt  char1, char2, charcode;
 
-        mid = (min + max) >> 1;
+
+        mid = ( min + max ) >> 1;
         p   = stream->cursor + mid*item->pair_size;
 
         if ( item->flags & PFR_KERN_2BYTE_CHAR )
         {
-          char1 = FT_NEXT_USHORT(p);
-          char2 = FT_NEXT_USHORT(p);
+          char1 = FT_NEXT_USHORT( p );
+          char2 = FT_NEXT_USHORT( p );
         }
         else
         {
-          char1 = FT_NEXT_USHORT(p);
-          char2 = FT_NEXT_USHORT(p);
+          char1 = FT_NEXT_USHORT( p );
+          char2 = FT_NEXT_USHORT( p );
         }
-        charcode = PFR_KERN_INDEX(char1,char2);
+        charcode = PFR_KERN_INDEX( char1, char2 );
 
         if ( idx == charcode )
         {
           if ( item->flags & PFR_KERN_2BYTE_ADJ )
-            kerning->x = item->base_adj + FT_NEXT_SHORT(p);
+            kerning->x = item->base_adj + FT_NEXT_SHORT( p );
           else
-            kerning->x = item->base_adj + FT_NEXT_CHAR(p);
+            kerning->x = item->base_adj + FT_NEXT_CHAR( p );
 
           break;
         }
         if ( idx > charcode )
-          min = mid+1;
+          min = mid + 1;
         else
           max = mid;
       }
diff --git a/src/pfr/pfrobjs.h b/src/pfr/pfrobjs.h
index 832c6fd..7664b36 100644
--- a/src/pfr/pfrobjs.h
+++ b/src/pfr/pfrobjs.h
@@ -91,3 +91,6 @@ FT_BEGIN_HEADER
 FT_END_HEADER
 
 #endif /* __PFROBJS_H__ */
+
+
+/* END */
diff --git a/src/pfr/pfrsbit.c b/src/pfr/pfrsbit.c
index 63e2a52..b93c207 100644
--- a/src/pfr/pfrsbit.c
+++ b/src/pfr/pfrsbit.c
@@ -1,3 +1,21 @@
+/***************************************************************************/
+/*                                                                         */
+/*  pfrsbit.c                                                              */
+/*                                                                         */
+/*    FreeType PFR bitmap loader (body).                                   */
+/*                                                                         */
+/*  Copyright 2002 by                                                      */
+/*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
+/*                                                                         */
+/*  This file is part of the FreeType project, and may only be used,       */
+/*  modified, and distributed under the terms of the FreeType project      */
+/*  license, LICENSE.TXT.  By continuing to use, modify, or distribute     */
+/*  this file you indicate that you have read the license and              */
+/*  understand and accept it fully.                                        */
+/*                                                                         */
+/***************************************************************************/
+
+
 #include "pfrsbit.h"
 #include "pfrload.h"
 #include FT_INTERNAL_DEBUG_H
@@ -8,6 +26,7 @@
 #undef  FT_COMPONENT
 #define FT_COMPONENT  trace_pfr
 
+
   /*************************************************************************/
   /*************************************************************************/
   /*****                                                               *****/
@@ -16,7 +35,7 @@
   /*************************************************************************/
   /*************************************************************************/
 
-  typedef  struct PFR_BitWriter_
+  typedef struct  PFR_BitWriter_
   {
     FT_Byte*  line;      /* current line start                    */
     FT_Int    pitch;     /* line size in bytes                    */
@@ -58,7 +77,8 @@
     FT_UInt   val  = 0;
     FT_UInt   c    = 0;
 
-    n = (FT_Int)(limit - p)*8;
+
+    n = (FT_Int)( limit - p ) * 8;
     if ( n > writer->total )
       n = writer->total;
 
@@ -66,7 +86,7 @@
 
     for ( ; n > 0; n-- )
     {
-      if ( (n & 7) == reload )
+      if ( ( n & 7 ) == reload )
         val = *p++;
 
       if ( val & 0x80 )
@@ -77,7 +97,7 @@
 
       if ( --left <= 0 )
       {
-        cur[0] = (FT_Byte) c;
+        cur[0] = (FT_Byte)c;
         left   = writer->width;
         mask   = 0x80;
 
@@ -110,6 +130,7 @@
     FT_UInt   mask = 0x80;
     FT_UInt   c    = 0;
 
+
     n = writer->total;
 
     phase     = 1;
@@ -128,12 +149,13 @@
           {
             FT_Int  v;
 
+
             if ( p >= limit )
               break;
 
             v         = *p++;
-            counts[0] = (v >> 4);
-            counts[1] = (v & 15);
+            counts[0] = v >> 4;
+            counts[1] = v & 15;
             phase     = 0;
             count     = counts[0];
           }
@@ -142,8 +164,8 @@
             phase = 1;
             count = counts[1];
           }
-        }
-        while ( count == 0 );
+
+        } while ( count == 0 );
       }
 
       if ( phase )
@@ -188,11 +210,12 @@
     FT_UInt   mask = 0x80;
     FT_UInt   c    = 0;
 
+
     n = writer->total;
 
-    phase     = 1;
-    count     = 0;
-    reload    = 1;
+    phase  = 1;
+    count  = 0;
+    reload = 1;
 
     for ( ; n > 0; n-- )
     {
@@ -205,8 +228,8 @@
 
           count = *p++;
           phase = phase ^ 1;
-        }
-        while ( count == 0 );
+
+        } while ( count == 0 );
       }
 
       if ( phase )
@@ -249,40 +272,44 @@
   /*************************************************************************/
 
   static void
-  pfr_lookup_bitmap_data( FT_Byte*    base,
-                          FT_Byte*    limit,
-                          FT_Int      count,
-                          FT_Byte     flags,
-                          FT_UInt     char_code,
-                          FT_ULong*   found_offset,
-                          FT_ULong*   found_size )
+  pfr_lookup_bitmap_data( FT_Byte*   base,
+                          FT_Byte*   limit,
+                          FT_Int     count,
+                          FT_Byte    flags,
+                          FT_UInt    char_code,
+                          FT_ULong*  found_offset,
+                          FT_ULong*  found_size )
   {
-    FT_UInt    left, right, char_len;
-    FT_Bool    two = (flags & 1);
-    FT_Byte*   buff;
+    FT_UInt   left, right, char_len;
+    FT_Bool   two = flags & 1;
+    FT_Byte*  buff;
+
 
     char_len = 4;
-    if ( two )      char_len += 1;
-    if ( flags & 2) char_len += 1;
-    if ( flags & 4) char_len += 1;
+    if ( two )       char_len += 1;
+    if ( flags & 2 ) char_len += 1;
+    if ( flags & 4 ) char_len += 1;
 
-    left      = 0;
-    right     = count;
+    left  = 0;
+    right = count;
 
     while ( left < right )
     {
       FT_UInt  middle, code;
 
-      middle = (left + right) >> 1;
-      buff   = base + middle*char_len;
 
-      /* check that we're not outside of the table */
-      /* this is possible with broken fonts...     */
+      middle = ( left + right ) >> 1;
+      buff   = base + middle * char_len;
+
+      /* check that we are not outside of the table -- */
+      /* this is possible with broken fonts...         */
       if ( buff + char_len > limit )
         goto Fail;
 
-      if (two) code = PFR_NEXT_USHORT(buff);
-         else  code = PFR_NEXT_BYTE(buff);
+      if ( two )
+        code = PFR_NEXT_USHORT( buff );
+      else
+        code = PFR_NEXT_BYTE( buff );
 
       if ( code == char_code )
         goto Found_It;
@@ -300,37 +327,42 @@
     return;
 
   Found_It:
-    if (flags & 2) *found_size = PFR_NEXT_USHORT(buff);
-              else *found_size = PFR_NEXT_BYTE(buff);
-
-    if (flags & 4) *found_offset = PFR_NEXT_ULONG(buff);
-              else *found_offset = PFR_NEXT_USHORT(buff);
+    if ( flags & 2 )
+      *found_size = PFR_NEXT_USHORT( buff );
+    else
+      *found_size = PFR_NEXT_BYTE( buff );
+
+    if ( flags & 4 )
+      *found_offset = PFR_NEXT_ULONG( buff );
+    else
+      *found_offset = PFR_NEXT_USHORT( buff );
   }
 
 
- /* load bitmap metrics. "*padvance" must be set to the default value */
- /* before calling this function...                                   */
- /*                                                                   */
+  /* load bitmap metrics.  "*padvance" must be set to the default value */
+  /* before calling this function...                                    */
+  /*                                                                    */
   static FT_Error
-  pfr_load_bitmap_metrics( FT_Byte** pdata,
-                           FT_Byte*  limit,
-                           FT_Long   scaled_advance,
-                           FT_Long  *axpos,
-                           FT_Long  *aypos,
-                           FT_UInt  *axsize,
-                           FT_UInt  *aysize,
-                           FT_Long  *aadvance,
-                           FT_UInt  *aformat )
+  pfr_load_bitmap_metrics( FT_Byte**  pdata,
+                           FT_Byte*   limit,
+                           FT_Long    scaled_advance,
+                           FT_Long   *axpos,
+                           FT_Long   *aypos,
+                           FT_UInt   *axsize,
+                           FT_UInt   *aysize,
+                           FT_Long   *aadvance,
+                           FT_UInt   *aformat )
   {
     FT_Error  error = 0;
-    FT_Byte    flags;
-    FT_Char    b;
-    FT_Byte*   p = *pdata;
-    FT_Long    xpos, ypos, advance;
-    FT_UInt    xsize, ysize;
+    FT_Byte   flags;
+    FT_Char   b;
+    FT_Byte*  p = *pdata;
+    FT_Long   xpos, ypos, advance;
+    FT_UInt   xsize, ysize;
 
-    PFR_CHECK(1);
-    flags = PFR_NEXT_BYTE(p);
+
+    PFR_CHECK( 1 );
+    flags = PFR_NEXT_BYTE( p );
 
     xpos    = 0;
     ypos    = 0;
@@ -338,93 +370,93 @@
     ysize   = 0;
     advance = 0;
 
-    switch (flags & 3)
+    switch ( flags & 3 )
     {
-      case 0:
-        PFR_CHECK(1);
-        b    = PFR_NEXT_INT8(p);
-        xpos = b >> 4;
-        ypos = ((FT_Char)(b << 4)) >> 4;
-        break;
-
-      case 1:
-        PFR_CHECK(2);
-        xpos = PFR_NEXT_INT8(p);
-        ypos = PFR_NEXT_INT8(p);
-        break;
-
-      case 2:
-        PFR_CHECK(4);
-        xpos = PFR_NEXT_SHORT(p);
-        ypos = PFR_NEXT_SHORT(p);
-        break;
-
-      case 3:
-        PFR_CHECK(6);
-        xpos = PFR_NEXT_LONG(p);
-        ypos = PFR_NEXT_LONG(p);
-        break;
-
-      default:
-        ;
+    case 0:
+      PFR_CHECK( 1 );
+      b    = PFR_NEXT_INT8( p );
+      xpos = b >> 4;
+      ypos = ( (FT_Char)( b << 4 ) ) >> 4;
+      break;
+
+    case 1:
+      PFR_CHECK( 2 );
+      xpos = PFR_NEXT_INT8( p );
+      ypos = PFR_NEXT_INT8( p );
+      break;
+
+    case 2:
+      PFR_CHECK( 4 );
+      xpos = PFR_NEXT_SHORT( p );
+      ypos = PFR_NEXT_SHORT( p );
+      break;
+
+    case 3:
+      PFR_CHECK( 6 );
+      xpos = PFR_NEXT_LONG( p );
+      ypos = PFR_NEXT_LONG( p );
+      break;
+
+    default:
+      ;
     }
 
     flags >>= 2;
-    switch (flags & 3)
+    switch ( flags & 3 )
     {
-      case 0:
-        /* blank image */
-        xsize = 0;
-        ysize = 0;
-        break;
-
-      case 1:
-        PFR_CHECK(1);
-        b     = PFR_NEXT_BYTE(p);
-        xsize = (b >> 4) & 0xF;
-        ysize =  b & 0xF;
-        break;
-
-      case 2:
-        PFR_CHECK(2);
-        xsize = PFR_NEXT_BYTE(p);
-        ysize = PFR_NEXT_BYTE(p);
-        break;
-
-      case 3:
-        PFR_CHECK(4);
-        xsize = PFR_NEXT_USHORT(p);
-        ysize = PFR_NEXT_USHORT(p);
-        break;
-
-      default:
-        ;
+    case 0:
+      /* blank image */
+      xsize = 0;
+      ysize = 0;
+      break;
+
+    case 1:
+      PFR_CHECK( 1 );
+      b     = PFR_NEXT_BYTE( p );
+      xsize = ( b >> 4 ) & 0xF;
+      ysize = b & 0xF;
+      break;
+
+    case 2:
+      PFR_CHECK( 2 );
+      xsize = PFR_NEXT_BYTE( p );
+      ysize = PFR_NEXT_BYTE( p );
+      break;
+
+    case 3:
+      PFR_CHECK( 4 );
+      xsize = PFR_NEXT_USHORT( p );
+      ysize = PFR_NEXT_USHORT( p );
+      break;
+
+    default:
+      ;
     }
 
     flags >>= 2;
-    switch (flags & 3)
+    switch ( flags & 3 )
     {
-      case 0:
-       advance = scaled_advance;
-       break;
-
-      case 1:
-        PFR_CHECK(1);
-        advance = PFR_NEXT_INT8(p) << 8;
-        break;
-
-      case 2:
-        PFR_CHECK(2);
-        advance = PFR_NEXT_SHORT(p);
-        break;
-
-      case 3:
-        PFR_CHECK(3);
-        advance = PFR_NEXT_LONG(p);
-        break;
-
-      default:
-        ;
+    case 0:
+      advance = scaled_advance;
+      break;
+
+    case 1:
+      PFR_CHECK( 1 );
+      advance = PFR_NEXT_INT8( p ) << 8;
+      break;
+
+    case 2:
+      PFR_CHECK( 2 );
+      advance = PFR_NEXT_SHORT( p );
+      break;
+
+    case 3:
+      PFR_CHECK( 3 );
+      advance = PFR_NEXT_LONG( p );
+      break;
+
+    default:
+      ;
     }
 
     *axpos    = xpos;
@@ -446,36 +478,37 @@
 
 
   static FT_Error
-  pfr_load_bitmap_bits( FT_Byte*        p,
-                        FT_Byte*        limit,
-                        FT_UInt         format,
-                        FT_UInt         decreasing,
-                        FT_Bitmap*      target )
+  pfr_load_bitmap_bits( FT_Byte*    p,
+                        FT_Byte*    limit,
+                        FT_UInt     format,
+                        FT_UInt     decreasing,
+                        FT_Bitmap*  target )
   {
     FT_Error          error = 0;
     PFR_BitWriterRec  writer;
 
+
     if ( target->rows > 0 && target->width > 0 )
     {
       pfr_bitwriter_init( &writer, target, decreasing );
 
-      switch (format)
+      switch ( format )
       {
-        case 0: /* packed bits */
-          pfr_bitwriter_decode_bytes( &writer, p, limit );
-          break;
+      case 0: /* packed bits */
+        pfr_bitwriter_decode_bytes( &writer, p, limit );
+        break;
 
-        case 1: /* RLE1 */
-          pfr_bitwriter_decode_rle1( &writer, p, limit );
-          break;
+      case 1: /* RLE1 */
+        pfr_bitwriter_decode_rle1( &writer, p, limit );
+        break;
 
-        case 2: /* RLE2 */
-          pfr_bitwriter_decode_rle2( &writer, p, limit );
-          break;
+      case 2: /* RLE2 */
+        pfr_bitwriter_decode_rle2( &writer, p, limit );
+        break;
 
-        default:
-          FT_ERROR(( "pfr_read_bitmap_data: invalid image type\n" ));
-          error = FT_Err_Invalid_File_Format;
+      default:
+        FT_ERROR(( "pfr_read_bitmap_data: invalid image type\n" ));
+        error = FT_Err_Invalid_File_Format;
       }
     }
 
@@ -505,22 +538,24 @@
     PFR_Char     character;
     PFR_Strike   strike;
 
+
     character = &phys->chars[glyph_index];
 
     /* Look-up a bitmap strike corresponding to the current */
     /* character dimensions                                 */
-
     {
-      FT_UInt     n;
+      FT_UInt  n;
+
 
       strike = phys->strikes;
       for ( n = 0; n < phys->num_strikes; n++ )
       {
-        if ( strike->x_ppm == (FT_UInt) size->root.metrics.x_ppem &&
-             strike->y_ppm == (FT_UInt) size->root.metrics.y_ppem )
+        if ( strike->x_ppm == (FT_UInt)size->root.metrics.x_ppem &&
+             strike->y_ppm == (FT_UInt)size->root.metrics.y_ppem )
         {
           goto Found_Strike;
         }
+
         strike++;
       }
 
@@ -532,7 +567,8 @@
 
     /* Now lookup the glyph's position within the file */
     {
-      FT_UInt   char_len;
+      FT_UInt  char_len;
+
 
       char_len = 4;
       if ( strike->flags & 1 ) char_len += 1;
@@ -541,7 +577,7 @@
 
       /* Access data directly in the frame to speed lookups */
       if ( FT_STREAM_SEEK( phys->bct_offset + strike->bct_offset ) ||
-           FT_FRAME_ENTER( char_len * strike->num_bitmaps )       )
+           FT_FRAME_ENTER( char_len * strike->num_bitmaps )        )
         goto Exit;
 
       pfr_lookup_bitmap_data( stream->cursor,
@@ -554,7 +590,7 @@
 
       FT_FRAME_EXIT();
 
-      if (gps_size == 0)
+      if ( gps_size == 0 )
       {
         /* Could not find a bitmap program string for this glyph */
         error = FT_Err_Invalid_Argument;
@@ -568,14 +604,15 @@
       FT_UInt   xsize, ysize, format;
       FT_Byte*  p;
 
+
       advance = FT_MulDiv( size->root.metrics.x_ppem << 8,
                            character->advance,
                            phys->metrics_resolution );
 
-      /* XXX: handle linearHoriAdvance correctly !! */
+      /* XXX: handle linearHoriAdvance correctly! */
 
       if ( FT_STREAM_SEEK( face->header.gps_section_offset + gps_offset ) ||
-           FT_FRAME_ENTER( gps_size )                             )
+           FT_FRAME_ENTER( gps_size )                                     )
         goto Exit;
 
       p     = stream->cursor;
@@ -589,16 +626,16 @@
         glyph->root.format = FT_GLYPH_FORMAT_BITMAP;
       
         /* Set up glyph bitmap and metrics */
-        glyph->root.bitmap.width      = (FT_Int) xsize;
-        glyph->root.bitmap.rows       = (FT_Int) ysize;
-        glyph->root.bitmap.pitch      = (FT_Long)(xsize+7) >> 3;
+        glyph->root.bitmap.width      = (FT_Int)xsize;
+        glyph->root.bitmap.rows       = (FT_Int)ysize;
+        glyph->root.bitmap.pitch      = (FT_Long)( xsize + 7 ) >> 3;
         glyph->root.bitmap.pixel_mode = FT_PIXEL_MODE_MONO;
 
         glyph->root.metrics.width        = (FT_Long)xsize << 6;
         glyph->root.metrics.height       = (FT_Long)ysize << 6;
         glyph->root.metrics.horiBearingX = xpos << 6;
         glyph->root.metrics.horiBearingY = ypos << 6;
-        glyph->root.metrics.horiAdvance  = ((advance >> 2) + 32) & -64;
+        glyph->root.metrics.horiAdvance  = ( ( advance >> 2 ) + 32 ) & -64;
         glyph->root.metrics.vertBearingX = - glyph->root.metrics.width >> 1;
         glyph->root.metrics.vertBearingY = 0;
         glyph->root.metrics.vertAdvance  = size->root.metrics.height;
@@ -609,21 +646,25 @@
         /* Allocate and read bitmap data */
         {
           FT_Memory  memory = face->root.memory;
-          FT_Long    len    = glyph->root.bitmap.pitch*ysize;
+          FT_Long    len    = glyph->root.bitmap.pitch * ysize;
+
 
           if ( !FT_ALLOC( glyph->root.bitmap.buffer, len ) )
           {
             error = pfr_load_bitmap_bits( p,
                                           stream->limit,
                                           format,
-                                          (face->header.color_flags & 2),
+                                          face->header.color_flags & 2,
                                           &glyph->root.bitmap );
           }
         }
       }
+
       FT_FRAME_EXIT();
     }
 
   Exit:
     return error;
   }
+
+/* END */
diff --git a/src/pfr/pfrsbit.h b/src/pfr/pfrsbit.h
index 49baa82..015e9e6 100644
--- a/src/pfr/pfrsbit.h
+++ b/src/pfr/pfrsbit.h
@@ -1,8 +1,8 @@
 /***************************************************************************/
 /*                                                                         */
-/*  pfrsbit.c                                                              */
+/*  pfrsbit.h                                                              */
 /*                                                                         */
-/*    FreeType PFR bitmap loader                                           */
+/*    FreeType PFR bitmap loader (specification).                          */
 /*                                                                         */
 /*  Copyright 2002 by                                                      */
 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
@@ -15,6 +15,7 @@
 /*                                                                         */
 /***************************************************************************/
 
+
 #ifndef __PFRSBIT_H__
 #define __PFRSBIT_H__
 
@@ -30,3 +31,6 @@ FT_BEGIN_HEADER
 FT_END_HEADER
 
 #endif /* __PFR_SBIT_H__ */
+
+
+/* END */
diff --git a/src/pfr/pfrtypes.h b/src/pfr/pfrtypes.h
index d769598..3b419da 100644
--- a/src/pfr/pfrtypes.h
+++ b/src/pfr/pfrtypes.h
@@ -192,7 +192,8 @@ FT_BEGIN_HEADER
   /************************************************************************/
 
   typedef struct PFR_KernItemRec_*  PFR_KernItem;
-  typedef struct PFR_KernItemRec_
+
+  typedef struct  PFR_KernItemRec_
   {
     PFR_KernItem  next;
     FT_UInt       pair_count;
@@ -205,7 +206,8 @@ FT_BEGIN_HEADER
 
   } PFR_KernItemRec;
 
-#define PFR_KERN_INDEX( g1, g2 )  ( ( (FT_UInt32)(g1) << 16 ) | (FT_UInt16)(g2) )
+#define PFR_KERN_INDEX( g1, g2 ) \
+  ( ( (FT_UInt32)(g1) << 16 ) | (FT_UInt16)(g2) )
 
   typedef struct  PFR_KernPairRec_
   {
diff --git a/src/sfnt/ttcmap0.c b/src/sfnt/ttcmap0.c
index 136a6a1..93a7ddf 100644
--- a/src/sfnt/ttcmap0.c
+++ b/src/sfnt/ttcmap0.c
@@ -597,8 +597,9 @@
     FT_Byte   *ends, *starts, *offsets, *deltas, *glyph_ids;
     FT_UInt   num_segs;
 
-    /* in certain fonts, the 'length' field is invalid and goes */
-    /* out of bound. We try to correct this here...             */
+
+    /* in certain fonts, the `length' field is invalid and goes */
+    /* out of bound.  We try to correct this here...            */
     if ( length < 16 )
       FT_INVALID_TOO_SHORT;