Commit 27c322e9835b8fec7e5f65a012f56e1c64fc9879

David Turner 2002-07-08T22:26:11

* include/freetype/freetype.h, src/base/ftobjs.h, freetype/internal/ftobjs.h, freetype/internal/psaux.h, freetype/internal/pshints.h, src/psaux/t1decode.c, src/cff/cffgload.h, src/cff/cffgload.c, src/pshinter/pshalgo1.h, src/pshinter/pshalgo1.c, src/pshinter/pshalgo2.h, src/pshinter/pshalgo2.c, src/pshinter/pshalgo3.h, src/pshinter/pshalgo3.c: Adding support for hinter-specific bit flags, and the new FT_Set_Hint_Flags high-level API

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
diff --git a/ChangeLog b/ChangeLog
index cefe642..0be5f22 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2002-07-07  Owen Taylor  <owen@redhat.com>
+
+    * include/freetype/freetype.h, src/base/ftobjs.h,
+    freetype/internal/ftobjs.h, freetype/internal/psaux.h,
+    freetype/internal/pshints.h, src/psaux/t1decode.c, src/cff/cffgload.h,
+    src/cff/cffgload.c, src/pshinter/pshalgo1.h, src/pshinter/pshalgo1.c,
+    src/pshinter/pshalgo2.h, src/pshinter/pshalgo2.c, src/pshinter/pshalgo3.h,
+    src/pshinter/pshalgo3.c: Adding support for hinter-specific bit flags,
+    and the new FT_Set_Hint_Flags high-level API
+
 2002-07-04  David Turner  <david@freetype.org>
 
     * src/pfr/pfrobjs.c (pfr_slot_load): fixed a small bug that returned
@@ -5,7 +15,7 @@
     metrics resolution
 
     * src/autohint/ahhint.c: removing compiler warnings
-    
+
     * src/autohint/ahglyph.c: slight improvements to the serif detection
     code. More work is needed though..
 
diff --git a/include/freetype/freetype.h b/include/freetype/freetype.h
index 57c0fcb..18659db 100644
--- a/include/freetype/freetype.h
+++ b/include/freetype/freetype.h
@@ -2775,6 +2775,65 @@ FT_BEGIN_HEADER
                        FT_Matrix*  matrix );
 
 
+
+  /*@***********************************************************************/
+  /*                                                                       */
+  /* <Function>                                                            */
+  /*    FT_Set_Hint_Flags                                                  */
+  /*                                                                       */
+  /* <Description>                                                         */
+  /*    A function used to set a number of flags that are used to control  */
+  /*    the hinting process when glyphs are loaded.                        */
+  /*                                                                       */
+  /* <InOut>                                                               */
+  /*    face   :: A handle to the source face object.                      */
+  /*                                                                       */
+  /* <Input>                                                               */
+  /*    flags  :: A set of bit flags that control the hinting process      */
+  /*              see the FT_HINT_XXX constants for details.               */
+  /*                                                                       */
+  /* <Note>                                                                */
+  /*    The interpretation of the flags depends on the hinter module in    */
+  /*    use. Not all modules will support all flags                        */
+  /*                                                                       */
+  FT_EXPORT( void )
+  FT_Set_Hint_Flags( FT_Face     face,
+                     FT_ULong    hint_flags );
+
+
+  /*@***********************************************************************/
+  /*                                                                       */
+  /* <Constant>                                                            */
+  /*    FT_HINT_NO_INTEGER_STEM                                            */
+  /*                                                                       */
+  /* <Description>                                                         */
+  /*    A bit-field constant, used with FT_Set_Hint_Flags() to to suppress */
+  /*    snapping of stem widths to integer values                          */
+  /*                                                                       */
+#define FT_HINT_NO_INTEGER_STEM 1
+
+  /*@***********************************************************************/
+  /*                                                                       */
+  /* <Constant>                                                            */
+  /*    FT_HINT_NO_HSTEM_ALIGN                                             */
+  /*                                                                       */
+  /* <Description>                                                         */
+  /*    A bit-field constant, used with FT_Set_Hint_Flags() to to suppress */
+  /*    alignment of horizontal stems with the pixel grid.                 */
+  /*                                                                       */
+#define FT_HINT_NO_HSTEM_ALIGN 2
+
+  /*@***********************************************************************/
+  /*                                                                       */
+  /* <Constant>                                                            */
+  /*    FT_HINT_NO_VSTEM_ALIGN                                             */
+  /*                                                                       */
+  /* <Description>                                                         */
+  /*    A bit-field constant, used with FT_Set_Hint_Flags() to to suppress */
+  /*    alignment of vertical stems with the pixel grid                    */
+  /*                                                                       */
+#define FT_HINT_NO_VSTEM_ALIGN 4
+
   /* */
 
 FT_END_HEADER
