[var] Adjust API in prep for 'avar' implementation

The 'avar' table does not allow random access to axis maps,
so change API to avoid quadratic-time implementation.

Removed -hb_ot_var_normalize_axis_value(), added
+hb_ot_var_normalize_variations() and
+hb_ot_var_normalize_coords() instead.
diff --git a/docs/harfbuzz-sections.txt b/docs/harfbuzz-sections.txt
index b4ae15d..fcf4e52 100644
--- a/docs/harfbuzz-sections.txt
+++ b/docs/harfbuzz-sections.txt
@@ -448,7 +448,8 @@
 hb_ot_var_find_axis
 hb_ot_var_get_axis_count
 hb_ot_var_get_axes
-hb_ot_var_normalize_axis_value
+hb_ot_var_normalize_variations
+hb_ot_var_normalize_coords
 </SECTION>
 
 <SECTION>
diff --git a/src/Makefile.sources b/src/Makefile.sources
index 279bc46..c74147c 100644
--- a/src/Makefile.sources
+++ b/src/Makefile.sources
@@ -109,6 +109,7 @@
 	hb-ot-shape-fallback.cc \
 	hb-ot-shape-private.hh \
 	hb-ot-var.cc \
+	hb-ot-var-avar-table.hh \
 	hb-ot-var-fvar-table.hh \
 	$(NULL)
 
diff --git a/src/hb-font.cc b/src/hb-font.cc
index a3f250d..ea45501 100644
--- a/src/hb-font.cc
+++ b/src/hb-font.cc
@@ -1570,22 +1570,15 @@
     return;
   }
 
-  hb_face_t *face = font->face;
-
-  unsigned int coords_length = hb_ot_var_get_axis_count (face);
+  unsigned int coords_length = hb_ot_var_get_axis_count (font->face);
 
   int *normalized = coords_length ? (int *) calloc (coords_length, sizeof (int)) : NULL;
   if (unlikely (coords_length && !normalized))
     return;
 
-  /* normalized is filled with zero already. */
-  for (unsigned int i = 0; i < variations_length; i++)
-  {
-    unsigned int axis_index;
-    if (hb_ot_var_find_axis (face, variations[i].tag, &axis_index, NULL))
-      normalized[axis_index] = hb_ot_var_normalize_axis_value (face, axis_index, variations[i].value);
-  }
-
+  hb_ot_var_normalize_variations (font->face,
+				  variations, variations_length,
+				  normalized, coords_length);
   _hb_font_adopt_var_coords_normalized (font, normalized, coords_length);
 }
 
@@ -1606,10 +1599,7 @@
   if (unlikely (coords_length && !normalized))
     return;
 
-  hb_face_t *face = font->face;
-  for (unsigned int i = 0; i < coords_length; i++)
-    normalized[i] = hb_ot_var_normalize_axis_value (face, i, coords[i]);
-
+  hb_ot_var_normalize_coords (font->face, coords_length, coords, normalized);
   _hb_font_adopt_var_coords_normalized (font, normalized, coords_length);
 }
 
diff --git a/src/hb-ot-var.cc b/src/hb-ot-var.cc
index 5080424..76016e6 100644
--- a/src/hb-ot-var.cc
+++ b/src/hb-ot-var.cc
@@ -27,6 +27,7 @@
 #include "hb-open-type-private.hh"
 
 #include "hb-ot-layout-private.hh"
+#include "hb-ot-var-avar-table.hh"
 #include "hb-ot-var-fvar-table.hh"
 #include "hb-ot-var.h"
 
@@ -105,16 +106,48 @@
   return fvar.find_axis (axis_tag, axis_index, axis_info);
 }
 
+
 /**
- * hb_ot_var_normalize_axis_value:
+ * hb_ot_var_normalize_variations:
  *
  * Since: 1.4.2
  **/
-int
-hb_ot_var_normalize_axis_value (hb_face_t    *face,
-				unsigned int  axis_index,
-				float         v)
+void
+hb_ot_var_normalize_variations (hb_face_t            *face,
+				const hb_variation_t *variations, /* IN */
+				unsigned int          variations_length,
+				int                  *coords, /* OUT */
+				unsigned int          coords_length)
+{
+  for (unsigned int i = 0; i < coords_length; i++)
+    coords[i] = 0;
+
+  const OT::fvar &fvar = _get_fvar (face);
+  for (unsigned int i = 0; i < variations_length; i++)
+  {
+    unsigned int axis_index;
+    if (hb_ot_var_find_axis (face, variations[i].tag, &axis_index, NULL) &&
+	axis_index < coords_length)
+      coords[axis_index] = fvar.normalize_axis_value (axis_index, variations[i].value);
+  }
+
+  /* TODO avar */
+}
+
+/**
+ * hb_ot_var_normalize_coords:
+ *
+ * Since: 1.4.2
+ **/
+void
+hb_ot_var_normalize_coords (hb_face_t    *face,
+			    unsigned int coords_length,
+			    const float *design_coords, /* IN */
+			    int *normalized_coords /* OUT */)
 {
   const OT::fvar &fvar = _get_fvar (face);
-  return fvar.normalize_axis_value (axis_index, v);
+  for (unsigned int i = 0; i < coords_length; i++)
+    normalized_coords[i] = fvar.normalize_axis_value (i, design_coords[i]);
+
+  /* TODO avar */
 }
diff --git a/src/hb-ot-var.h b/src/hb-ot-var.h
index 652a78d..bce7c7a 100644
--- a/src/hb-ot-var.h
+++ b/src/hb-ot-var.h
@@ -83,10 +83,18 @@
 		     hb_ot_var_axis_t *axis_info);
 
 
-HB_EXTERN int
-hb_ot_var_normalize_axis_value (hb_face_t    *face,
-				unsigned int  axis_index,
-				float         v);
+HB_EXTERN void
+hb_ot_var_normalize_variations (hb_face_t            *face,
+				const hb_variation_t *variations, /* IN */
+				unsigned int          variations_length,
+				int                  *coords, /* OUT */
+				unsigned int          coords_length);
+
+HB_EXTERN void
+hb_ot_var_normalize_coords (hb_face_t    *face,
+			    unsigned int coords_length,
+			    const float *design_coords, /* IN */
+			    int *normalized_coords /* OUT */);
 
 
 HB_END_DECLS