Commit 110fc56beadee6a9414edff34222a54555b3a490

Werner Lemberg 2003-05-03T20:13:48

* src/autohint/ahoptim.c (LOG): Renamed to... (AH_OPTIM_LOG): This. (AH_Dump_Springs): Fix log message format. * src/autohint/ahhint.c (ah_hint_edges_3): Renamed to... (ah_hint_edges): This.

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
diff --git a/ChangeLog b/ChangeLog
index 7c29f6f..ee6928b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2003-05-02  Werner Lemberg  <wl@gnu.org>
+
+	* src/autohint/ahoptim.c (LOG): Renamed to...
+	(AH_OPTIM_LOG): This.
+	(AH_Dump_Springs): Fix log message format.
+
+	* src/autohint/ahhint.c (ah_hint_edges_3): Renamed to...
+	(ah_hint_edges): This.
+
 2002-05-02  Keith Packard  <keithp@keithp.com>
 
 	* src/bdf/bdfdrivr.c (BDF_Set_Pixel_Size): Initialize `max_advance'.
diff --git a/src/autohint/ahhint.c b/src/autohint/ahhint.c
index 9585d4c..c172340 100644
--- a/src/autohint/ahhint.c
+++ b/src/autohint/ahhint.c
@@ -27,11 +27,12 @@
 #include FT_OUTLINE_H
 
 
-#define FACE_GLOBALS( face )  ((AH_Face_Globals)(face)->autohint.data)
+#define FACE_GLOBALS( face )  ( (AH_Face_Globals)(face)->autohint.data )
 
 #define AH_USE_IUP
 #define OPTIM_STEM_SNAP
 
+
   /*************************************************************************/
   /*************************************************************************/
   /****                                                                 ****/
@@ -70,7 +71,7 @@
       }
     }
 
-    scaled = (reference+32) & -64;
+    scaled = ( reference + 32 ) & -64;
 
     if ( width >= reference )
     {
@@ -116,7 +117,7 @@
     else if ( (  vertical && !hinter->do_vert_snapping ) ||
               ( !vertical && !hinter->do_horz_snapping ) )
     {
-      /* smooth hinting process, very lightly quantize the stem width */
+      /* smooth hinting process: very lightly quantize the stem width */
       /*                                                              */
 
       /* leave the widths of serifs alone */
@@ -150,8 +151,8 @@
 
         if ( dist < 3 * 64 )
         {
-          delta = ( dist & 63 );
-          dist &= -64;
+          delta  = dist & 63;
+          dist  &= -64;
 
           if ( delta < 10 )
             dist += delta;
@@ -171,7 +172,7 @@
     }
     else
     {
-      /* strong hinting process, snap the stem width to integer pixels */
+      /* strong hinting process: snap the stem width to integer pixels */
       /*                                                               */
       if ( vertical )
       {
@@ -186,7 +187,7 @@
       }
       else
       {
-        dist = ah_snap_width( globals->widths,  globals->num_widths, dist );
+        dist = ah_snap_width( globals->widths, globals->num_widths, dist );
 
         if ( hinter->flags & AH_HINTER_MONOCHROME )
         {
@@ -208,7 +209,7 @@
           else if ( dist < 128 )
             dist = ( dist + 22 ) & -64;
           else
-            /* XXX: round otherwise, prevent color fringes in LCD mode */
+            /* XXX: round otherwise to prevent color fringes in LCD mode */
             dist = ( dist + 32 ) & -64;
         }
       }
@@ -246,7 +247,7 @@
     else if ( (  vertical && !hinter->do_vert_snapping ) ||
               ( !vertical && !hinter->do_horz_snapping ) )
     {
-      /* smooth hinting process, very lightly quantize the stem width */
+      /* smooth hinting process: very lightly quantize the stem width */
       /*                                                              */
       if ( dist < 64 )
         dist = 64;
@@ -267,8 +268,8 @@
 
         if ( dist < 3 * 64 )
         {
-          delta = ( dist & 63 );
-          dist &= -64;
+          delta  = dist & 63;
+          dist  &= -64;
 
           if ( delta < 10 )
             dist += delta;
@@ -288,7 +289,7 @@
     }
     else
     {
-      /* strong hinting process, snap the stem width to integer pixels */
+      /* strong hinting process: snap the stem width to integer pixels */
       /*                                                               */
       if ( vertical )
       {
@@ -303,7 +304,7 @@
       }
       else
       {
-        dist = ah_snap_width( globals->widths,  globals->num_widths, dist );
+        dist = ah_snap_width( globals->widths, globals->num_widths, dist );
 
         if ( hinter->flags & AH_HINTER_MONOCHROME )
         {
@@ -325,7 +326,7 @@
           else if ( dist < 128 )
             dist = ( dist + 22 ) & -64;
           else
-            /* XXX: round otherwise, prevent color fringes in LCD mode */
+            /* XXX: round otherwise to prevent color fringes in LCD mode */
             dist = ( dist + 32 ) & -64;
         }
       }
@@ -357,6 +358,7 @@
                                                   base_edge->flags,
                                                   stem_edge->flags );
 
+
     stem_edge->pos = base_edge->pos + fitted_width;
 
 #else
@@ -381,6 +383,7 @@
     FT_UNUSED( hinter );
     FT_UNUSED( vertical );
 
+
     dist = serif->opos - base->opos;
     if ( dist < 0 )
     {
@@ -388,15 +391,16 @@
       sign = -1;
     }
 
-    /* do not touch serifs widths !! */
 #if 0
+    /* do not touch serifs widths! */
     if ( base->flags & AH_EDGE_DONE )
     {
       if ( dist >= 64 )
-        dist = (dist+8) & -64;
+        dist = ( dist + 8 ) & -64;
 
       else if ( dist <= 32 && !vertical )
         dist = ( dist + 33 ) >> 1;
+
       else
         dist = 0;
     }
@@ -417,9 +421,8 @@
   /*************************************************************************/
 
 
-  /* Another alternative edge hinting algorithm */
   static void
-  ah_hint_edges_3( AH_Hinter  hinter )
+  ah_hint_edges( AH_Hinter  hinter )
   {
     AH_Edge     edges;
     AH_Edge     edge_limit;
@@ -464,7 +467,7 @@
           {
             edge1 = edge;
           }
-          else if (edge2 && edge2->blue_edge)
+          else if ( edge2 && edge2->blue_edge )
           {
             blue  = edge2->blue_edge;
             edge1 = edge2;
@@ -488,8 +491,8 @@
         }
       }
 
-      /* now, we will align all stem edges, trying to maintain the */
-      /* relative order of stems in the glyph..                    */
+      /* now we will align all stem edges, trying to maintain the */
+      /* relative order of stems in the glyph                     */
       for ( edge = edges; edge < edge_limit; edge++ )
       {
         AH_EdgeRec*  edge2;
@@ -506,12 +509,11 @@
           continue;
         }
 
-        /* now, align the stem */
+        /* now align the stem */
 
-        /* this should not happen, but it's better to be safe. */
+        /* this should not happen, but it's better to be safe */
         if ( edge2->blue_edge || edge2 < edge )
         {
-
           ah_align_linked_edge( hinter, edge2, edge, dimension );
           edge->flags |= AH_EDGE_DONE;
           continue;
@@ -522,14 +524,15 @@
 
 #ifdef FT_CONFIG_CHESTER_STEM
 
-          FT_Pos   org_len, org_center, cur_len;
-          FT_Pos   cur_pos1, error1, error2, u_off, d_off;
+          FT_Pos  org_len, org_center, cur_len;
+          FT_Pos  cur_pos1, error1, error2, u_off, d_off;
 
-          org_len    = edge2->opos - edge->opos;
-          cur_len    = ah_compute_stem_width( hinter, dimension, org_len,
-                                              edge->flags, edge2->flags   );
 
-          if (cur_len <= 64 )
+          org_len = edge2->opos - edge->opos;
+          cur_len = ah_compute_stem_width( hinter, dimension, org_len,
+                                           edge->flags, edge2->flags );
+
+          if ( cur_len <= 64 )
             u_off = d_off = 32;
           else
           {
@@ -563,7 +566,7 @@
           else
             edge->pos = ( edge->opos + 32 ) & -64;
 
-          anchor    = edge;
+          anchor = edge;
 
           edge->flags |= AH_EDGE_DONE;
 
@@ -583,23 +586,23 @@
         }
         else
         {
-          FT_Pos   org_pos, org_len, org_center, cur_len;
-          FT_Pos   cur_pos1, cur_pos2, delta1, delta2;
+          FT_Pos  org_pos, org_len, org_center, cur_len;
+          FT_Pos  cur_pos1, cur_pos2, delta1, delta2;
 
 
-          org_pos    = anchor->pos + (edge->opos - anchor->opos);
+          org_pos    = anchor->pos + ( edge->opos - anchor->opos );
           org_len    = edge2->opos - edge->opos;
           org_center = org_pos + ( org_len >> 1 );
 
 #ifdef FT_CONFIG_CHESTER_SERIF
 
-          cur_len    = ah_compute_stem_width( hinter, dimension, org_len,
-                                              edge->flags, edge2->flags  );
+          cur_len = ah_compute_stem_width( hinter, dimension, org_len,
+                                           edge->flags, edge2->flags  );
 
 
 #else  /* !FT_CONFIG_CHESTER_SERIF */
 
-          cur_len    = ah_compute_stem_width( hinter, dimension, org_len );
+          cur_len = ah_compute_stem_width( hinter, dimension, org_len );
 
 #endif /* !FT_CONFIG_CHESTER_SERIF */
 
@@ -610,7 +613,7 @@
             FT_Pos  u_off, d_off;
 
 
-            cur_pos1   = ( org_center + 32 ) & -64;
+            cur_pos1 = ( org_center + 32 ) & -64;
 
             if (cur_len <= 64 )
               u_off = d_off = 32;
@@ -620,11 +623,11 @@
               d_off = 26;
             }
 
-            delta1 = org_center - (cur_pos1 - u_off);
+            delta1 = org_center - ( cur_pos1 - u_off );
             if ( delta1 < 0 )
               delta1 = -delta1;
 
-            delta2 = org_center - (cur_pos1 + d_off);
+            delta2 = org_center - ( cur_pos1 + d_off );
             if ( delta2 < 0 )
               delta2 = -delta2;
 
@@ -638,8 +641,7 @@
           }
           else
           {
-
-            org_pos    = anchor->pos + (edge->opos - anchor->opos);
+            org_pos    = anchor->pos + ( edge->opos - anchor->opos );
             org_len    = edge2->opos - edge->opos;
             org_center = org_pos + ( org_len >> 1 );
 
@@ -688,8 +690,8 @@
       if ( !has_serifs )
         goto Next_Dimension;
 
-      /* now, hint the remaining edges (serifs and single) in order */
-      /* to complete our processing                                 */
+      /* now hint the remaining edges (serifs and single) in order */
+      /* to complete our processing                                */
       for ( edge = edges; edge < edge_limit; edge++ )
       {
         if ( edge->flags & AH_EDGE_DONE )
@@ -731,7 +733,7 @@
     /* reduce the problem of the disappearing eye in the `e' of Times... */
     /* also, creates some artifacts near the blue zones?                 */
     {
-      ah_hint_edges_3( hinter );
+      ah_hint_edges( hinter );
     }
   }
 
