[repacker] correct lookup link insertion.

This commit is contained in:
Garret Rieger 2022-08-05 01:25:16 +00:00
parent a733a9afa5
commit e1ab355056
2 changed files with 10 additions and 2 deletions

View File

@ -183,10 +183,13 @@ struct Lookup : public OT::Lookup
Lookup* new_lookup = (Lookup*) buffer; Lookup* new_lookup = (Lookup*) buffer;
unsigned shift = 0;
new_lookup->subTable.len = subTable.len + new_subtable_count; new_lookup->subTable.len = subTable.len + new_subtable_count;
for (const auto& p : subtable_ids) for (const auto& p : subtable_ids)
{ {
unsigned offset_index = p.first + 1; unsigned offset_index = p.first + shift + 1;
shift += p.second.length;
for (unsigned subtable_id : p.second) for (unsigned subtable_id : p.second)
{ {
if (is_ext) if (is_ext)
@ -220,11 +223,13 @@ struct Lookup : public OT::Lookup
auto& v = c.graph.vertices_[this_index]; auto& v = c.graph.vertices_[this_index];
Lookup* lookup = (Lookup*) v.obj.head; Lookup* lookup = (Lookup*) v.obj.head;
unsigned shift = 0;
for (const auto& p : subtable_ids) for (const auto& p : subtable_ids)
{ {
unsigned insert_index = p.first; unsigned insert_index = p.first + shift;
unsigned pos_offset = p.second.length * OT::Offset16::static_size; unsigned pos_offset = p.second.length * OT::Offset16::static_size;
unsigned insert_offset = (char*) &lookup->subTable[insert_index] - (char*) lookup; unsigned insert_offset = (char*) &lookup->subTable[insert_index] - (char*) lookup;
shift += p.second.length;
for (auto& l : v.obj.all_links_writer ()) for (auto& l : v.obj.all_links_writer ())
{ {

View File

@ -1907,6 +1907,9 @@ main (int argc, char **argv)
test_resolve_with_basic_pair_pos_2_split (); test_resolve_with_basic_pair_pos_2_split ();
test_resolve_with_pair_pos_2_split_with_device_tables (); test_resolve_with_pair_pos_2_split_with_device_tables ();
// TODO(grieger): have run overflow tests compare graph equality not final packed binary.
// TODO(grieger): split test where multiple subtables in one lookup are split to test link ordering.
// TODO(grieger): split test where coverage table in subtable that is being split is shared.
// TODO(grieger): test with extensions already mixed in as well. // TODO(grieger): test with extensions already mixed in as well.
// TODO(grieger): test two layer ext promotion setup. // TODO(grieger): test two layer ext promotion setup.
// TODO(grieger): test sorting by subtables per byte in ext. promotion. // TODO(grieger): test sorting by subtables per byte in ext. promotion.