[kerx] Don't loop over kerning subtables if kerning disabled
authorBehdad Esfahbod <behdad@behdad.org>
Wed, 10 Oct 2018 22:10:05 +0000 (18:10 -0400)
committerBehdad Esfahbod <behdad@behdad.org>
Wed, 10 Oct 2018 22:10:05 +0000 (18:10 -0400)
src/hb-aat-layout-kerx-table.hh
src/hb-ot-shape.cc
src/hb-ot-shape.hh

index 005208c..f5540b6 100644 (file)
@@ -59,6 +59,9 @@ struct KerxSubTableFormat0
   {
     TRACE_APPLY (this);
 
+    if (!c->plan->requested_kerning)
+      return false;
+
     hb_kern_machine_t<KerxSubTableFormat0> 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);
index 7a15d52..3b1c93d 100644 (file)
@@ -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. */
index fc444b2..4943c51 100644 (file)
@@ -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;