@@ -807,6 +809,7 @@
 
 
   /* hint the strong points -- this is equivalent to the TrueType `IP' */
+  /* hinting instruction                                               */
   static void
   ah_hinter_align_strong_points( AH_Hinter  hinter )
   {
@@ -872,7 +875,7 @@
             goto Store_Point;
           }
 
-          /* is the point after the last edge ? */
+          /* is the point after the last edge? */
           edge  = edge_limit - 1;
           delta = u - edge->fpos;
           if ( delta >= 0 )
@@ -1023,6 +1026,7 @@
 
 
   /* interpolate weak points -- this is equivalent to the TrueType `IUP' */
+  /* hinting instruction                                                 */
   static void
   ah_hinter_align_weak_points( AH_Hinter  hinter )
   {
@@ -1163,8 +1167,8 @@
   {
     FT_Int           n;
     AH_Face_Globals  globals = hinter->globals;
-    AH_Globals       design = &globals->design;
-    AH_Globals       scaled = &globals->scaled;
+    AH_Globals       design  = &globals->design;
+    AH_Globals       scaled  = &globals->scaled;
 
 
     /* copy content */
@@ -1233,7 +1237,7 @@
       ah_outline_done( hinter->glyph );
 
       /* note: the `globals' pointer is _not_ owned by the hinter */
-      /*       but by the current face object, we don't need to   */
+      /*       but by the current face object; we don't need to   */
       /*       release it                                         */
       hinter->globals = 0;
       hinter->face    = 0;
@@ -1382,8 +1386,8 @@
         }
       }
 
