Commit 1be9ebf5f909d7fc026eb185a8b5eeb6a372afe6

Werner Lemberg 2006-01-22T06:58:16

* src/autofit/rules.mk (AUTOF_DRV_SRC): Add afwarp.c. Formatting, copyright notices, copyright years.

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
diff --git a/ChangeLog b/ChangeLog
index b5b69cb..10e217b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,11 +1,34 @@
+2006-01-21  Werner Lemberg  <wl@gnu.org>
+
+	* src/autofit/rules.mk (AUTOF_DRV_SRC): Add afwarp.c.
+
 2006-01-20  David Turner  <david@freetype.org>
 
-	* src/autofit/aflatin.c, src/autofit/afwarp.h, src/autofit/afwarp.c,
-	src/autofit/aftypes.h, src/autofit/afloader.c,
-	src/autofit/autofit.c: Adding experimental implementation of `warp
-	hinting' (new hinting algorithm for gray-level and LCD rendering). 
-	It is disabled by default, you need to #define AF_USE_WARPER in
-	aftypes.h to enable it.
+	Adding experimental implementation of `warp hinting' (new hinting
+	algorithm for gray-level and LCD rendering).  It is disabled by
+	default, you need to #define AF_USE_WARPER in aftypes.h.
+
+	* src/autofit/afhints.c (af_glyph_hints_scale_dim) [AF_USE_WARPER]:
+	New function.
+	* src/autofit/afhints.h: Updated.
+
+	* src/autofit/aflatin.c [AF_USE_WARPER]: Include afwarp.h.
+	(af_latin_hints_init) [AF_USE_WARPER]: Reset mode to
+	FT_RENDER_MODE_NORMAL if an LCD mode is selected.
+	(af_latin_hints_apply) [AF_USE_WARPER]: Call af_warper_compute
+	appropriately.
+
+	* src/autofit/afloader.c (af_loader_load_g) [!AF_USER_WARPER]:
+	Isolate code for adjusting metrics.
+
+	* src/autofit/aftypes.h (AF_USE_WARPER): New macro (commented out by
+	default).
+
+	* src/autofit/afwarp.c, src/autofit/afwarp.h: New files.
+
+	* src/autofit/autofit.c [AF_USE_WARPER]: Include afwarp.c.
+
+	* src/autofit/Jamfile (_sources): Add afwarp.
 
 2006-01-19  David Turner  <david@freetype.org>
 
diff --git a/src/autofit/Jamfile b/src/autofit/Jamfile
index bf10323..9f6dc2a 100644
--- a/src/autofit/Jamfile
+++ b/src/autofit/Jamfile
@@ -1,6 +1,6 @@
 # FreeType 2 src/autofit Jamfile
 #
-# Copyright 2003, 2004, 2005 by
+# Copyright 2003, 2004, 2005, 2006 by
 # David Turner, Robert Wilhelm, and Werner Lemberg.
 #
 # This file is part of the FreeType project, and may only be used, modified,
diff --git a/src/autofit/afhints.c b/src/autofit/afhints.c
index f38a33e..b011c15 100644
--- a/src/autofit/afhints.c
+++ b/src/autofit/afhints.c
@@ -4,7 +4,7 @@
 /*                                                                         */
 /*    Auto-fitter hinting routines (body).                                 */
 /*                                                                         */
-/*  Copyright 2003, 2004, 2005 by                                          */
+/*  Copyright 2003, 2004, 2005, 2006 by                                    */
 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
 /*                                                                         */
 /*  This file is part of the FreeType project, and may only be used,       */
@@ -1140,7 +1140,9 @@
     }
   }
 
+
 #ifdef AF_USE_WARPER
