From 5f17dbc3025093308d2191a4abd2eec24db35c0e Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Fri, 7 Sep 2018 10:24:22 -0400 Subject: [PATCH 1/2] [subset] Fix div-by-zero --- src/hb-subset.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/hb-subset.cc b/src/hb-subset.cc index adc7c51d0..2bed35868 100644 --- a/src/hb-subset.cc +++ b/src/hb-subset.cc @@ -51,6 +51,9 @@ _plan_estimate_subset_table_size (hb_subset_plan_t *plan, unsigned int src_glyphs = plan->source->get_num_glyphs (); unsigned int dst_glyphs = plan->glyphset->get_population (); + if (unlikely (!src_glyphs)) + return 512 + table_len; + return 512 + (unsigned int) (table_len * sqrt ((double) dst_glyphs / src_glyphs)); } From ebe67137ab3559c2c6aaf53442ca223cb34df5af Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Fri, 7 Sep 2018 10:46:13 -0400 Subject: [PATCH 2/2] Try fixing bots --- src/hb-ot-layout-common.hh | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/src/hb-ot-layout-common.hh b/src/hb-ot-layout-common.hh index 656d31dca..ca3d7d5d1 100644 --- a/src/hb-ot-layout-common.hh +++ b/src/hb-ot-layout-common.hh @@ -702,6 +702,23 @@ struct Lookup return_trace (true); } + /* Older compileres need this to NOT be locally defined in a function. */ + template + struct SubTableSubsetWrapper + { + inline SubTableSubsetWrapper (const TSubTable &subtable_, + unsigned int lookup_type_) : + subtable (subtable_), + lookup_type (lookup_type_) {} + + inline bool subset (hb_subset_context_t *c) const + { return subtable.dispatch (c, lookup_type); } + + private: + const TSubTable &subtable; + unsigned int lookup_type; + }; + template inline bool subset (hb_subset_context_t *c) const { @@ -717,20 +734,7 @@ struct Lookup unsigned int count = subTable.len; for (unsigned int i = 0; i < count; i++) { - struct Wrapper - { - inline Wrapper (const TSubTable &subtable_, - unsigned int lookup_type_) : - subtable (subtable_), - lookup_type (lookup_type_) {} - - inline bool subset (hb_subset_context_t *c) const - { return subtable.dispatch (c, lookup_type); } - - private: - const TSubTable &subtable; - unsigned int lookup_type; - } wrapper (this+subtables[i], get_type ()); + SubTableSubsetWrapper wrapper (this+subtables[i], get_type ()); out_subtables[i].serialize_subset (c, wrapper, out); }