-      /* copy the outline points in the loader's current                */
-      /* extra points, which is used to keep original glyph coordinates */
+      /* copy the outline points in the loader's current               */
+      /* extra points which is used to keep original glyph coordinates */
       error = ah_loader_check_points( gloader, slot->outline.n_points + 2,
                                       slot->outline.n_contours );
       if ( error )
@@ -1411,8 +1415,8 @@
       if ( slot->outline.n_points == 0 )
         goto Hint_Metrics;
 
-      /* now, load the slot image into the auto-outline, and run the */
-      /* automatic hinting process                                   */
+      /* now load the slot image into the auto-outline and run the */
+      /* automatic hinting process                                 */
       error = ah_outline_load( outline, x_scale, y_scale, face );
       if ( error )
         goto Exit;
@@ -1560,7 +1564,7 @@
 
             l += num_base_points;
 
-            /* for now, only use the current point coordinates     */
+            /* for now, only use the current point coordinates;    */
             /* we may consider another approach in the near future */
             p1 = gloader->base.outline.points + start_point + k;
             p2 = gloader->base.outline.points + start_point + l;
@@ -1605,8 +1609,8 @@
       if ( hinter->transformed )
         FT_Outline_Transform( &gloader->base.outline, &hinter->trans_matrix );
 
-      /* we must translate our final outline by -pp1.x, and compute */
-      /* the new metrics                                            */
+      /* we must translate our final outline by -pp1.x and compute */
+      /* the new metrics                                           */
       if ( hinter->pp1.x )
         FT_Outline_Translate( &gloader->base.outline, -hinter->pp1.x, 0 );
 
