shithub: freetype+ttf2subf

Download patch

ref: d91eebda1c2eb722eeb63fce27fbbf243a701cf0
parent: 3b3f2baae494d4513c438212294953f56f13a44a
author: David Turner <[email protected]>
date: Fri Jan 26 10:05:41 EST 2007

improvement to glyph spacing, especially when light auto-hinting

git/fs: mount .git/fs: mount/attach disallowed
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2007-01-25  David Turner  <[email protected]>
+
+	* 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  <[email protected]>
 
 	* docs/release: Updated -- Savannah uses a new uploading scheme.
--- 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;
--- a/src/autofit/afhints.h
+++ b/src/autofit/afhints.h
@@ -208,6 +208,9 @@
                                      /* implementations          */
     AF_ScriptMetrics  metrics;
 
+    FT_Pos            xmin_delta;    /* used for warping */
+    FT_Pos            xmax_delta;
+    
   } AF_GlyphHintsRec;
 
 
--- 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,17 +216,27 @@
           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 */
--- 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 */