From cf817f3d99d46dd39e9004ef94ec71077d8af8d9 Mon Sep 17 00:00:00 2001 From: Garret Rieger Date: Thu, 11 Aug 2022 19:26:59 +0000 Subject: [PATCH] [repacker] Hook up MarkBasePos splitting. --- src/graph/gsubgpos-graph.hh | 27 +++++++++++++++++++++---- src/graph/markbasepos-graph.hh | 37 +++++++++++++++------------------- 2 files changed, 39 insertions(+), 25 deletions(-) diff --git a/src/graph/gsubgpos-graph.hh b/src/graph/gsubgpos-graph.hh index f963a49ad..31fc1d8e4 100644 --- a/src/graph/gsubgpos-graph.hh +++ b/src/graph/gsubgpos-graph.hh @@ -29,6 +29,7 @@ #include "../OT/Layout/GSUB/ExtensionSubst.hh" #include "gsubgpos-context.hh" #include "pairpos-graph.hh" +#include "markbasepos-graph.hh" #ifndef GRAPH_GSUBGPOS_GRAPH_HH #define GRAPH_GSUBGPOS_GRAPH_HH @@ -142,11 +143,18 @@ struct Lookup : public OT::Lookup continue; } - PairPos* pairPos = (PairPos*) c.graph.object (subtable_index).head; - if (!pairPos || !pairPos->sanitize (c.graph.vertices_[subtable_index])) continue; - - hb_vector_t new_sub_tables = pairPos->split_subtables (c, subtable_index); + hb_vector_t new_sub_tables; + switch (type) + { + case 2: + new_sub_tables = split_subtable (c, subtable_index); break; + case 4: + new_sub_tables = split_subtable (c, subtable_index); break; + default: + break; + } if (new_sub_tables.in_error ()) return false; + if (!new_sub_tables) continue; hb_pair_t>* entry = all_new_subtables.push (); entry->first = i; entry->second = std::move (new_sub_tables); @@ -159,6 +167,17 @@ struct Lookup : public OT::Lookup return true; } + template + hb_vector_t split_subtable (gsubgpos_graph_context_t& c, + unsigned objidx) + { + T* sub_table = (T*) c.graph.object (objidx).head; + if (!sub_table || !sub_table->sanitize (c.graph.vertices_[objidx])) + return hb_vector_t (); + + return sub_table->split_subtables (c, objidx); + } + void add_sub_tables (gsubgpos_graph_context_t& c, unsigned this_index, unsigned type, diff --git a/src/graph/markbasepos-graph.hh b/src/graph/markbasepos-graph.hh index 9007188b1..d6d3c7aaf 100644 --- a/src/graph/markbasepos-graph.hh +++ b/src/graph/markbasepos-graph.hh @@ -68,9 +68,6 @@ struct MarkBasePosFormat1 : public OT::Layout::GPOS_impl::MarkBasePosFormat1_2::min_size + @@ -87,6 +84,7 @@ struct MarkBasePosFormat1 : public OT::Layout::GPOS_impl::MarkBasePosFormat1_2pairSet.len; + return thiz->classCount; } unsigned clone_range (unsigned start, unsigned end) @@ -146,41 +144,38 @@ struct MarkBasePosFormat1 : public OT::Layout::GPOS_impl::MarkBasePosFormat1_2 class_to_info; unsigned class_count= classCount; - class_to_size.resize (class_count); + class_to_info.resize (class_count); unsigned mark_array_id = c.graph.index_for_offset (this_index, &markArray); - auto& mark_array_v = graph.vertices_[coverage_id]; - MarkArray* mark_array = (MarkArray*) mark_array_v.head; + auto& mark_array_v = c.graph.vertices_[mark_array_id]; + MarkArray* mark_array = (MarkArray*) mark_array_v.obj.head; // TODO sanitize - unsigned mark_count = mark_array->length; + unsigned mark_count = mark_array->len; for (unsigned mark = 0; mark < mark_count; mark++) { - unsigned klass = (*mark_array)[mark].klass; - class_to_size[klass].num_marks++; + unsigned klass = (*mark_array)[mark].get_class (); + class_to_info[klass].num_marks++; } - for (const auto* link : mark_array_v.obj.real_links) + for (const auto& link : mark_array_v.obj.real_links) { - unsiged mark = (link->position - 2) / - OT::Layout::GPOS_impl::MarkReecord::static_size; - unsigned klass = (*mark_array)[mark].klass; + unsigned mark = (link.position - 2) / + OT::Layout::GPOS_impl::MarkRecord::static_size; + unsigned klass = (*mark_array)[mark].get_class (); class_to_info[klass].child_indices.push (link.objidx); } unsigned base_array_id = c.graph.index_for_offset (this_index, &baseArray); - auto& base_array_v = graph.vertices_[coverage_id]; - AnchorMatrix* base_array = (AnchorMatrix*) base_array_v.head; - // TODO sanitize + auto& base_array_v = c.graph.vertices_[base_array_id]; - unsigned base_count = base_array->rows; - for (const auto* link : base_array_v.obj.real_links) + for (const auto& link : base_array_v.obj.real_links) { - unsigned index = (link->position - 2) / OT::Offset16::static_size; + unsigned index = (link.position - 2) / OT::Offset16::static_size; unsigned klass = index % class_count; - class_to_info[klass].child_indices.push (link->objidx); + class_to_info[klass].child_indices.push (link.objidx); } return class_to_info;