diff --git a/src/graph/graph.hh b/src/graph/graph.hh index b0b6df71a..a73d86f15 100644 --- a/src/graph/graph.hh +++ b/src/graph/graph.hh @@ -291,12 +291,12 @@ struct graph_t check_success (!queue.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); - hb_swap (vertices_, sorted_graph); + + if (!check_success (new_id == -1)) + print_orphaned_nodes (); } /* diff --git a/src/graph/gsubgpos-graph.hh b/src/graph/gsubgpos-graph.hh index de7cc4992..937e05876 100644 --- a/src/graph/gsubgpos-graph.hh +++ b/src/graph/gsubgpos-graph.hh @@ -142,7 +142,8 @@ struct Lookup : public OT::Lookup + new_sub_tables.iter() | hb_sink (all_new_subtables); } - add_sub_tables (c, this_index, type, all_new_subtables); + if (all_new_subtables) + add_sub_tables (c, this_index, type, all_new_subtables); return true; } @@ -150,7 +151,7 @@ struct Lookup : public OT::Lookup void add_sub_tables (gsubgpos_graph_context_t& c, unsigned this_index, unsigned type, - hb_vector_t subtable_indices) + hb_vector_t& subtable_indices) { bool is_ext = is_extension (c.table_tag); auto& v = c.graph.vertices_[this_index]; @@ -184,6 +185,10 @@ struct Lookup : public OT::Lookup (char*) new_lookup; 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, diff --git a/src/hb-repacker.hh b/src/hb-repacker.hh index e80360266..36bdf24f0 100644 --- a/src/hb-repacker.hh +++ b/src/hb-repacker.hh @@ -82,7 +82,8 @@ bool _presplit_subtables_if_needed (graph::gsubgpos_graph_context_t& ext_context for (unsigned lookup_index : ext_context.lookups.keys ()) { 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;