diff --git a/src/OT/Layout/GDEF/GDEF.hh b/src/OT/Layout/GDEF/GDEF.hh index 0551fcf81..df51ea70f 100644 --- a/src/OT/Layout/GDEF/GDEF.hh +++ b/src/OT/Layout/GDEF/GDEF.hh @@ -32,6 +32,7 @@ #include "../../../hb-ot-layout-common.hh" #include "../../../hb-font.hh" +#include "../../../hb-cache.hh" namespace OT { @@ -861,7 +862,21 @@ struct GDEF } ~accelerator_t () { table.destroy (); } + unsigned int get_glyph_props (hb_codepoint_t glyph) const + { + unsigned v; + if (glyph_props_cache.get (glyph, &v)) + return v; + + v = table->get_glyph_props (glyph); + if (likely (table)) // Don't try setting if we are the null instance! + glyph_props_cache.set (glyph, v); + + return v; + } + hb_blob_ptr_t table; + mutable hb_cache_t<21, 3, 8> glyph_props_cache; }; void collect_variation_indices (hb_collect_variation_indices_context_t *c) const diff --git a/src/hb-null.hh b/src/hb-null.hh index 0d7f4da79..3da2d75ef 100644 --- a/src/hb-null.hh +++ b/src/hb-null.hh @@ -37,7 +37,7 @@ /* Global nul-content Null pool. Enlarge as necessary. */ -#define HB_NULL_POOL_SIZE 448 +#define HB_NULL_POOL_SIZE 520 template struct _hb_has_min_size : hb_false_type {}; diff --git a/src/hb-ot-layout-gsubgpos.hh b/src/hb-ot-layout-gsubgpos.hh index 5328cc024..25dcdae19 100644 --- a/src/hb-ot-layout-gsubgpos.hh +++ b/src/hb-ot-layout-gsubgpos.hh @@ -695,6 +695,7 @@ struct hb_ot_apply_context_t : hb_buffer_t *buffer; recurse_func_t recurse_func = nullptr; const GDEF &gdef; + const GDEF::accelerator_t &gdef_accel; const VariationStore &var_store; VariationStore::cache_t *var_store_cache; hb_set_digest_t digest; @@ -726,6 +727,13 @@ struct hb_ot_apply_context_t : *face->table.GDEF->table #else Null (GDEF) +#endif + ), + gdef_accel ( +#ifndef HB_NO_OT_LAYOUT + *face->table.GDEF +#else + Null (GDEF::accelerator_t) #endif ), var_store (gdef.get_var_store ()), @@ -836,7 +844,7 @@ struct hb_ot_apply_context_t : if (likely (has_glyph_classes)) { props &= HB_OT_LAYOUT_GLYPH_PROPS_PRESERVE; - _hb_glyph_info_set_glyph_props (&buffer->cur(), props | gdef.get_glyph_props (glyph_index)); + _hb_glyph_info_set_glyph_props (&buffer->cur(), props | gdef_accel.get_glyph_props (glyph_index)); } else if (class_guess) { diff --git a/src/hb-ot-layout.cc b/src/hb-ot-layout.cc index 769af56a0..86d176454 100644 --- a/src/hb-ot-layout.cc +++ b/src/hb-ot-layout.cc @@ -257,7 +257,7 @@ _hb_ot_layout_set_glyph_props (hb_font_t *font, { _hb_buffer_assert_gsubgpos_vars (buffer); - const OT::GDEF &gdef = *font->face->table.GDEF->table; + const auto &gdef = *font->face->table.GDEF; unsigned int count = buffer->len; hb_glyph_info_t *info = buffer->info; for (unsigned int i = 0; i < count; i++)