From 723b01eadd71549b7315fd20d858d043ed9e9562 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Mon, 18 Dec 2017 14:06:02 -0500 Subject: [PATCH] Fix clamping of font variation axis values We were clamping the value correctly here, but then used the original value for normalization anyway. --- src/truetype/ttgxvar.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/truetype/ttgxvar.c b/src/truetype/ttgxvar.c index 0d4872f4a..4b4069111 100644 --- a/src/truetype/ttgxvar.c +++ b/src/truetype/ttgxvar.c @@ -54,6 +54,7 @@ #include "tterrors.h" +#include #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT @@ -1733,7 +1734,7 @@ /* based on the [min,def,max] values for the axis to be [-1,0,1]. */ /* Then, if there's an `avar' table, we renormalize this range. */ - FT_TRACE5(( "design coordinates:\n" )); + printf( "design coordinates: %d\n", num_coords); a = mmvar->axis; for ( i = 0; i < num_coords; i++, a++ ) @@ -1741,15 +1742,15 @@ FT_Fixed coord = coords[i]; - FT_TRACE5(( " %.5f\n", coord / 65536.0 )); + printf( " %.5f\n", coord / 65536.0 ); if ( coord > a->maximum || coord < a->minimum ) { - FT_TRACE1(( + printf( "ft_var_to_normalized: design coordinate %.5f\n" " is out of range [%.5f;%.5f]; clamping\n", coord / 65536.0, a->minimum / 65536.0, - a->maximum / 65536.0 )); + a->maximum / 65536.0 ); if ( coord > a->maximum) coord = a->maximum; @@ -1758,10 +1759,10 @@ } if ( coord < a->def ) - normalized[i] = -FT_DivFix( coords[i] - a->def, + normalized[i] = -FT_DivFix( coord - a->def, a->minimum - a->def ); else if ( coord > a->def ) - normalized[i] = FT_DivFix( coords[i] - a->def, + normalized[i] = FT_DivFix( coord - a->def, a->maximum - a->def ); else normalized[i] = 0; -- 2.15.1