From 815bb82b4d1074d236382ce75b05fc69ef0c44ca Mon Sep 17 00:00:00 2001 From: Garret Rieger Date: Wed, 20 Jul 2022 18:17:29 +0000 Subject: [PATCH] [repack] fix incorrect extension object bounds. --- src/graph/graph.hh | 36 ------------------------------------ src/graph/gsubgpos-graph.hh | 9 +++++++-- 2 files changed, 7 insertions(+), 38 deletions(-) diff --git a/src/graph/graph.hh b/src/graph/graph.hh index 8afa570eb..c9aaec171 100644 --- a/src/graph/graph.hh +++ b/src/graph/graph.hh @@ -310,41 +310,6 @@ struct graph_t } } - - /* - void promote_extension_lookups (const hb_set_t& subtable_indices) - { - const OT::GSUBGPOS* gstar = (OT::GSUBGPOS*) root ().obj.head; - - unsigned lookup_list_idx = index_for_offset (root_idx (), &(gstar->lookupList)); - const OT::LookupList* lookupList = - (OT::LookupList*) object (lookup_list_idx).head; - - - for (unsigned i = 0; i < lookupList->len; i++) - { - unsigned lookup_idx = index_for_offset (lookup_list_idx, &(lookupList->arrayZ[i])); - const OT::Lookup* lookup = (OT::Lookup*) object (lookup_idx).head; - - // TODO(grieger): use the correct type for GSUB vs GPOS - if (lookup->get_type () == 9) continue; // skip extensions - - for (unsigned j = 0; j < lookup->subTable.len; j++) - { - unsigned subtable_idx = index_for_offset (lookup_idx, &(lookup->subTable.arrayZ[j])); - if (subtable_indices.has (subtable_idx)) - promote_to_extension (lookup_idx); - } - } - } - - void promote_to_extension (unsigned lookup_idx) - { - DEBUG_MSG (SUBSET_REPACK, nullptr, "Promoting %d to extension lookup.", lookup_idx); - // TODO(garretrieger): implement me. - } - */ - unsigned index_for_offset(unsigned node_idx, const void* offset) const { const auto& node = object (node_idx); @@ -642,7 +607,6 @@ struct graph_t { positions_invalid = true; distance_invalid = true; - parents_invalid = true; // TODO: remove auto* clone = vertices_.push (); if (vertices_.in_error ()) { diff --git a/src/graph/gsubgpos-graph.hh b/src/graph/gsubgpos-graph.hh index 5a3321b8e..3a3b4c333 100644 --- a/src/graph/gsubgpos-graph.hh +++ b/src/graph/gsubgpos-graph.hh @@ -104,7 +104,7 @@ struct Lookup : public OT::Lookup unsigned type = lookupType; unsigned extension_size = OT::ExtensionFormat1::static_size; unsigned start = buffer.length; - unsigned end = start + extension_size - 1; + unsigned end = start + extension_size; if (!buffer.resize (buffer.length + extension_size)) // TODO: resizing potentially invalidates existing head/tail pointers. return false; @@ -115,7 +115,11 @@ struct Lookup : public OT::Lookup extension->extensionLookupType = type; extension->extensionOffset = 0; - unsigned ext_index = graph.new_node (&buffer[start], &buffer[end]); + unsigned type_prime = extension->extensionLookupType; + printf("Assigned type %d to extension\n", type_prime); + + unsigned ext_index = graph.new_node (&buffer.arrayZ[start], + &buffer.arrayZ[end]); if (ext_index == (unsigned) -1) return false; auto& lookup_vertex = graph.vertices_[lookup_index]; @@ -142,6 +146,7 @@ struct Lookup : public OT::Lookup l->position = 4; l->bias = 0; + ext_vertex.parents.push (lookup_index); subtable_vertex.remap_parent (lookup_index, ext_index); return true;