improvement to glyph spacing, especially when light auto-hinting
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
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 */