Commit d91eebda1c2eb722eeb63fce27fbbf243a701cf0

David Turner 2007-01-26T15:05:41

improvement to glyph spacing, especially when light auto-hinting

diff --git a/ChangeLog b/ChangeLog
index 62bba20..4360a6f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2007-01-25  David Turner  <david@freetype.org>
+
+	* src/autofit/afhints.h, src/autofit/afhints.c, src/autofit/aftypes.h,
+	src/autofit/afwarp.c: light auto-hinting, improve glyph advance widths
+	and ressurect normal/full hinting to its normal quality
+
 2007-01-25  Werner Lemberg  <wl@gnu.org>
 
 	* docs/release: Updated -- Savannah uses a new uploading scheme.
diff --git a/src/autofit/afhints.c b/src/autofit/afhints.c
index 65a4662..b1360a1 100644
--- a/src/autofit/afhints.c
+++ b/src/autofit/afhints.c
@@ -727,6 +727,9 @@
     hints->x_delta = x_delta;
     hints->y_delta = y_delta;
 
+    hints->xmin_delta = 0;
+    hints->xmax_delta = 0;
+
     points = hints->points;
     if ( hints->num_points == 0 )
       goto Exit;
diff --git a/src/autofit/afhints.h b/src/autofit/afhints.h
index c889aad..fd43620 100644
--- a/src/autofit/afhints.h
+++ b/src/autofit/afhints.h
@@ -208,6 +208,9 @@ FT_BEGIN_HEADER
                                      /* implementations          */
     AF_ScriptMetrics  metrics;
 
+    FT_Pos            xmin_delta;    /* used for warping */
+    FT_Pos            xmax_delta;
+    
   } AF_GlyphHintsRec;
 
 
diff --git a/src/autofit/afloader.c b/src/autofit/afloader.c
index 5157158..769aebf 100644
--- a/src/autofit/afloader.c
+++ b/src/autofit/afloader.c
@@ -171,8 +171,8 @@
 
       /* we now need to hint the metrics according to the change in */
       /* width/positioning that occured during the hinting process  */
+      if ( scaler->render_mode != FT_RENDER_MODE_LIGHT )
       {
-#ifndef AF_USE_WARPER
         FT_Pos        old_advance, old_rsb, old_lsb, new_lsb;
         FT_Pos        pp1x_uh, pp2x_uh;
         AF_AxisHints  axis  = &hints->axis[AF_DIMENSION_HORZ];
@@ -216,18 +216,28 @@
           slot->rsb_delta = loader->pp2.x - pp2x_uh;
         }
         else
-#endif /* !AF_USE_WARPER */
         {
           FT_Pos   pp1x = loader->pp1.x;
           FT_Pos   pp2x = loader->pp2.x;
 
-          loader->pp1.x = FT_PIX_ROUND( loader->pp1.x );
-          loader->pp2.x = FT_PIX_ROUND( loader->pp2.x );
+          loader->pp1.x = FT_PIX_ROUND( pp1x );
+          loader->pp2.x = FT_PIX_ROUND( pp2x );
 
           slot->lsb_delta = loader->pp1.x - pp1x;
           slot->rsb_delta = loader->pp2.x - pp2x;
         }
       }
+      else
+      {
+        FT_Pos   pp1x = loader->pp1.x;
+        FT_Pos   pp2x = loader->pp2.x;
+
+        loader->pp1.x = FT_PIX_ROUND( pp1x + hints->xmin_delta );
+        loader->pp2.x = FT_PIX_ROUND( pp2x + hints->xmax_delta + 16 );
+
+        slot->lsb_delta = loader->pp1.x - pp1x;
+        slot->rsb_delta = loader->pp2.x - pp2x;
+      }
 
       /* good, we simply add the glyph to our loader's base */
       FT_GlyphLoader_Add( gloader );
diff --git a/src/autofit/afwarp.c b/src/autofit/afwarp.c
index dbad882..7af840c 100644
--- a/src/autofit/afwarp.c
+++ b/src/autofit/afwarp.c
@@ -24,11 +24,11 @@
   static const AF_WarpScore
   af_warper_weights[64] =
   {
-    35, 32, 30, 20, 15, 12, 10,  5,  2,  1,  0,  0,  0,  0,  0,  0,
+    35, 32, 30, 25, 20, 15, 12, 10,  5,  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, 30, 32,
+     0,  0,  0,  0,  0,  0,  0,  1,  5, 10, 12, 15, 20, 25, 30, 32,
   };
 #else
   static const AF_WarpScore
@@ -314,8 +314,16 @@
                                    segments, num_segments );
     }
 
-    *a_scale = warper->best_scale;
-    *a_delta = warper->best_delta;
+    {
+      FT_Fixed  best_scale = warper->best_scale;
+      FT_Pos    best_delta = warper->best_delta;
+     
+      hints->xmin_delta = FT_MulFix( X1, best_scale-org_scale ) + best_delta;
+      hints->xmax_delta = FT_MulFix( X2, best_scale-org_scale ) + best_delta;
+
+      *a_scale = best_scale;
+      *a_delta = best_delta;
+    }
   }
 
 #else /* !AF_USE_WARPER */