[pshinter] Slightly simplify BlueScale application.

* src/pshinter/pshglob.c (psh_globals_new): Update condition and
properly rescale BlueScale.
(psh_blues_scale_zones): Use it directly.
This commit is contained in:
Alexei Podtelezhnikov
2025-11-14 15:45:59 -05:00
parent d783d336e6
commit 04743f152a

View File

@@ -376,36 +376,24 @@
/* not. We simply need to compare the vertical scale */
/* parameter to the raw bluescale value. Here is why: */
/* */
/* We need to suppress overshoots for all pointsizes. */
/* At 300dpi that satisfies: */
/* The specs explain how the bluescale is calculated */
/* from the desired maximum rounded pointsize at 300 dpi */
/* and assuming upem of 1000. */
/* */
/* pointsize < 240*bluescale + 0.49 */
/* bluescale = ( pointsize - 0.49 ) / 240 */
/* */
/* This corresponds to: */
/* For unrounded pointsize in general terms */
/* */
/* pixelsize < 1000*bluescale + 49/24 */
/* bluescale = ( pointsize * dpi / 72 ) / upem */
/* */
/* scale*EM_Size < 1000*bluescale + 49/24 */
/* which is */
/* */
/* However, for normal Type 1 fonts, EM_Size is 1000! */
/* We thus only check: */
/* bluescale = pixelsize / upem */
/* */
/* scale < bluescale + 49/24000 */
/* Therefore, the bluescale value can be used directly */
/* as a scale limit, now that it is in comparable units */
/* */
/* which we shorten to */
/* */
/* "scale < bluescale" */
/* */
/* Note that `blue_scale' is stored 1000 times its real */
/* value, and that `scale' converts from font units to */
/* fractional pixels. */
/* */
/* 1000 / 64 = 125 / 8 */
if ( scale >= 0x20C49BAL )
blues->no_overshoots = FT_BOOL( scale < blues->blue_scale * 8 / 125 );
else
blues->no_overshoots = FT_BOOL( scale * 125 < blues->blue_scale * 8 );
blues->no_overshoots = FT_BOOL( scale < blues->blue_scale );
/* */
/* The blue threshold is the font units distance under */
@@ -708,7 +696,6 @@
/* limit the BlueScale value to `1 / max_of_blue_zone_heights' */
{
FT_Fixed max_scale;
FT_Short max_height = 1;
@@ -725,11 +712,12 @@
priv->family_other_blues,
max_height );
/* BlueScale is scaled 1000 times */
max_scale = FT_DivFix( 1000, max_height );
globals->blues.blue_scale = priv->blue_scale < max_scale
? priv->blue_scale
: max_scale;
/* restrict BlueScale value that is amplified 1000-fold and */
/* rescale it to be comparable to the metrics scale */
if ( FT_MulFix( max_height, priv->blue_scale ) < 1000 )
globals->blues.blue_scale = priv->blue_scale * 8 / 125;
else
globals->blues.blue_scale = 64 * 0x10000L / max_height;
}
globals->blues.blue_shift = priv->blue_shift;