diff --git a/src/hb-ot-var-common.hh b/src/hb-ot-var-common.hh index ae6a0bda8..9a33af299 100644 --- a/src/hb-ot-var-common.hh +++ b/src/hb-ot-var-common.hh @@ -251,7 +251,8 @@ struct TupleVariationHeader bool unpack_axis_tuples (unsigned axis_count, const hb_array_t shared_tuples, - hb_hashmap_t& axis_tuples /* OUT */) const + const hb_map_t *axes_old_index_tag_map, + hb_hashmap_t& axis_tuples /* OUT */) const { const F2DOT14 *peak_tuple = nullptr; if (has_peak ()) @@ -279,6 +280,10 @@ struct TupleVariationHeader float peak = peak_tuple[i].to_float (); if (peak == 0.f) continue; + hb_tag_t *axis_tag; + if (!axes_old_index_tag_map->has (i, &axis_tag)) + return false; + float start, end; if (has_interm) { @@ -290,7 +295,7 @@ struct TupleVariationHeader start = hb_min (peak, 0.f); end = hb_max (peak, 0.f); } - axis_tuples.set (i, Triple (start, peak, end)); + axis_tuples.set (*axis_tag, Triple (start, peak, end)); } return true; @@ -562,6 +567,7 @@ struct TupleVariationData unsigned tuple_var_count, unsigned point_count, bool is_gvar, + const hb_map_t *axes_old_index_tag_map, const hb_vector_t &shared_indices, const hb_array_t shared_tuples) { @@ -572,8 +578,8 @@ struct TupleVariationData if (unlikely (!iterator.var_data_bytes.check_range (p, length))) { fini (); return false; } - hb_hashmap_t axis_tuples; - if (!iterator.current_tuple->unpack_axis_tuples (iterator.get_axis_count (), shared_tuples, axis_tuples) + hb_hashmap_t axis_tuples; + if (!iterator.current_tuple->unpack_axis_tuples (iterator.get_axis_count (), shared_tuples, axes_old_index_tag_map, axis_tuples) || axis_tuples.is_empty ()) { fini (); return false; } @@ -849,12 +855,14 @@ struct TupleVariationData bool decompile_tuple_variations (unsigned point_count, bool is_gvar, tuple_iterator_t iterator, + const hb_map_t *axes_old_index_tag_map, const hb_vector_t &shared_indices, const hb_array_t shared_tuples, tuple_variations_t& tuple_variations /* OUT */) const { return tuple_variations.create_from_tuple_var_data (iterator, tupleVarCount, point_count, is_gvar, + axes_old_index_tag_map, shared_indices, shared_tuples); } diff --git a/src/hb-ot-var-cvar-table.hh b/src/hb-ot-var-cvar-table.hh index 110a3af40..c85da7adc 100644 --- a/src/hb-ot-var-cvar-table.hh +++ b/src/hb-ot-var-cvar-table.hh @@ -54,6 +54,7 @@ struct cvar bool decompile_tuple_variations (unsigned axis_count, unsigned point_count, bool is_gvar, + const hb_map_t *axes_old_index_tag_map, TupleVariationData::tuple_variations_t& tuple_variations /* OUT */) const { hb_vector_t shared_indices; @@ -65,6 +66,7 @@ struct cvar return false; return tupleVariationData.decompile_tuple_variations (point_count, is_gvar, iterator, + axes_old_index_tag_map, shared_indices, hb_array (), tuple_variations); diff --git a/src/test-tuple-varstore.cc b/src/test-tuple-varstore.cc index 569189677..8387d1e88 100644 --- a/src/test-tuple-varstore.cc +++ b/src/test-tuple-varstore.cc @@ -33,8 +33,13 @@ test_decompile_cvar () const OT::cvar* cvar_table = reinterpret_cast (cvar_data); unsigned point_count = 65; unsigned axis_count = 1; + + hb_tag_t axis_tag = HB_TAG ('w', 'g', 'h', 't'); + hb_map_t axis_idx_tag_map; + axis_idx_tag_map.set (0, axis_tag); + OT::TupleVariationData::tuple_variations_t tuple_variations; - bool result = cvar_table->decompile_tuple_variations (axis_count, point_count, false, tuple_variations); + bool result = cvar_table->decompile_tuple_variations (axis_count, point_count, false, &axis_idx_tag_map, tuple_variations); assert (result); assert (tuple_variations.tuple_vars.length == 2); for (unsigned i = 0; i < 2; i++) @@ -44,8 +49,8 @@ test_decompile_cvar () assert (tuple_variations.tuple_vars[i].indices.length == 65); assert (tuple_variations.tuple_vars[i].indices.length == tuple_variations.tuple_vars[i].deltas_x.length); } - assert (tuple_variations.tuple_vars[0].axis_tuples.get (0) == Triple (-1.f, -1.f, 0.f)); - assert (tuple_variations.tuple_vars[1].axis_tuples.get (0) == Triple (0.f, 1.f, 1.f)); + assert (tuple_variations.tuple_vars[0].axis_tuples.get (axis_tag) == Triple (-1.f, -1.f, 0.f)); + assert (tuple_variations.tuple_vars[1].axis_tuples.get (axis_tag) == Triple (0.f, 1.f, 1.f)); hb_vector_t deltas_1 {0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, -1.f, 0.f, -3.f, 1.f, 0.f, -1.f, 0.f, -3.f, 1.f, 0.f, -37.f, -37.f, -26.f, -26.f, 0.f, 0.f, 0.f, -3.f, 0.f, 0.f, 0.f, 0.f, 0.f, -3.f, 0.f, 2.f, -29.f, -29.f, -20.f, -20.f, 0.f, 0.f, 0.f, 1.f, -29.f, -29.f, -20.f, -20.f, 0.f, 0.f, 0.f, 1.f}; for (unsigned i = 0; i < 65; i++)