Commit 1f8f46758ed233010f946ba1f5a8c93473082b6d

Werner Lemberg 2003-05-07T10:39:45

* src/cid/cidload.c (is_alpha): Removed. (cid_parse_dict): Use `cid_parser_skip_alpha' instead of `is_alpha'. * src/autohint/ahoptim.c, src/autohint/ahoptim.h: Obsolete, removed.

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
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
diff --git a/ChangeLog b/ChangeLog
index ecfd6ad..908c3ec 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2003-15-07  YAMANO-UCHI Hidetoshi  <mer@din.or.jp>
+
+	* src/cid/cidload.c (is_alpha): Removed.
+	(cid_parse_dict): Use `cid_parser_skip_alpha' instead of `is_alpha'.
+
+2003-05-07  Werner Lemberg  <wl@gnu.org>
+
+	* src/autohint/ahoptim.c, src/autohint/ahoptim.h: Obsolete, removed.
+
 2003-05-07  David Turner  <david@freetype.org>
 
 	* src/autohint/ahglyph.c (ah_setup_uv): Exchange `for' loop and
diff --git a/src/autohint/ahoptim.c b/src/autohint/ahoptim.c
deleted file mode 100644
index 2c2c858..0000000
--- a/src/autohint/ahoptim.c
+++ /dev/null
@@ -1,883 +0,0 @@
-/***************************************************************************/
-/*                                                                         */
-/*  ahoptim.c                                                              */
-/*                                                                         */
-/*    FreeType auto hinting outline optimization (body).                   */
-/*                                                                         */
-/*  Copyright 2000-2001, 2002, 2003 Catharon Productions Inc.              */
-/*  Author: David Turner                                                   */
-/*                                                                         */
-/*  This file is part of the Catharon Typography Project and shall only    */
-/*  be used, modified, and distributed under the terms of the Catharon     */
-/*  Open Source License that should come with this file under the name     */
-/*  `CatharonLicense.txt'.  By continuing to use, modify, or distribute    */
-/*  this file you indicate that you have read the license and              */
-/*  understand and accept it fully.                                        */
-/*                                                                         */
-/*  Note that this license is compatible with the FreeType license.        */
-/*                                                                         */
-/***************************************************************************/
-
-
-  /*************************************************************************/
-  /*                                                                       */
-  /* 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.                 */
-  /*                                                                       */
-  /* The technique used in this module is a simplified simulated           */
-  /* annealing.                                                            */
-  /*                                                                       */
-  /*************************************************************************/
-
-
-#include <ft2build.h>
-#include FT_INTERNAL_OBJECTS_H       /* for FT_ALLOC_ARRAY() and FT_FREE() */
-#include "ahoptim.h"
-
-
-  /* define this macro to use brute force optimization -- this is slow,  */
-  /* but a good way to perfect the distortion function `by hand' through */
-  /* tweaking                                                            */
-#define AH_BRUTE_FORCE
-
-
-#define xxAH_DEBUG_OPTIM
-
-
-#undef AH_OPTIM_LOG
-#ifdef AH_DEBUG_OPTIM
-
-#define AH_OPTIM_LOG( x )  optim_log ## x
-
-#else
-
-#define AH_OPTIM_LOG( x )  do ; while ( 0 ) /* nothing */
-
-#endif /* AH_DEBUG_OPTIM */
-
-
-#ifdef AH_DEBUG_OPTIM
-
-#include <stdarg.h>
-#include <stdlib.h>
-
-#define FLOAT( x )  ( (float)( (x) / 64.0 ) )
-
-
-  static void
-  optim_log( const char*  fmt, ... )
-  {
-    va_list  ap;
-
-
-    va_start( ap, fmt );
-    vprintf( fmt, ap );
-    va_end( ap );
-  }
-
-
-  static void
-  AH_Dump_Stems( AH_Optimizer*  optimizer )
-  {
-    int       n;
-    AH_Stem*  stem;
-
-
-    stem = optimizer->stems;
-    for ( n = 0; n < optimizer->num_stems; n++, stem++ )
-    {
-      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 ) ));
-    }
-  }
-
-
-  static void
-  AH_Dump_Stems2( AH_Optimizer*  optimizer )
-  {
-    int       n;
-    AH_Stem*  stem;
-
-
-    stem = optimizer->stems;
-    for ( n = 0; n < optimizer->num_stems; n++, stem++ )
-    {
-      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 ) ));
-    }
-  }
-
-
-  static void
-  AH_Dump_Springs( AH_Optimizer*  optimizer )
-  {
-    int  n;
-    AH_Spring*  spring;
-    AH_Stem*    stems;
-
-
-    spring = optimizer->springs;
-    stems  = optimizer->stems;
-    AH_OPTIM_LOG(( "%cSprings ", optimizer->vertical ? 'V' : 'H' ));
-
-    for ( n = 0; n < optimizer->num_springs; n++, spring++ )
-    {
-      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 ) ));
-    }
-
-    AH_OPTIM_LOG(( "\n" ));
-  }
-
-#endif /* AH_DEBUG_OPTIM */
-
-
-  /*************************************************************************/
-  /*************************************************************************/
-  /*************************************************************************/
-  /****                                                                 ****/
-  /****   COMPUTE STEMS AND SPRINGS IN AN OUTLINE                       ****/
-  /****                                                                 ****/
-  /*************************************************************************/
-  /*************************************************************************/
-  /*************************************************************************/
-
-
-  static int
-  valid_stem_segments( AH_Segment  seg1,
-                       AH_Segment  seg2 )
-  {
-    return seg1->serif == 0                   &&
-           seg2                               &&
-           seg2->link == seg1                 &&
-           seg1->pos < seg2->pos              &&
-           seg1->min_coord <= seg2->max_coord &&
-           seg2->min_coord <= seg1->max_coord;
-  }
-
-
-  /* compute all stems in an outline */
-  static int
-  optim_compute_stems( AH_Optimizer*  optimizer )
-  {
-    AH_Outline  outline = optimizer->outline;
-    FT_Fixed    scale;
-    FT_Memory   memory  = optimizer->memory;
-    FT_Error    error   = 0;
-    FT_Int      dimension;
-    AH_Edge     edges;
-    AH_Edge     edge_limit;
-    AH_Stem**   p_stems;
-    FT_Int*     p_num_stems;
-
-
-    edges      = outline->horz_edges;
-    edge_limit = edges + outline->num_hedges;
-    scale      = outline->y_scale;
-
-    p_stems     = &optimizer->horz_stems;
-    p_num_stems = &optimizer->num_hstems;
-
-    for ( dimension = 1; dimension >= 0; dimension-- )
-    {
-      AH_Stem*  stems     = 0;
-      FT_Int    num_stems = 0;
-      AH_Edge   edge;
-
-
-      /* first of all, count the number of stems in this direction */
-      for ( edge = edges; edge < edge_limit; edge++ )
-      {
-        AH_Segment  seg = edge->first;
-
-
-        do
-        {
-          if (valid_stem_segments( seg, seg->link ) )
-            num_stems++;
-
-          seg = seg->edge_next;
-
-        } while ( seg != edge->first );
-      }
-
-      /* now allocate the stems and build their table */
-      if ( num_stems > 0 )
-      {
-        AH_Stem*  stem;
-
-
-        if ( FT_NEW_ARRAY( stems, num_stems ) )
-          goto Exit;
-
-        stem = stems;
-        for ( edge = edges; edge < edge_limit; edge++ )
-        {
-          AH_Segment  seg = edge->first;
-          AH_Segment  seg2;
-
-
-          do
-          {
-            seg2 = seg->link;
-            if ( valid_stem_segments( seg, seg2 ) )
-            {
-              AH_Edge  edge1 = seg->edge;
-              AH_Edge  edge2 = seg2->edge;
-
-
-              stem->edge1  = edge1;
-              stem->edge2  = edge2;
-              stem->opos   = edge1->opos;
-              stem->pos    = edge1->pos;
-              stem->owidth = edge2->opos - edge1->opos;
-              stem->width  = edge2->pos  - edge1->pos;
-
-              /* compute min_coord and max_coord */
-              {
-                FT_Pos  min_coord = seg->min_coord;
-                FT_Pos  max_coord = seg->max_coord;
-
-
-                if ( seg2->min_coord > min_coord )
-                  min_coord = seg2->min_coord;
-
-                if ( seg2->max_coord < max_coord )
-                  max_coord = seg2->max_coord;
-
-                stem->min_coord = min_coord;
-                stem->max_coord = max_coord;
-              }
-
-              /* compute minimum and maximum positions for stem --   */
-              /* note that the left-most/bottom-most stem has always */
-              /* a fixed position                                    */
-              if ( stem == stems || edge1->blue_edge || edge2->blue_edge )
-              {
-                /* this stem cannot move; it is snapped to a blue edge */
-                stem->min_pos = stem->pos;
-                stem->max_pos = stem->pos;
-              }
-              else
-              {
-                /* this edge can move; compute its min and max positions */
-                FT_Pos  pos1 = stem->opos;
-                FT_Pos  pos2 = pos1 + stem->owidth - stem->width;
-                FT_Pos  min1 = pos1 & -64;
-                FT_Pos  min2 = pos2 & -64;
-
-
-                stem->min_pos = min1;
-                stem->max_pos = min1 + 64;
-                if ( min2 < min1 )
-                  stem->min_pos = min2;
-                else
-                  stem->max_pos = min2 + 64;
-
-                /* XXX: just to see what it does */
-                stem->max_pos += 64;
-
-                /* just for the case where direct hinting did some */
-                /* incredible things (e.g. blue edge shifts)       */
-                if ( stem->min_pos > stem->pos )
-                  stem->min_pos = stem->pos;
-
-                if ( stem->max_pos < stem->pos )
-                  stem->max_pos = stem->pos;
-              }
-
-              stem->velocity = 0;
-              stem->force    = 0;
-
-              stem++;
-            }
-            seg = seg->edge_next;
-
-          } while ( seg != edge->first );
-        }
-      }
-
-      *p_stems     = stems;
-      *p_num_stems = num_stems;
-
-      edges      = outline->vert_edges;
-      edge_limit = edges + outline->num_vedges;
-      scale      = outline->x_scale;
-
-      p_stems     = &optimizer->vert_stems;
-      p_num_stems = &optimizer->num_vstems;
-    }
-
-  Exit:
-
-#ifdef AH_DEBUG_OPTIM
-    AH_Dump_Stems( optimizer );
-#endif
-
-    return error;
-  }
-
-
-  /* returns the spring area between two stems, 0 if none */
-  static FT_Pos
-  stem_spring_area( AH_Stem*  stem1,
-                    AH_Stem*  stem2 )
-  {
-    FT_Pos  area1 = stem1->max_coord - stem1->min_coord;
-    FT_Pos  area2 = stem2->max_coord - stem2->min_coord;
-    FT_Pos  min   = stem1->min_coord;
-    FT_Pos  max   = stem1->max_coord;
-    FT_Pos  area;
-
-
-    /* order stems */
-    if ( stem2->opos <= stem1->opos + stem1->owidth )
-      return 0;
-
-    if ( min < stem2->min_coord )
-      min = stem2->min_coord;
-
-    if ( max < stem2->max_coord )
-      max = stem2->max_coord;
-
-    area = ( max-min );
-    if ( 2 * area < area1 && 2 * area < area2 )
-      area = 0;
-
-    return area;
-  }
-
-
-  /* compute all springs in an outline */
-  static int
-  optim_compute_springs( AH_Optimizer*  optimizer )
-  {
-    /* basically, a spring exists between two stems if most of their */
-    /* surface is aligned                                            */
-    FT_Memory    memory  = optimizer->memory;
-
-    AH_Stem*     stems;
-    AH_Stem*     stem_limit;
-    AH_Stem*     stem;
-    int          dimension;
-    int          error = 0;
-
-    FT_Int*      p_num_springs;
-    AH_Spring**  p_springs;
-
-
-    stems      = optimizer->horz_stems;
-    stem_limit = stems + optimizer->num_hstems;
-
-    p_springs     = &optimizer->horz_springs;
-    p_num_springs = &optimizer->num_hsprings;
-
-    for ( dimension = 1; dimension >= 0; dimension-- )
-    {
-      FT_Int      num_springs = 0;
-      AH_Spring*  springs     = 0;
-
-
-      /* first of all, count stem springs */
-      for ( stem = stems; stem + 1 < stem_limit; stem++ )
-      {
-        AH_Stem*  stem2;
-
-
-        for ( stem2 = stem+1; stem2 < stem_limit; stem2++ )
-          if ( stem_spring_area( stem, stem2 ) )
-            num_springs++;
-      }
-
-      /* then allocate and build the springs table */
-      if ( num_springs > 0 )
-      {
-        AH_Spring*  spring;
-
-
-        /* allocate table of springs */
-        if ( FT_NEW_ARRAY( springs, num_springs ) )
-          goto Exit;
-
-        /* fill the springs table */
-        spring = springs;
-        for ( stem = stems; stem+1 < stem_limit; stem++ )
-        {
-          AH_Stem*  stem2;
-          FT_Pos    area;
-
-
-          for ( stem2 = stem + 1; stem2 < stem_limit; stem2++ )
-          {
-            area = stem_spring_area( stem, stem2 );
-            if ( area )
-            {
-              /* add a new spring here */
-              spring->stem1   = stem;
-              spring->stem2   = stem2;
-              spring->owidth  = stem2->opos - ( stem->opos + stem->owidth );
-              spring->tension = 0;
-
-              spring++;
-            }
-          }
-        }
-      }
-      *p_num_springs = num_springs;
-      *p_springs     = springs;
-
-      stems      = optimizer->vert_stems;
-      stem_limit = stems + optimizer->num_vstems;
-
-      p_springs     = &optimizer->vert_springs;
-      p_num_springs = &optimizer->num_vsprings;
-    }
-
-  Exit:
-
-#ifdef AH_DEBUG_OPTIM
-    AH_Dump_Springs( optimizer );
-#endif
-
-    return error;
-  }
-
-
-  /*************************************************************************/
-  /*************************************************************************/
-  /*************************************************************************/
-  /****                                                                 ****/
-  /****   OPTIMIZE THROUGH MY STRANGE SIMULATED ANNEALING ALGO ;-)      ****/
-  /****                                                                 ****/
-  /*************************************************************************/
-  /*************************************************************************/
-  /*************************************************************************/
-
-#ifndef AH_BRUTE_FORCE
-
-  /* compute all spring tensions */
-  static void
-  optim_compute_tensions( AH_Optimizer*  optimizer )
-  {
-    AH_Spring*  spring = optimizer->springs;
-    AH_Spring*  limit  = spring + optimizer->num_springs;
-
-
-    for ( ; spring < limit; spring++ )
-    {
-      AH_Stem*  stem1 = spring->stem1;
-      AH_Stem*  stem2 = spring->stem2;
-      FT_Int    status;
-
-      FT_Pos  width;
-      FT_Pos  tension;
-      FT_Pos  sign;
-
-
-      /* compute the tension; it simply is -K*(new_width-old_width) */
-      width   = stem2->pos - ( stem1->pos + stem1->width );
-      tension = width - spring->owidth;
-
-      sign = 1;
-      if ( tension < 0 )
-      {
-        sign    = -1;
-        tension = -tension;
-      }
-
-      if ( width <= 0 )
-        tension = 32000;
-      else
-        tension = ( tension << 10 ) / width;
-
-      tension = -sign * FT_MulFix( tension, optimizer->tension_scale );
-      spring->tension = tension;
-
-      /* now, distribute tension among the englobing stems, if they */
-      /* are able to move                                           */
-      status = 0;
-      if ( stem1->pos <= stem1->min_pos )
-        status |= 1;
-      if ( stem2->pos >= stem2->max_pos )
-        status |= 2;
-
-      if ( !status )
-        tension /= 2;
-
-      if ( ( status & 1 ) == 0 )
-        stem1->force -= tension;
-
-      if ( ( status & 2 ) == 0 )
-        stem2->force += tension;
-    }
-  }
-
-
-  /* compute all stem movements -- returns 0 if nothing moved */
-  static int
-  optim_compute_stem_movements( AH_Optimizer*  optimizer )
-  {
-    AH_Stem*  stems = optimizer->stems;
-    AH_Stem*  limit = stems + optimizer->num_stems;
-    AH_Stem*  stem  = stems;
-    int       moved = 0;
-
-
-    /* set initial forces to velocity */
-    for ( stem = stems; stem < limit; stem++ )
-    {
-      stem->force     = stem->velocity;
-      stem->velocity /= 2;                  /* XXX: Heuristics */
-    }
-
-    /* compute the sum of forces applied on each stem */
-    optim_compute_tensions( optimizer );
-
-#ifdef AH_DEBUG_OPTIM
-    AH_Dump_Springs( optimizer );
-    AH_Dump_Stems2( optimizer );
-#endif
-
-    /* now, see whether something can move */
-    for ( stem = stems; stem < limit; stem++ )
-    {
-      if ( stem->force > optimizer->tension_threshold )
-      {
-        /* there is enough tension to move the stem to the right */
-        if ( stem->pos < stem->max_pos )
-        {
-          stem->pos     += 64;
-          stem->velocity = stem->force / 2;
-          moved          = 1;
-        }
-        else
-          stem->velocity = 0;
-      }
-      else if ( stem->force < optimizer->tension_threshold )
-      {
-        /* there is enough tension to move the stem to the left */
-        if ( stem->pos > stem->min_pos )
-        {
-          stem->pos     -= 64;
-          stem->velocity = stem->force / 2;
-          moved          = 1;
-        }
-        else
-          stem->velocity = 0;
-      }
-    }
-
-    /* return 0 if nothing moved */
-    return moved;
-  }
-
-#endif /* AH_BRUTE_FORCE */
-
-
-  /* compute current global distortion from springs */
-  static FT_Pos
-  optim_compute_distortion( AH_Optimizer*  optimizer )
-  {
-    AH_Spring*  spring = optimizer->springs;
-    AH_Spring*  limit  = spring + optimizer->num_springs;
-    FT_Pos      distortion = 0;
-
-
-    for ( ; spring < limit; spring++ )
-    {
-      AH_Stem*  stem1 = spring->stem1;
-      AH_Stem*  stem2 = spring->stem2;
-      FT_Pos    width;
-
-
-      width  = stem2->pos - ( stem1->pos + stem1->width );
-      width -= spring->owidth;
-      if ( width < 0 )
-        width = -width;
-
-      distortion += width;
-    }
-
-    return distortion;
-  }
-
-
-  /* record stems configuration in `best of' history */
-  static void
-  optim_record_configuration( AH_Optimizer*  optimizer )
-  {
-    FT_Pos             distortion;
-    AH_Configuration*  configs = optimizer->configs;
-    AH_Configuration*  limit   = configs + optimizer->num_configs;
-    AH_Configuration*  config;
-
-
-    distortion = optim_compute_distortion( optimizer );
-    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 )
-    {
-      AH_OPTIM_LOG(( "ejected\n" ));
-      return;
-    }
-
-    /* add new configuration at the end of the table */
-    {
-      int  n;
-
-
-      config = limit;
-      if ( optimizer->num_configs < AH_MAX_CONFIGS )
-        optimizer->num_configs++;
-      else
-        config--;
-
-      config->distortion = distortion;
-
-      for ( n = 0; n < optimizer->num_stems; n++ )
-        config->positions[n] = optimizer->stems[n].pos;
-    }
-
-    /* move the current configuration towards the front of the list */
-    /* when necessary -- yes this is slow bubble sort ;-)           */
-    while ( config > configs && config[0].distortion < config[-1].distortion )
-    {
-      AH_Configuration  temp;
-
-
-      config--;
-      temp      = config[0];
-      config[0] = config[1];
-      config[1] = temp;
-    }
-    AH_OPTIM_LOG(( "recorded!\n" ));
-  }
-
-
-#ifdef AH_BRUTE_FORCE
-
-  /* optimize outline in a single direction */
-  static void
-  optim_compute( AH_Optimizer*  optimizer )
-  {
-    int       n;
-    FT_Bool   moved;
-
-    AH_Stem*  stem  = optimizer->stems;
-    AH_Stem*  limit = stem + optimizer->num_stems;
-
-
-    /* empty, exit */
-    if ( stem >= limit )
-      return;
-
-    optimizer->num_configs = 0;
-
-    stem = optimizer->stems;
-    for ( ; stem < limit; stem++ )
-      stem->pos = stem->min_pos;
-
-    do
-    {
-      /* record current configuration */
-      optim_record_configuration( optimizer );
-
-      /* now change configuration */
-      moved = 0;
-      for ( stem = optimizer->stems; stem < limit; stem++ )
-      {
-        if ( stem->pos < stem->max_pos )
-        {
-          stem->pos += 64;
-          moved      = 1;
-          break;
-        }
-
-        stem->pos = stem->min_pos;
-      }
-    } while ( moved );
-
-    /* now, set the best stem positions */
-    for ( n = 0; n < optimizer->num_stems; n++ )
-    {
-      AH_Stem*  stem = optimizer->stems + n;
-      FT_Pos    pos  = optimizer->configs[0].positions[n];
-
-
-      stem->edge1->pos = pos;
-      stem->edge2->pos = pos + stem->width;
-
-      stem->edge1->flags |= AH_EDGE_DONE;
-      stem->edge2->flags |= AH_EDGE_DONE;
-    }
-  }
-
-#else /* AH_BRUTE_FORCE */
-
-  /* optimize outline in a single direction */
-  static void
-  optim_compute( AH_Optimizer*  optimizer )
-  {
-    int  n, counter, counter2;
-
-
-    optimizer->num_configs       = 0;
-    optimizer->tension_scale     = 0x80000L;
-    optimizer->tension_threshold = 64;
-
-    /* record initial configuration threshold */
-    optim_record_configuration( optimizer );
-
-    counter = 0;
-    for ( counter2 = optimizer->num_stems*8; counter2 >= 0; counter2-- )
-    {
-      if ( counter == 0 )
-        counter = 2 * optimizer->num_stems;
-
-      if ( !optim_compute_stem_movements( optimizer ) )
-        break;
-
-      optim_record_configuration( optimizer );
-
-      counter--;
-      if ( counter == 0 )
-        optimizer->tension_scale /= 2;
-    }
-
-    /* now, set the best stem positions */
-    for ( n = 0; n < optimizer->num_stems; n++ )
-    {
-      AH_Stem*  stem = optimizer->stems + n;
-      FT_Pos    pos  = optimizer->configs[0].positions[n];
-
-
-      stem->edge1->pos = pos;
-      stem->edge2->pos = pos + stem->width;
-
-      stem->edge1->flags |= AH_EDGE_DONE;
-      stem->edge2->flags |= AH_EDGE_DONE;
-    }
-  }
-
-#endif /* AH_BRUTE_FORCE */
-
-
-  /*************************************************************************/
-  /*************************************************************************/
-  /*************************************************************************/
-  /****                                                                 ****/
-  /****   HIGH-LEVEL OPTIMIZER API                                      ****/
-  /****                                                                 ****/
-  /*************************************************************************/
-  /*************************************************************************/
-  /*************************************************************************/
-
-
-  /* releases the optimization data */
-  void
-  AH_Optimizer_Done( AH_Optimizer*  optimizer )
-  {
-    if ( optimizer )
-    {
-      FT_Memory  memory = optimizer->memory;
-
-
-      FT_FREE( optimizer->horz_stems );
-      FT_FREE( optimizer->vert_stems );
-      FT_FREE( optimizer->horz_springs );
-      FT_FREE( optimizer->vert_springs );
-      FT_FREE( optimizer->positions );
-    }
-  }
-
-
-  /* loads the outline into the optimizer */
-  int
-  AH_Optimizer_Init( AH_Optimizer*  optimizer,
-                     AH_Outline     outline,
-                     FT_Memory      memory )
-  {
-    FT_Error  error;
-
-
-    FT_MEM_ZERO( optimizer, sizeof ( *optimizer ) );
-    optimizer->outline = outline;
-    optimizer->memory  = memory;
-
-    AH_OPTIM_LOG(( "initializing new optimizer\n" ));
-    /* compute stems and springs */
-    error = optim_compute_stems  ( optimizer ) ||
-            optim_compute_springs( optimizer );
-    if ( error )
-      goto Fail;
-
-    /* allocate stem positions history and configurations */
-    {
-      int  n, max_stems;
-
-
-      max_stems = optimizer->num_hstems;
-      if ( max_stems < optimizer->num_vstems )
-        max_stems = optimizer->num_vstems;
-
-      if ( FT_NEW_ARRAY( optimizer->positions, max_stems * AH_MAX_CONFIGS ) )
-        goto Fail;
-
-      optimizer->num_configs = 0;
-      for ( n = 0; n < AH_MAX_CONFIGS; n++ )
-        optimizer->configs[n].positions = optimizer->positions +
-                                          n * max_stems;
-    }
-
-    return error;
-
-  Fail:
-    AH_Optimizer_Done( optimizer );
-    return error;
-  }
-
-
-  /* compute optimal outline */
-  void
-  AH_Optimizer_Compute( AH_Optimizer*  optimizer )
-  {
-    optimizer->num_stems   = optimizer->num_hstems;
-    optimizer->stems       = optimizer->horz_stems;
-    optimizer->num_springs = optimizer->num_hsprings;
-    optimizer->springs     = optimizer->horz_springs;
-
-    if ( optimizer->num_springs > 0 )
-    {
-      AH_OPTIM_LOG(( "horizontal optimization ------------------------\n" ));
-      optim_compute( optimizer );
-    }
-
-    optimizer->num_stems   = optimizer->num_vstems;
-    optimizer->stems       = optimizer->vert_stems;
-    optimizer->num_springs = optimizer->num_vsprings;
-    optimizer->springs     = optimizer->vert_springs;
-
-    if ( optimizer->num_springs )
-    {
-      AH_OPTIM_LOG(( "vertical optimization --------------------------\n" ));
-      optim_compute( optimizer );
-    }
-  }
-
-
-/* END */
diff --git a/src/autohint/ahoptim.h b/src/autohint/ahoptim.h
deleted file mode 100644
index d7862ba..0000000
--- a/src/autohint/ahoptim.h
+++ /dev/null
@@ -1,137 +0,0 @@
-/***************************************************************************/
-/*                                                                         */
-/*  ahoptim.h                                                              */
-/*                                                                         */
-/*    FreeType auto hinting outline optimization (declaration).            */
-/*                                                                         */
-/*  Copyright 2000-2001 Catharon Productions Inc.                          */
-/*  Author: David Turner                                                   */
-/*                                                                         */
-/*  This file is part of the Catharon Typography Project and shall only    */
-/*  be used, modified, and distributed under the terms of the Catharon     */
-/*  Open Source License that should come with this file under the name     */
-/*  `CatharonLicense.txt'.  By continuing to use, modify, or distribute    */
-/*  this file you indicate that you have read the license and              */
-/*  understand and accept it fully.                                        */
-/*                                                                         */
-/*  Note that this license is compatible with the FreeType license.        */
-/*                                                                         */
-/***************************************************************************/
-
-
-#ifndef __AHOPTIM_H__
-#define __AHOPTIM_H__
-
-
-#include <ft2build.h>
-#include "ahtypes.h"
-
-
-FT_BEGIN_HEADER
-
-
-  /* the maximal number of stem configurations to record */
-  /* during optimization                                 */
-#define AH_MAX_CONFIGS  8
-
-
-  typedef struct  AH_Stem_
-  {
-    FT_Pos   pos;       /* current position        */
-    FT_Pos   velocity;  /* current velocity        */
-    FT_Pos   force;     /* sum of current forces   */
-    FT_Pos   width;     /* normalized width        */
-
-    FT_Pos   min_pos;   /* minimum grid position */
-    FT_Pos   max_pos;   /* maximum grid position */
-
-    AH_Edge  edge1;     /* left/bottom edge */
-    AH_Edge  edge2;     /* right/top edge   */
-
-    FT_Pos   opos;      /* original position */
-    FT_Pos   owidth;    /* original width    */
-
-    FT_Pos   min_coord; /* minimum coordinate */
-    FT_Pos   max_coord; /* maximum coordinate */
-
-  } AH_Stem;
-
-
-  /* A spring between two stems */
-  typedef struct  AH_Spring_
-  {
-    AH_Stem*  stem1;
-    AH_Stem*  stem2;
-    FT_Pos    owidth;   /* original width  */
-    FT_Pos    tension;  /* current tension */
-
-  } AH_Spring;
-
-
-  /* A configuration records the position of each stem at a given time  */
-  /* as well as the associated distortion                               */
-  typedef struct AH_Configuration_
-  {
-    FT_Pos*  positions;
-    FT_Long  distortion;
-
-  } AH_Configuration;
-
-
-  typedef struct  AH_Optimizer_
-  {
-    FT_Memory         memory;
-    AH_Outline        outline;
-
-    FT_Int            num_hstems;
-    AH_Stem*          horz_stems;
-
-    FT_Int            num_vstems;
-    AH_Stem*          vert_stems;
-
-    FT_Int            num_hsprings;
-    FT_Int            num_vsprings;
-    AH_Spring*        horz_springs;
-    AH_Spring*        vert_springs;
-
-    FT_Int            num_configs;
-    AH_Configuration  configs[AH_MAX_CONFIGS];
-    FT_Pos*           positions;
-
-    /* during each pass, use these instead */
-    FT_Int            num_stems;
-    AH_Stem*          stems;
-
-    FT_Int            num_springs;
-    AH_Spring*        springs;
-    FT_Bool           vertical;
-
-    FT_Fixed          tension_scale;
-    FT_Pos            tension_threshold;
-
-  } AH_Optimizer;
-
-
-  /* loads the outline into the optimizer */
-  int
-  AH_Optimizer_Init( AH_Optimizer*  optimizer,
-                     AH_Outline     outline,
-                     FT_Memory      memory );
-
-
-  /* compute optimal outline */
-  void
-  AH_Optimizer_Compute( AH_Optimizer*  optimizer );
-
-
-  /* release the optimization data */
-  void
-  AH_Optimizer_Done( AH_Optimizer*  optimizer );
-
-
-FT_END_HEADER
-
-#endif /* __AHOPTIM_H__ */
-
-
-/* END */
diff --git a/src/cid/cidload.c b/src/cid/cidload.c
index 19cfab5..866b2f0 100644
--- a/src/cid/cidload.c
+++ b/src/cid/cidload.c
@@ -4,7 +4,7 @@
 /*                                                                         */
 /*    CID-keyed Type1 font loader (body).                                  */
 /*                                                                         */
