Partially switch ot shaper to shape_plan
diff --git a/src/hb-buffer-private.hh b/src/hb-buffer-private.hh
index e06a7fa..b800aeb 100644
--- a/src/hb-buffer-private.hh
+++ b/src/hb-buffer-private.hh
@@ -46,6 +46,7 @@
     hb_language_t       language;
     ASSERT_POD ();
 } hb_segment_properties_t;
+#define _HB_BUFFER_PROPS_DEFAULT { HB_DIRECTION_INVALID, HB_SCRIPT_INVALID, HB_LANGUAGE_INVALID }
 
 
 struct hb_buffer_t {
diff --git a/src/hb-buffer.cc b/src/hb-buffer.cc
index 2b4acff..f8c62ac 100644
--- a/src/hb-buffer.cc
+++ b/src/hb-buffer.cc
@@ -38,7 +38,6 @@
 #endif
 
 #define _HB_BUFFER_UNICODE_FUNCS_DEFAULT (const_cast<hb_unicode_funcs_t *> (&_hb_unicode_funcs_default))
-#define _HB_BUFFER_PROPS_DEFAULT { HB_DIRECTION_INVALID, HB_SCRIPT_INVALID, HB_LANGUAGE_INVALID }
 
 /* Here is how the buffer works internally:
  *
diff --git a/src/hb-font-private.hh b/src/hb-font-private.hh
index 2540dd6..f1b43c0 100644
--- a/src/hb-font-private.hh
+++ b/src/hb-font-private.hh
@@ -97,8 +97,6 @@
   void                      *user_data;
   hb_destroy_func_t          destroy;
 
-  struct hb_ot_layout_t *ot_layout;
-
   unsigned int index;
   unsigned int upem;
 
diff --git a/src/hb-font.cc b/src/hb-font.cc
index 1261077..5a3219a 100644
--- a/src/hb-font.cc
+++ b/src/hb-font.cc
@@ -589,10 +589,14 @@
   NULL, /* user_data */
   NULL, /* destroy */
 
-  NULL, /* ot_layout */
-
   0,    /* index */
-  1000  /* upem */
+  1000, /* upem */
+
+  {
+#define HB_SHAPER_IMPLEMENT(shaper) HB_SHAPER_DATA_INVALID,
+#include "hb-shaper-list.hh"
+#undef HB_SHAPER_IMPLEMENT
+  }
 };
 
 
@@ -613,8 +617,6 @@
   face->user_data = user_data;
   face->destroy = destroy;
 
-  face->ot_layout = _hb_ot_layout_create (face);
-
   face->upem = 0;
 
   return face;
@@ -707,8 +709,6 @@
 {
   if (!hb_object_destroy (face)) return;
 
-  _hb_ot_layout_destroy (face->ot_layout);
-
 #define HB_SHAPER_IMPLEMENT(shaper) HB_SHAPER_DATA_DESTROY(shaper, face);
 #include "hb-shaper-list.hh"
 #undef HB_SHAPER_IMPLEMENT
@@ -877,7 +877,13 @@
 
     const_cast<hb_font_funcs_t *> (&_hb_font_funcs_nil), /* klass */
     NULL, /* user_data */
-    NULL  /* destroy */
+    NULL, /* destroy */
+
+    {
+#define HB_SHAPER_IMPLEMENT(shaper) HB_SHAPER_DATA_INVALID,
+#include "hb-shaper-list.hh"
+#undef HB_SHAPER_IMPLEMENT
+    }
   };
 
   return const_cast<hb_font_t *> (&_hb_font_nil);
