[repacker] Hook up MarkBasePos splitting.
This commit is contained in:
parent
4418beac93
commit
cf817f3d99
|
@ -29,6 +29,7 @@
|
||||||
#include "../OT/Layout/GSUB/ExtensionSubst.hh"
|
#include "../OT/Layout/GSUB/ExtensionSubst.hh"
|
||||||
#include "gsubgpos-context.hh"
|
#include "gsubgpos-context.hh"
|
||||||
#include "pairpos-graph.hh"
|
#include "pairpos-graph.hh"
|
||||||
|
#include "markbasepos-graph.hh"
|
||||||
|
|
||||||
#ifndef GRAPH_GSUBGPOS_GRAPH_HH
|
#ifndef GRAPH_GSUBGPOS_GRAPH_HH
|
||||||
#define GRAPH_GSUBGPOS_GRAPH_HH
|
#define GRAPH_GSUBGPOS_GRAPH_HH
|
||||||
|
@ -142,11 +143,18 @@ struct Lookup : public OT::Lookup
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
PairPos* pairPos = (PairPos*) c.graph.object (subtable_index).head;
|
hb_vector_t<unsigned> new_sub_tables;
|
||||||
if (!pairPos || !pairPos->sanitize (c.graph.vertices_[subtable_index])) continue;
|
switch (type)
|
||||||
|
{
|
||||||
hb_vector_t<unsigned> new_sub_tables = pairPos->split_subtables (c, subtable_index);
|
case 2:
|
||||||
|
new_sub_tables = split_subtable<PairPos> (c, subtable_index); break;
|
||||||
|
case 4:
|
||||||
|
new_sub_tables = split_subtable<MarkBasePos> (c, subtable_index); break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
if (new_sub_tables.in_error ()) return false;
|
if (new_sub_tables.in_error ()) return false;
|
||||||
|
if (!new_sub_tables) continue;
|
||||||
hb_pair_t<unsigned, hb_vector_t<unsigned>>* entry = all_new_subtables.push ();
|
hb_pair_t<unsigned, hb_vector_t<unsigned>>* entry = all_new_subtables.push ();
|
||||||
entry->first = i;
|
entry->first = i;
|
||||||
entry->second = std::move (new_sub_tables);
|
entry->second = std::move (new_sub_tables);
|
||||||
|
@ -159,6 +167,17 @@ struct Lookup : public OT::Lookup
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
hb_vector_t<unsigned> 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<unsigned> ();
|
||||||
|
|
||||||
|
return sub_table->split_subtables (c, objidx);
|
||||||
|
}
|
||||||
|
|
||||||
void add_sub_tables (gsubgpos_graph_context_t& c,
|
void add_sub_tables (gsubgpos_graph_context_t& c,
|
||||||
unsigned this_index,
|
unsigned this_index,
|
||||||
unsigned type,
|
unsigned type,
|
||||||
|
|
|
@ -68,9 +68,6 @@ struct MarkBasePosFormat1 : public OT::Layout::GPOS_impl::MarkBasePosFormat1_2<S
|
||||||
{
|
{
|
||||||
hb_set_t visited;
|
hb_set_t visited;
|
||||||
|
|
||||||
const unsigned coverage_id = c.graph.index_for_offset (this_index, &markCoverage);
|
|
||||||
const unsigned coverage_size = c.graph.vertices_[coverage_id].table_size ();
|
|
||||||
|
|
||||||
const unsigned base_coverage_id = c.graph.index_for_offset (this_index, &baseCoverage);
|
const unsigned base_coverage_id = c.graph.index_for_offset (this_index, &baseCoverage);
|
||||||
const unsigned base_size =
|
const unsigned base_size =
|
||||||
OT::Layout::GPOS_impl::PairPosFormat1_3<SmallTypes>::min_size +
|
OT::Layout::GPOS_impl::PairPosFormat1_3<SmallTypes>::min_size +
|
||||||
|
@ -87,6 +84,7 @@ struct MarkBasePosFormat1 : public OT::Layout::GPOS_impl::MarkBasePosFormat1_2<S
|
||||||
class_info_t& info = class_to_info[klass];
|
class_info_t& info = class_to_info[klass];
|
||||||
partial_coverage_size += OT::HBUINT16::static_size * info.num_marks;
|
partial_coverage_size += OT::HBUINT16::static_size * info.num_marks;
|
||||||
unsigned accumulated_delta = OT::Layout::GPOS_impl::MarkRecord::static_size * info.num_marks;
|
unsigned accumulated_delta = OT::Layout::GPOS_impl::MarkRecord::static_size * info.num_marks;
|
||||||
|
// TODO this doesn't count up null offsets.
|
||||||
accumulated_delta += OT::Offset16::static_size * info.child_indices.length;
|
accumulated_delta += OT::Offset16::static_size * info.child_indices.length;
|
||||||
for (unsigned objidx : info.child_indices)
|
for (unsigned objidx : info.child_indices)
|
||||||
accumulated_delta += c.graph.find_subgraph_size (objidx, visited);
|
accumulated_delta += c.graph.find_subgraph_size (objidx, visited);
|
||||||
|
@ -121,7 +119,7 @@ struct MarkBasePosFormat1 : public OT::Layout::GPOS_impl::MarkBasePosFormat1_2<S
|
||||||
|
|
||||||
unsigned original_count ()
|
unsigned original_count ()
|
||||||
{
|
{
|
||||||
return thiz->pairSet.len;
|
return thiz->classCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned clone_range (unsigned start, unsigned end)
|
unsigned clone_range (unsigned start, unsigned end)
|
||||||
|
@ -146,41 +144,38 @@ struct MarkBasePosFormat1 : public OT::Layout::GPOS_impl::MarkBasePosFormat1_2<S
|
||||||
hb_vector_t<class_info_t> class_to_info;
|
hb_vector_t<class_info_t> class_to_info;
|
||||||
|
|
||||||
unsigned class_count= classCount;
|
unsigned class_count= classCount;
|
||||||
class_to_size.resize (class_count);
|
class_to_info.resize (class_count);
|
||||||
|
|
||||||
unsigned mark_array_id =
|
unsigned mark_array_id =
|
||||||
c.graph.index_for_offset (this_index, &markArray);
|
c.graph.index_for_offset (this_index, &markArray);
|
||||||
auto& mark_array_v = graph.vertices_[coverage_id];
|
auto& mark_array_v = c.graph.vertices_[mark_array_id];
|
||||||
MarkArray* mark_array = (MarkArray*) mark_array_v.head;
|
MarkArray* mark_array = (MarkArray*) mark_array_v.obj.head;
|
||||||
// TODO sanitize
|
// TODO sanitize
|
||||||
|
|
||||||
unsigned mark_count = mark_array->length;
|
unsigned mark_count = mark_array->len;
|
||||||
for (unsigned mark = 0; mark < mark_count; mark++)
|
for (unsigned mark = 0; mark < mark_count; mark++)
|
||||||
{
|
{
|
||||||
unsigned klass = (*mark_array)[mark].klass;
|
unsigned klass = (*mark_array)[mark].get_class ();
|
||||||
class_to_size[klass].num_marks++;
|
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) /
|
unsigned mark = (link.position - 2) /
|
||||||
OT::Layout::GPOS_impl::MarkReecord::static_size;
|
OT::Layout::GPOS_impl::MarkRecord::static_size;
|
||||||
unsigned klass = (*mark_array)[mark].klass;
|
unsigned klass = (*mark_array)[mark].get_class ();
|
||||||
class_to_info[klass].child_indices.push (link.objidx);
|
class_to_info[klass].child_indices.push (link.objidx);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned base_array_id =
|
unsigned base_array_id =
|
||||||
c.graph.index_for_offset (this_index, &baseArray);
|
c.graph.index_for_offset (this_index, &baseArray);
|
||||||
auto& base_array_v = graph.vertices_[coverage_id];
|
auto& base_array_v = c.graph.vertices_[base_array_id];
|
||||||
AnchorMatrix* base_array = (AnchorMatrix*) base_array_v.head;
|
|
||||||
// TODO sanitize
|
|
||||||
|
|
||||||
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;
|
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;
|
return class_to_info;
|
||||||
|
|
Loading…
Reference in New Issue