diff --git a/include/freetype/internal/ftobjs.h b/include/freetype/internal/ftobjs.h
index f92115c..015349a 100644
--- a/include/freetype/internal/ftobjs.h
+++ b/include/freetype/internal/ftobjs.h
@@ -291,6 +291,9 @@ FT_BEGIN_HEADER
   /*    transform_flags  :: Some flags used to classify the transform.     */
   /*                        Only used by the convenience functions.        */
   /*                                                                       */
+  /*    hint_flags       :: Some flags used to change the hinters'         */
+  /*                        behaviour. Only used for debugging for now     */
+  /*                                                                       */
   /*    postscript_name  :: Postscript font name for this face.            */
   /*                                                                       */
   typedef struct  FT_Face_InternalRec_
@@ -302,6 +305,8 @@ FT_BEGIN_HEADER
     FT_Vector    transform_delta;
     FT_Int       transform_flags;
 
+    FT_UInt32    hint_flags;
+
     const char*  postscript_name;
 
   } FT_Face_InternalRec;
diff --git a/include/freetype/internal/psaux.h b/include/freetype/internal/psaux.h
index a2cf527..2f1557d 100644
--- a/include/freetype/internal/psaux.h
+++ b/include/freetype/internal/psaux.h
@@ -142,10 +142,10 @@ FT_BEGIN_HEADER
   typedef struct PS_ParserRec_*  PS_Parser;
 
   typedef struct T1_TokenRec_*   T1_Token;
-  
+
   typedef struct T1_FieldRec_*   T1_Field;
 
-  
+
   /* simple enumeration type used to identify token types */
   typedef enum  T1_TokenType_
   {
@@ -388,7 +388,7 @@ FT_BEGIN_HEADER
     FT_Memory  memory;
 
     PS_Parser_FuncsRec  funcs;
-    
+
   } PS_ParserRec;
 
 
@@ -544,7 +544,7 @@ FT_BEGIN_HEADER
     void*           hints_globals;  /* hinter-specific */
 
     T1_Builder_FuncsRec  funcs;
-    
+
   } T1_BuilderRec;
 
 
@@ -613,7 +613,7 @@ FT_BEGIN_HEADER
     (*parse_charstrings)( T1_Decoder  decoder,
                           FT_Byte*    base,
                           FT_UInt     len );
-                          
+
   } T1_Decoder_FuncsRec;
 
 
@@ -645,9 +645,11 @@ FT_BEGIN_HEADER
 
     PS_Blend             blend;       /* for multiple master support */
 
+    FT_UInt32            hint_flags;
+
     T1_Decoder_Callback  parse_callback;
     T1_Decoder_FuncsRec  funcs;
-    
+
   } T1_DecoderRec;
 
 
@@ -667,9 +669,9 @@ FT_BEGIN_HEADER
     FT_CMap_Class  expert;
     FT_CMap_Class  custom;
     FT_CMap_Class  unicode;
-  
+
   } T1_CMap_ClassesRec;
-  
+
 
   /*************************************************************************/
   /*************************************************************************/
diff --git a/include/freetype/internal/pshints.h b/include/freetype/internal/pshints.h
index 9b85065..e7fd76f 100644
--- a/include/freetype/internal/pshints.h
+++ b/include/freetype/internal/pshints.h
@@ -267,6 +267,8 @@ FT_BEGIN_HEADER
   /*                                                                       */
   /*   globals :: The hinter globals for this font.                        */
   /*                                                                       */
+  /*   hint_flags :: hinter bit flags                                      */
+  /*                                                                       */
   /* @return:                                                              */
   /*   FreeType error code.  0 means success.                              */
   /*                                                                       */
@@ -280,7 +282,8 @@ FT_BEGIN_HEADER
   typedef FT_Error
   (*T1_Hints_ApplyFunc)( T1_Hints     hints,
                          FT_Outline*  outline,
-                         PSH_Globals  globals );
+                         PSH_Globals  globals,
+                         FT_UInt32    hint_flags );
 
 
   /*************************************************************************/
@@ -545,6 +548,8 @@ FT_BEGIN_HEADER
   /*                                                                       */
   /*    globals :: The hinter globals for this font.                       */
   /*                                                                       */
+  /*    hint_flags :: hinter bit flags                                     */
+  /*                                                                       */
   /* @return:                                                              */
   /*   FreeType error code.  0 means success.                              */
   /*                                                                       */