+
   FT_LOCAL_DEF( void )
   af_glyph_hints_scale_dim( AF_GlyphHints  hints,
                             AF_Dimension   dim,
@@ -1151,6 +1153,7 @@
     AF_Point  points_limit = points + hints->num_points;
     AF_Point  point;
     
+
     if ( dim == AF_DIMENSION_HORZ )
     {
       for ( point = points; point < points_limit; point++ )
@@ -1162,6 +1165,7 @@
         point->y = FT_MulFix( point->fy, scale ) + delta;
     }
   }
+
 #endif /* AF_USE_WARPER */
 
 /* END */
diff --git a/src/autofit/afhints.h b/src/autofit/afhints.h
index a5a28ac..351e5da 100644
--- a/src/autofit/afhints.h
+++ b/src/autofit/afhints.h
@@ -4,7 +4,7 @@
 /*                                                                         */
 /*    Auto-fitter hinting routines (specification).                        */
 /*                                                                         */
-/*  Copyright 2003, 2004, 2005 by                                          */
+/*  Copyright 2003, 2004, 2005, 2006 by                                    */
 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
 /*                                                                         */
 /*  This file is part of the FreeType project, and may only be used,       */
diff --git a/src/autofit/aflatin.c b/src/autofit/aflatin.c
index 7a1b60b..ad70456 100644
--- a/src/autofit/aflatin.c
+++ b/src/autofit/aflatin.c
@@ -4,7 +4,7 @@
 /*                                                                         */
 /*    Auto-fitter hinting routines for latin script (body).                */
 /*                                                                         */
-/*  Copyright 2003, 2004, 2005 by                                          */
+/*  Copyright 2003, 2004, 2005, 2006 by                                    */
 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
 /*                                                                         */
 /*  This file is part of the FreeType project, and may only be used,       */
@@ -24,6 +24,7 @@
 #include "afwarp.h"
 #endif
 
+
   /*************************************************************************/
   /*************************************************************************/
   /*****                                                               *****/
