From 60f86d32d7c735ccf783b382e18ecdc096eaa682 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Wed, 10 Oct 2018 18:10:05 -0400 Subject: [PATCH] [kerx] Don't loop over kerning subtables if kerning disabled --- src/hb-aat-layout-kerx-table.hh | 12 ++++++++++++ src/hb-ot-shape.cc | 4 ++-- src/hb-ot-shape.hh | 1 + 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/hb-aat-layout-kerx-table.hh b/src/hb-aat-layout-kerx-table.hh index 005208c60..f5540b6e9 100644 --- a/src/hb-aat-layout-kerx-table.hh +++ b/src/hb-aat-layout-kerx-table.hh @@ -59,6 +59,9 @@ struct KerxSubTableFormat0 { TRACE_APPLY (this); + if (!c->plan->requested_kerning) + return false; + hb_kern_machine_t machine (*this); machine.kern (c->font, c->buffer, c->plan->kern_mask); @@ -85,6 +88,9 @@ struct KerxSubTableFormat1 { TRACE_APPLY (this); + if (!c->plan->requested_kerning) + return false; + /* TODO */ return_trace (true); @@ -123,6 +129,9 @@ struct KerxSubTableFormat2 { TRACE_APPLY (this); + if (!c->plan->requested_kerning) + return false; + accelerator_t accel (*this, c->sanitizer.end, c->face->get_num_glyphs ()); @@ -203,6 +212,9 @@ struct KerxSubTableFormat6 { TRACE_APPLY (this); + if (!c->plan->requested_kerning) + return false; + /* TODO */ return_trace (true); diff --git a/src/hb-ot-shape.cc b/src/hb-ot-shape.cc index 7a15d5234..3b1c93db4 100644 --- a/src/hb-ot-shape.cc +++ b/src/hb-ot-shape.cc @@ -71,7 +71,7 @@ hb_ot_shape_planner_t::compile (hb_ot_shape_plan_t &plan, HB_TAG ('k','e','r','n') : HB_TAG ('v','k','r','n'); plan.kern_mask = plan.map.get_mask (kern_tag); - bool kerning_requested = !!plan.kern_mask; + plan.requested_kerning = !!plan.kern_mask; bool has_gpos_kern = plan.map.get_feature_index (1, kern_tag) != HB_OT_LAYOUT_NO_FEATURE_INDEX; bool disable_gpos = plan.shaper->gpos_tag && plan.shaper->gpos_tag != plan.map.chosen_script[1]; @@ -100,7 +100,7 @@ hb_ot_shape_planner_t::compile (hb_ot_shape_plan_t &plan, else if (hb_aat_layout_has_positioning (face)) plan.apply_kerx = true; - if (kerning_requested) + if (plan.requested_kerning) { if (plan.apply_kerx) ;/* kerx supercedes kern. */ diff --git a/src/hb-ot-shape.hh b/src/hb-ot-shape.hh index fc444b252..4943c5155 100644 --- a/src/hb-ot-shape.hh +++ b/src/hb-ot-shape.hh @@ -43,6 +43,7 @@ struct hb_ot_shape_plan_t hb_mask_t rtlm_mask, frac_mask, numr_mask, dnom_mask; hb_mask_t kern_mask; + bool requested_kerning : 1; bool has_frac : 1; bool has_gpos_mark : 1; bool fallback_glyph_classes : 1;