[config] Add HB_NO_OT_KERN, enabled by HB_MINI / HB_NO_LEGACY

Part of https://github.com/harfbuzz/harfbuzz/issues/1652
diff --git a/src/hb-config.hh b/src/hb-config.hh
index c1a15f8..e02694b 100644
--- a/src/hb-config.hh
+++ b/src/hb-config.hh
@@ -101,6 +101,7 @@
 
 #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
diff --git a/src/hb-ot-face-table-list.hh b/src/hb-ot-face-table-list.hh
index 74ee198..1dcfad4 100644
--- a/src/hb-ot-face-table-list.hh
+++ b/src/hb-ot-face-table-list.hh
@@ -50,7 +50,6 @@
 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, 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)
diff --git a/src/hb-ot-layout.cc b/src/hb-ot-layout.cc
index 0e75049..0761b8e 100644
--- a/src/hb-ot-layout.cc
+++ b/src/hb-ot-layout.cc
@@ -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 @@
   return face->table.kern->has_data ();
 }
 
-
 /**
  * hb_ot_layout_has_machine_kerning:
  * @face: The #hb_face_t to work on
@@ -95,7 +95,6 @@
   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 @@
 
   kern.apply (&c);
 }
+#endif
 
 
 /*
diff --git a/src/hb-ot-shape.cc b/src/hb-ot-shape.cc
index 635fa94..f5f1ae6 100644
--- a/src/hb-ot-shape.cc
+++ b/src/hb-ot-shape.cc
@@ -157,18 +157,28 @@
       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 @@
   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);
 
diff --git a/src/hb-ot-shape.hh b/src/hb-ot-shape.hh
index b7c0f10..0916442 100644
--- a/src/hb-ot-shape.hh
+++ b/src/hb-ot-shape.hh
@@ -80,7 +80,11 @@
   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;