diff --git a/src/OT/Layout/GPOS/CursivePos.hh b/src/OT/Layout/GPOS/CursivePos.hh index 38a29dd9e..1f2d594f4 100644 --- a/src/OT/Layout/GPOS/CursivePos.hh +++ b/src/OT/Layout/GPOS/CursivePos.hh @@ -12,7 +12,10 @@ struct CursivePos protected: union { struct { HBUINT16 v; } format; /* Format identifier */ - CursivePosFormat1 format1; + CursivePosFormat1_2 format1; +#ifndef HB_NO_BEYOND_64K + CursivePosFormat1_2 format2; +#endif } u; public: @@ -23,6 +26,9 @@ struct CursivePos TRACE_DISPATCH (this, u.format.v); switch (u.format.v) { case 1: return_trace (c->dispatch (u.format1, std::forward (ds)...)); +#ifndef HB_NO_BEYOND_64K + case 2: return_trace (c->dispatch (u.format2, std::forward (ds)...)); +#endif default:return_trace (c->default_return_value ()); } } diff --git a/src/OT/Layout/GPOS/CursivePosFormat1.hh b/src/OT/Layout/GPOS/CursivePosFormat1.hh index 3e2c15d56..271511d3e 100644 --- a/src/OT/Layout/GPOS/CursivePosFormat1.hh +++ b/src/OT/Layout/GPOS/CursivePosFormat1.hh @@ -7,25 +7,29 @@ namespace OT { namespace Layout { namespace GPOS_impl { +template +struct CursivePosFormat1_2; + +template struct EntryExitRecord { - friend struct CursivePosFormat1; + template friend struct CursivePosFormat1_2; - bool sanitize (hb_sanitize_context_t *c, const struct CursivePosFormat1 *base) const + bool sanitize (hb_sanitize_context_t *c, const struct CursivePosFormat1_2 *base) const { TRACE_SANITIZE (this); return_trace (entryAnchor.sanitize (c, base) && exitAnchor.sanitize (c, base)); } void collect_variation_indices (hb_collect_variation_indices_context_t *c, - const struct CursivePosFormat1 *src_base) const + const struct CursivePosFormat1_2 *src_base) const { (src_base+entryAnchor).collect_variation_indices (c); (src_base+exitAnchor).collect_variation_indices (c); } bool subset (hb_subset_context_t *c, - const struct CursivePosFormat1 *src_base) const + const struct CursivePosFormat1_2 *src_base) const { TRACE_SERIALIZE (this); auto *out = c->serializer->embed (this); @@ -38,16 +42,16 @@ struct EntryExitRecord } protected: - Offset16To + typename Types::template OffsetTo> entryAnchor; /* Offset to EntryAnchor table--from * beginning of CursivePos * subtable--may be NULL */ - Offset16To + typename Types::template OffsetTo> exitAnchor; /* Offset to ExitAnchor table--from * beginning of CursivePos * subtable--may be NULL */ public: - DEFINE_SIZE_STATIC (4); + DEFINE_SIZE_STATIC (2 * Types::size); }; static inline void @@ -91,18 +95,19 @@ reverse_cursive_minor_offset (hb_glyph_position_t *pos, } -struct CursivePosFormat1 +template +struct CursivePosFormat1_2 { + protected: HBUINT16 format; /* Format identifier--format = 1 */ - Offset16To - coverage; /* Offset to Coverage table--from - * beginning of subtable */ - Array16Of + typename Types::template LOffsetTo + coverage; /* Offset to Coverage table--from beginning of subtable */ + typename Types::template ArrayOf> entryExitRecord; /* Array of EntryExit records--in * Coverage Index order */ public: - DEFINE_SIZE_ARRAY (6, entryExitRecord); + DEFINE_SIZE_ARRAY (2 + Types::LOffset::static_size + Types::HBUINT::static_size, entryExitRecord); bool sanitize (hb_sanitize_context_t *c) const { @@ -126,7 +131,7 @@ struct CursivePosFormat1 + hb_zip (this+coverage, entryExitRecord) | hb_filter (c->glyph_set, hb_first) | hb_map (hb_second) - | hb_apply ([&] (const EntryExitRecord& record) { record.collect_variation_indices (c, this); }) + | hb_apply ([&] (const EntryExitRecord& record) { record.collect_variation_indices (c, this); }) ; } @@ -140,7 +145,7 @@ struct CursivePosFormat1 TRACE_APPLY (this); hb_buffer_t *buffer = c->buffer; - const EntryExitRecord &this_record = entryExitRecord[(this+coverage).get_coverage (buffer->cur().codepoint)]; + const EntryExitRecord &this_record = entryExitRecord[(this+coverage).get_coverage (buffer->cur().codepoint)]; if (!this_record.entryAnchor || unlikely (!this_record.entryAnchor.sanitize (&c->sanitizer, this))) return_trace (false); hb_barrier (); @@ -154,7 +159,7 @@ struct CursivePosFormat1 return_trace (false); } - const EntryExitRecord &prev_record = entryExitRecord[(this+coverage).get_coverage (buffer->info[skippy_iter.idx].codepoint)]; + const EntryExitRecord &prev_record = entryExitRecord[(this+coverage).get_coverage (buffer->info[skippy_iter.idx].codepoint)]; if (!prev_record.exitAnchor || unlikely (!prev_record.exitAnchor.sanitize (&c->sanitizer, this))) { @@ -285,14 +290,14 @@ struct CursivePosFormat1 hb_requires (hb_is_iterator (Iterator))> void serialize (hb_subset_context_t *c, Iterator it, - const struct CursivePosFormat1 *src_base) + const struct CursivePosFormat1_2 *src_base) { if (unlikely (!c->serializer->extend_min ((*this)))) return; this->format = 1; this->entryExitRecord.len = it.len (); - for (const EntryExitRecord& entry_record : + it - | hb_map (hb_second)) + for (const EntryExitRecord& entry_record : + it + | hb_map (hb_second)) entry_record.subset (c, src_base); auto glyphs = @@ -311,12 +316,13 @@ struct CursivePosFormat1 auto *out = c->serializer->start_embed (*this); - auto it = - + hb_zip (this+coverage, entryExitRecord) - | hb_filter (glyphset, hb_first) - | hb_map_retains_sorting ([&] (hb_pair_t p) -> hb_pair_t - { return hb_pair (glyph_map[p.first], p.second);}) - ; + auto it = + + hb_zip (this+coverage, entryExitRecord) + | hb_filter (glyphset, hb_first) + | hb_map_retains_sorting ([&] (hb_pair_t&> p) + -> hb_pair_t&> + { return hb_pair (glyph_map[p.first], p.second);}) + ; bool ret = bool (it); out->serialize (c, it, this); diff --git a/src/OT/Layout/types.hh b/src/OT/Layout/types.hh index 5cf9eb368..299c09457 100644 --- a/src/OT/Layout/types.hh +++ b/src/OT/Layout/types.hh @@ -44,8 +44,11 @@ struct SmallTypes { using HBUINT = HBUINT16; using HBGlyphID = HBGlyphID16; using Offset = Offset16; + using LOffset = Offset16; template using OffsetTo = OT::Offset16To; + template + using LOffsetTo = OT::Offset16To; template using ArrayOf = OT::Array16Of; template @@ -58,8 +61,12 @@ struct MediumTypes { using HBUINT = HBUINT24; using HBGlyphID = HBGlyphID24; using Offset = Offset24; + /* Long offsets for large tables. */ + using LOffset = Offset32; template using OffsetTo = OT::Offset24To; + template + using LOffsetTo = OT::Offset32To; template using ArrayOf = OT::Array24Of; template