From 0a5b69b25508680c09e098bf0ea615f3c277653a Mon Sep 17 00:00:00 2001 From: Garret Rieger Date: Mon, 25 Jul 2022 20:11:24 +0000 Subject: [PATCH] [repacker] when calculating 16bit space size also consider ext lookup subtables. --- src/hb-repacker.hh | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/hb-repacker.hh b/src/hb-repacker.hh index d22245845..bbc35f554 100644 --- a/src/hb-repacker.hh +++ b/src/hb-repacker.hh @@ -93,11 +93,26 @@ bool _promote_extensions_if_needed (graph::make_extension_context_t& ext_context size_t accumlated_bytes = ext_context.graph.vertices_[ext_context.lookup_list_index].table_size (); + // For the size of 16bit space, first add the size of all ext lookup subtables (as if all lookups + // were extensions). for (auto p : lookup_sizes) { unsigned lookup_index = p.first; + accumlated_bytes += ext_context.lookups.get(lookup_index)->number_of_subtables () * 8; + } + + for (auto p : lookup_sizes) + { + unsigned lookup_index = p.first; + const graph::Lookup* lookup = ext_context.lookups.get(lookup_index); + if (lookup->is_extension (ext_context.table_tag)) + // already extension, size is counted by the loop above. + continue; + size_t size = p.second; accumlated_bytes += size; + // will not be an extension lookup so subtract size counted in the above loop. + accumlated_bytes -= lookup->number_of_subtables () * 8; if (accumlated_bytes < (1 << 16)) continue; // this lookup fits with 64k, which won't overflow.