From 2ba0b9ee94e4fdea5c3e9d20fa73eb893c0bb95e Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Thu, 29 Aug 2024 11:41:28 -0700 Subject: [PATCH] Turn some byte data into unsigned char, from char Fixes https://github.com/harfbuzz/harfbuzz/issues/4844 --- src/hb-open-type.hh | 10 +++++----- src/hb-ot-var-common.hh | 20 ++++++++++---------- src/test-tuple-varstore.cc | 12 ++++++------ 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/hb-open-type.hh b/src/hb-open-type.hh index 6b3a4612a..18883d4b6 100644 --- a/src/hb-open-type.hh +++ b/src/hb-open-type.hh @@ -1496,7 +1496,7 @@ struct TupleValues }; static unsigned compile (hb_array_t values, /* IN */ - hb_array_t encoded_bytes /* OUT */) + hb_array_t encoded_bytes /* OUT */) { unsigned num_values = values.length; unsigned encoded_len = 0; @@ -1517,7 +1517,7 @@ struct TupleValues } static unsigned encode_value_run_as_zeroes (unsigned& i, - hb_array_t encoded_bytes, + hb_array_t encoded_bytes, hb_array_t values) { unsigned num_values = values.length; @@ -1546,7 +1546,7 @@ struct TupleValues } static unsigned encode_value_run_as_bytes (unsigned &i, - hb_array_t encoded_bytes, + hb_array_t encoded_bytes, hb_array_t values) { unsigned start = i; @@ -1600,7 +1600,7 @@ struct TupleValues } static unsigned encode_value_run_as_words (unsigned &i, - hb_array_t encoded_bytes, + hb_array_t encoded_bytes, hb_array_t values) { unsigned start = i; @@ -1661,7 +1661,7 @@ struct TupleValues } static unsigned encode_value_run_as_longs (unsigned &i, - hb_array_t encoded_bytes, + hb_array_t encoded_bytes, hb_array_t values) { unsigned start = i; diff --git a/src/hb-ot-var-common.hh b/src/hb-ot-var-common.hh index 92b1caa17..efbbfb25d 100644 --- a/src/hb-ot-var-common.hh +++ b/src/hb-ot-var-common.hh @@ -238,8 +238,8 @@ struct tuple_delta_t /* compiled data: header and deltas * compiled point data is saved in a hashmap within tuple_variations_t cause * some point sets might be reused by different tuple variations */ - hb_vector_t compiled_tuple_header; - hb_vector_t compiled_deltas; + hb_vector_t compiled_tuple_header; + hb_vector_t compiled_deltas; /* compiled peak coords, empty for non-gvar tuples */ hb_vector_t compiled_peak_coords; @@ -517,7 +517,7 @@ struct tuple_delta_t static bool compile_deltas (const hb_vector_t &point_indices, const hb_vector_t &x_deltas, const hb_vector_t &y_deltas, - hb_vector_t &compiled_deltas /* OUT */) + hb_vector_t &compiled_deltas /* OUT */) { hb_vector_t rounded_deltas; if (unlikely (!rounded_deltas.alloc (point_indices.length))) @@ -560,7 +560,7 @@ struct tuple_delta_t return compiled_deltas.resize (encoded_len); } - static unsigned compile_deltas (hb_array_t encoded_bytes, + static unsigned compile_deltas (hb_array_t encoded_bytes, hb_array_t deltas) { return TupleValues::compile (deltas, encoded_bytes); @@ -705,20 +705,20 @@ struct tuple_delta_t opt_indices.arrayZ[i] = false; } - hb_vector_t opt_point_data; + hb_vector_t opt_point_data; if (!compile_point_set (opt_indices, opt_point_data)) return false; - hb_vector_t opt_deltas_data; + hb_vector_t opt_deltas_data; if (!compile_deltas (opt_indices, is_comp_glyph_wo_deltas ? opt_deltas_x : deltas_x, is_comp_glyph_wo_deltas ? opt_deltas_y : deltas_y, opt_deltas_data)) return false; - hb_vector_t point_data; + hb_vector_t point_data; if (!compile_point_set (indices, point_data)) return false; - hb_vector_t deltas_data; + hb_vector_t deltas_data; if (!compile_deltas (indices, deltas_x, deltas_y, deltas_data)) return false; @@ -740,7 +740,7 @@ struct tuple_delta_t } static bool compile_point_set (const hb_vector_t &point_indices, - hb_vector_t& compiled_points /* OUT */) + hb_vector_t& compiled_points /* OUT */) { unsigned num_points = 0; for (bool i : point_indices) @@ -1134,7 +1134,7 @@ struct TupleVariationData continue; } - hb_vector_t compiled_point_data; + hb_vector_t compiled_point_data; if (!tuple_delta_t::compile_point_set (*points_set, compiled_point_data)) return false; diff --git a/src/test-tuple-varstore.cc b/src/test-tuple-varstore.cc index 16a43381b..1e07d27d3 100644 --- a/src/test-tuple-varstore.cc +++ b/src/test-tuple-varstore.cc @@ -25,7 +25,7 @@ #include "hb-ot-var-cvar-table.hh" // cvar table data from Multi-ABC.ttf -const char cvar_data[] = "\x0\x1\x0\x0\x0\x2\x0\x14\x0\x51\xa0\x0\xc0\x0\x0\x54\xa0\x0\x40\x0\x2a\x29\x17\x1\x1\x1\x1\x1\x1\x1\x1\x1\x1\x1\x1\x1\x1\x1\x1\x1\x1\x1\x1\x1\x1\x1\x1\x1\x1\x1\x1\x1\x1\x1\x1\x1\x1\x1\x1\x1\x1\x1\x1\x1\xd\xff\x0\xfd\x1\x0\xff\x0\xfd\x1\x0\xdb\xdb\xe6\xe6\x82\x0\xfd\x84\x6\xfd\x0\x2\xe3\xe3\xec\xec\x82\x4\x1\xe3\xe3\xec\xec\x82\x0\x1\x2a\x29\x17\x1\x1\x1\x1\x1\x1\x1\x1\x1\x1\x1\x1\x1\x1\x1\x1\x1\x1\x1\x1\x1\x1\x1\x1\x1\x1\x1\x1\x1\x1\x1\x1\x1\x1\x1\x1\x1\x1\x1\x1\x1\xd\x1\x0\x5\xfd\x0\x1\x0\x5\xfd\x0\x61\x61\x44\x44\x82\x0\x5\x81\x9\x1\xff\x1\x7\xff\xfb\x49\x49\x35\x35\x82\x4\xff\x49\x49\x35\x35\x82\x0\xff"; +const unsigned char cvar_data[] = "\x0\x1\x0\x0\x0\x2\x0\x14\x0\x51\xa0\x0\xc0\x0\x0\x54\xa0\x0\x40\x0\x2a\x29\x17\x1\x1\x1\x1\x1\x1\x1\x1\x1\x1\x1\x1\x1\x1\x1\x1\x1\x1\x1\x1\x1\x1\x1\x1\x1\x1\x1\x1\x1\x1\x1\x1\x1\x1\x1\x1\x1\x1\x1\x1\x1\xd\xff\x0\xfd\x1\x0\xff\x0\xfd\x1\x0\xdb\xdb\xe6\xe6\x82\x0\xfd\x84\x6\xfd\x0\x2\xe3\xe3\xec\xec\x82\x4\x1\xe3\xe3\xec\xec\x82\x0\x1\x2a\x29\x17\x1\x1\x1\x1\x1\x1\x1\x1\x1\x1\x1\x1\x1\x1\x1\x1\x1\x1\x1\x1\x1\x1\x1\x1\x1\x1\x1\x1\x1\x1\x1\x1\x1\x1\x1\x1\x1\x1\x1\x1\x1\xd\x1\x0\x5\xfd\x0\x1\x0\x5\xfd\x0\x61\x61\x44\x44\x82\x0\x5\x81\x9\x1\xff\x1\x7\xff\xfb\x49\x49\x35\x35\x82\x4\xff\x49\x49\x35\x35\x82\x0\xff"; static void test_decompile_cvar () @@ -45,7 +45,7 @@ test_decompile_cvar () const OT::TupleVariationData* tuple_var_data = reinterpret_cast (cvar_data + 4); unsigned len = sizeof (cvar_data); - hb_bytes_t var_data_bytes{cvar_data+4, len - 4}; + hb_bytes_t var_data_bytes{(const char* ) cvar_data + 4, len - 4}; bool result = OT::TupleVariationData::get_tuple_iterator (var_data_bytes, axis_count, cvar_table, shared_indices, &iterator); assert (result); @@ -131,22 +131,22 @@ test_decompile_cvar () bool res = tuple_variations.compile_bytes (axes_index_map, axis_idx_tag_map, false); 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"; + const unsigned 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.arrayZ[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"; + const unsigned 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.arrayZ[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"; + const unsigned 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.arrayZ[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"; + const unsigned 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.arrayZ[i] == compiled_deltas_2[i]); }