@@ -558,7 +563,8 @@ FT_BEGIN_HEADER
   typedef FT_Error
   (*T2_Hints_ApplyFunc)( T2_Hints     hints,
                          FT_Outline*  outline,
-                         PSH_Globals  globals );
+                         PSH_Globals  globals,
+                         FT_UInt32    hint_flags );
 
 
   /*************************************************************************/
diff --git a/src/base/ftobjs.c b/src/base/ftobjs.c
index 0fce50c..c37072d 100644
--- a/src/base/ftobjs.c
+++ b/src/base/ftobjs.c
@@ -380,6 +380,23 @@
   }
 
 
+  /* documentation is in freetype.h */
+
+  FT_EXPORT_DEF( void )
+  FT_Set_Hint_Flags( FT_Face     face,
+                     FT_ULong    flags )
+  {
+    FT_Face_Internal  internal;
+
+    if ( !face )
+      return;
+
+    internal = face->internal;
+
+    internal->hint_flags = (FT_UInt)flags;
+  }
+
+
   static FT_Renderer
   ft_lookup_glyph_renderer( FT_GlyphSlot  slot );
 
diff --git a/src/cff/cffgload.c b/src/cff/cffgload.c
index 07a137c..519346d 100644
--- a/src/cff/cffgload.c
+++ b/src/cff/cffgload.c
@@ -246,6 +246,7 @@
       builder->current = &loader->current.outline;
       FT_GlyphLoader_Rewind( loader );
 
+      builder->hint_flags    = FT_FACE(face)->internal->hint_flags;
       builder->hints_globals = 0;
       builder->hints_funcs   = 0;
 
@@ -1676,7 +1677,8 @@
             /* apply hints to the loaded glyph outline now */
             hinter->apply( hinter->hints,
                            builder->current,
-                           (PSH_Globals)builder->hints_globals );
+                           (PSH_Globals)builder->hints_globals,
+                           builder->hint_flags );
           }
 
           /* add current outline to the glyph slot */
diff --git a/src/cff/cffgload.h b/src/cff/cffgload.h
index b749d1d..15182fe 100644
--- a/src/cff/cffgload.h
+++ b/src/cff/cffgload.h
@@ -114,6 +114,8 @@ FT_BEGIN_HEADER
     FT_Error        error;         /* only used for memory errors */
     FT_Bool         metrics_only;
 
+    FT_UInt32       hint_flags;
+
     void*           hints_funcs;    /* hinter-specific */
     void*           hints_globals;  /* hinter-specific */
 
diff --git a/src/psaux/t1decode.c b/src/psaux/t1decode.c
index 4544ad1..91220fc 100644
--- a/src/psaux/t1decode.c
+++ b/src/psaux/t1decode.c
@@ -752,7 +752,8 @@
             /* apply hints to the loaded glyph outline now */
             hinter->apply( hinter->hints,
                            builder->current,
-                           (PSH_Globals)builder->hints_globals );
+                           (PSH_Globals)builder->hints_globals,
+                           decoder->hint_flags );
           }
 
           /* add current outline to the glyph slot */
@@ -1146,6 +1147,7 @@
 
     decoder->num_glyphs     = face->num_glyphs;
     decoder->glyph_names    = glyph_names;
+    decoder->hint_flags     = face->internal->hint_flags;
     decoder->blend          = blend;
     decoder->parse_callback = parse_callback;
 
