diff options
Diffstat (limited to 'Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-layout-gpos-table.hh')
-rw-r--r-- | Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-layout-gpos-table.hh | 175 |
1 files changed, 114 insertions, 61 deletions
diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-layout-gpos-table.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-layout-gpos-table.hh index 7d57056d135..73107f490b5 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-layout-gpos-table.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-layout-gpos-table.hh @@ -238,8 +238,8 @@ struct ValueFormat : HBUINT16 template<typename Iterator> static inline void SinglePos_serialize (hb_serialize_context_t *c, - Iterator it, - ValueFormat valFormat); + Iterator it, + ValueFormat valFormat); struct AnchorFormat1 @@ -257,6 +257,12 @@ struct AnchorFormat1 TRACE_SANITIZE (this); return_trace (c->check_struct (this)); } + + AnchorFormat1* copy (hb_serialize_context_t *c) const + { + TRACE_SERIALIZE (this); + return_trace (c->embed<AnchorFormat1> (this)); + } protected: HBUINT16 format; /* Format identifier--format = 1 */ @@ -296,6 +302,12 @@ struct AnchorFormat2 return_trace (c->check_struct (this)); } + AnchorFormat2* copy (hb_serialize_context_t *c) const + { + TRACE_SERIALIZE (this); + return_trace (c->embed<AnchorFormat2> (this)); + } + protected: HBUINT16 format; /* Format identifier--format = 2 */ FWORD xCoordinate; /* Horizontal value--in design units */ @@ -326,6 +338,17 @@ struct AnchorFormat3 return_trace (c->check_struct (this) && xDeviceTable.sanitize (c, this) && yDeviceTable.sanitize (c, this)); } + AnchorFormat3* copy (hb_serialize_context_t *c) const + { + TRACE_SERIALIZE (this); + auto *out = c->embed<AnchorFormat3> (this); + if (unlikely (!out)) return_trace (nullptr); + + out->xDeviceTable.serialize_copy (c, xDeviceTable, this, out); + out->yDeviceTable.serialize_copy (c, yDeviceTable, this, out); + return_trace (out); + } + protected: HBUINT16 format; /* Format identifier--format = 3 */ FWORD xCoordinate; /* Horizontal value--in design units */ @@ -368,6 +391,17 @@ struct Anchor } } + Anchor* copy (hb_serialize_context_t *c) const + { + TRACE_SERIALIZE (this); + switch (u.format) { + case 1: return_trace (reinterpret_cast<Anchor *> (u.format1.copy (c))); + case 2: return_trace (reinterpret_cast<Anchor *> (u.format2.copy (c))); + case 3: return_trace (reinterpret_cast<Anchor *> (u.format3.copy (c))); + default:return_trace (nullptr); + } + } + protected: union { HBUINT16 format; /* Format identifier */ @@ -510,14 +544,8 @@ struct SinglePosFormat1 if (unlikely (!c->extend_min (*this))) return; if (unlikely (!c->check_assign (valueFormat, valFormat))) return; - auto vals = hb_second (*it); - - + vals - | hb_apply ([=] (const Value& _) - { - c->copy (_); - }) - ; + for (const auto &_ : hb_second (*it)) + c->copy (_); auto glyphs = + it @@ -533,15 +561,11 @@ struct SinglePosFormat1 const hb_set_t &glyphset = *c->plan->glyphset_gsub (); const hb_map_t &glyph_map = *c->plan->glyph_map; - unsigned length = valueFormat.get_len (); - auto it = + hb_iter (this+coverage) | hb_filter (glyphset) - | hb_map_retains_sorting ([&] (hb_codepoint_t p) - { - return hb_pair (glyph_map[p], values.as_array (length)); - }) + | hb_map_retains_sorting (glyph_map) + | hb_zip (hb_repeat (values.as_array (valueFormat.get_len ()))) ; bool ret = bool (it); @@ -602,30 +626,21 @@ struct SinglePosFormat2 hb_requires (hb_is_iterator (Iterator))> void serialize (hb_serialize_context_t *c, Iterator it, - ValueFormat valFormat) + ValueFormat valFormat) { if (unlikely (!c->extend_min (*this))) return; if (unlikely (!c->check_assign (valueFormat, valFormat))) return; if (unlikely (!c->check_assign (valueCount, it.len ()))) return; - - + it - | hb_map (hb_second) - | hb_apply ([=] (hb_array_t<const Value> val_iter) - { - + val_iter - | hb_apply ([=] (const Value& _) - { - c->copy (_); - }) - ; - }) - ; + + for (const auto iter : it) + for (const auto &_ : iter.second) + c->copy (_); auto glyphs = + it | hb_map_retains_sorting (hb_first) ; - + coverage.serialize (c, this).serialize (c, glyphs); } @@ -636,15 +651,17 @@ struct SinglePosFormat2 const hb_map_t &glyph_map = *c->plan->glyph_map; unsigned sub_length = valueFormat.get_len (); - unsigned total_length = (unsigned)valueCount * sub_length; + auto values_array = values.as_array (valueCount * sub_length); auto it = + hb_zip (this+coverage, hb_range ((unsigned) valueCount)) | hb_filter (glyphset, hb_first) | hb_map_retains_sorting ([&] (const hb_pair_t<hb_codepoint_t, unsigned>& _) - { - return hb_pair (glyph_map[_.first], values.as_array (total_length).sub_array (_.second * sub_length, sub_length)); - }) + { + return hb_pair (glyph_map[_.first], + values_array.sub_array (_.second * sub_length, + sub_length)); + }) ; bool ret = bool (it); @@ -680,27 +697,14 @@ struct SinglePos hb_requires (hb_is_iterator (Iterator))> unsigned get_format (Iterator glyph_val_iter_pairs) { - unsigned subset_format = 1; hb_array_t<const Value> first_val_iter = hb_second (*glyph_val_iter_pairs); - + glyph_val_iter_pairs - | hb_map (hb_second) - | hb_apply ([&] (hb_array_t<const Value> val_iter) - { - + hb_zip (val_iter, first_val_iter) - | hb_apply ([&] (const hb_pair_t<Value, Value>& _) - { - if (_.first != _.second) - { - subset_format = 2; - return; - } - }) - ; - }) - ; + for (const auto iter : glyph_val_iter_pairs) + for (const auto _ : hb_zip (iter.second, first_val_iter)) + if (_.first != _.second) + return 2; - return subset_format; + return 1; } @@ -708,7 +712,7 @@ struct SinglePos hb_requires (hb_is_iterator (Iterator))> void serialize (hb_serialize_context_t *c, Iterator glyph_val_iter_pairs, - ValueFormat valFormat) + ValueFormat valFormat) { if (unlikely (!c->extend_min (u.format))) return; unsigned format = 2; @@ -718,9 +722,9 @@ struct SinglePos u.format = format; switch (u.format) { case 1: u.format1.serialize (c, glyph_val_iter_pairs, valFormat); - return; + return; case 2: u.format2.serialize (c, glyph_val_iter_pairs, valFormat); - return; + return; default:return; } } @@ -748,8 +752,8 @@ struct SinglePos template<typename Iterator> static inline void SinglePos_serialize (hb_serialize_context_t *c, - Iterator it, - ValueFormat valFormat) + Iterator it, + ValueFormat valFormat) { c->start_embed<SinglePos> ()->serialize (c, it, valFormat); } @@ -758,7 +762,7 @@ struct PairValueRecord friend struct PairSet; protected: - GlyphID secondGlyph; /* GlyphID of second glyph in the + HBGlyphID secondGlyph; /* GlyphID of second glyph in the * pair--first glyph is listed in the * Coverage table */ ValueRecord values; /* Positioning data for the first glyph @@ -1094,6 +1098,19 @@ struct EntryExitRecord return_trace (entryAnchor.sanitize (c, base) && exitAnchor.sanitize (c, base)); } + EntryExitRecord* copy (hb_serialize_context_t *c, + const void *src_base, + const void *dst_base) const + { + TRACE_SERIALIZE (this); + auto *out = c->embed (this); + if (unlikely (!out)) return_trace (nullptr); + + out->entryAnchor.serialize_copy (c, entryAnchor, src_base, dst_base); + out->exitAnchor.serialize_copy (c, exitAnchor, src_base, dst_base); + return_trace (out); + } + protected: OffsetTo<Anchor> entryAnchor; /* Offset to EntryAnchor table--from @@ -1221,11 +1238,47 @@ struct CursivePosFormat1 return_trace (true); } + template <typename Iterator, + hb_requires (hb_is_iterator (Iterator))> + void serialize (hb_serialize_context_t *c, + Iterator it, + const void *src_base) + { + if (unlikely (!c->extend_min ((*this)))) return; + this->format = 1; + this->entryExitRecord.len = it.len (); + + for (const EntryExitRecord& entry_record : + it + | hb_map (hb_second)) + c->copy (entry_record, src_base, this); + + auto glyphs = + + it + | hb_map_retains_sorting (hb_first) + ; + + coverage.serialize (c, this).serialize (c, glyphs); + } + bool subset (hb_subset_context_t *c) const { TRACE_SUBSET (this); - // TODO(subset) - return_trace (false); + const hb_set_t &glyphset = *c->plan->glyphset (); + const hb_map_t &glyph_map = *c->plan->glyph_map; + + auto *out = c->serializer->start_embed (*this); + if (unlikely (!out)) return_trace (false); + + auto it = + + hb_zip (this+coverage, entryExitRecord) + | hb_filter (glyphset, hb_first) + | hb_map_retains_sorting ([&] (hb_pair_t<hb_codepoint_t, const EntryExitRecord&> p) -> hb_pair_t<hb_codepoint_t, const EntryExitRecord&> + { return hb_pair (glyph_map[p.first], p.second);}) + ; + + bool ret = bool (it); + out->serialize (c->serializer, it, this); + return_trace (ret); } bool sanitize (hb_sanitize_context_t *c) const |