diff --git a/src/graph/graph.hh b/src/graph/graph.hh index 7dc5413f8..b0b6df71a 100644 --- a/src/graph/graph.hh +++ b/src/graph/graph.hh @@ -228,6 +228,17 @@ struct graph_t return vertices_[i].obj; } + /* + * Generates a new topological sorting of graph ordered by the shortest + * distance to each node if positions are marked as invalid. + */ + void sort_shortest_distance_if_needed () + { + if (!positions_invalid) return; + sort_shortest_distance (); + } + + /* * Generates a new topological sorting of graph ordered by the shortest * distance to each node. @@ -541,6 +552,9 @@ struct graph_t unsigned new_parent_idx, const O* new_offset) { + distance_invalid = true; + positions_invalid = true; + auto& old_v = vertices_[old_parent_idx]; auto& new_v = vertices_[new_parent_idx]; diff --git a/src/graph/gsubgpos-graph.hh b/src/graph/gsubgpos-graph.hh index 1fa4247b6..de7cc4992 100644 --- a/src/graph/gsubgpos-graph.hh +++ b/src/graph/gsubgpos-graph.hh @@ -159,14 +159,14 @@ struct Lookup : public OT::Lookup + subtable_indices.length * OT::Offset16::static_size; char* buffer = (char*) hb_calloc (1, new_size); c.add_buffer (buffer); + memcpy (buffer, v.obj.head, v.table_size()); + v.obj.head = buffer; v.obj.tail = buffer + new_size; - memcpy (buffer, v.obj.head, v.table_size()); - Lookup* new_lookup = (Lookup*) buffer; - new_lookup->subTable.len = subTable.len + subtable_indices.length; + new_lookup->subTable.len = subTable.len + subtable_indices.length; unsigned offset_index = subTable.len; for (unsigned subtable_id : subtable_indices) { @@ -181,7 +181,7 @@ struct Lookup : public OT::Lookup link->width = 2; link->objidx = subtable_id; link->position = (char*) &new_lookup->subTable[offset_index++] - - (char*) &new_lookup->subTable[0]; + (char*) new_lookup; c.graph.vertices_[subtable_id].parents.push (this_index); } } diff --git a/src/hb-repacker.hh b/src/hb-repacker.hh index 1ee5985be..e80360266 100644 --- a/src/hb-repacker.hh +++ b/src/hb-repacker.hh @@ -314,11 +314,13 @@ hb_resolve_overflows (const T& packed, { if (recalculate_extensions) { + DEBUG_MSG (SUBSET_REPACK, nullptr, "Splitting subtables if needed."); if (!_presplit_subtables_if_needed (ext_context)) { DEBUG_MSG (SUBSET_REPACK, nullptr, "Subtable splitting failed."); return nullptr; } + DEBUG_MSG (SUBSET_REPACK, nullptr, "Promoting lookups to extensions if needed."); if (!_promote_extensions_if_needed (ext_context)) { DEBUG_MSG (SUBSET_REPACK, nullptr, "Extensions promotion failed."); return nullptr; @@ -328,6 +330,8 @@ hb_resolve_overflows (const T& packed, DEBUG_MSG (SUBSET_REPACK, nullptr, "Assigning spaces to 32 bit subgraphs."); if (sorted_graph.assign_spaces ()) sorted_graph.sort_shortest_distance (); + else + sorted_graph.sort_shortest_distance_if_needed (); } unsigned round = 0;