[repacker] include LookupList size when calculating size of 16bit space for ext promotion decisions.
diff --git a/src/graph/graph.hh b/src/graph/graph.hh
index df845da..5c5b5a4 100644
--- a/src/graph/graph.hh
+++ b/src/graph/graph.hh
@@ -111,6 +111,10 @@
return priority >= 3;
}
+ size_t table_size () const {
+ return obj.tail - obj.head;
+ }
+
int64_t modified_distance (unsigned order) const
{
// TODO(garretrieger): once priority is high enough, should try
diff --git a/src/graph/gsubgpos-graph.cc b/src/graph/gsubgpos-graph.cc
index 12f44f8..d12e52f 100644
--- a/src/graph/gsubgpos-graph.cc
+++ b/src/graph/gsubgpos-graph.cc
@@ -34,11 +34,14 @@
: table_tag (table_tag_),
graph (graph_),
buffer (buffer_),
+ lookup_list_index (0),
lookups ()
{
GSTAR* gstar = graph::GSTAR::graph_to_gstar (graph_);
- if (gstar)
+ if (gstar) {
gstar->find_lookups (graph, lookups);
+ lookup_list_index = gstar->get_lookup_list_index (graph_);
+ }
unsigned extension_size = OT::ExtensionFormat1<OT::Layout::GSUB_impl::ExtensionSubst>::static_size;
buffer.alloc (num_non_ext_subtables () * extension_size);
diff --git a/src/graph/gsubgpos-graph.hh b/src/graph/gsubgpos-graph.hh
index 73abc3e..80fffaf 100644
--- a/src/graph/gsubgpos-graph.hh
+++ b/src/graph/gsubgpos-graph.hh
@@ -40,6 +40,7 @@
hb_tag_t table_tag;
graph_t& graph;
hb_vector_t<char>& buffer;
+ unsigned lookup_list_index;
hb_hashmap_t<unsigned, graph::Lookup*> lookups;
HB_INTERNAL make_extension_context_t (hb_tag_t table_tag_,
@@ -224,12 +225,17 @@
}
}
+ unsigned get_lookup_list_index (graph_t& graph)
+ {
+ return graph.index_for_offset (graph.root_idx (),
+ get_lookup_list_field_offset());
+ }
+
template<typename Types>
void find_lookups (graph_t& graph,
hb_hashmap_t<unsigned, Lookup*>& lookups /* OUT */)
{
- unsigned lookup_list_idx = graph.index_for_offset (graph.root_idx (),
- get_lookup_list_field_offset());
+ unsigned lookup_list_idx = get_lookup_list_index (graph);
const LookupList<Types>* lookupList =
(const LookupList<Types>*) graph.object (lookup_list_idx).head;
diff --git a/src/hb-repacker.hh b/src/hb-repacker.hh
index af7017a..d222458 100644
--- a/src/hb-repacker.hh
+++ b/src/hb-repacker.hh
@@ -74,6 +74,8 @@
// TODO(garretrieger): also support extension promotion during iterative resolution phase, then
// we can use a less conservative threshold here.
+ if (!ext_context.lookups) return true;
+
hb_vector_t<hb_pair_t<unsigned, size_t>> lookup_sizes;
lookup_sizes.alloc (ext_context.lookups.get_population ());
@@ -88,7 +90,9 @@
lookup_sizes.qsort (compare_sizes);
- size_t accumlated_bytes = 0;
+ size_t accumlated_bytes =
+ ext_context.graph.vertices_[ext_context.lookup_list_index].table_size ();
+
for (auto p : lookup_sizes)
{
unsigned lookup_index = p.first;