From 981f5a54c3cbc1de45ba941fdf5315c62d86b6f3 Mon Sep 17 00:00:00 2001 From: Ebrahim Byagowi Date: Wed, 7 Aug 2019 18:45:39 +0430 Subject: [PATCH] [fvar] Implement inverse normalize, unnormalize --- src/hb-ot-var-fvar-table.hh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/hb-ot-var-fvar-table.hh b/src/hb-ot-var-fvar-table.hh index 18b9518d3..f1d024560 100644 --- a/src/hb-ot-var-fvar-table.hh +++ b/src/hb-ot-var-fvar-table.hh @@ -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