@@ -1621,8 +1625,8 @@
       slot->metrics.horiBearingX = bbox.xMin;
       slot->metrics.horiBearingY = bbox.yMax;
 
-      /* for mono-width fonts (like Andale, Courier, etc.), we need */
-      /* to keep the original rounded advance width                 */
+      /* for mono-width fonts (like Andale, Courier, etc.) we need */
+      /* to keep the original rounded advance width                */
       if ( !FT_IS_FIXED_WIDTH( slot->face ) )
         slot->metrics.horiAdvance = hinter->pp2.x - hinter->pp1.x;
       else
@@ -1663,7 +1667,7 @@
     FT_Fixed         x_scale      = size->metrics.x_scale;
     FT_Fixed         y_scale      = size->metrics.y_scale;
     AH_Face_Globals  face_globals = FACE_GLOBALS( face );
-    FT_Render_Mode   hint_mode    = FT_LOAD_TARGET_MODE(load_flags);
+    FT_Render_Mode   hint_mode    = FT_LOAD_TARGET_MODE( load_flags );
 
 
     /* first of all, we need to check that we're using the correct face and */
diff --git a/src/autohint/ahoptim.c b/src/autohint/ahoptim.c
index 8d10f4a..2c2c858 100644
--- a/src/autohint/ahoptim.c
+++ b/src/autohint/ahoptim.c
@@ -4,7 +4,7 @@
 /*                                                                         */
 /*    FreeType auto hinting outline optimization (body).                   */
 /*                                                                         */
