[config] Add HB_NO_OT_KERN, enabled by HB_MINI / HB_NO_LEGACY
authorBehdad Esfahbod <behdad@behdad.org>
Wed, 19 Jun 2019 23:24:51 +0000 (16:24 -0700)
committerBehdad Esfahbod <behdad@behdad.org>
Wed, 19 Jun 2019 23:24:51 +0000 (16:24 -0700)
Part of https://github.com/harfbuzz/harfbuzz/issues/1652

src/hb-config.hh
src/hb-ot-face-table-list.hh
src/hb-ot-layout.cc
src/hb-ot-shape.cc
src/hb-ot-shape.hh

index c1a15f8..e02694b 100644 (file)
 
 #ifdef HB_NO_LEGACY
 #define HB_NO_FALLBACK_SHAPE
+#define HB_NO_OT_KERN
 #define HB_NO_OT_LAYOUT_BLACKLIST
 #define HB_NO_OT_SHAPE_FALLBACK
 #endif
index 74ee198..1dcfad4 100644 (file)
@@ -50,7 +50,6 @@ HB_OT_TABLE (OT, head)
 HB_OT_ACCELERATOR (OT, cmap)
 HB_OT_ACCELERATOR (OT, hmtx)
 HB_OT_ACCELERATOR (OT, post)
-HB_OT_TABLE (OT, kern)
 HB_OT_ACCELERATOR (OT, name)
 HB_OT_TABLE (OT, OS2)
 HB_OT_TABLE (OT, STAT)
@@ -73,6 +72,11 @@ HB_OT_TABLE (OT, fvar)
 HB_OT_TABLE (OT, avar)
 HB_OT_TABLE (OT, MVAR)
 
+/* Legacy kern. */
+#ifndef HB_NO_OT_KERN
+HB_OT_TABLE (OT, kern)
+#endif
+
 /* OpenType shaping. */
 HB_OT_ACCELERATOR (OT, GDEF)
 HB_OT_ACCELERATOR (OT, GSUB)
index 0e75049..0761b8e 100644 (file)
@@ -62,6 +62,7 @@
  * kern
  */
 
+#ifndef HB_NO_OT_KERN
 /**
  * hb_ot_layout_has_kerning:
  * @face: The #hb_face_t to work on
@@ -78,7 +79,6 @@ hb_ot_layout_has_kerning (hb_face_t *face)
   return face->table.kern->has_data ();
 }
 
-
 /**
  * hb_ot_layout_has_machine_kerning:
  * @face: The #hb_face_t to work on
@@ -95,7 +95,6 @@ hb_ot_layout_has_machine_kerning (hb_face_t *face)
   return face->table.kern->has_state_machine ();
 }
 
-
 /**
  * hb_ot_layout_has_cross_kerning:
  * @face: The #hb_face_t to work on
@@ -128,6 +127,7 @@ hb_ot_layout_kern (const hb_ot_shape_plan_t *plan,
 
   kern.apply (&c);
 }
+#endif
 
 
 /*
index 635fa94..f5f1ae6 100644 (file)
@@ -157,18 +157,28 @@ hb_ot_shape_planner_t::compile (hb_ot_shape_plan_t           &plan,
       plan.apply_kerx = true;
     else
 #endif
+#ifndef HB_NO_OT_KERN
     if (hb_ot_layout_has_kerning (face))
       plan.apply_kern = true;
+#endif
   }
 
   plan.zero_marks = script_zero_marks &&
                    !plan.apply_kerx &&
-                   (!plan.apply_kern || !hb_ot_layout_has_machine_kerning (face));
+                   (!plan.apply_kern
+#ifndef HB_NO_OT_KERN
+                    || !hb_ot_layout_has_machine_kerning (face)
+#endif
+                   );
   plan.has_gpos_mark = !!plan.map.get_1_mask (HB_TAG ('m','a','r','k'));
 
   plan.adjust_mark_positioning_when_zeroing = !plan.apply_gpos &&
                                              !plan.apply_kerx &&
-                                             (!plan.apply_kern || !hb_ot_layout_has_cross_kerning (face));
+                                             (!plan.apply_kern
+#ifndef HB_NO_OT_KERN
+                                              || !hb_ot_layout_has_cross_kerning (face)
+#endif
+                                             );
 
   plan.fallback_mark_positioning = plan.adjust_mark_positioning_when_zeroing &&
                                   script_fallback_mark_positioning;
@@ -237,8 +247,10 @@ hb_ot_shape_plan_t::position (hb_font_t   *font,
   else if (this->apply_kerx)
     hb_aat_layout_position (this, font, buffer);
 #endif
+#ifndef HB_NO_OT_KERN
   else if (this->apply_kern)
     hb_ot_layout_kern (this, font, buffer);
+#endif
   else
     _hb_ot_shape_fallback_kern (this, font, buffer);
 
index b7c0f10..0916442 100644 (file)
@@ -80,7 +80,11 @@ struct hb_ot_shape_plan_t
   bool adjust_mark_positioning_when_zeroing : 1;
 
   bool apply_gpos : 1;
+#ifndef HB_NO_OT_KERN
   bool apply_kern : 1;
+#else
+  static constexpr bool apply_kern = false;
+#endif
 #ifndef HB_NO_SHAPE_AAT
   bool apply_kerx : 1;
   bool apply_morx : 1;