diff --git a/src/pshinter/pshalgo1.c b/src/pshinter/pshalgo1.c
index 8fa0325..25e3433 100644
--- a/src/pshinter/pshalgo1.c
+++ b/src/pshinter/pshalgo1.c
@@ -744,13 +744,16 @@
   FT_Error
   ps1_hints_apply( PS_Hints     ps_hints,
                    FT_Outline*  outline,
-                   PSH_Globals  globals )
+                   PSH_Globals  globals,
+                   FT_UInt32    hint_flags )
   {
     PSH1_Hint_TableRec  hints;
     FT_Error            error = 0;
     FT_Int              dimension;
 
 
+    FT_UNUSED( hint_flags );
+
     for ( dimension = 1; dimension >= 0; dimension-- )
     {
       PS_Dimension  dim = &ps_hints->dimension[dimension];
diff --git a/src/pshinter/pshalgo1.h b/src/pshinter/pshalgo1.h
index ed1031f..1eae160 100644
--- a/src/pshinter/pshalgo1.h
+++ b/src/pshinter/pshalgo1.h
@@ -88,7 +88,8 @@ FT_BEGIN_HEADER
   extern FT_Error
   ps1_hints_apply( PS_Hints     ps_hints,
                    FT_Outline*  outline,
-                   PSH_Globals  globals );
+                   PSH_Globals  globals,
+                   FT_UInt32    hint_flags );
 
 
 #ifdef DEBUG_HINTER
diff --git a/src/pshinter/pshalgo2.c b/src/pshinter/pshalgo2.c
index 2eb8b8c..b8ece3c 100644
--- a/src/pshinter/pshalgo2.c
+++ b/src/pshinter/pshalgo2.c
@@ -1494,7 +1494,8 @@
   FT_Error
   ps2_hints_apply( PS_Hints     ps_hints,
                    FT_Outline*  outline,
-                   PSH_Globals  globals )
+                   PSH_Globals  globals,
+                   FT_UInt32    hint_flags )
   {
     PSH2_GlyphRec  glyphrec;
     PSH2_Glyph     glyph = &glyphrec;
@@ -1504,6 +1505,7 @@
 #endif
     FT_Int         dimension;
 
+    FT_UNUSED( hint_flags );
 
 #ifdef DEBUG_HINTER
     memory = globals->memory;
diff --git a/src/pshinter/pshalgo2.h b/src/pshinter/pshalgo2.h
index 5d6a61e..408cd95 100644
--- a/src/pshinter/pshalgo2.h
+++ b/src/pshinter/pshalgo2.h
@@ -190,7 +190,8 @@ FT_BEGIN_HEADER
   extern FT_Error
   ps2_hints_apply( PS_Hints     ps_hints,
                    FT_Outline*  outline,
-                   PSH_Globals  globals );
+                   PSH_Globals  globals,
+                   FT_UInt32    hint_flags );
 
 
 FT_END_HEADER
diff --git a/src/pshinter/pshalgo3.c b/src/pshinter/pshalgo3.c
index afc357e..35b8ad0 100644
--- a/src/pshinter/pshalgo3.c
+++ b/src/pshinter/pshalgo3.c
@@ -34,7 +34,7 @@
 
 #undef  SNAP_STEMS
 #undef  ONLY_ALIGN_Y
-      
+
 
 
   /*************************************************************************/
