[config] Add HB_NO_VAR to disable variations support, enabled by HB_TINY

Part of https://github.com/harfbuzz/harfbuzz/issues/1652
diff --git a/src/hb-config.hh b/src/hb-config.hh
index 3f9a9ca..8f78ede 100644
--- a/src/hb-config.hh
+++ b/src/hb-config.hh
@@ -69,6 +69,7 @@
 #define HB_NO_OT_SHAPE_FRACTIONS
 #define HB_NO_STAT
 #define HB_NO_SUBSET_LAYOUT
+#define HB_NO_VAR
 #endif
 
 #ifdef HB_MINI
diff --git a/src/hb-font.cc b/src/hb-font.cc
index 7eee284..f450d88 100644
--- a/src/hb-font.cc
+++ b/src/hb-font.cc
@@ -1824,6 +1824,7 @@
   font->num_coords = coords_length;
 }
 
+#ifndef HB_NO_VAR
 /**
  * hb_font_set_variations:
  *
@@ -1854,7 +1855,6 @@
 				  normalized, coords_length);
   _hb_font_adopt_var_coords_normalized (font, normalized, coords_length);
 }
-
 /**
  * hb_font_set_var_coords_design:
  *
@@ -1875,6 +1875,7 @@
   hb_ot_var_normalize_coords (font->face, coords_length, coords, normalized);
   _hb_font_adopt_var_coords_normalized (font, normalized, coords_length);
 }
+#endif
 
 /**
  * hb_font_set_var_coords_normalized:
diff --git a/src/hb-ot-face-table-list.hh b/src/hb-ot-face-table-list.hh
index 348c3b2..e4ed6b0 100644
--- a/src/hb-ot-face-table-list.hh
+++ b/src/hb-ot-face-table-list.hh
@@ -74,9 +74,11 @@
 #endif
 
 /* OpenType variations. */
+#ifndef HB_NO_VAR
 HB_OT_TABLE (OT, fvar)
 HB_OT_TABLE (OT, avar)
 HB_OT_TABLE (OT, MVAR)
+#endif
 
 /* Legacy kern. */
 #ifndef HB_NO_OT_KERN
diff --git a/src/hb-ot-layout-common.hh b/src/hb-ot-layout-common.hh
index f801f5a..c332e28 100644
--- a/src/hb-ot-layout-common.hh
+++ b/src/hb-ot-layout-common.hh
@@ -1747,11 +1747,11 @@
                     float *scalars /*OUT */,
                     unsigned int num_scalars) const
   {
-    assert (num_scalars == regionIndices.len);
-   for (unsigned int i = 0; i < num_scalars; i++)
-   {
-     scalars[i] = regions.evaluate (regionIndices.arrayZ[i], coords, coord_count);
-   }
+    unsigned count = hb_min (num_scalars, regionIndices.len);
+    for (unsigned int i = 0; i < count; i++)
+      scalars[i] = regions.evaluate (regionIndices.arrayZ[i], coords, coord_count);
+    for (unsigned int i = count; i < num_scalars; i++)
+      scalars[i] = 0.f;
   }
 
   bool sanitize (hb_sanitize_context_t *c) const