@@ -1955,9 +1956,10 @@
         if ( dim == AF_DIMENSION_HORZ &&
              metrics->root.scaler.render_mode == FT_RENDER_MODE_NORMAL )
         {
-          AF_WarperRec   warper;
-          FT_Fixed       scale;
-          FT_Pos         delta;
+          AF_WarperRec  warper;
+          FT_Fixed      scale;
+          FT_Pos        delta;
+
 
           af_warper_compute( &warper, hints, dim, &scale, &delta );
           af_glyph_hints_scale_dim( hints, dim, scale, delta );
diff --git a/src/autofit/afloader.c b/src/autofit/afloader.c
index f0e3cae..a24070e 100644
--- a/src/autofit/afloader.c
+++ b/src/autofit/afloader.c
@@ -4,7 +4,7 @@
 /*                                                                         */
 /*    Auto-fitter glyph loading routines (body).                           */
 /*                                                                         */
-/*  Copyright 2003, 2004, 2005 by                                          */
+/*  Copyright 2003, 2004, 2005, 2006 by                                    */
 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
 /*                                                                         */
 /*  This file is part of the FreeType project, and may only be used,       */
diff --git a/src/autofit/aftypes.h b/src/autofit/aftypes.h
index fbcf640..117977b 100644
--- a/src/autofit/aftypes.h
+++ b/src/autofit/aftypes.h
@@ -4,7 +4,7 @@
 /*                                                                         */
 /*    Auto-fitter types (specification only).                              */
 /*                                                                         */
-/*  Copyright 2003, 2004, 2005 by                                          */
+/*  Copyright 2003, 2004, 2005, 2006 by                                    */
 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
 /*                                                                         */
 /*  This file is part of the FreeType project, and may only be used,       */
diff --git a/src/autofit/afwarp.c b/src/autofit/afwarp.c
index d445cf1..24129d8 100644
--- a/src/autofit/afwarp.c
+++ b/src/autofit/afwarp.c
@@ -1,270 +1,307 @@
+/***************************************************************************/
+/*                                                                         */
+/*  afwarp.c                                                               */
+/*                                                                         */
+/*    Auto-fitter warping algorithm (body).                                */
+/*                                                                         */
+/*  Copyright 2006 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 "afwarp.h"
 
+
 #if 1
-static const AF_WarpScore
-af_warper_weights[ 64 ] =
-{
-  35, 20, 20, 20, 15, 12, 10,  5,  2,  1,  0,  0,  0,  0,  0,  0,
-   0,  0,  0,  0,  0,  0, -1, -2, -5, -8,-10,-10,-20,-20,-30,-30,
-
- -30,-30,-20,-20,-10,-10, -8, -5, -2, -1,  0,  0,  0,  0,  0,  0,
-   0,  0,  0,  0,  0,  0,  0,  1,  2,  5, 10, 12, 15, 20, 20, 20,
-};
+  static const AF_WarpScore
+  af_warper_weights[64] =
+  {
+    35, 20, 20, 20, 15, 12, 10,  5,  2,  1,  0,  0,  0,  0,  0,  0,
+     0,  0,  0,  0,  0,  0, -1, -2, -5, -8,-10,-10,-20,-20,-30,-30,
+
+   -30,-30,-20,-20,-10,-10, -8, -5, -2, -1,  0,  0,  0,  0,  0,  0,
+     0,  0,  0,  0,  0,  0,  0,  1,  2,  5, 10, 12, 15, 20, 20, 20,
+  };
 #else
-static const AF_WarpScore
-af_warper_weights[ 64 ] =
-{
-  30, 20, 10,  5,  4,  4,  3,  2,  1,  0,  0,  0,  0,  0,  0,  0,
-   0,  0,  0,  0,  0,  0,  0, -1, -2, -2, -5, -5,-10,-10,-15,-20,
-
- -20,-15,-15,-10,-10, -5, -5, -2, -2, -1,  0,  0,  0,  0,  0,  0,
-   0,  0,  0,  0,  0,  0,  0,  0,  1,  2,  3,  4,  4,  5, 10, 20,
-};
+  static const AF_WarpScore
+  af_warper_weights[64] =
+  {
+    30, 20, 10,  5,  4,  4,  3,  2,  1,  0,  0,  0,  0,  0,  0,  0,
+     0,  0,  0,  0,  0,  0,  0, -1, -2, -2, -5, -5,-10,-10,-15,-20,
+
+   -20,-15,-15,-10,-10, -5, -5, -2, -2, -1,  0,  0,  0,  0,  0,  0,
+     0,  0,  0,  0,  0,  0,  0,  0,  1,  2,  3,  4,  4,  5, 10, 20,
+  };
 #endif
 
-static void
-af_warper_compute_line_best( AF_Warper     warper,
-                             FT_Fixed      scale,
-                             FT_Pos        delta,
-                             FT_Pos        xx1,
-                             FT_Pos        xx2,
-                             AF_WarpScore  base_distort,
-                             AF_Segment    segments,
-                             FT_UInt       num_segments )
-{
-  FT_Int  idx_min, idx_max, idx0, xx1min, xx1max;
-  FT_UInt  nn;
-  AF_WarpScore  scores[64];
-
-  for ( nn = 0; nn < 64; nn++ )
-    scores[nn] = 0;
-
-  idx0 = xx1 - warper->t1;
-
-  /* compute minimum and maximum indices */
+
+  static void
+  af_warper_compute_line_best( AF_Warper     warper,
+                               FT_Fixed      scale,
+                               FT_Pos        delta,
+                               FT_Pos        xx1,
+                               FT_Pos        xx2,
+                               AF_WarpScore  base_distort,
+                               AF_Segment    segments,
+                               FT_UInt       num_segments )
   {
-    FT_Pos  xx1min = warper->x1min;
-    FT_Pos  xx1max = warper->x1max;
-    FT_Pos  w      = xx2 - xx1;
+    FT_Int        idx_min, idx_max, idx0, xx1min, xx1max;
+    FT_UInt       nn;
+    AF_WarpScore  scores[64];
 
-    if ( xx1min + w < warper->x2min )
-      xx1min = warper->x2min - (xx2-xx1);
 
-    xx1max = warper->x1max;
-    if ( xx1max + w > warper->x2max )
-      xx1max = warper->x2max - (xx2-xx1);
+    for ( nn = 0; nn < 64; nn++ )
+      scores[nn] = 0;
 
-    idx_min = xx1min - warper->t1;
-    idx_max = xx1max - warper->t1;
+    idx0 = xx1 - warper->t1;
 
-    if ( idx_min > idx_max )
+    /* compute minimum and maximum indices */
     {
-      printf( "invalid indices min=%d max=%d xx1=%d xx2=%d x1min=%d x1max=%d x2min=%d x2max=%d\n",
-              idx_min, idx_max, xx1, xx2, warper->x1min, warper->x1max, warper->x2min, warper->x2max );
-      return;
+      FT_Pos  xx1min = warper->x1min;
+      FT_Pos  xx1max = warper->x1max;
+      FT_Pos  w      = xx2 - xx1;
+
+
+      if ( xx1min + w < warper->x2min )
+        xx1min = warper->x2min - ( xx2 - xx1 );
+
+      xx1max = warper->x1max;
+      if ( xx1max + w > warper->x2max )
+        xx1max = warper->x2max - ( xx2 - xx1 );
+
+      idx_min = xx1min - warper->t1;
+      idx_max = xx1max - warper->t1;
+
+      if ( idx_min > idx_max )
+      {
+        printf( "invalid indices:\n"
+                "  min=%d max=%d, xx1=%d xx2=%d,\n"
+                "  x1min=%d x1max=%d, x2min=%d x2max=%d\n",
+                idx_min, idx_max, xx1, xx2,
+                warper->x1min, warper->x1max, warper->x2min, warper->x2max );
+        return;
+      }
     }
-  }
 
-  for ( nn = 0; nn < num_segments; nn++ )
-  {
-    FT_Pos  len = segments[nn].max_coord - segments[nn].min_coord;
-    FT_Pos  y0  = FT_MulFix( segments[nn].pos, scale ) + delta;
-    FT_Pos  y   = y0 + (idx_min - idx0);
-    FT_Int  idx;
+    for ( nn = 0; nn < num_segments; nn++ )
+    {
+      FT_Pos  len = segments[nn].max_coord - segments[nn].min_coord;
+      FT_Pos  y0  = FT_MulFix( segments[nn].pos, scale ) + delta;
+      FT_Pos  y   = y0 + ( idx_min - idx0 );
 
-    for ( idx = idx_min; idx <= idx_max; idx++, y++ )
-      scores[idx] += af_warper_weights[ y & 63 ]*len;
-  }
+      FT_Int  idx;
 
-  /* find best score */
-  {
-    FT_Int  idx;
 
-    for ( idx = idx_min; idx <= idx_max; idx++ )
+      for ( idx = idx_min; idx <= idx_max; idx++, y++ )
+        scores[idx] += af_warper_weights[y & 63] * len;
+    }
+
+    /* find best score */
     {
-      AF_WarpScore  score = scores[idx];
-      AF_WarpScore  distort = base_distort + (idx - idx0);
+      FT_Int  idx;
+
 
-      if ( score > warper->best_score           ||
-           ( score == warper->best_score    &&
-             distort < warper->best_distort )   )
+      for ( idx = idx_min; idx <= idx_max; idx++ )
       {
-        warper->best_score   = score;
-        warper->best_distort = distort;
-        warper->best_scale   = scale;
-        warper->best_delta   = delta + (idx-idx0);
+        AF_WarpScore  score = scores[idx];
+        AF_WarpScore  distort = base_distort + ( idx - idx0 );
+
+
+        if ( score > warper->best_score           ||
+             ( score == warper->best_score    &&
+               distort < warper->best_distort )   )
+        {
+          warper->best_score   = score;
+          warper->best_distort = distort;
+          warper->best_scale   = scale;
+          warper->best_delta   = delta + ( idx - idx0 );
+        }
       }
     }
   }
-}
-
-
-FT_LOCAL_DEF( void )
-af_warper_compute( AF_Warper      warper,
-                   AF_GlyphHints  hints,
-                   AF_Dimension   dim,
-                   FT_Fixed      *a_scale,
-                   FT_Pos        *a_delta )
-{
-  AF_AxisHints  axis;
-  AF_Point      points;
-  FT_Fixed      org_scale;
-  FT_Pos        org_delta;
-  FT_UInt       nn, num_points, num_segments;
-  FT_Int        X1, X2;
-  FT_Int        w;
-  AF_WarpScore  base_distort;
-  AF_Segment    segments;
-
-  /* get original scaling transform */
-  if ( dim == AF_DIMENSION_VERT )
-  {
-    org_scale = hints->y_scale;
-    org_delta = hints->y_delta;
-  }
-  else
+
+
+  FT_LOCAL_DEF( void )
+  af_warper_compute( AF_Warper      warper,
+                     AF_GlyphHints  hints,
+                     AF_Dimension   dim,
+                     FT_Fixed      *a_scale,
+                     FT_Pos        *a_delta )
   {
-    org_scale = hints->x_scale;
-    org_delta = hints->x_delta;
-  }
+    AF_AxisHints  axis;
+    AF_Point      points;
 
-  warper->best_scale   = org_scale;
-  warper->best_delta   = org_delta;
-  warper->best_score   = 0;
-  warper->best_distort = 0;
+    FT_Fixed      org_scale;
+    FT_Pos        org_delta;
 
-  axis         = &hints->axis[dim];
-  segments     = axis->segments;
-  num_segments = axis->num_segments;
-  points       = hints->points;
-  num_points   = hints->num_points;
+    FT_UInt       nn, num_points, num_segments;
+    FT_Int        X1, X2;
+    FT_Int        w;
 
-  *a_scale = org_scale;
-  *a_delta = org_delta;
+    AF_WarpScore  base_distort;
+    AF_Segment    segments;
 
-  /* get X1 and X2, minimum and maximum in original coordinates */
-  if ( axis->num_segments < 1 )
-    return;
+
+    /* get original scaling transformation */
+    if ( dim == AF_DIMENSION_VERT )
+    {
+      org_scale = hints->y_scale;
+      org_delta = hints->y_delta;
+    }
+    else
+    {
+      org_scale = hints->x_scale;
+      org_delta = hints->x_delta;
+    }
+
+    warper->best_scale   = org_scale;
+    warper->best_delta   = org_delta;
+    warper->best_score   = 0;
+    warper->best_distort = 0;
+
+    axis         = &hints->axis[dim];
+    segments     = axis->segments;
+    num_segments = axis->num_segments;
+    points       = hints->points;
+    num_points   = hints->num_points;
+
+    *a_scale = org_scale;
+    *a_delta = org_delta;
+
+    /* get X1 and X2, minimum and maximum in original coordinates */
+    if ( axis->num_segments < 1 )
+      return;
 
 #if 1
-  X1 = X2 = points[0].fx;
-  for ( nn = 1; nn < num_points; nn++ )
-  {
-    FT_Int  X = points[nn].fx;
+    X1 = X2 = points[0].fx;
+    for ( nn = 1; nn < num_points; nn++ )
+    {
+      FT_Int  X = points[nn].fx;
 
-    if ( X < X1 )
-      X1 = X;
-    if ( X > X2 )
-      X2 = X;
-  }
+
+      if ( X < X1 )
+        X1 = X;
+      if ( X > X2 )
+        X2 = X;
+    }
 #else
-  X1 = X2 = segments[0].pos;
-  for ( nn = 1; nn < num_segments; nn++ )
-  {
-    FT_Int  X = segments[nn].pos;
+    X1 = X2 = segments[0].pos;
+    for ( nn = 1; nn < num_segments; nn++ )
+    {
+      FT_Int  X = segments[nn].pos;
 
-    if ( X < X1 )
-      X1 = X;
-    if ( X > X2 )
-      X2 = X;
-  }
-#endif
 
-  if ( X1 >= X2 )
-    return;
+      if ( X < X1 )
+        X1 = X;
+      if ( X > X2 )
+        X2 = X;
+    }
+#endif
 
-  warper->x1 = FT_MulFix( X1, org_scale ) + org_delta;
-  warper->x2 = FT_MulFix( X2, org_scale ) + org_delta;
+    if ( X1 >= X2 )
+      return;
 
-  warper->t1 = AF_WARPER_FLOOR(warper->x1);
-  warper->t2 = AF_WARPER_CEIL(warper->x2);
+    warper->x1 = FT_MulFix( X1, org_scale ) + org_delta;
+    warper->x2 = FT_MulFix( X2, org_scale ) + org_delta;
 
-  warper->x1min = warper->x1 & ~31;
-  warper->x1max = warper->x1min + 32;
-  warper->x2min = warper->x2 & ~31;
-  warper->x2max = warper->x2min + 32;
+    warper->t1 = AF_WARPER_FLOOR( warper->x1 );
+    warper->t2 = AF_WARPER_CEIL( warper->x2 );
 
-  if ( warper->x1max > warper->x2 )
-    warper->x1max = warper->x2;
+    warper->x1min = warper->x1 & ~31;
+    warper->x1max = warper->x1min + 32;
+    warper->x2min = warper->x2 & ~31;
+    warper->x2max = warper->x2min + 32;
 
-  if ( warper->x2min < warper->x1 )
-    warper->x2min = warper->x1;
+    if ( warper->x1max > warper->x2 )
+      warper->x1max = warper->x2;
 
-  warper->w0 = warper->x2 - warper->x1;
+    if ( warper->x2min < warper->x1 )
+      warper->x2min = warper->x1;
 
-  if ( warper->w0 <= 64 )
-  {
-    warper->x1max = warper->x1;
-    warper->x2min = warper->x2;
-  }
+    warper->w0 = warper->x2 - warper->x1;
 
-  warper->wmin = warper->x2min - warper->x1max;
-  warper->wmax = warper->x2max - warper->x1min;
+    if ( warper->w0 <= 64 )
+    {
+      warper->x1max = warper->x1;
+      warper->x2min = warper->x2;
+    }
 
-  if ( warper->wmin < warper->w0 - 32 )
-    warper->wmin = warper->w0 - 32;
+    warper->wmin = warper->x2min - warper->x1max;
+    warper->wmax = warper->x2max - warper->x1min;
 
-  if ( warper->wmax > warper->w0 + 32 )
-    warper->wmax = warper->w0 + 32;
+    if ( warper->wmin < warper->w0 - 32 )
+      warper->wmin = warper->w0 - 32;
 
-  if ( warper->wmin < warper->w0*3/4 )
-    warper->wmin = warper->w0*3/4;
+    if ( warper->wmax > warper->w0 + 32 )
+      warper->wmax = warper->w0 + 32;
 
-  if ( warper->wmax > warper->w0*5/4 )
-    warper->wmax = warper->w0*5/4;
+    if ( warper->wmin < warper->w0 * 3 / 4 )
+      warper->wmin = warper->w0 * 3 / 4;
 
+    if ( warper->wmax > warper->w0 * 5 / 4 )
+      warper->wmax = warper->w0 * 5 / 4;
 
-  /* warper->wmin = warper->wmax = warper->w0; */
+    /* warper->wmin = warper->wmax = warper->w0; */
 
-  for ( w = warper->wmin; w <= warper->wmax; w++ )
-  {
-    FT_Int   line = w - warper->wmin;
-    FT_Fixed  new_scale;
-    FT_Pos    new_delta;
-    FT_Pos    xx1, xx2;
-
-    xx1 = warper->x1;
-    xx2 = warper->x2;
-    if ( w >= warper->w0 )
+    for ( w = warper->wmin; w <= warper->wmax; w++ )
     {
-      xx1 -= (w-warper->w0);
-      if ( xx1 < warper->x1min )
+      FT_Int    line = w - warper->wmin;
+      FT_Fixed  new_scale;
+      FT_Pos    new_delta;
+      FT_Pos    xx1, xx2;
+
+
+      xx1 = warper->x1;
+      xx2 = warper->x2;
+      if ( w >= warper->w0 )
       {
-        xx2 += warper->x1min - xx1;
-        xx1  = warper->x1min;
+        xx1 -= w - warper->w0;
+        if ( xx1 < warper->x1min )
+        {
+          xx2 += warper->x1min - xx1;
+          xx1  = warper->x1min;
+        }
       }
-    }
-    else
-    {
-      xx1 -= (w-warper->w0);
-      if ( xx1 > warper->x1max )
+      else
       {
-        xx2 -= (xx1-warper->x1max);
-        xx1  = warper->x1max;
+        xx1 -= w - warper->w0;
+        if ( xx1 > warper->x1max )
+        {
+          xx2 -= xx1 - warper->x1max;
+          xx1  = warper->x1max;
+        }
       }
-    }
 
-    if ( xx1 < warper->x1 )
-      base_distort = warper->x1 - xx1;
-    else
-      base_distort = xx1 - warper->x1;
+      if ( xx1 < warper->x1 )
+        base_distort = warper->x1 - xx1;
+      else
+        base_distort = xx1 - warper->x1;
 
-    if ( xx2 < warper->x2 )
-      base_distort += warper->x2 - xx2;
-    else
-      base_distort += xx2 - warper->x2;
+      if ( xx2 < warper->x2 )
+        base_distort += warper->x2 - xx2;
+      else
+        base_distort += xx2 - warper->x2;
 
-    base_distort *= 10;
+      base_distort *= 10;
 
-    new_scale = org_scale + FT_DivFix( w - warper->w0, X2-X1 );
-    new_delta = xx1 - FT_MulFix( X1, new_scale );
+      new_scale = org_scale + FT_DivFix( w - warper->w0, X2 - X1 );
+      new_delta = xx1 - FT_MulFix( X1, new_scale );
+
+      af_warper_compute_line_best( warper, new_scale, new_delta, xx1, xx2,
+                                   base_distort,
+                                   segments, num_segments );
+    }
 
-    af_warper_compute_line_best( warper, new_scale, new_delta, xx1, xx2,
-                                 base_distort,
-                                 segments, num_segments );
+    *a_scale = warper->best_scale;
+    *a_delta = warper->best_delta;
   }
 