@@ -359,11 +359,11 @@
 
   static FT_Fixed
   psh3_hint_snap_stem_side_delta ( FT_Fixed pos,
-				   FT_Fixed len )
+                                   FT_Fixed len )
   {
     FT_Fixed delta1 = ( ( pos + 32 ) & -64 ) - pos;
     FT_Fixed delta2 = ( ( pos + len + 32 ) & -64  ) - pos - len;
-	      
+
     if ( ABS( delta1 ) <= ABS( delta2 ) )
     {
       return delta1;
@@ -378,7 +378,8 @@
   static void
   psh3_hint_align( PSH3_Hint    hint,
                    PSH_Globals  globals,
-                   FT_Int       dimension )
+                   FT_Int       dimension,
+                   FT_UInt32    hint_flags )
   {
     PSH_Dimension  dim   = &globals->dimension[dimension];
     FT_Fixed       scale = dim->scale_mult;
@@ -390,22 +391,38 @@
       FT_Pos  pos = FT_MulFix( hint->org_pos, scale ) + delta;
       FT_Pos  len = FT_MulFix( hint->org_len, scale );
 
-#ifdef SNAP_STEMS
-      FT_Pos  fit_center;
-      FT_Pos  fit_len;
-
+      FT_Pos            fit_center;
+      FT_Pos            fit_len;
       PSH_AlignmentRec  align;
 
-      /* compute fitted width/height */
-      fit_len = 0;
-      if ( hint->org_len )
+
+      /* ignore stem alignments when requested through the hint flags */
+      if ( ( dimension == 0 && ( hint_flags & FT_HINT_NO_VSTEM_ALIGN ) != 0 ) ||
+           ( dimension == 1 && ( hint_flags & FT_HINT_NO_HSTEM_ALIGN ) != 0 ) )
       {
-        fit_len = psh_dimension_snap_width( dim, hint->org_len );
-        if ( fit_len < 64 )
-          fit_len = 64;
-        else
-          fit_len = ( fit_len + 32 ) & -64;
+        hint->cur_pos = pos;
+        hint->cur_len = len;
+
+        psh3_hint_set_fitted( hint );
+        return;
+          }
+
+      /* perform stem snapping when requested */
+      if ( ( hint_flags & FT_HINT_NO_INTEGER_STEM ) == 0 )
+      {
+        /* compute fitted width/height */
+        fit_len = 0;
+        if ( hint->org_len )
+        {
+          fit_len = psh_dimension_snap_width( dim, hint->org_len );
+          if ( fit_len < 64 )
+            fit_len = 64;
+          else
+            fit_len = ( fit_len + 32 ) & -64;
+        }
       }
+      else
+        fit_len = len;
 
       hint->cur_len = fit_len;
 
@@ -450,182 +467,113 @@
 
             /* ensure that parent is already fitted */
             if ( !psh3_hint_is_fitted( parent ) )
-              psh3_hint_align( parent, globals, dimension );
+              psh3_hint_align( parent, globals, dimension, hint_flags );
 
             par_org_center = parent->org_pos + ( parent->org_len / 2);
             par_cur_center = parent->cur_pos + ( parent->cur_len / 2);
             cur_org_center = hint->org_pos   + ( hint->org_len   / 2);
 
             cur_delta = FT_MulFix( cur_org_center - par_org_center, scale );
-#if 0
-            if ( cur_delta >= 0 )
-              cur_delta = ( cur_delta + 16 ) & -64;
-            else
-              cur_delta = -( (-cur_delta + 16 ) & -64 );
-#endif
-            pos = par_cur_center + cur_delta - ( len >> 1 );
+            pos       = par_cur_center + cur_delta - ( len >> 1 );
           }
 
-          /* normal processing */
-          if ( ( fit_len / 64 ) & 1 )
+          if ( ( hint_flags & FT_HINT_NO_INTEGER_STEM ) == 0 )
           {
-            /* odd number of pixels */
-            fit_center = ( ( pos + ( len >> 1 ) ) & -64 ) + 32;
+            /* normal processing */
+            if ( ( fit_len / 64 ) & 1 )
+            {
+              /* odd number of pixels */
+              fit_center = ( ( pos + ( len >> 1 ) ) & -64 ) + 32;
+            }
+            else
+            {
+              /* even number of pixels */
+              fit_center = ( pos + ( len >> 1 ) + 32 ) & -64;
+            }
+            hint->cur_pos = fit_center - ( fit_len >> 1 );
           }
           else
           {
-            /* even number of pixels */
-            fit_center = ( pos + ( len >> 1 ) + 32 ) & -64;
-          }
-
-          hint->cur_pos = fit_center - ( fit_len >> 1 );
-        }
-      }
-#else
-      PSH_AlignmentRec  align;
-
-      hint->cur_len = len;
-
-      /* check blue zones for horizontal stems */
-      align.align = PSH_BLUE_ALIGN_NONE;
-      align.align_bot = align.align_top = 0;
-
-      if ( dimension == 1 )
-        psh_blues_snap_stem( &globals->blues,
-                             hint->org_pos + hint->org_len,
-                             hint->org_pos,
-                             &align );
-#ifdef ONLY_ALIGN_Y
-      else
-      {
-	hint->cur_pos = pos;
-	return;
-      }
-#endif
-      
-      switch ( align.align )
-      {
-      case PSH_BLUE_ALIGN_TOP:
-        /* the top of the stem is aligned against a blue zone */
-        hint->cur_pos = align.align_top - len;
-        break;
-
-      case PSH_BLUE_ALIGN_BOT:
-        /* the bottom of the stem is aligned against a blue zone */
-        hint->cur_pos = align.align_bot;
-        break;
-
-      case PSH_BLUE_ALIGN_TOP | PSH_BLUE_ALIGN_BOT:
-        /* both edges of the stem are aligned against blue zones */
-        hint->cur_pos = align.align_bot;
-        hint->cur_len = align.align_top - align.align_bot;
-        break;
-
-      default:
-        {
-          PSH3_Hint  parent = hint->parent;
-
-          if ( parent )
-          {
-            FT_Pos  par_org_center, par_cur_center;
-            FT_Pos  cur_org_center, cur_delta;
+            /* Stems less than one pixel wide are easy - we want to
+             * make them as dark as possible, so they must fall within
+             * one pixel. If the stem is split between two pixels
+             * then snap the edge that is nearer to the pixel boundary
+             * to the pixel boundary
+             */
+            if (len <= 64)
+            {
+              if ( ( pos + len + 63 ) / 64  != pos / 64 + 1 )
+                pos += psh3_hint_snap_stem_side_delta ( pos, len );
+            }
+            /* Position stems other to minimize the amount of mid-grays.
+             * There are, in general, two positions that do this,
+             * illustrated as A) and B) below.
+             *
+             *   +                   +                   +                   +
+             *
+             * A)             |--------------------------------|
+             * B)   |--------------------------------|
+             * C)       |--------------------------------|
+             *
+             * Position A) (split the excess stem equally) should be better
+             * for stems of width N + f where f < 0.5
+             *
+             * Position B) (split the deficiency equally) should be better
+             * for stems of width N + f where f > 0.5
+             *
+             * It turns out though that minimizing the total number of touched
+             * pixels is also important, so position C), with one edge
+             * aligned with a pixel boundary is actually preferable
+             * to A). There are also more possible positions for C) than
+             * for A) or B), so there will be less distortion of the overall
+             * character shape.
+             */
+            else
+            {
+              FT_Fixed frac_len = len & 63;
+              FT_Fixed center = pos + ( len >> 1 );
 
+              FT_Fixed delta_a, delta_b;
 
-            /* ensure that parent is already fitted */
-            if ( !psh3_hint_is_fitted( parent ) )
-              psh3_hint_align( parent, globals, dimension );
+              if ( ( len / 64 ) & 1 )
+              {
+                delta_a = ( center & -64 ) + 32 - center;
+                delta_b = ( ( center + 32 ) & - 64 ) - center;
+              }
+              else
+              {
+                delta_a = ( ( center + 32 ) & - 64 ) - center;
+                delta_b = ( center & -64 ) + 32 - center;
+              }
 
-            par_org_center = parent->org_pos + ( parent->org_len / 2);
-            par_cur_center = parent->cur_pos + ( parent->cur_len / 2);
-            cur_org_center = hint->org_pos   + ( hint->org_len   / 2);
+              /* We choose between B) and C) above based on the amount
+               * of fractional stem width: for small amounts, choose
+               * C) always; for large amounts, B) always; inbetween,
+               * pick whichever one involves less stem movement.
+               */
+              if (frac_len < 32)
+              {
+                pos += psh3_hint_snap_stem_side_delta ( pos, len );
+              }
+              else if (frac_len < 48)
+              {
+                FT_Fixed side_delta = psh3_hint_snap_stem_side_delta ( pos, len );
 
-            cur_delta = FT_MulFix( cur_org_center - par_org_center, scale );
-            pos = par_cur_center + cur_delta - ( len >> 1 );
+                if ( ABS( side_delta ) < ABS( delta_b ) )
+                  pos += side_delta;
+                else
+                  pos += delta_b;
+              }
+              else
+              {
+                pos += delta_b;
+              }
+            }
+            hint->cur_pos = pos;
           }
-
-          {
-	    /* Stems less than one pixel wide are easy - we want to
-	     * make them as dark as possible, so they must fall within
-	     * one pixel. If the stem is split between two pixels
-	     * then snap the edge that is nearer to the pixel boundary
-	     * to the pixel boundary
-	     */
-	    if (len <= 64)
-	    {
-	      if ( ( pos + len + 63 ) / 64  != pos / 64 + 1 )
-		pos += psh3_hint_snap_stem_side_delta ( pos, len );
-	    }
-	    /* Position stems other to minimize the amount of mid-grays.
-	     * There are, in general, two positions that do this,
-	     * illustrated as A) and B) below.
-	     *
-	     *   +                   +                   +                   +
-	     *
-	     * A)             |--------------------------------|
-	     * B)   |--------------------------------|
-	     * C)       |--------------------------------|
-	     *
-	     * Position A) (split the excess stem equally) should be better
-	     * for stems of width N + f where f < 0.5
-	     *
-	     * Position B) (split the deficiency equally) should be better
-	     * for stems of width N + f where f > 0.5
-	     *
-	     * It turns out though that minimizing the total number of lit
-	     * pixels is also important, so position C), with one edge
-	     * aligned with a pixel boundary is actually preferable
-	     * to A). There are also more possibile positions for C) than
-	     * for A) or B), so it involves less distortion of the overall
-	     * character shape.
-	     */
-	    else
-	    {
-	      FT_Fixed frac_len = len & 63;
-	      FT_Fixed center = pos + ( len >> 1 );
-
-	      FT_Fixed delta_a, delta_b;
-
-	      if ( ( len / 64 ) & 1 )
-	      {
-	        delta_a = ( center & -64 ) + 32 - center;
-	        delta_b = ( ( center + 32 ) & - 64 ) - center;
-	      }
-	      else
-	      {
-	        delta_a = ( ( center + 32 ) & - 64 ) - center;
-	        delta_b = ( center & -64 ) + 32 - center;
-	      }
-
-	      /* We choose between B) and C) above based on the amount
-	       * of fractinal stem width; for small amounts, choose
-	       * C) always, for large amounts, B) always, and inbetween,
-	       * pick whichever one involves less stem movement.
-	       */
-	      if (frac_len < 32)
-	      {
-		pos += psh3_hint_snap_stem_side_delta ( pos, len );
-	      }
-	      else if (frac_len < 48)
-	      {
-		FT_Fixed side_delta = psh3_hint_snap_stem_side_delta ( pos, len );
-		  
-		if ( ABS( side_delta ) < ABS( delta_b ) )
-		  pos += side_delta;
-		else
-		  pos += delta_b;
-	      }
-	      else
-	      {
-		pos += delta_b;
-	      }
-	    }
-	  }
-	 
-	  hint->cur_pos = pos;
-	}
+        }
       }