-/*  Copyright 2000-2001, 2002 Catharon Productions Inc.                    */
+/*  Copyright 2000-2001, 2002, 2003 Catharon Productions Inc.              */
 /*  Author: David Turner                                                   */
 /*                                                                         */
 /*  This file is part of the Catharon Typography Project and shall only    */
@@ -21,9 +21,9 @@
 
   /*************************************************************************/
   /*                                                                       */
-  /* This module is in charge of optimising the outlines produced by the   */
+  /* This module is in charge of optimizing the outlines produced by the   */
   /* auto-hinter in direct mode. This is required at small pixel sizes in  */
-  /* order to ensure coherent spacing, among other things..                */
+  /* order to ensure coherent spacing, among other things.                 */
   /*                                                                       */
   /* The technique used in this module is a simplified simulated           */
   /* annealing.                                                            */
@@ -42,17 +42,17 @@
 #define AH_BRUTE_FORCE
 
 
-#define xxxAH_DEBUG_OPTIM
+#define xxAH_DEBUG_OPTIM
 
 
-#undef LOG
+#undef AH_OPTIM_LOG
 #ifdef AH_DEBUG_OPTIM
 
-#define LOG( x )  optim_log ## x
+#define AH_OPTIM_LOG( x )  optim_log ## x
 
 #else
 
-#define LOG( x )
+#define AH_OPTIM_LOG( x )  do ; while ( 0 ) /* nothing */
 
 #endif /* AH_DEBUG_OPTIM */
 
@@ -87,13 +87,13 @@
     stem = optimizer->stems;
     for ( n = 0; n < optimizer->num_stems; n++, stem++ )
     {
-      LOG(( " %c%2d [%.1f:%.1f]={%.1f:%.1f}="
-            "<%1.f..%1.f> force=%.1f speed=%.1f\n",
-            optimizer->vertical ? 'V' : 'H', n,
-            FLOAT( stem->edge1->opos ), FLOAT( stem->edge2->opos ),
-            FLOAT( stem->edge1->pos ),  FLOAT( stem->edge2->pos ),
-            FLOAT( stem->min_pos ),     FLOAT( stem->max_pos ),
-            FLOAT( stem->force ),       FLOAT( stem->velocity ) ));
+      AH_OPTIM_LOG(( " %c%2d [%.1f:%.1f]={%.1f:%.1f}="
+                     "<%1.f..%1.f> force=%.1f speed=%.1f\n",
+                     optimizer->vertical ? 'V' : 'H', n,
+                     FLOAT( stem->edge1->opos ), FLOAT( stem->edge2->opos ),
+                     FLOAT( stem->edge1->pos ),  FLOAT( stem->edge2->pos ),
+                     FLOAT( stem->min_pos ),     FLOAT( stem->max_pos ),
+                     FLOAT( stem->force ),       FLOAT( stem->velocity ) ));
     }
   }
 
@@ -108,11 +108,11 @@
     stem = optimizer->stems;
     for ( n = 0; n < optimizer->num_stems; n++, stem++ )
     {
-      LOG(( " %c%2d [%.1f]=<%1.f..%1.f> force=%.1f speed=%.1f\n",
-            optimizer->vertical ? 'V' : 'H', n,
-            FLOAT( stem->pos ),
-            FLOAT( stem->min_pos ), FLOAT( stem->max_pos ),
-            FLOAT( stem->force ),   FLOAT( stem->velocity ) ));
+      AH_OPTIM_LOG(( " %c%2d [%.1f]=<%1.f..%1.f> force=%.1f speed=%.1f\n",
+                     optimizer->vertical ? 'V' : 'H', n,
+                     FLOAT( stem->pos ),
+                     FLOAT( stem->min_pos ), FLOAT( stem->max_pos ),
+                     FLOAT( stem->force ),   FLOAT( stem->velocity ) ));
     }
   }
 