@@ -1779,8 +1779,12 @@
   float get_delta (unsigned int outer, unsigned int inner,
 		   const int *coords, unsigned int coord_count) const
   {
+#ifdef HB_NO_VAR
+    return 0.f;
+#endif
+
     if (unlikely (outer >= dataSets.len))
-      return 0.;
+      return 0.f;
 
     return (this+dataSets[outer]).get_delta (inner,
 					     coords, coord_count,
@@ -1797,6 +1801,10 @@
 
   bool sanitize (hb_sanitize_context_t *c) const
   {
+#ifdef HB_NO_VAR
+    return true;
+#endif
+
     TRACE_SANITIZE (this);
     return_trace (c->check_struct (this) &&
 		  format == 1 &&
@@ -1812,6 +1820,12 @@
 		    float *scalars /*OUT*/,
 		    unsigned int num_scalars) const
   {
+#ifdef HB_NO_VAR
+    for (unsigned i = 0; i < num_scalars; i++)
+      scalars[i] = 0.f;
+    return;
+#endif
+
     (this+dataSets[ivs]).get_scalars (coords, coord_count, this+regions,
                                       &scalars[0], num_scalars);
   }
@@ -2154,8 +2168,10 @@
     {
     case 1: case 2: case 3:
       return u.hinting.get_x_delta (font);
+#ifndef HB_NO_VAR
     case 0x8000:
       return u.variation.get_x_delta (font, store);
+#endif
     default:
       return 0;
     }
@@ -2166,8 +2182,10 @@
     {
     case 1: case 2: case 3:
       return u.hinting.get_y_delta (font);
+#ifndef HB_NO_VAR
     case 0x8000:
       return u.variation.get_y_delta (font, store);
+#endif
     default:
       return 0;
     }
@@ -2180,8 +2198,10 @@
     switch (u.b.format) {
     case 1: case 2: case 3:
       return_trace (u.hinting.sanitize (c));
+#ifndef HB_NO_VAR
     case 0x8000:
       return_trace (u.variation.sanitize (c));
+#endif
     default:
       return_trace (true);
     }
@@ -2191,7 +2211,9 @@
   union {
   DeviceHeader		b;
   HintingDevice		hinting;
+#ifndef HB_NO_VAR
   VariationDevice	variation;
+#endif
   } u;
   public:
   DEFINE_SIZE_UNION (6, b);
diff --git a/src/hb-ot-layout-gsubgpos.hh b/src/hb-ot-layout-gsubgpos.hh
index 4bc3d7e..dd54c9b 100644
--- a/src/hb-ot-layout-gsubgpos.hh
+++ b/src/hb-ot-layout-gsubgpos.hh
@@ -2661,11 +2661,17 @@
 
   bool find_variations_index (const int *coords, unsigned int num_coords,
 			      unsigned int *index) const
-  { return (version.to_int () >= 0x00010001u ? this+featureVars : Null(FeatureVariations))
-	   .find_index (coords, num_coords, index); }
+  {
+#ifdef HB_NOVAR
+    return false;
+#endif
+    return (version.to_int () >= 0x00010001u ? this+featureVars : Null(FeatureVariations))
+	    .find_index (coords, num_coords, index);
+  }
   const Feature& get_feature_variation (unsigned int feature_index,
 					unsigned int variations_index) const
   {
+#ifndef HB_NO_VAR
     if (FeatureVariations::NOT_FOUND_INDEX != variations_index &&
 	version.to_int () >= 0x00010001u)
     {
@@ -2674,6 +2680,7 @@
       if (feature)
 	return *feature;
     }
+#endif
     return get_feature (feature_index);
   }
 
@@ -2695,8 +2702,10 @@
 			 this,
 			 out);
 
+#ifndef HB_NO_VAR
     if (version.to_int () >= 0x00010001u)
      out->featureVars.serialize_copy (c->serializer, featureVars, this, out);
+#endif
 
     return_trace (true);
   }
@@ -2717,7 +2726,10 @@
 		  scriptList.sanitize (c, this) &&
 		  featureList.sanitize (c, this) &&
 		  CastR<OffsetTo<TLookupList>> (lookupList).sanitize (c, this) &&
-		  (version.to_int () < 0x00010001u || featureVars.sanitize (c, this)));
+#ifndef HB_NO_VAR
+		  (version.to_int () < 0x00010001u || featureVars.sanitize (c, this)) &&
+#endif
+		  true);
   }
 
   template <typename T>
diff --git a/src/hb-ot-var.cc b/src/hb-ot-var.cc
index 5eea90d..6b8b09b 100644
--- a/src/hb-ot-var.cc
+++ b/src/hb-ot-var.cc
@@ -24,7 +24,9 @@
  * Google Author(s): Behdad Esfahbod
  */
 
-#include "hb-open-type.hh"
+#include "hb.hh"
+
+#ifndef HB_NO_VAR
 
 #include "hb-ot-var.h"
 
@@ -213,3 +215,6 @@
 
   face->table.avar->map_coords (normalized_coords, coords_length);
 }
+
+
+#endif
diff --git a/src/hb-subset-plan.cc b/src/hb-subset-plan.cc
index f487733..6b33c17 100644
--- a/src/hb-subset-plan.cc
+++ b/src/hb-subset-plan.cc
@@ -197,7 +197,9 @@
 #ifndef HB_NO_STAT
   face->table.STAT->collect_name_ids (nameids);
 #endif
+#ifndef HB_NO_VAR
   face->table.fvar->collect_name_ids (nameids);
+#endif
 }
 
 /**