diff --git a/src/graph/graph.hh b/src/graph/graph.hh index a56d7f48a..8afa570eb 100644 --- a/src/graph/graph.hh +++ b/src/graph/graph.hh @@ -653,6 +653,7 @@ struct graph_t clone->obj.tail = tail; clone->distance = 0; clone->space = 0; + printf("Creating new node from %p to %p\n", head, tail); unsigned clone_idx = vertices_.length - 2; diff --git a/src/graph/gsubgpos-graph.hh b/src/graph/gsubgpos-graph.hh index 984cb2467..5a3321b8e 100644 --- a/src/graph/gsubgpos-graph.hh +++ b/src/graph/gsubgpos-graph.hh @@ -104,8 +104,9 @@ struct Lookup : public OT::Lookup unsigned type = lookupType; unsigned extension_size = OT::ExtensionFormat1::static_size; unsigned start = buffer.length; - unsigned end = start + extension_size; + unsigned end = start + extension_size - 1; if (!buffer.resize (buffer.length + extension_size)) + // TODO: resizing potentially invalidates existing head/tail pointers. return false; OT::ExtensionFormat1* extension = diff --git a/src/graph/serialize.hh b/src/graph/serialize.hh index ecc6cc5ae..8797ed95a 100644 --- a/src/graph/serialize.hh +++ b/src/graph/serialize.hh @@ -205,6 +205,7 @@ inline hb_blob_t* serialize (const graph_t& graph) { hb_vector_t buffer; size_t size = graph.total_size_in_bytes (); + printf("Expected graph size: %lu.\n", size); if (!buffer.alloc (size)) { DEBUG_MSG (SUBSET_REPACK, nullptr, "Unable to allocate output buffer."); return nullptr; diff --git a/src/hb-repacker.hh b/src/hb-repacker.hh index ea2431a94..041b5260d 100644 --- a/src/hb-repacker.hh +++ b/src/hb-repacker.hh @@ -44,7 +44,7 @@ using graph::graph_t; */ static inline -void _make_extensions (hb_tag_t table_tag, graph_t& sorted_graph, hb_vector_t& buffer) +bool _make_extensions (hb_tag_t table_tag, graph_t& sorted_graph, hb_vector_t& buffer) { // TODO: Move this into graph or gsubgpos graph? hb_hashmap_t lookups; @@ -52,8 +52,10 @@ void _make_extensions (hb_tag_t table_tag, graph_t& sorted_graph, hb_vector_tmake_extension (table_tag, sorted_graph, p.first, buffer); + if (!p.second->make_extension (table_tag, sorted_graph, p.first, buffer)) + return false; } + return true; } static inline @@ -175,6 +177,8 @@ hb_resolve_overflows (const T& packed, printf("Resolving overflows!\n"); graph_t sorted_graph (packed); sorted_graph.sort_shortest_distance (); + printf("Initial graph size: %lu.\n", + sorted_graph.total_size_in_bytes ()); bool will_overflow = graph::will_overflow (sorted_graph); if (!will_overflow) @@ -183,11 +187,17 @@ hb_resolve_overflows (const T& packed, } hb_vector_t extension_buffer; + if (!extension_buffer.alloc(100000)) // TODO: cleanup + return nullptr; if ((table_tag == HB_OT_TAG_GPOS || table_tag == HB_OT_TAG_GSUB) && will_overflow) { - _make_extensions (table_tag, sorted_graph, extension_buffer); + if (!_make_extensions (table_tag, sorted_graph, extension_buffer)) { + printf("make extensions failed.\n"); + return nullptr; + } + DEBUG_MSG (SUBSET_REPACK, nullptr, "Assigning spaces to 32 bit subgraphs."); if (sorted_graph.assign_spaces ()) sorted_graph.sort_shortest_distance ();