@@ -127,19 +127,19 @@
 
     spring = optimizer->springs;
     stems  = optimizer->stems;
-    LOG(( "%cSprings ", optimizer->vertical ? 'V' : 'H' ));
+    AH_OPTIM_LOG(( "%cSprings ", optimizer->vertical ? 'V' : 'H' ));
 
     for ( n = 0; n < optimizer->num_springs; n++, spring++ )
     {
-      LOG(( " [%d-%d:%.1f:%1.f:%.1f]",
-            spring->stem1 - stems, spring->stem2 - stems,
-            FLOAT( spring->owidth ),
-            FLOAT( spring->stem2->pos -
-                   ( spring->stem1->pos + spring->stem1->width ) ),
-            FLOAT( spring->tension ) ));
+      AH_OPTIM_LOG(( " [%d-%d:%.1f:%1.f:%.1f]\n",
+                     spring->stem1 - stems, spring->stem2 - stems,
+                     FLOAT( spring->owidth ),
+                     FLOAT( spring->stem2->pos -
+                            ( spring->stem1->pos + spring->stem1->width ) ),
+                     FLOAT( spring->tension ) ));
     }
 
-    LOG(( "\n" ));
+    AH_OPTIM_LOG(( "\n" ));
   }
 
 #endif /* AH_DEBUG_OPTIM */
@@ -600,7 +600,8 @@
     {
       AH_Stem*  stem1 = spring->stem1;
       AH_Stem*  stem2 = spring->stem2;
-      FT_Pos  width;
+      FT_Pos    width;
+
 
       width  = stem2->pos - ( stem1->pos + stem1->width );
       width -= spring->owidth;
@@ -625,13 +626,13 @@
 
 
     distortion = optim_compute_distortion( optimizer );
-    LOG(( "config distortion = %.1f ", FLOAT( distortion * 64 ) ));
+    AH_OPTIM_LOG(( "config distortion = %.1f ", FLOAT( distortion * 64 ) ));
 
     /* check that we really need to add this configuration to our */
     /* sorted history                                             */
     if ( limit > configs && limit[-1].distortion < distortion )
     {
-      LOG(( "ejected\n" ));
+      AH_OPTIM_LOG(( "ejected\n" ));
       return;
     }
 
@@ -664,7 +665,7 @@
       config[0] = config[1];
       config[1] = temp;
     }
-    LOG(( "recorded!\n" ));
+    AH_OPTIM_LOG(( "recorded!\n" ));
   }
 
 
@@ -818,7 +819,7 @@
     optimizer->outline = outline;
     optimizer->memory  = memory;
 
-    LOG(( "initializing new optimizer\n" ));
+    AH_OPTIM_LOG(( "initializing new optimizer\n" ));
     /* compute stems and springs */
     error = optim_compute_stems  ( optimizer ) ||
             optim_compute_springs( optimizer );
@@ -862,7 +863,7 @@
 
     if ( optimizer->num_springs > 0 )
     {
-      LOG(( "horizontal optimization ------------------------\n" ));
+      AH_OPTIM_LOG(( "horizontal optimization ------------------------\n" ));
       optim_compute( optimizer );
     }
 
@@ -873,7 +874,7 @@
 
     if ( optimizer->num_springs )
     {
-      LOG(( "vertical optimization --------------------------\n" ));
+      AH_OPTIM_LOG(( "vertical optimization --------------------------\n" ));
       optim_compute( optimizer );
     }
   }