-#endif
-      
+
       psh3_hint_set_fitted( hint );
 
 #ifdef DEBUG_HINTER
@@ -639,7 +587,8 @@
   static void
   psh3_hint_table_align_hints( PSH3_Hint_Table  table,
                                PSH_Globals      globals,
-                               FT_Int           dimension )
+                               FT_Int           dimension,
+                               FT_UInt32        hint_flags )
   {
     PSH3_Hint      hint;
     FT_UInt        count;
@@ -667,7 +616,7 @@
     count = table->max_hints;
 
     for ( ; count > 0; count--, hint++ )
-      psh3_hint_align( hint, globals, dimension );
+      psh3_hint_align( hint, globals, dimension, hint_flags );
   }
 
 
@@ -705,230 +654,6 @@
 
 #endif
 
-#if 0
-  /* setup interpolation zones once the hints have been grid-fitted */
-  /* by the optimizer                                               */
-  static void
-  psh3_hint_table_setup_zones( PSH3_Hint_Table  table,
-                               FT_Fixed         scale,
-                               FT_Fixed         delta )
-  {
-    FT_UInt     count;
-    PSH3_Zone   zone;
-    PSH3_Hint  *sort, hint, hint2;
-
-
-    zone = table->zones;
-
-    /* special case, no hints defined */
-    if ( table->num_hints == 0 )
-    {
-      zone->scale = scale;
-      zone->delta = delta;
-      zone->min   = PSH3_ZONE_MIN;
-      zone->max   = PSH3_ZONE_MAX;
-
-      table->num_zones = 1;
-      table->zone      = zone;
-      return;
-    }
-
-    /* the first zone is before the first hint */
-    /* x' = (x-x0)*s + x0' = x*s + ( x0' - x0*s ) */
-    sort = table->sort;
-    hint = sort[0];
-
-    zone->scale = scale;
-    zone->delta = hint->cur_pos - FT_MulFix( hint->org_pos, scale );
-    zone->min   = PSH3_ZONE_MIN;
-    zone->max   = hint->org_pos;
-
-    psh3_print_zone( zone );
-
-    zone++;
-
-    for ( count = table->num_hints; count > 0; count-- )
-    {
-      FT_Fixed  scale2;
-
-
-      if ( hint->org_len > 0 )
-      {
-        /* setup a zone for inner-stem interpolation */
-        /* (x' - x0') = (x - x0)*(x1'-x0')/(x1-x0)   */
-        /* x' = x*s2 + x0' - x0*s2                   */
-
-        scale2      = FT_DivFix( hint->cur_len, hint->org_len );
-        zone->scale = scale2;
-        zone->min   = hint->org_pos;
-        zone->max   = hint->org_pos + hint->org_len;
-        zone->delta = hint->cur_pos - FT_MulFix( zone->min, scale2 );
-
-        psh3_print_zone( zone );
-
-        zone++;
-      }
-
-      if ( count == 1 )
-        break;
-
-      sort++;
-      hint2 = sort[0];
-
-      /* setup zone for inter-stem interpolation */
-      /* (x'-x1') = (x-x1)*(x2'-x1')/(x2-x1)     */
-      /* x' = x*s3 + x1' - x1*s3                 */
-
-      scale2 = FT_DivFix( hint2->cur_pos - (hint->cur_pos + hint->cur_len),
-                          hint2->org_pos - (hint->org_pos + hint->org_len) );
-      zone->scale = scale2;
-      zone->min   = hint->org_pos + hint->org_len;
-      zone->max   = hint2->org_pos;
-      zone->delta = hint->cur_pos + hint->cur_len -
-                    FT_MulFix( zone->min, scale2 );
-
-      psh3_print_zone( zone );
-
-      zone++;
-
-      hint = hint2;
-    }
-
-    /* the last zone */
-    zone->scale = scale;
-    zone->min   = hint->org_pos + hint->org_len;
-    zone->max   = PSH3_ZONE_MAX;
-    zone->delta = hint->cur_pos + hint->cur_len -
-                  FT_MulFix( zone->min, scale );
-
-    psh3_print_zone( zone );
-
-    zone++;
-
-    table->num_zones = zone - table->zones;
-    table->zone      = table->zones;
-  }
-#endif
-
-#if 0
-  /* tune a single coordinate with the current interpolation zones */
-  static FT_Pos
-  psh3_hint_table_tune_coord( PSH3_Hint_Table  table,
-                              FT_Int           coord )
-  {
-    PSH3_Zone   zone;
-
-
-    zone = table->zone;
-
-    if ( coord < zone->min )
-    {
-      do
-      {
-        if ( zone == table->zones )
-          break;
-
-        zone--;
-
-      } while ( coord < zone->min );
-      table->zone = zone;
-    }
-    else if ( coord > zone->max )
-    {
-      do
-      {
-        if ( zone == table->zones + table->num_zones - 1 )
-          break;
-
-        zone++;
-
-      } while ( coord > zone->max );
-      table->zone = zone;
-    }
-
-    return FT_MulFix( coord, zone->scale ) + zone->delta;
-  }
-#endif
-
-#if 0
- /* tune a given outline with current interpolation zones */
- /* the function only works in a single dimension..       */
-  static void
-  psh3_hint_table_tune_outline( PSH3_Hint_Table  table,
-                                FT_Outline*      outline,
-                                PSH_Globals      globals,
-                                FT_Int           dimension )
-
-  {
-    FT_UInt        count, first, last;
-    PS_Mask_Table  hint_masks = table->hint_masks;
-    PS_Mask        mask;
-    PSH_Dimension  dim        = &globals->dimension[dimension];
-    FT_Fixed       scale      = dim->scale_mult;
-    FT_Fixed       delta      = dim->scale_delta;
-
-
-    if ( hint_masks && hint_masks->num_masks > 0 )
-    {
-      first = 0;
-      mask  = hint_masks->masks;
-      count = hint_masks->num_masks;
-
-      for ( ; count > 0; count--, mask++ )
-      {
-        last = mask->end_point;
-
-        if ( last > first )
-        {
-          FT_Vector*   vec;
-          FT_Int       count2;
-
-
-          psh3_hint_table_activate_mask( table, mask );
-          psh3_hint_table_optimize( table, globals, outline, dimension );
-          psh3_hint_table_setup_zones( table, scale, delta );
-          last = mask->end_point;
-
-          vec    = outline->points + first;
-          count2 = last - first;
-
-          for ( ; count2 > 0; count2--, vec++ )
-          {
-            FT_Pos  x, *px;
-
-
-            px  = dimension ? &vec->y : &vec->x;
-            x   = *px;
-
-            *px = psh3_hint_table_tune_coord( table, (FT_Int)x );
-          }
-        }
-
-        first = last;
-      }
-    }
-    else    /* no hints in this glyph, simply scale the outline */
-    {
-      FT_Vector*  vec;
-
-
-      vec   = outline->points;
-      count = outline->n_points;
-
-      if ( dimension == 0 )
-      {
-        for ( ; count > 0; count--, vec++ )
-          vec->x = FT_MulFix( vec->x, scale ) + delta;
-      }
-      else
-      {
-        for ( ; count > 0; count--, vec++ )
-          vec->y = FT_MulFix( vec->y, scale ) + delta;
-      }
-    }
-  }
-#endif
-
 
   /*************************************************************************/
   /*************************************************************************/