-  *a_scale = warper->best_scale;
-  *a_delta = warper->best_delta;
-}
 
+/* END */
diff --git a/src/autofit/afwarp.h b/src/autofit/afwarp.h
index 86af0b8..6ca1ce7 100644
--- a/src/autofit/afwarp.h
+++ b/src/autofit/afwarp.h
@@ -1,3 +1,21 @@
+/***************************************************************************/
+/*                                                                         */
+/*  afwarp.h                                                               */
+/*                                                                         */
+/*    Auto-fitter warping algorithm (specification).                       */
+/*                                                                         */
+/*  Copyright 2006 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.                                        */
+/*                                                                         */
+/***************************************************************************/
+
+
 #ifndef __AFWARP_H__
 #define __AFWARP_H__
 
@@ -5,36 +23,43 @@
 
 FT_BEGIN_HEADER
 
-#define  AF_WARPER_SCALE
+#define AF_WARPER_SCALE
+
+#define AF_WARPER_FLOOR( x )  ( (x) & ~63 )
+#define AF_WARPER_CEIL( x )   AF_WARPER_FLOOR( (x) + 63 )
+
 
-#define  AF_WARPER_FLOOR(x)  ((x) & ~63)
-#define  AF_WARPER_CEIL(x)   AF_WARPER_FLOOR((x)+63)
+  typedef FT_Int32  AF_WarpScore;
 
