[repacker] implement sanitize methods for MarkBasePos.
diff --git a/src/graph/graph.hh b/src/graph/graph.hh
index a69deb0..4a036af 100644
--- a/src/graph/graph.hh
+++ b/src/graph/graph.hh
@@ -489,14 +489,14 @@
}
}
- template <typename T>
- vertex_and_table_t<T> as_table (unsigned parent, const void* offset)
+ template <typename T, typename ...Ts>
+ vertex_and_table_t<T> as_table (unsigned parent, const void* offset, Ts... ds)
{
- return as_table<T> (index_for_offset (parent, offset));
+ return as_table_from_index<T> (index_for_offset (parent, offset), std::forward<Ts>(ds)...);
}
- template <typename T>
- vertex_and_table_t<T> as_table (unsigned index)
+ template <typename T, typename ...Ts>
+ vertex_and_table_t<T> as_table_from_index (unsigned index, Ts... ds)
{
if (index >= vertices_.length)
return vertex_and_table_t<T> ();
@@ -508,7 +508,7 @@
if (!r.table)
return vertex_and_table_t<T> ();
- if (!r.table->sanitize (*(r.vertex)))
+ if (!r.table->sanitize (*(r.vertex), std::forward<Ts>(ds)...))
return vertex_and_table_t<T> ();
return r;
diff --git a/src/graph/markbasepos-graph.hh b/src/graph/markbasepos-graph.hh
index 69f8fc7..d4dd39a 100644
--- a/src/graph/markbasepos-graph.hh
+++ b/src/graph/markbasepos-graph.hh
@@ -36,10 +36,13 @@
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 @@
{
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 @@
bool sanitize (graph_t::vertex_t& vertex) const
{
int64_t vertex_len = vertex.obj.tail - vertex.obj.head;
- unsigned min_size = OT::Layout::GPOS_impl::MarkBasePosFormat1_2<SmallTypes>::min_size;
- if (vertex_len < min_size) return false;
-
- // TODO
- return true;
+ return vertex_len >= MarkBasePosFormat1::static_size;
}
hb_vector_t<unsigned> split_subtables (gsubgpos_graph_context_t& c, unsigned this_index)
@@ -368,7 +370,8 @@
auto base_array = sc.c.graph.as_table<AnchorMatrix> (this_index,
- &baseArray);
+ &baseArray,
+ old_count);
if (!base_array || !base_array.table->shrink (sc.c,
base_array.index,
old_count,
@@ -438,8 +441,9 @@
start);
graph.add_link (&(prime->markArray), prime_id, new_mark_array);
+ unsigned class_count = classCount;
auto base_array =
- graph.as_table<AnchorMatrix> (sc.this_index, &baseArray);
+ graph.as_table<AnchorMatrix> (sc.this_index, &baseArray, class_count);
if (!base_array) return -1;
unsigned new_base_array =
base_array.table->clone (sc.c,