diff --git a/src/hb-ot-var-common.hh b/src/hb-ot-var-common.hh index 6e7eb61c6..c4317f224 100644 --- a/src/hb-ot-var-common.hh +++ b/src/hb-ot-var-common.hh @@ -1189,6 +1189,34 @@ struct TupleVariationData return res; } + void instantiate (const hb_hashmap_t& normalized_axes_location) + { + change_tuple_variations_axis_limits (&normalized_axes_location); + merge_tuple_variations (); + } + + bool compile_bytes (const hb_map_t& axes_index_map, + const hb_map_t& axes_old_index_tag_map) + { + // compile points set and store data in hashmap + if (!compile_all_point_sets ()) + return false; + // compile delta and tuple var header for each tuple variation + for (auto& tuple: tuple_vars) + { + const hb_vector_t* points_set = &(tuple.indices); + byte_data_t *points_data; + if (unlikely (!point_data_map.has (points_set, &points_data))) + return false; + + if (!tuple.compile_deltas ()) + return false; + + if (!tuple.compile_tuple_var_header (axes_index_map, points_data->length, axes_old_index_tag_map)) + return false; + } + return true; + } }; struct tuple_iterator_t diff --git a/src/test-tuple-varstore.cc b/src/test-tuple-varstore.cc index 85cccbfba..3b49928bc 100644 --- a/src/test-tuple-varstore.cc +++ b/src/test-tuple-varstore.cc @@ -110,6 +110,29 @@ test_decompile_cvar () } } + hb_map_t axes_index_map; + axes_index_map.set (0, 0); + bool res = tuple_variations.compile_bytes (axes_index_map, axis_idx_tag_map); + assert (res); + assert (tuple_variations.tuple_vars[0].compiled_tuple_header.length == 6); + const char tuple_var_header_1[] = "\x0\x51\xa0\x0\xc0\x0"; + for (unsigned i = 0; i < 6; i++) + assert(tuple_variations.tuple_vars[0].compiled_tuple_header.p[i] == tuple_var_header_1[i]); + + assert (tuple_variations.tuple_vars[1].compiled_tuple_header.length == 6); + const char tuple_var_header_2[] = "\x0\x54\xa0\x0\x40\x0"; + for (unsigned i = 0; i < 6; i++) + assert(tuple_variations.tuple_vars[1].compiled_tuple_header.p[i] == tuple_var_header_2[i]); + + assert (tuple_variations.tuple_vars[0].compiled_deltas.length == 37); + assert (tuple_variations.tuple_vars[1].compiled_deltas.length == 40); + const char compiled_deltas_1[] = "\x0d\xff\x00\xfe\x01\x00\xff\x00\xfe\x01\x00\xed\xed\xf3\xf3\x82\x00\xfe\x84\x06\xfe\x00\x01\xf1\xf1\xf6\xf6\x82\x04\x01\xf1\xf1\xf6\xf6\x82\x00\x01"; + for (unsigned i = 0; i < 37; i++) + assert (tuple_variations.tuple_vars[0].compiled_deltas.p[i] == compiled_deltas_1[i]); + + const char compiled_deltas_2[] = "\x0d\x01\x00\x04\xfe\x00\x01\x00\x04\xfe\x00\x44\x44\x30\x30\x82\x00\x04\x81\x09\x01\xff\x01\x05\xff\xfc\x33\x33\x25\x25\x82\x04\xff\x33\x33\x25\x25\x82\x00\xff"; + for (unsigned i = 0; i < 40; i++) + assert (tuple_variations.tuple_vars[1].compiled_deltas.p[i] == compiled_deltas_2[i]); } int