-typedef FT_Int32  AF_WarpScore;
+  typedef struct  AF_WarperRec_
+  {
+    FT_Int        X1, X2;
+    FT_Pos        x1, x2;
+    FT_Pos        t1, t2;
+    FT_Pos        x1min, x1max;
+    FT_Pos        x2min, x2max;
+    FT_Pos        w0, wmin, wmax;
 
-typedef struct
-{
-  FT_Int    X1, X2;
-  FT_Pos    x1, x2;
-  FT_Pos    t1, t2;
-  FT_Pos    x1min, x1max;
-  FT_Pos    x2min, x2max;
-  FT_Pos    w0, wmin, wmax;
+    FT_Fixed      best_scale;
+    FT_Pos        best_delta;
+    AF_WarpScore  best_score;
+    AF_WarpScore  best_distort;
 
-  FT_Fixed      best_scale;
-  FT_Pos        best_delta;
-  AF_WarpScore  best_score;
-  AF_WarpScore  best_distort;
+  } AF_WarperRec, *AF_Warper;
 
-} AF_WarperRec, *AF_Warper;
 
-FT_LOCAL( void )
-af_warper_compute( AF_Warper      warper,
-                   AF_GlyphHints  hints,
-                   AF_Dimension   dim,
-                   FT_Fixed      *a_scale,
-                   FT_Fixed      *a_delta );
+  FT_LOCAL( void )
+  af_warper_compute( AF_Warper      warper,
+                     AF_GlyphHints  hints,
+                     AF_Dimension   dim,
+                     FT_Fixed      *a_scale,
+                     FT_Fixed      *a_delta );
+
 
 FT_END_HEADER
 
