From 90a36c5522a93fb6e829851ef29626d20159044e Mon Sep 17 00:00:00 2001 From: David Turner Date: Tue, 4 Apr 2000 18:21:45 +0000 Subject: [PATCH] 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 :-) --- src/type1/t1hinter.c | 64 ++++++++++++++++++++++++++++++++++---------- 1 file changed, 50 insertions(+), 14 deletions(-) diff --git a/src/type1/t1hinter.c b/src/type1/t1hinter.c index 1d8648aca..bb2f2355f 100644 --- a/src/type1/t1hinter.c +++ b/src/type1/t1hinter.c @@ -889,16 +889,34 @@ { 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; } } }