From c414ef292b7dee52cdf4fb8afaa8f0835b58749b Mon Sep 17 00:00:00 2001 From: Garret Rieger Date: Mon, 15 Aug 2022 22:10:37 +0000 Subject: [PATCH] [repacker] Implement MarkArray::shrink. --- src/graph/markbasepos-graph.hh | 46 +++++++++++++++++++++++++++++----- 1 file changed, 40 insertions(+), 6 deletions(-) diff --git a/src/graph/markbasepos-graph.hh b/src/graph/markbasepos-graph.hh index 5ff7fbdf4..aac19cf94 100644 --- a/src/graph/markbasepos-graph.hh +++ b/src/graph/markbasepos-graph.hh @@ -120,6 +120,38 @@ struct MarkArray : public OT::Layout::GPOS_impl::MarkArray return false; } + bool shrink (gsubgpos_graph_context_t& c, + const hb_hashmap_t& mark_array_links, + unsigned this_index, + unsigned new_class_count) + { + auto& o = c.graph.vertices_[this_index].obj; + o.real_links.reset (); + + unsigned new_index = 0; + for (const auto& record : this->iter ()) + { + unsigned klass = record.klass; + if (klass >= new_class_count) continue; + + (*this)[new_index].klass = klass; + unsigned position = (char*) &record.markAnchor - (char*) this; + unsigned* objidx; + if (!mark_array_links.has (position, &objidx)) + { + new_index++; + continue; + } + + c.graph.add_link (&(*this)[new_index].markAnchor, this_index, *objidx); + new_index++; + } + + this->len = new_index; + o.tail = o.head + MarkArray::min_size + OT::Offset16::static_size * new_index; + return true; + } + unsigned clone (gsubgpos_graph_context_t& c, unsigned this_index, const hb_hashmap_t& pos_to_index, @@ -339,13 +371,15 @@ struct MarkBasePosFormat1 : public OT::Layout::GPOS_impl::MarkBasePosFormat1_2 (this_index, + &markArray); + if (!mark_array || !mark_array.table->shrink (sc.c, + sc.mark_array_links, + mark_array.index, + count)) + return false; - - return Coverage::make_coverage (c, new_coverage, coverage_id, coverage_size); - */ - return -1; // TODO + return true; } // Create a new PairPos including PairSet's from start (inclusive) to end (exclusive).