+
 #endif /* __AFWARP_H__ */
+
+
+/* END */
diff --git a/src/autofit/autofit.c b/src/autofit/autofit.c
index 2526179..d7e8864 100644
--- a/src/autofit/autofit.c
+++ b/src/autofit/autofit.c
@@ -4,7 +4,7 @@
 /*                                                                         */
 /*    Auto-fitter module (body).                                           */
 /*                                                                         */
-/*  Copyright 2003, 2004, 2005 by                                          */
+/*  Copyright 2003, 2004, 2005, 2006 by                                    */
 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
 /*                                                                         */
 /*  This file is part of the FreeType project, and may only be used,       */
diff --git a/src/autofit/rules.mk b/src/autofit/rules.mk
index 7f7ff99..e1bb9e3 100644
--- a/src/autofit/rules.mk
+++ b/src/autofit/rules.mk
@@ -3,7 +3,7 @@
 #
 
 
-# Copyright 2003, 2004, 2005 by
+# Copyright 2003, 2004, 2005, 2006 by
 # David Turner, Robert Wilhelm, and Werner Lemberg.
 #
 # This file is part of the FreeType project, and may only be used, modified,
@@ -31,7 +31,8 @@ AUTOF_DRV_SRC := $(AUTOF_DIR)/afangles.c \
                  $(AUTOF_DIR)/afhints.c  \
                  $(AUTOF_DIR)/aflatin.c  \
                  $(AUTOF_DIR)/afloader.c \
-                 $(AUTOF_DIR)/afmodule.c
+                 $(AUTOF_DIR)/afmodule.c \
+                 $(AUTOF_DIR)/afwarp.c
 
 # AUTOF driver headers
 #