-/*  Copyright 1996-2001, 2002 by                                           */
+/*  Copyright 1996-2001, 2002, 2003 by                                     */
 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
 /*                                                                         */
 /*  This file is part of the FreeType project, and may only be used,       */
@@ -279,15 +279,6 @@
   };
 
 
-  static int
-  is_alpha( char  c )
-  {
-    return ( ft_isalnum( (int)c ) ||
-             c == '.'             ||
-             c == '_'             );
-  }
-
-
   static FT_Error
   cid_parse_dict( CID_Face     face,
                   CID_Loader*  loader,
@@ -322,17 +313,15 @@
         /* look for immediates */
         else if ( *cur == '/' && cur + 2 < limit )
         {
-          FT_Byte*  cur2;
-          FT_Int    len;
+          FT_Int  len;
 
 
           cur++;
 
-          cur2 = cur;
-          while ( cur2 < limit && is_alpha( *cur2 ) )
-            cur2++;
+          parser->root.cursor = cur;
+          cid_parser_skip_alpha( parser );
 
-          len = (FT_Int)( cur2 - cur );
+          len = (FT_Int)( parser->root.cursor - cur );
           if ( len > 0 && len < 22 )
           {
             /* now compare the immediate name to the keyword table */
@@ -361,7 +350,6 @@
                 if ( n >= len )
                 {
                   /* we found it - run the parsing callback */
-                  parser->root.cursor = cur2;
                   cid_parser_skip_spaces( parser );
                   parser->root.error = cid_load_keyword( face,
                                                          loader,