diff --git a/src/hb-ot-layout-gpos-table.hh b/src/hb-ot-layout-gpos-table.hh
index 5b71407..a35f633 100644
--- a/src/hb-ot-layout-gpos-table.hh
+++ b/src/hb-ot-layout-gpos-table.hh
@@ -1553,7 +1553,7 @@
 
 static inline bool position_lookup (hb_apply_context_t *c, unsigned int lookup_index)
 {
-  const GPOS &gpos = *(c->face->ot_layout->gpos);
+  const GPOS &gpos = *(hb_ot_layout_from_face (c->face)->gpos);
   const PosLookup &l = gpos.get_lookup (lookup_index);
 
   if (unlikely (c->nesting_level_left == 0))
diff --git a/src/hb-ot-layout-gsub-table.hh b/src/hb-ot-layout-gsub-table.hh
index 600a92a..038cb93 100644
--- a/src/hb-ot-layout-gsub-table.hh
+++ b/src/hb-ot-layout-gsub-table.hh
@@ -1241,7 +1241,7 @@
 
 static inline void closure_lookup (hb_closure_context_t *c, unsigned int lookup_index)
 {
-  const GSUB &gsub = *(c->face->ot_layout->gsub);
+  const GSUB &gsub = *(hb_ot_layout_from_face (c->face)->gsub);
   const SubstLookup &l = gsub.get_lookup (lookup_index);
 
   if (unlikely (c->nesting_level_left == 0))
@@ -1254,7 +1254,7 @@
 
 static inline bool substitute_lookup (hb_apply_context_t *c, unsigned int lookup_index)
 {
-  const GSUB &gsub = *(c->face->ot_layout->gsub);
+  const GSUB &gsub = *(hb_ot_layout_from_face (c->face)->gsub);
   const SubstLookup &l = gsub.get_lookup (lookup_index);
 
   if (unlikely (c->nesting_level_left == 0))
diff --git a/src/hb-ot-layout-private.hh b/src/hb-ot-layout-private.hh
index ba375aa..294c359 100644
--- a/src/hb-ot-layout-private.hh
+++ b/src/hb-ot-layout-private.hh
@@ -36,6 +36,7 @@
 #include "hb-ot-shape-complex-private.hh"
 
 
+#define hb_ot_layout_from_face(face) ((hb_ot_layout_t *) face->shaper_data.ot)
 
 /*
  * GDEF
diff --git a/src/hb-ot-layout.cc b/src/hb-ot-layout.cc
index c6de75c..dff3673 100644
--- a/src/hb-ot-layout.cc
+++ b/src/hb-ot-layout.cc
@@ -70,17 +70,20 @@
 static inline const GDEF&
 _get_gdef (hb_face_t *face)
 {
-  return likely (face->ot_layout && face->ot_layout->gdef) ? *face->ot_layout->gdef : Null(GDEF);
+  /* XXX ensure ot_layout, and speed up */
+  return *hb_ot_layout_from_face (face)->gdef;
 }
 static inline const GSUB&
 _get_gsub (hb_face_t *face)
 {
-  return likely (face->ot_layout && face->ot_layout->gsub) ? *face->ot_layout->gsub : Null(GSUB);
+  /* XXX ensure ot_layout, and speed up */
+  return *hb_ot_layout_from_face (face)->gsub;
 }
 static inline const GPOS&
 _get_gpos (hb_face_t *face)
 {
-  return likely (face->ot_layout && face->ot_layout->gpos) ? *face->ot_layout->gpos : Null(GPOS);
+  /* XXX ensure ot_layout, and speed up */
+  return *hb_ot_layout_from_face (face)->gpos;
 }
 
 
diff --git a/src/hb-ot-shape.cc b/src/hb-ot-shape.cc
index 639748e..22dea07 100644
--- a/src/hb-ot-shape.cc
+++ b/src/hb-ot-shape.cc
@@ -44,12 +44,13 @@
 hb_ot_shaper_face_data_t *
 _hb_ot_shaper_face_data_create (hb_face_t *face)
 {
-  return (hb_ot_shaper_face_data_t *) HB_SHAPER_DATA_SUCCEEDED;
+  return _hb_ot_layout_create (face);
 }
 
 void
 _hb_ot_shaper_face_data_destroy (hb_ot_shaper_face_data_t *data)
 {
+  _hb_ot_layout_destroy (data);
 }
 
 
diff --git a/src/hb-shape-plan.cc b/src/hb-shape-plan.cc
index db21e88..099d09c 100644
--- a/src/hb-shape-plan.cc
+++ b/src/hb-shape-plan.cc
@@ -136,6 +136,17 @@
 {
   static const hb_shape_plan_t _hb_shape_plan_nil = {
     HB_OBJECT_HEADER_STATIC,
+
+    NULL, /* face */
+    _HB_BUFFER_PROPS_DEFAULT, /* props */
+
+    {NULL}, /* shapers */
+
+    {
+#define HB_SHAPER_IMPLEMENT(shaper) HB_SHAPER_DATA_INVALID,
+#include "hb-shaper-list.hh"
+#undef HB_SHAPER_IMPLEMENT
+    }
   };
 
   return const_cast<hb_shape_plan_t *> (&_hb_shape_plan_nil);
diff --git a/src/hb-shaper-private.hh b/src/hb-shaper-private.hh
index 1cf7c5b..e50d869 100644
--- a/src/hb-shaper-private.hh
+++ b/src/hb-shaper-private.hh
@@ -68,7 +68,8 @@
 #define HB_SHAPER_DATA_IS_INVALID(data) ((void *) (data) == HB_SHAPER_DATA_INVALID)
 
 #define HB_SHAPER_DATA_TYPE(shaper, object)		struct hb_##shaper##_shaper_##object##_data_t
-#define HB_SHAPER_DATA(shaper, object)			(* (HB_SHAPER_DATA_TYPE(shaper, object) **) &(object)->shaper_data.shaper)
+#define HB_SHAPER_DATA_INSTANCE(shaper, object, instance)	(* (HB_SHAPER_DATA_TYPE(shaper, object) **) &(instance)->shaper_data.shaper)
+#define HB_SHAPER_DATA(shaper, object)			HB_SHAPER_DATA_INSTANCE (shaper, object, object)
 #define HB_SHAPER_DATA_CREATE_FUNC(shaper, object)	_hb_##shaper##_shaper_##object##_data_create
 #define HB_SHAPER_DATA_DESTROY_FUNC(shaper, object)	_hb_##shaper##_shaper_##object##_data_destroy