[fvar] Implement inverse normalize, unnormalize

This commit is contained in:
Ebrahim Byagowi 2019-08-07 18:45:39 +04:30 committed by Behdad Esfahbod
parent dcb4cd400f
commit 981f5a54c3
1 changed files with 14 additions and 0 deletions

View File

@ -240,6 +240,20 @@ struct fvar
return roundf (v * 16384.f);
}
float unnormalize_axis_value (unsigned int axis_index, float v) const
{
hb_ot_var_axis_info_t axis;
get_axis_info (axis_index, &axis);
if (v == 0)
return axis.default_value;
else if (v < 0)
v = v * (axis.default_value - axis.min_value) / 16384.f + axis.default_value;
else
v = v * (axis.max_value - axis.default_value) / 16384.f + axis.default_value;
return v;
}
unsigned int get_instance_count () const { return instanceCount; }
hb_ot_name_id_t get_instance_subfamily_name_id (unsigned int instance_index) const