diff --git a/src/hb-cff-interp-common.hh b/src/hb-cff-interp-common.hh index aacd1cd74..49ba85886 100644 --- a/src/hb-cff-interp-common.hh +++ b/src/hb-cff-interp-common.hh @@ -244,8 +244,10 @@ struct number_t void set_real (double v) { value = v; } double to_real () const { return value; } - bool in_int_range () const + bool in_int16_range () const { return value >= INT16_MIN && value <= INT16_MAX && (double) (int16_t) value == value; } + bool in_int32_range () const + { return value >= INT32_MIN && value <= INT32_MAX && (double) (int32_t) value == value; } bool operator > (const number_t &n) const { return value > n.to_real (); } bool operator < (const number_t &n) const { return n > *this; } @@ -481,9 +483,12 @@ struct arg_stack_t : cff_stack_t return (unsigned) i; } + static int parse_longint (uint8_t a, uint8_t b, uint8_t c, uint8_t d) + { return (int) ((uint32_t (a) << 24) | (b << 16) | (c << 8) | d); } + void push_longint_from_substr (byte_str_ref_t& str_ref) { - push_int ((int) ((uint32_t (str_ref[0]) << 24) | (str_ref[1] << 16) | (str_ref[2] << 8) | (str_ref[3]))); + push_int (parse_longint (str_ref[0], str_ref[1], str_ref[2], str_ref[3])); str_ref.inc (4); } @@ -617,37 +622,52 @@ using num_interp_env_t = interp_env_t<>; template struct opset_t { +private: + static constexpr int one_byte_bias = (OpCode_OneByteIntFirst + OpCode_OneByteIntLast) / 2; + static constexpr int two_byte_base = OpCode_OneByteIntLast - one_byte_bias + 1; + static_assert (one_byte_bias == 139, "CFF one-byte range centers on 139"); + static_assert (two_byte_base == 108, "CFF two-byte range starts at 108"); + +public: + static bool is_one_byte_integer (op_code_t op) + { return (OpCode_OneByteIntFirst <= op) && (op <= OpCode_OneByteIntLast); } + static int parse_one_byte_integer (op_code_t op) { return (int)op - one_byte_bias; } + + static bool is_two_bytes_positive_integer (op_code_t op) + { return OpCode_TwoBytePosInt0 <= op && op <= OpCode_TwoBytePosInt3; } + static int parse_two_bytes_positive_integer (op_code_t op, uint8_t b) + { return (int16_t)(op - OpCode_TwoBytePosInt0) * 256 + b + two_byte_base; } + + static bool is_two_bytes_negative_integer (op_code_t op) + { return OpCode_TwoByteNegInt0 <= op && op <= OpCode_TwoByteNegInt3; } + static int parse_two_bytes_negative_integer (op_code_t op, uint8_t b) + { return -(int16_t)(op - OpCode_TwoByteNegInt0) * 256 - b - two_byte_base; } + + static bool is_shortint(op_code_t op) { return op == OpCode_shortint; } + static int parse_shortint (uint8_t a, uint8_t b) { return (int16_t) ((a << 8) | b); } + static void process_op (op_code_t op, interp_env_t& env) { - switch (op) { - case OpCode_shortint: - env.argStack.push_int ((int16_t)((env.str_ref[0] << 8) | env.str_ref[1])); - env.str_ref.inc (2); - break; - - case OpCode_TwoBytePosInt0: case OpCode_TwoBytePosInt1: - case OpCode_TwoBytePosInt2: case OpCode_TwoBytePosInt3: - env.argStack.push_int ((int16_t)((op - OpCode_TwoBytePosInt0) * 256 + env.str_ref[0] + 108)); - env.str_ref.inc (); - break; - - case OpCode_TwoByteNegInt0: case OpCode_TwoByteNegInt1: - case OpCode_TwoByteNegInt2: case OpCode_TwoByteNegInt3: - env.argStack.push_int ((-(int16_t)(op - OpCode_TwoByteNegInt0) * 256 - env.str_ref[0] - 108)); - env.str_ref.inc (); - break; - - default: - /* 1-byte integer */ - if (likely ((OpCode_OneByteIntFirst <= op) && (op <= OpCode_OneByteIntLast))) - { - env.argStack.push_int ((int)op - 139); - } else { - /* invalid unknown operator */ - env.clear_args (); - } - break; + if (is_one_byte_integer (op)) + env.argStack.push_int (parse_one_byte_integer (op)); + else if (is_two_bytes_positive_integer (op)) + { + env.argStack.push_int (parse_two_bytes_positive_integer (op, env.str_ref[0])); + env.str_ref.inc (); } + else if (is_two_bytes_negative_integer (op)) + { + env.argStack.push_int (parse_two_bytes_negative_integer (op, env.str_ref[0])); + env.str_ref.inc (); + } + else if (is_shortint (op)) + { + env.argStack.push_int (parse_shortint (env.str_ref[0], env.str_ref[1])); + env.str_ref.inc (2); + } + else + /* invalid unknown operator */ + env.clear_args (); } }; diff --git a/src/hb-subset-cff-common.hh b/src/hb-subset-cff-common.hh index 2fd8d9489..5f355a2f9 100644 --- a/src/hb-subset-cff-common.hh +++ b/src/hb-subset-cff-common.hh @@ -94,28 +94,32 @@ struct str_encoder_t // Encode number for CharString void encode_num_cs (const number_t& n) { - if (n.in_int_range ()) - { + if (n.in_int16_range ()) encode_int (n.to_int ()); - } else { - int32_t v = n.to_fixed (); encode_byte (OpCode_fixedcs); - encode_byte ((v >> 24) & 0xFF); - encode_byte ((v >> 16) & 0xFF); - encode_byte ((v >> 8) & 0xFF); - encode_byte (v & 0xFF); + encode_int32_payload (n.to_fixed ()); } } + void encode_int32_payload (int32_t v) + { + encode_byte ((v >> 24) & 0xFF); + encode_byte ((v >> 16) & 0xFF); + encode_byte ((v >> 8) & 0xFF); + encode_byte (v & 0xFF); + } + // Encode number for TopDict / Private void encode_num_tp (const number_t& n) { - if (n.in_int_range ()) - { - // TODO longint + if (n.in_int16_range ()) encode_int (n.to_int ()); + else if (n.in_int32_range ()) + { + encode_byte (OpCode_longintdict); + encode_int32_payload (n.to_int ()); } else { @@ -201,7 +205,8 @@ struct str_encoder_t memmove (s + sign, s2, len); snprintf (s + sign + len, sizeof (buf) - (s + sign + len - buf), "E-%u", (unsigned) (strlen (s + sign) - 1)); } - hb_vector_t nibbles; + /* Nibble capacity must cover widest %.8G output plus END and pad */ + nibble_buffer_t nibbles; while (*s) { char c = s[0]; @@ -237,20 +242,11 @@ struct str_encoder_t nibbles.push (c - '0'); } - nibbles.push (0x0F); - if (nibbles.length % 2) - nibbles.push (0x0F); - if (unlikely (nibbles.in_error ())) - { - buff.set_error (); - return; - } + hb_ubytes_t bytes = nibbles.commit (); + if (unlikely (bytes.length == 0)) { buff.set_error (); return; } encode_byte (OpCode_BCD); - - unsigned count = nibbles.length; - for (unsigned i = 0; i < count; i += 2) - encode_byte ((nibbles[i] << 4) | nibbles[i+1]); + copy_str (bytes); } } @@ -265,18 +261,43 @@ struct str_encoder_t encode_byte (op); } - void copy_str (const unsigned char *str, unsigned length) + void copy_str (const hb_ubytes_t str) { - assert ((signed) (buff.length + length) <= buff.allocated); - hb_memcpy (buff.arrayZ + buff.length, str, length); - buff.length += length; + unsigned buff_tip = buff.length; + if (likely (buff.resize_dirty (buff_tip + str.length))) + hb_memcpy (buff.arrayZ + buff_tip, str, str.length); + else buff.ensure_error (); } bool in_error () const { return buff.in_error (); } - protected: - +protected: str_buff_t &buff; +private: + template + struct nibble_buffer_t + { + static_assert (0 < size && size < 64, ""); + void push (uint8_t nibble) + { + if (unlikely (in_error || nibble_count >= size)) { in_error = true; return; } + if (!(nibble_count & 1)) + bytes[nibble_count >> 1] = nibble << 4; + else + bytes[nibble_count >> 1] |= nibble; + nibble_count++; + } + hb_ubytes_t commit () + { + push (0x0F); + if (nibble_count & 1) push (0x0F); + return unlikely (in_error) ? hb_ubytes_t () : hb_ubytes_t (bytes, nibble_count >> 1); + } + private: + bool in_error = false; + uint8_t bytes[(size + 1) / 2]; + unsigned nibble_count = 0; + }; }; struct cff_sub_table_info_t { @@ -1294,16 +1315,16 @@ struct subr_subsetter_t { case OpCode_callsubr: encoder.encode_int (remaps.local_remaps[fd].biased_num (opstr.subr_num)); - encoder.copy_str (opstr.ptr, opstr.length); + encoder.copy_str (hb_ubytes_t (opstr.ptr, opstr.length)); break; case OpCode_callgsubr: encoder.encode_int (remaps.global_remap.biased_num (opstr.subr_num)); - encoder.copy_str (opstr.ptr, opstr.length); + encoder.copy_str (hb_ubytes_t (opstr.ptr, opstr.length)); break; default: - encoder.copy_str (opstr.ptr, opstr.length); + encoder.copy_str (hb_ubytes_t (opstr.ptr, opstr.length)); break; } } diff --git a/src/test-cff.cc b/src/test-cff.cc index 06ae9fcc3..16e5e90fc 100644 --- a/src/test-cff.cc +++ b/src/test-cff.cc @@ -28,6 +28,7 @@ #include "hb-subset-cff-common.hh" #include "hb-cff-specializer.hh" #include "hb-cff-interp-dict-common.hh" +#include "hb-cff-interp-common.hh" static void test_specialized_line_geometry () @@ -179,6 +180,137 @@ test_index_count_limits () } } +static void +test_roundtrip_parse_encode_num_tp () +{ + CFF::str_buff_t buff; + CFF::str_encoder_t encoder (buff); + CFF::number_t number; + struct num_tp_test { + double input; + unsigned length; + unsigned char output[8]; + }; + struct num_tp_test num_tp_tests[] = { + { -9.399999999999999, 4, { OpCode_BCD, 0xE9, 0xA4, 0xFF } }, // -9.4 + { 9.399999999999999999, 3, { OpCode_BCD, 0x9A, 0x4F } }, // 9.4 + { 456.8, 4, { OpCode_BCD, 0x45, 0x6A, 0x8F } }, // 456.8 + { 98765.37e2, 5, { OpCode_longintdict, 0x00, 0x96, 0xB4, 0x39 } }, // 9876537 + { 1234567890.0, 5, { OpCode_longintdict, 0x49, 0x96, 0x02, 0xD2 } }, // 1234567900 + { 1234567900.0, 5, { OpCode_longintdict, 0x49, 0x96, 0x02, 0xDC } }, // 1234567900 + { 9.876537e-4, 7, { OpCode_BCD, 0x98, 0x76, 0x53, 0x7C, 0x10, 0xFF } }, // 9876537E-10 + { 9.876537e4, 6, { OpCode_BCD, 0x98, 0x76, 0x5A, 0x37, 0xFF } }, // 98765.37 + { 1e8, 5, { OpCode_longintdict, 0x05, 0xF5, 0xE1, 0x00 } }, // 100000000 + { 1e-5, 3, { OpCode_BCD, 0x1C, 0x5F } }, // 1E-5 + { 1.2e8, 5, { OpCode_longintdict, 0x07, 0x27, 0x0E, 0x00 } }, // 120000000 + { 1.2345e-5, 5, { OpCode_BCD, 0x12, 0x34, 0x5C, 0x9F } }, // 12345E-9 + { 9.0987654e8, 5, { OpCode_longintdict, 0x36, 0x3B, 0x9D, 0x3C } }, // 909876540 + { 0.1, 3, { OpCode_BCD, 0xA1, 0xFF } }, // .1 + { -0.1, 3, { OpCode_BCD, 0xEA, 0x1F } }, // -.1 + { 0.01, 3, { OpCode_BCD, 0x1C, 0x2F } }, // 1E-2 + { -0.01, 4, { OpCode_BCD, 0xE1, 0xC2, 0xFF } }, // -1E-2 + { 0.0123, 4, { OpCode_BCD, 0x12, 0x3C, 0x4F } }, // 123E-4 + { -0.0123, 5, { OpCode_BCD, 0xE1, 0x23, 0xC4, 0xFF } }, // -123E-4 + { 0.0012, 4, { OpCode_BCD, 0x12, 0xC4, 0xFF } }, // 12E-4 + { 1.23e-5, 4, { OpCode_BCD, 0x12, 0x3C, 0x7F } }, // 123E-7 + { 123456780.0, 5, { OpCode_longintdict, 0x07, 0x5B, 0xCD, 0x0C } }, // 123456780 + { 0.000123, 4, { OpCode_BCD, 0x12, 0x3C, 0x6F } }, // 123E-6 + { -0.000123, 5, { OpCode_BCD, 0xE1, 0x23, 0xC6, 0xFF } }, // -123E-6 + { 123000.00001, 4, { OpCode_BCD, 0x12, 0x3B, 0x3F } }, + { 12340000.0, 5, { OpCode_longintdict, 0x00, 0xBC, 0x4B, 0x20 } }, // 12340000 + { 1000000.0, 5, { OpCode_longintdict, 0x00, 0x0F, 0x42, 0x40 } }, // 1000000 + { 5000.0, 3, { OpCode_shortint, 0x13, 0x88 } }, // 5000 + { 0.0, 1, { 0x8B } }, + { -0.0, 1, { 0x8B } }, + { 107.0, 1, { 0xF6 } }, // max positive one-byte + { -107.0, 1, { 0x20 } }, // min negative one-byte + + { -2000.0, 3, { OpCode_shortint, 0xF8, 0x30 } }, + { -32767.0, 3, { OpCode_shortint, 0x80, 0x01 } }, + { -2147483647.0, 5, { OpCode_longintdict, 0x80, 0x00, 0x00, 0x01 } }, + + { 108.0, 2, { OpCode_TwoBytePosInt0, 0x00 } }, // min two-byte negative + { 364.0, 2, { OpCode_TwoBytePosInt1, 0x00 } }, // 364 (first Int1) + { 620.0, 2, { OpCode_TwoBytePosInt2, 0x00 } }, // 620 (first Int2) + { 876.0, 2, { OpCode_TwoBytePosInt3, 0x00 } }, // 876 (first Int3) + { 1131.0, 2, { OpCode_TwoBytePosInt3, 0xFF } }, // 1131 (max) + + /* Two-byte negative: symmetric coverage. */ + { -108.0, 2, { OpCode_TwoByteNegInt0, 0x00 } }, + { -364.0, 2, { OpCode_TwoByteNegInt1, 0x00 } }, + { -620.0, 2, { OpCode_TwoByteNegInt2, 0x00 } }, + { -876.0, 2, { OpCode_TwoByteNegInt3, 0x00 } }, + { -1131.0, 2, { OpCode_TwoByteNegInt3, 0xFF } }, + + { 1132.0, 3, { OpCode_shortint, 0x04, 0x6C } }, // 1132 = 0x046C + { -1132.0, 3, { OpCode_shortint, 0xFB, 0x94 } }, // -1132 = 0xFB94 + { 32767.0, 3, { OpCode_shortint, 0x7F, 0xFF } }, // INT16_MAX + { -32768.0, 3, { OpCode_shortint, 0x80, 0x00 } }, // INT16_MIN + + { 32768.0, 5, { OpCode_longintdict, 0x00, 0x00, 0x80, 0x00 } }, // INT16_MAX + 1 + { 100000.0, 5, { OpCode_longintdict, 0x00, 0x01, 0x86, 0xA0 } }, // spec Table 4 + { -100000.0, 5, { OpCode_longintdict, 0xFF, 0xFE, 0x79, 0x60 } }, // spec Table 4 + { 2147483647.0, 5, { OpCode_longintdict, 0x7F, 0xFF, 0xFF, 0xFF } }, // INT32_MAX + { -2147483648.0, 5, { OpCode_longintdict, 0x80, 0x00, 0x00, 0x00 } }, // INT32_MIN + + { -4.9406565e-324, 8, { OpCode_BCD, 0xE4, 0x94, 0x06, 0x56, 0x5C, 0x33, 0x1F } }, + { 1.7976931348623157e308, 8, { OpCode_BCD, 0x17, 0x97, 0x69, 0x31, 0xB3, 0x01, 0xFF } }, // DBL_MAX + { -1.7976931348623157e308, 8, { OpCode_BCD, 0xE1, 0x79, 0x76, 0x93, 0x1B, 0x30, 0x1F } }, // -DBL_MAX + { 2.2250738585072014e-308, 8, { OpCode_BCD, 0x22, 0x25, 0x07, 0x39, 0xC3, 0x15, 0xFF } }, // DBL_MIN + { 4.9406564584124654e-324, 8, { OpCode_BCD, 0x49, 0x40, 0x65, 0x65, 0xC3, 0x31, 0xFF } }, // DBL_TRUE_MIN positive + { 1e200, 4, { OpCode_BCD, 0x1B, 0x20, 0x0F } }, // 1E+200 + { 1e-200, 4, { OpCode_BCD, 0x1C, 0x20, 0x0F } }, // 1E-200 + { 1e300, 4, { OpCode_BCD, 0x1B, 0x30, 0x0F } }, // 1E+300 + { 1e-300, 4, { OpCode_BCD, 0x1C, 0x30, 0x0F } }, // 1E-300 + { 1e-320, 8, { OpCode_BCD, 0x99, 0x99, 0x88, 0x87, 0xC3, 0x28, 0xFF } }, // 9.9998887E-321 + }; + for (auto &num_tp_test : num_tp_tests) + { + number.set_real (num_tp_test.input); + encoder.encode_num_tp (number); + hb_always_assert (buff.length == num_tp_test.length); + for (unsigned i = 0; i < buff.length; i++) + hb_always_assert (buff[i] == num_tp_test.output[i]); + using opset_t = CFF::cff1_font_dict_opset_t::opset_t; + if (opset_t::is_one_byte_integer (buff[0])) + { + hb_always_assert (buff.length == 1); + hb_always_assert (opset_t::parse_one_byte_integer (buff[0]) == (int) num_tp_test.input); + } + else if (opset_t::is_two_bytes_positive_integer (buff[0])) + { + hb_always_assert (buff.length == 2); + hb_always_assert (opset_t::parse_two_bytes_positive_integer (buff[0], buff[1]) == (int) num_tp_test.input); + } + else if (opset_t::is_two_bytes_negative_integer (buff[0])) + { + hb_always_assert (buff.length == 2); + hb_always_assert (opset_t::parse_two_bytes_negative_integer (buff[0], buff[1]) == (int) num_tp_test.input); + } + else if (opset_t::is_shortint (buff[0])) + { + hb_always_assert (buff.length == 3); + hb_always_assert (opset_t::parse_shortint (buff[1], buff[2]) == (int) num_tp_test.input); + } + else if (buff[0] == OpCode_longintdict) + { + hb_always_assert (buff.length == 5); + hb_always_assert (CFF::arg_stack_t<>::parse_longint (buff[1], buff[2], buff[3], buff[4]) == (int) num_tp_test.input); + } + else if (buff[0] == OpCode_BCD) + { + hb_always_assert (buff.length > 1); + hb_ubytes_t bytes (buff.arrayZ + 1, buff.length - 1); + CFF::byte_str_ref_t str_ref (bytes); + double parsed = CFF::dict_opset_t::parse_bcd (str_ref); + bool almost_equal = fabs (parsed - num_tp_test.input) <= fabs (num_tp_test.input) * 1e-7; + hb_always_assert (almost_equal); + } + else hb_always_assert (false); /* Unsupported opcode */ + encoder.reset (); + } +} + int main (int argc, char **argv) { @@ -188,65 +320,7 @@ main (int argc, char **argv) test_charset1_splits_long_ranges (); test_fd_select_sentinel (); test_fd_select_sentinel (); - - /* Test encode_num_tp */ - { - CFF::str_buff_t buff; - CFF::str_encoder_t encoder (buff); - CFF::number_t number; - struct num_tp_test { - double input; - unsigned length; - unsigned char output[7]; - }; - struct num_tp_test num_tp_tests[] = { - { -9.399999999999999, 4, { 0x1E, 0xE9, 0xA4, 0xFF } }, // -9.4 - { 9.399999999999999999, 3, { 0x1E, 0x9A, 0x4F } }, // 9.4 - { 456.8, 4, { 0x1E, 0x45, 0x6A, 0x8F } }, // 456.8 - { 98765.37e2, 5, { 0x1E, 0x98, 0x76, 0x53, 0x7F } }, // 9876537 - { 1234567890.0, 7, { 0x1E, 0x12, 0x34, 0x56, 0x79, 0xB2, 0xFF } }, // 12345679E2 (rounded) - { 1234567900.0, 7, { 0x1E, 0x12, 0x34, 0x56, 0x79, 0xB2, 0xFF } }, // 12345679E2 - { 9.876537e-4, 7, { 0x1E, 0x98, 0x76, 0x53, 0x7C, 0x10, 0xFF } }, // 9876537E-10 - { 9.876537e4, 6, { 0x1E, 0x98, 0x76, 0x5A, 0x37, 0xFF } }, // 98765.37 - { 1e8, 3, { 0x1E, 0x1B, 0x8F } }, // 1E8 - { 1e-5, 3, { 0x1E, 0x1C, 0x5F } }, // 1E-5 - { 1.2e8, 4, { 0x1E, 0x12, 0xB7, 0xFF } }, // 12E7 - { 1.2345e-5, 5, { 0x1E, 0x12, 0x34, 0x5C, 0x9F } }, // 12345E-9 - { 9.0987654e8, 6, { 0x1E, 0x90, 0x98, 0x76, 0x54, 0x0F } }, // 909876540 - { 0.1, 3, { 0x1E, 0xA1, 0xFF } }, // .1 - { -0.1, 3, { 0x1E, 0xEA, 0x1F } }, // -.1 - { 0.01, 3, { 0x1E, 0x1C, 0x2F } }, // 1E-2 - { -0.01, 4, { 0x1E, 0xE1, 0xC2, 0xFF } }, // -1E-2 - { 0.0123, 4, { 0x1E, 0x12, 0x3C, 0x4F } }, // 123E-4 - { -0.0123, 5, { 0x1E, 0xE1, 0x23, 0xC4, 0xFF } }, // -123E-4 - { 0.0012, 4, { 0x1E, 0x12, 0xC4, 0xFF } }, - { 1.23e-5, 4, { 0x1E, 0x12, 0x3C, 0x7F } }, // 123E-7 - { 123456780.0, 6, { 0x1E, 0x12, 0x34, 0x56, 0x78, 0x0F } }, // 123456780 - { 0.000123, 4, { 0x1E, 0x12, 0x3C, 0x6F } }, // 123E-6 - { -0.000123, 5, { 0x1E, 0xE1, 0x23, 0xC6, 0xFF } }, // -123E-6 - /* Test cases for trailing zeros fix */ - { 5000.0, 3, { 0x1C, 0x13, 0x88 } }, // 5000 - { 12340000.0, 5, { 0x1E, 0x12, 0x34, 0xB4, 0xFF } }, // 1234E4 - { 1000000.0, 3, { 0x1E, 0x1B, 0x6F } }, // 1E6 - }; - for (auto &num_tp_test : num_tp_tests) - { - number.set_real (num_tp_test.input); - encoder.encode_num_tp (number); - hb_always_assert (buff.length == num_tp_test.length); - for (unsigned i = 0; i < buff.length; i++) - hb_always_assert (buff[i] == num_tp_test.output[i]); - if (buff.length > 1 && buff[0] == 0x1E) /* OpCode_BCD = 30 = 0x1E */ - { - hb_ubytes_t bytes (buff.arrayZ + 1, buff.length - 1); - CFF::byte_str_ref_t str_ref (bytes); - double parsed = CFF::dict_opset_t::parse_bcd (str_ref); - bool almost_equal = fabs (parsed - num_tp_test.input) <= fabs (num_tp_test.input) * 1e-7; - hb_always_assert (almost_equal); - } - encoder.reset (); - } - } + test_roundtrip_parse_encode_num_tp (); return 0; } diff --git a/test/api/test-subset-cff2.c b/test/api/test-subset-cff2.c index af739e3ac..1b6a3cd2e 100644 --- a/test/api/test-subset-cff2.c +++ b/test/api/test-subset-cff2.c @@ -270,9 +270,11 @@ test_subset_cff2_pinned_private_blend_overflow (void) * Private DICT blends directly without a partial instancer and must clamp * out-of-range rounded values to INT_MAX instead of invoking float-to-int UB * (which produces x86 integer indefinite INT_MIN 0x80000000 in release builds). */ - /* CFF BCD encoding of +2.1474836E9 (clamped INT_MAX) + OpCode_StdVW (0x0b), - * vs negative -2.1474836E9 (0x1e 0xe2 ...) from unpatched float-to-int UB. */ - static const unsigned char clamped_int_max[8] = {0x1e, 0x21, 0x47, 0x48, 0x36, 0xb2, 0xff, 0x0b}; + /* CFF2 longint encoding of +2147483647 (clamped INT_MAX), followed by + * OpCode_StdVW (0x0b), vs. the longint encoding of -2147483648 that + * unpatched float-to-int UB produces on x86 (which casts the 1e12 blend + * result to INT_MIN 0x80000000). */ + static const unsigned char clamped_int_max[6] = {0x1d, 0x7f, 0xff, 0xff, 0xff, 0x0b}; static const unsigned char indef_int_min[6] = {0x1e, 0xe2, 0x14, 0x74, 0x83, 0x6b}; hb_face_t *face = hb_test_open_font_file ("fonts/AdobeVFPrototype.abc.huge-blend.otf"); const hb_subset_flags_t modes[] = {