From 2f63f0c86117f115792ae10fe7274c1455dcb97c Mon Sep 17 00:00:00 2001 From: Garret Rieger Date: Thu, 21 Jul 2022 21:54:42 +0000 Subject: [PATCH] [repacker] support extension promotion in 24bit GSUB/GPOS. --- src/graph/gsubgpos-graph.hh | 19 ++++++++++++++----- src/hb-repacker.hh | 2 +- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/graph/gsubgpos-graph.hh b/src/graph/gsubgpos-graph.hh index beabec9f0..d62a8496e 100644 --- a/src/graph/gsubgpos-graph.hh +++ b/src/graph/gsubgpos-graph.hh @@ -77,7 +77,6 @@ struct Lookup : public OT::Lookup bool make_extension (make_extension_context_t& c, unsigned this_index) { - // TODO: use a context_t? unsigned type = lookupType; unsigned ext_type = extension_type (c.table_tag); if (!ext_type || is_extension (c.table_tag)) @@ -113,7 +112,6 @@ struct Lookup : public OT::Lookup unsigned start = c.buffer.length; unsigned end = start + extension_size; if (!c.buffer.resize (c.buffer.length + extension_size)) - // TODO: resizing potentially invalidates existing head/tail pointers. return false; OT::ExtensionFormat1* extension = @@ -209,12 +207,23 @@ struct GSTAR : public OT::GSUBGPOS void find_lookups (graph_t& graph, hb_hashmap_t& lookups /* OUT */) { - // TODO: template on types, based on gstar version. + switch (u.version.major) { + case 1: find_lookups (graph, lookups); break; +#ifndef HB_NO_BORING_EXPANSION + case 2: find_lookups (graph, lookups); break; +#endif + } + } + + template + void find_lookups (graph_t& graph, + hb_hashmap_t& lookups /* OUT */) + { unsigned lookup_list_idx = graph.index_for_offset (graph.root_idx (), get_lookup_list_field_offset()); - const LookupList* lookupList = - (const LookupList*) graph.object (lookup_list_idx).head; + const LookupList* lookupList = + (const LookupList*) graph.object (lookup_list_idx).head; if (!lookupList->sanitize (graph.vertices_[lookup_list_idx])) return; diff --git a/src/hb-repacker.hh b/src/hb-repacker.hh index c434c67ec..e52d0c00c 100644 --- a/src/hb-repacker.hh +++ b/src/hb-repacker.hh @@ -193,7 +193,7 @@ hb_resolve_overflows (const T& packed, if (ext_context.in_error ()) return nullptr; - if (1 && !_promote_extensions_if_needed (ext_context)) { + if (0 && !_promote_extensions_if_needed (ext_context)) { DEBUG_MSG (SUBSET_REPACK, nullptr, "Extensions promotion failed."); return nullptr; }