[repacker] implement sanitize methods for MarkBasePos.
This commit is contained in:
parent
a3ed9f9099
commit
ac1a853abc
|
@ -489,14 +489,14 @@ struct graph_t
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T, typename ...Ts>
|
||||||
vertex_and_table_t<T> as_table (unsigned parent, const void* offset)
|
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>
|
template <typename T, typename ...Ts>
|
||||||
vertex_and_table_t<T> as_table (unsigned index)
|
vertex_and_table_t<T> as_table_from_index (unsigned index, Ts... ds)
|
||||||
{
|
{
|
||||||
if (index >= vertices_.length)
|
if (index >= vertices_.length)
|
||||||
return vertex_and_table_t<T> ();
|
return vertex_and_table_t<T> ();
|
||||||
|
@ -508,7 +508,7 @@ struct graph_t
|
||||||
if (!r.table)
|
if (!r.table)
|
||||||
return vertex_and_table_t<T> ();
|
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 vertex_and_table_t<T> ();
|
||||||
|
|
||||||
return r;
|
return r;
|
||||||
|
|
|
@ -36,10 +36,13 @@ namespace graph {
|
||||||
|
|
||||||
struct AnchorMatrix : public OT::Layout::GPOS_impl::AnchorMatrix
|
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
|
int64_t vertex_len = vertex.obj.tail - vertex.obj.head;
|
||||||
return true;
|
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,
|
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
|
bool sanitize (graph_t::vertex_t& vertex) const
|
||||||
{
|
{
|
||||||
// TODO
|
int64_t vertex_len = vertex.obj.tail - vertex.obj.head;
|
||||||
return true;
|
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,
|
bool shrink (gsubgpos_graph_context_t& c,
|
||||||
|
@ -194,11 +200,7 @@ struct MarkBasePosFormat1 : public OT::Layout::GPOS_impl::MarkBasePosFormat1_2<S
|
||||||
bool sanitize (graph_t::vertex_t& vertex) const
|
bool sanitize (graph_t::vertex_t& vertex) const
|
||||||
{
|
{
|
||||||
int64_t vertex_len = vertex.obj.tail - vertex.obj.head;
|
int64_t vertex_len = vertex.obj.tail - vertex.obj.head;
|
||||||
unsigned min_size = OT::Layout::GPOS_impl::MarkBasePosFormat1_2<SmallTypes>::min_size;
|
return vertex_len >= MarkBasePosFormat1::static_size;
|
||||||
if (vertex_len < min_size) return false;
|
|
||||||
|
|
||||||
// TODO
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
hb_vector_t<unsigned> split_subtables (gsubgpos_graph_context_t& c, unsigned this_index)
|
hb_vector_t<unsigned> split_subtables (gsubgpos_graph_context_t& c, unsigned this_index)
|
||||||
|
@ -368,7 +370,8 @@ struct MarkBasePosFormat1 : public OT::Layout::GPOS_impl::MarkBasePosFormat1_2<S
|
||||||
|
|
||||||
|
|
||||||
auto base_array = sc.c.graph.as_table<AnchorMatrix> (this_index,
|
auto base_array = sc.c.graph.as_table<AnchorMatrix> (this_index,
|
||||||
&baseArray);
|
&baseArray,
|
||||||
|
old_count);
|
||||||
if (!base_array || !base_array.table->shrink (sc.c,
|
if (!base_array || !base_array.table->shrink (sc.c,
|
||||||
base_array.index,
|
base_array.index,
|
||||||
old_count,
|
old_count,
|
||||||
|
@ -438,8 +441,9 @@ struct MarkBasePosFormat1 : public OT::Layout::GPOS_impl::MarkBasePosFormat1_2<S
|
||||||
start);
|
start);
|
||||||
graph.add_link (&(prime->markArray), prime_id, new_mark_array);
|
graph.add_link (&(prime->markArray), prime_id, new_mark_array);
|
||||||
|
|
||||||
|
unsigned class_count = classCount;
|
||||||
auto base_array =
|
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;
|
if (!base_array) return -1;
|
||||||
unsigned new_base_array =
|
unsigned new_base_array =
|
||||||
base_array.table->clone (sc.c,
|
base_array.table->clone (sc.c,
|
||||||
|
|
Loading…
Reference in New Issue