diff --git a/src/autohint/ahtypes.h b/src/autohint/ahtypes.h
index d004ed4..07ec37d 100644
--- a/src/autohint/ahtypes.h
+++ b/src/autohint/ahtypes.h
@@ -251,9 +251,9 @@ FT_BEGIN_HEADER
   /*    contour    :: A pointer to the first point of the segment's        */
   /*                  contour.                                             */
   /*                                                                       */
-  /*    pos        :: The segment position in font units.                  */
+  /*    min_coord  :: The minimum coordinate of the segment.               */
   /*                                                                       */
-  /*    size       :: The segment size.                                    */
+  /*    max_coord  :: The maximum coordinate of the segment.               */
   /*                                                                       */
   /*    edge       :: The edge of the current segment.                     */
   /*                                                                       */
@@ -320,12 +320,12 @@ FT_BEGIN_HEADER
   /*                                                                       */
   /*    serif      :: The serif edge.                                      */
   /*                                                                       */
-  /*    num_paired :: The number of other edges that pair to this one.     */
+  /*    num_linked :: The number of other edges that pair to this one.     */
   /*                                                                       */
   /*    score      :: Used to score the edge when selecting them.          */
   /*                                                                       */
   /*    blue_edge  :: Indicate the blue zone edge this edge is related to. */
-  /*                  Only set for some of the horizontal edges in a Latin */
+  /*                  Only set for some of the horizontal edges in a latin */
   /*                  font.                                                */
   /*                                                                       */
   typedef struct  AH_EdgeRec_
@@ -368,7 +368,7 @@ FT_BEGIN_HEADER
 
     FT_Int        max_contours;
     FT_Int        num_contours;
-    AH_Point *    contours;
+    AH_Point*     contours;
 
     FT_Int        num_hedges;
     AH_Edge       horz_edges;
@@ -399,7 +399,7 @@ FT_BEGIN_HEADER
 
 #define AH_BLUE_CAPITAL_TOP     0                              /* THEZOCQS */
 #define AH_BLUE_CAPITAL_BOTTOM  ( AH_BLUE_CAPITAL_TOP + 1 )    /* HEZLOCUS */
-#define AH_BLUE_SMALL_TOP       ( AH_BLUE_CAPITAL_BOTTOM + 1)  /* xzroesc  */
+#define AH_BLUE_SMALL_TOP       ( AH_BLUE_CAPITAL_BOTTOM + 1 ) /* xzroesc  */
 #define AH_BLUE_SMALL_BOTTOM    ( AH_BLUE_SMALL_TOP + 1 )      /* xzroesc  */
 #define AH_BLUE_SMALL_MINOR     ( AH_BLUE_SMALL_BOTTOM + 1 )   /* pqgjy    */
 #define AH_BLUE_MAX             ( AH_BLUE_SMALL_MINOR + 1 )
@@ -429,6 +429,9 @@ FT_BEGIN_HEADER
   /*                                                                       */
   /*    num_heights :: The number of heights.                              */
   /*                                                                       */
+  /*    stds        :: A two-element array giving the default stem width   */
+  /*                   and height.                                         */
+  /*                                                                       */
   /*    widths      :: Snap widths, including standard one.                */
   /*                                                                       */
   /*    heights     :: Snap height, including standard one.                */
@@ -474,6 +477,9 @@ FT_BEGIN_HEADER
   /*                                                                       */
   /*    y_scale :: The current vertical scale.                             */
   /*                                                                       */
+  /*    control_overshoot ::                                               */
+  /*               Currently unused.                                       */
+  /*                                                                       */
   typedef struct  AH_Face_GlobalsRec_
   {
     FT_Face        face;
@@ -486,39 +492,39 @@ FT_BEGIN_HEADER
   } AH_Face_GlobalsRec, *AH_Face_Globals;
 
 
