[repacker] ensure lookup map is updated when lookup memory location changes.

This commit is contained in:
Garret Rieger 2022-07-29 00:25:19 +00:00
parent 4e7360f78d
commit fb3f6ad7c0
3 changed files with 12 additions and 6 deletions

View File

@ -291,12 +291,12 @@ struct graph_t
check_success (!queue.in_error ()); check_success (!queue.in_error ());
check_success (!sorted_graph.in_error ()); check_success (!sorted_graph.in_error ());
if (!check_success (new_id == -1))
print_orphaned_nodes ();
remap_all_obj_indices (id_map, &sorted_graph); remap_all_obj_indices (id_map, &sorted_graph);
hb_swap (vertices_, sorted_graph); hb_swap (vertices_, sorted_graph);
if (!check_success (new_id == -1))
print_orphaned_nodes ();
} }
/* /*

View File

@ -142,6 +142,7 @@ struct Lookup : public OT::Lookup
+ new_sub_tables.iter() | hb_sink (all_new_subtables); + new_sub_tables.iter() | hb_sink (all_new_subtables);
} }
if (all_new_subtables)
add_sub_tables (c, this_index, type, all_new_subtables); add_sub_tables (c, this_index, type, all_new_subtables);
return true; return true;
@ -150,7 +151,7 @@ struct Lookup : public OT::Lookup
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,
hb_vector_t<unsigned> subtable_indices) hb_vector_t<unsigned>& subtable_indices)
{ {
bool is_ext = is_extension (c.table_tag); bool is_ext = is_extension (c.table_tag);
auto& v = c.graph.vertices_[this_index]; auto& v = c.graph.vertices_[this_index];
@ -184,6 +185,10 @@ struct Lookup : public OT::Lookup
(char*) new_lookup; (char*) new_lookup;
c.graph.vertices_[subtable_id].parents.push (this_index); c.graph.vertices_[subtable_id].parents.push (this_index);
} }
// The head location of the lookup has changed, invalidating the lookups map entry
// in the context. Update the map.
c.lookups.set (this_index, new_lookup);
} }
unsigned create_extension_subtable (gsubgpos_graph_context_t& c, unsigned create_extension_subtable (gsubgpos_graph_context_t& c,

View File

@ -82,7 +82,8 @@ bool _presplit_subtables_if_needed (graph::gsubgpos_graph_context_t& ext_context
for (unsigned lookup_index : ext_context.lookups.keys ()) for (unsigned lookup_index : ext_context.lookups.keys ())
{ {
graph::Lookup* lookup = ext_context.lookups.get(lookup_index); graph::Lookup* lookup = ext_context.lookups.get(lookup_index);
lookup->split_subtables_if_needed (ext_context, lookup_index); if (!lookup->split_subtables_if_needed (ext_context, lookup_index))
return false;
} }
return true; return true;