Commit e6472c1251b6abdc884e63c752b862248eff8904

David Turner 2007-04-02T13:13:54

detect "extra-light" fonts in the auto-hinter in order to avoid producing weird results with them

diff --git a/ChangeLog b/ChangeLog
index 8f79222..56ea485 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2007-04-02  David Turner  <david@freetype.org>
+
+	* src/autofit/aflatin.h, src/autofit/aflatin.c: add special code to
+	detect "extra-light" fonts and do not snap their stem widths too much
+	to avoid bizarre hinting effects.
+
 2007-03-28  David Turner  <david@freetype.org>
 
 	* src/base/ftbitmap.c (ft_bitmap_assure_buffer): Fix zero-ing of the
diff --git a/src/autofit/aflatin.c b/src/autofit/aflatin.c
index cba9b6e..59aaa8d 100644
--- a/src/autofit/aflatin.c
+++ b/src/autofit/aflatin.c
@@ -133,6 +133,8 @@
 
         /* let's try 20% of the smallest width */
         axis->edge_distance_threshold = stdw / 5;
+        axis->standard_width          = stdw;
+        axis->extra_light             = 0;
       }
     }
 
@@ -523,6 +525,11 @@
       width->fit = width->cur;
     }
 
+   /* an extra-light axis corresponds to a standard width that is smaller
+    * than 0.75 pixels
+   */
+    axis->extra_light = (FT_MulFix(axis->standard_width, scale) < 32+8);
+
     if ( dim == AF_DIMENSION_VERT )
     {
       /* scale the blue zones */
@@ -1531,7 +1538,8 @@
     FT_Int           vertical = ( dim == AF_DIMENSION_VERT );
 
 
-    if ( !AF_LATIN_HINTS_DO_STEM_ADJUST( hints ) )
+    if ( !AF_LATIN_HINTS_DO_STEM_ADJUST( hints ) ||
+          axis->extra_light )
       return width;
 
     if ( dist < 0 )
diff --git a/src/autofit/aflatin.h b/src/autofit/aflatin.h
index e73c44a..756e778 100644
--- a/src/autofit/aflatin.h
+++ b/src/autofit/aflatin.h
@@ -102,6 +102,8 @@ FT_BEGIN_HEADER
     FT_UInt          width_count;
     AF_WidthRec      widths[AF_LATIN_MAX_WIDTHS];
     FT_Pos           edge_distance_threshold;
+    FT_Pos           standard_width;
+    FT_Bool          extra_light;
 
     /* ignored for horizontal metrics */
     FT_Bool          control_overshoot;