ref: 90a36c5522a93fb6e829851ef29626d20159044e
parent: 46ab6331e0c23bddb563ffd909162aa73364b4bc
author: David Turner <[email protected]>
date: Tue Apr 4 14:21:45 EDT 2000
a small improvement to the Type 1 hinter, that comes from research with the auto-hinter. Nothing fancy but gets rid of the un-normalized widths :-)
--- a/src/type1/t1hinter.c
+++ b/src/type1/t1hinter.c
@@ -889,18 +889,36 @@
{
T1_Snap_Zone* zone = hints->snap_heights;
T1_Snap_Zone* zone_limit = zone + hints->num_snap_heights;
+ T1_Pos best_dist = 32000;
+ T1_Snap_Zone* best_zone = 0;
for ( ; zone < zone_limit; zone++ )
{
- if ( width_pix < zone->min )
- break;
-
- if ( width_pix <= zone->max )
+ T1_Pos dist;
+
+ dist = width_pix - zone->min; if (dist < 0) dist = -dist;
+ if (dist < best_dist)
{
- width_pix = zone->pix;
- break;
+ best_zone = zone;
+ best_dist = dist;
}
}
+
+ if (best_zone)
+ {
+ if (width_pix > best_zone->pix)
+ {
+ width_pix -= 0x20;
+ if (width_pix < best_zone->pix)
+ width_pix = best_zone->pix;
+ }
+ else
+ {
+ width_pix += 0x20;
+ if (width_pix > best_zone->pix)
+ width_pix = best_zone->pix;
+ }
+ }
}
/******************************************************************/
@@ -1053,18 +1071,36 @@
/* Snap pixel width if in stem snap range */
{
- T1_Snap_Zone* zone = hints->snap_widths;
- T1_Snap_Zone* zone_limit = zone + hints->num_snap_widths;
+ T1_Snap_Zone* zone = hints->snap_heights;
+ T1_Snap_Zone* zone_limit = zone + hints->num_snap_heights;
+ T1_Pos best_dist = 32000;
+ T1_Snap_Zone* best_zone = 0;
for ( ; zone < zone_limit; zone++ )
{
- if ( width_pix < zone->min )
- break;
-
- if ( width_pix <= zone->max )
+ T1_Pos dist;
+
+ dist = width_pix - zone->min; if (dist < 0) dist = -dist;
+ if (dist < best_dist)
{
- width_pix = zone->pix;
- break;
+ best_zone = zone;
+ best_dist = dist;
+ }
+ }
+
+ if (best_zone)
+ {
+ if (width_pix > best_zone->pix)
+ {
+ width_pix -= 0x20;
+ if (width_pix < best_zone->pix)
+ width_pix = best_zone->pix;
+ }
+ else
+ {
+ width_pix += 0x20;
+ if (width_pix > best_zone->pix)
+ width_pix = best_zone->pix;
}
}
}