@@ -1661,7 +1386,8 @@
   FT_Error
   ps3_hints_apply( PS_Hints     ps_hints,
                    FT_Outline*  outline,
-                   PSH_Globals  globals )
+                   PSH_Globals  globals,
+                   FT_UInt32    hint_flags )
   {
     PSH3_GlyphRec  glyphrec;
     PSH3_Glyph     glyph = &glyphrec;
@@ -1699,7 +1425,8 @@
       /* compute aligned stem/hints positions */
       psh3_hint_table_align_hints( &glyph->hint_tables[dimension],
                                    glyph->globals,
-                                   dimension );
+                                   dimension,
+                                   hint_flags );
 
       /* find strong points, align them, then interpolate others */
       psh3_glyph_find_strong_points( glyph, dimension );
diff --git a/src/pshinter/pshalgo3.h b/src/pshinter/pshalgo3.h
index 4d4abb7..6ad6371 100644
--- a/src/pshinter/pshalgo3.h
+++ b/src/pshinter/pshalgo3.h
@@ -190,7 +190,8 @@ FT_BEGIN_HEADER
   extern FT_Error
   ps3_hints_apply( PS_Hints     ps_hints,
                    FT_Outline*  outline,
-                   PSH_Globals  globals );
+                   PSH_Globals  globals,
+                   FT_UInt32    hint_flags );
 
 
 FT_END_HEADER