diff --git a/src/graph/graph.hh b/src/graph/graph.hh index a69deb00a..4a036af87 100644 --- a/src/graph/graph.hh +++ b/src/graph/graph.hh @@ -489,14 +489,14 @@ struct graph_t } } - template - vertex_and_table_t as_table (unsigned parent, const void* offset) + template + vertex_and_table_t as_table (unsigned parent, const void* offset, Ts... ds) { - return as_table (index_for_offset (parent, offset)); + return as_table_from_index (index_for_offset (parent, offset), std::forward(ds)...); } - template - vertex_and_table_t as_table (unsigned index) + template + vertex_and_table_t as_table_from_index (unsigned index, Ts... ds) { if (index >= vertices_.length) return vertex_and_table_t (); @@ -508,7 +508,7 @@ struct graph_t if (!r.table) return vertex_and_table_t (); - if (!r.table->sanitize (*(r.vertex))) + if (!r.table->sanitize (*(r.vertex), std::forward(ds)...)) return vertex_and_table_t (); return r; diff --git a/src/graph/markbasepos-graph.hh b/src/graph/markbasepos-graph.hh index 69f8fc72b..d4dd39a98 100644 --- a/src/graph/markbasepos-graph.hh +++ b/src/graph/markbasepos-graph.hh @@ -36,10 +36,13 @@ namespace graph { struct AnchorMatrix : public OT::Layout::GPOS_impl::AnchorMatrix { - bool sanitize (graph_t::vertex_t& vertex) const + bool sanitize (graph_t::vertex_t& vertex, unsigned class_count) const { - // TODO - return true; + int64_t vertex_len = vertex.obj.tail - vertex.obj.head; + if (vertex_len < AnchorMatrix::min_size) return false; + + return vertex_len >= AnchorMatrix::min_size + + OT::Offset16::static_size * class_count * this->rows; } bool shrink (gsubgpos_graph_context_t& c, @@ -116,8 +119,11 @@ struct MarkArray : public OT::Layout::GPOS_impl::MarkArray { bool sanitize (graph_t::vertex_t& vertex) const { - // TODO - return true; + int64_t vertex_len = vertex.obj.tail - vertex.obj.head; + unsigned min_size = MarkArray::min_size; + if (vertex_len < min_size) return false; + + return vertex_len >= get_size (); } bool shrink (gsubgpos_graph_context_t& c, @@ -194,11 +200,7 @@ struct MarkBasePosFormat1 : public OT::Layout::GPOS_impl::MarkBasePosFormat1_2::min_size; - if (vertex_len < min_size) return false; - - // TODO - return true; + return vertex_len >= MarkBasePosFormat1::static_size; } hb_vector_t split_subtables (gsubgpos_graph_context_t& c, unsigned this_index) @@ -368,7 +370,8 @@ struct MarkBasePosFormat1 : public OT::Layout::GPOS_impl::MarkBasePosFormat1_2 (this_index, - &baseArray); + &baseArray, + old_count); if (!base_array || !base_array.table->shrink (sc.c, base_array.index, old_count, @@ -438,8 +441,9 @@ struct MarkBasePosFormat1 : public OT::Layout::GPOS_impl::MarkBasePosFormat1_2markArray), prime_id, new_mark_array); + unsigned class_count = classCount; auto base_array = - graph.as_table (sc.this_index, &baseArray); + graph.as_table (sc.this_index, &baseArray, class_count); if (!base_array) return -1; unsigned new_base_array = base_array.table->clone (sc.c,