diff --git a/src/OT/Layout/GPOS/SinglePos.hh b/src/OT/Layout/GPOS/SinglePos.hh index 30fc1aacd..132a32a1c 100644 --- a/src/OT/Layout/GPOS/SinglePos.hh +++ b/src/OT/Layout/GPOS/SinglePos.hh @@ -13,8 +13,12 @@ struct SinglePos protected: union { struct { HBUINT16 v; } format; /* Format identifier */ - SinglePosFormat1 format1; - SinglePosFormat2 format2; + SinglePosFormat1_3 format1; + SinglePosFormat2_4 format2; +#ifndef HB_NO_BEYOND_64K + SinglePosFormat1_3 format3; + SinglePosFormat2_4 format4; +#endif } u; public: @@ -49,6 +53,13 @@ struct SinglePos if (glyph_val_iter_pairs) format = get_format (glyph_val_iter_pairs); +#ifndef HB_NO_BEYOND_64K + if (+ glyph_val_iter_pairs + | hb_map_retains_sorting (hb_first) + | hb_filter ([] (hb_codepoint_t gid) { return gid > 0xFFFFu; })) + format += 2; +#endif + u.format.v = format; switch (u.format.v) { case 1: u.format1.serialize (c, @@ -63,6 +74,20 @@ struct SinglePos new_format, layout_variation_idx_delta_map); return; +#ifndef HB_NO_BEYOND_64K + case 3: u.format3.serialize (c, + src, + glyph_val_iter_pairs, + new_format, + layout_variation_idx_delta_map); + return; + case 4: u.format4.serialize (c, + src, + glyph_val_iter_pairs, + new_format, + layout_variation_idx_delta_map); + return; +#endif default:return; } } @@ -75,6 +100,10 @@ struct SinglePos switch (u.format.v) { case 1: return_trace (c->dispatch (u.format1, std::forward (ds)...)); case 2: return_trace (c->dispatch (u.format2, std::forward (ds)...)); +#ifndef HB_NO_BEYOND_64K + case 3: return_trace (c->dispatch (u.format3, std::forward (ds)...)); + case 4: return_trace (c->dispatch (u.format4, std::forward (ds)...)); +#endif default:return_trace (c->default_return_value ()); } } diff --git a/src/OT/Layout/GPOS/SinglePosFormat1.hh b/src/OT/Layout/GPOS/SinglePosFormat1.hh index 4792a4974..bacb1a9dc 100644 --- a/src/OT/Layout/GPOS/SinglePosFormat1.hh +++ b/src/OT/Layout/GPOS/SinglePosFormat1.hh @@ -8,11 +8,12 @@ namespace OT { namespace Layout { namespace GPOS_impl { -struct SinglePosFormat1 : ValueBase +template +struct SinglePosFormat1_3 : ValueBase { protected: HBUINT16 format; /* Format identifier--format = 1 */ - Offset16To + typename Types::template OffsetTo coverage; /* Offset to Coverage table--from * beginning of subtable */ ValueFormat valueFormat; /* Defines the types of data in the @@ -21,7 +22,7 @@ struct SinglePosFormat1 : ValueBase * value(s)--applied to all glyphs in * the Coverage table */ public: - DEFINE_SIZE_ARRAY (6, values); + DEFINE_SIZE_ARRAY (4 + Types::size, values); bool sanitize (hb_sanitize_context_t *c) const { diff --git a/src/OT/Layout/GPOS/SinglePosFormat2.hh b/src/OT/Layout/GPOS/SinglePosFormat2.hh index dc92f6a52..61a420f83 100644 --- a/src/OT/Layout/GPOS/SinglePosFormat2.hh +++ b/src/OT/Layout/GPOS/SinglePosFormat2.hh @@ -7,20 +7,22 @@ namespace OT { namespace Layout { namespace GPOS_impl { -struct SinglePosFormat2 : ValueBase +template +struct SinglePosFormat2_4 : ValueBase { protected: HBUINT16 format; /* Format identifier--format = 2 */ - Offset16To + typename Types::template OffsetTo coverage; /* Offset to Coverage table--from * beginning of subtable */ ValueFormat valueFormat; /* Defines the types of data in the * ValueRecord */ - HBUINT16 valueCount; /* Number of ValueRecords */ + typename Types::HBUINT + valueCount; /* Number of ValueRecords */ ValueRecord values; /* Array of ValueRecords--positioning * values applied to glyphs */ public: - DEFINE_SIZE_ARRAY (8, values); + DEFINE_SIZE_ARRAY (4 + 2 * Types::size, values); bool sanitize (hb_sanitize_context_t *c) const { @@ -181,7 +183,7 @@ struct SinglePosFormat2 : ValueBase const hb_map_t &glyph_map = *c->plan->glyph_map; unsigned sub_length = valueFormat.get_len (); - auto values_array = values.as_array (valueCount * sub_length); + auto values_array = values.as_array ((unsigned) valueCount * sub_length); auto it = + hb_zip (this+coverage, hb_range ((unsigned) valueCount))