-  typedef struct  AH_HinterRec
+  typedef struct  AH_HinterRec_
   {
-    FT_Memory         memory;
-    AH_Hinter_Flags   flags;
+    FT_Memory        memory;
+    AH_Hinter_Flags  flags;
 
-    FT_Int            algorithm;
-    FT_Face           face;
+    FT_Int           algorithm;
+    FT_Face          face;
 
-    AH_Face_Globals   globals;
+    AH_Face_Globals  globals;
 
-    AH_Outline        glyph;
+    AH_Outline       glyph;
 
-    AH_Loader         loader;
-    FT_Vector         pp1;
-    FT_Vector         pp2;
+    AH_Loader        loader;
+    FT_Vector        pp1;
+    FT_Vector        pp2;
 
-    FT_Bool           transformed;
-    FT_Vector         trans_delta;
-    FT_Matrix         trans_matrix;
+    FT_Bool          transformed;
+    FT_Vector        trans_delta;
+    FT_Matrix        trans_matrix;
 
-    FT_Bool           do_horz_hints;     /* disable X hinting            */
-    FT_Bool           do_vert_hints;     /* disable Y hinting            */
-    FT_Bool           do_horz_snapping;  /* disable X stem size snapping */
-    FT_Bool           do_vert_snapping;  /* disable Y stem size snapping */
-    FT_Bool           do_stem_adjust;    /* disable light stem snapping  */
+    FT_Bool          do_horz_hints;     /* disable X hinting            */
+    FT_Bool          do_vert_hints;     /* disable Y hinting            */
+    FT_Bool          do_horz_snapping;  /* disable X stem size snapping */
+    FT_Bool          do_vert_snapping;  /* disable Y stem size snapping */
+    FT_Bool          do_stem_adjust;    /* disable light stem snapping  */
 
   } AH_HinterRec, *AH_Hinter;
 
 
-#ifdef  DEBUG_HINTER
-  extern AH_Hinter   ah_debug_hinter;
-  extern FT_Bool     ah_debug_disable_horz;
-  extern FT_Bool     ah_debug_disable_vert;
+#ifdef DEBUG_HINTER
+  extern AH_Hinter  ah_debug_hinter;
+  extern FT_Bool    ah_debug_disable_horz;
+  extern FT_Bool    ah_debug_disable_vert;
 #else
 #define ah_debug_disable_horz  0
 #define ah_debug_disable_vert  0
diff --git a/src/autohint/rules.mk b/src/autohint/rules.mk
index 6dcaa20..b70fcb5 100644
--- a/src/autohint/rules.mk
+++ b/src/autohint/rules.mk
@@ -3,7 +3,7 @@
 #
 
 
-# Copyright 2000, 2001 Catharon Productions Inc.
+# Copyright 2000, 2001, 2002 Catharon Productions Inc.
 # Author: David Turner
 #
 # This file is part of the Catharon Typography Project and shall only
@@ -29,17 +29,17 @@ AUTO_COMPILE := $(FT_COMPILE) $I$(AUTO_DIR)
 
 # AUTO driver sources (i.e., C files)
 #
-AUTO_DRV_SRC := $(AUTO_DIR_)ahangles.c  \
-                $(AUTO_DIR_)ahglobal.c  \
-                $(AUTO_DIR_)ahglyph.c   \
-                $(AUTO_DIR_)ahhint.c    \
+AUTO_DRV_SRC := $(AUTO_DIR_)ahangles.c \
+                $(AUTO_DIR_)ahglobal.c \
+                $(AUTO_DIR_)ahglyph.c  \
+                $(AUTO_DIR_)ahhint.c   \
                 $(AUTO_DIR_)ahmodule.c
 
 # AUTO driver headers
 #
 AUTO_DRV_H := $(AUTO_DRV_SRC:%c=%h)  \
               $(AUTO_DIR_)ahloader.h \
-              $(AUTO_DIR_)ahtypes.h \
+              $(AUTO_DIR_)ahtypes.h  \
               $(AUTO_DIR_)aherrors.h