Change DEFINE_SIZE_VAR to DEFINE_SIZE_ARRAY
diff --git a/src/hb-open-file-private.hh b/src/hb-open-file-private.hh
index ffe8ba7..f9fede3 100644
--- a/src/hb-open-file-private.hh
+++ b/src/hb-open-file-private.hh
@@ -112,7 +112,7 @@
   USHORT	rangeShift;	/* NumTables x 16-searchRange. */
   TableDirectory tableDir[VAR];	/* TableDirectory entries. numTables items */
   public:
-  DEFINE_SIZE_VAR (12, TableDirectory);
+  DEFINE_SIZE_ARRAY (12, tableDir);
 } OpenTypeFontFace;
 
 
@@ -140,7 +140,7 @@
 		table;		/* Array of offsets to the OffsetTable for each font
 				 * from the beginning of the file */
   public:
-  DEFINE_SIZE_VAR (12, LongOffset);
+  DEFINE_SIZE_ARRAY (12, table);
 };
 
 struct TTCHeader
diff --git a/src/hb-open-type-private.hh b/src/hb-open-type-private.hh
index 5194771..17a037b 100644
--- a/src/hb-open-type-private.hh
+++ b/src/hb-open-type-private.hh
@@ -103,11 +103,11 @@
   _DEFINE_SIZE_ASSERTION (sizeof (*this) >= (size)); \
   static const unsigned int min_size = (size)
 
-#define DEFINE_SIZE_VAR(size, _var_type) \
-  _DEFINE_SIZE_ASSERTION (sizeof (*this) == (size) + VAR0 * sizeof (_var_type)); \
+#define DEFINE_SIZE_ARRAY(size, array) \
+  _DEFINE_SIZE_ASSERTION (sizeof (*this) == (size) + array[0].static_size); \
   static const unsigned int min_size = (size)
 
-#define DEFINE_SIZE_VAR2(size, array1, array2) \
+#define DEFINE_SIZE_ARRAY2(size, array1, array2) \
   _DEFINE_SIZE_ASSERTION (sizeof (*this) == (size) + this->array1[0].static_size + this->array2[0].static_size); \
   static const unsigned int min_size = (size)
 
@@ -586,7 +586,7 @@
   LenType len;
   Type array[VAR];
   public:
-  DEFINE_SIZE_VAR (sizeof (LenType), Type);
+  DEFINE_SIZE_ARRAY (sizeof (LenType), array);
 };
 
 /* An array with a USHORT number of elements. */
@@ -671,7 +671,7 @@
   USHORT len;
   Type array[VAR];
   public:
-  DEFINE_SIZE_VAR (sizeof (USHORT), Type);
+  DEFINE_SIZE_ARRAY (sizeof (USHORT), array);
 };
 
 
diff --git a/src/hb-ot-layout-common-private.hh b/src/hb-ot-layout-common-private.hh
index d0ab1d1..7fadc2d 100644
--- a/src/hb-ot-layout-common-private.hh
+++ b/src/hb-ot-layout-common-private.hh
@@ -119,10 +119,13 @@
 
 struct IndexArray : ArrayOf<USHORT>
 {
-  inline unsigned int operator [] (unsigned int i) const
+  inline USHORT operator [] (unsigned int i) const
   {
-    if (unlikely (i >= this->len))
-      return NO_INDEX;
+    if (unlikely (i >= this->len)) {
+      USHORT u;
+      u.set (NO_INDEX);
+      return u;
+    }
     return this->array[i];
   }
   inline unsigned int get_indexes (unsigned int start_offset,
@@ -177,7 +180,7 @@
 				 * = 0xFFFF */
   IndexArray	featureIndex;	/* Array of indices into the FeatureList */
   public:
-  DEFINE_SIZE_VAR (6, USHORT);
+  DEFINE_SIZE_ARRAY (6, featureIndex);
 };
 DEFINE_NULL_DATA (LangSys, "\0\0\xFF\xFF");
 
@@ -217,7 +220,7 @@
 		langSys;	/* Array of LangSysRecords--listed
 				 * alphabetically by LangSysTag */
   public:
-  DEFINE_SIZE_VAR (4, Record<LangSys>);
+  DEFINE_SIZE_ARRAY (4, langSys);
 };
 
 typedef RecordListOf<Script> ScriptList;
@@ -248,7 +251,7 @@
 				 * if not required */
   IndexArray	 lookupIndex;	/* Array of LookupList indices */
   public:
-  DEFINE_SIZE_VAR (4, USHORT);
+  DEFINE_SIZE_ARRAY (4, lookupIndex);
 };
 
 typedef RecordListOf<Feature> FeatureList;
@@ -307,7 +310,7 @@
 					 * structure. This field is only present if bit
 					 * UseMarkFilteringSet of lookup flags is set. */
   public:
-  DEFINE_SIZE_VAR2 (6, subTable, markFilteringSetX);
+  DEFINE_SIZE_ARRAY2 (6, subTable, markFilteringSetX);
 };
 
 typedef OffsetListOf<Lookup> LookupList;
@@ -346,7 +349,7 @@
   ArrayOf<GlyphID>
 		glyphArray;	/* Array of GlyphIDs--in numerical order */
   public:
-  DEFINE_SIZE_VAR (4, GlyphID);
+  DEFINE_SIZE_ARRAY (4, glyphArray);
 };
 
 struct CoverageRangeRecord
@@ -407,7 +410,7 @@
 				 * Start GlyphID. rangeCount entries
 				 * long */
   public:
-  DEFINE_SIZE_VAR (4, CoverageRangeRecord);
+  DEFINE_SIZE_ARRAY (4, rangeRecord);
 };
 
 struct Coverage
@@ -471,7 +474,7 @@
   ArrayOf<USHORT>
 		classValue;		/* Array of Class Values--one per GlyphID */
   public:
-  DEFINE_SIZE_VAR (6, USHORT);
+  DEFINE_SIZE_ARRAY (6, classValue);
 };
 
 struct ClassRangeRecord
@@ -529,7 +532,7 @@
 		rangeRecord;	/* Array of glyph ranges--ordered by
 				 * Start GlyphID */
   public:
-  DEFINE_SIZE_VAR (4, ClassRangeRecord);
+  DEFINE_SIZE_ARRAY (4, rangeRecord);
 };
 
 struct ClassDef
@@ -620,7 +623,7 @@
 					 */
   USHORT	deltaValue[VAR];	/* Array of compressed data */
   public:
-  DEFINE_SIZE_VAR (6, USHORT);
+  DEFINE_SIZE_ARRAY (6, deltaValue);
 };
 
 
diff --git a/src/hb-ot-layout-gdef-private.hh b/src/hb-ot-layout-gdef-private.hh
index 85782b0..cfad57a 100644
--- a/src/hb-ot-layout-gdef-private.hh
+++ b/src/hb-ot-layout-gdef-private.hh
@@ -80,7 +80,7 @@
 		attachPoint;		/* Array of AttachPoint tables
 					 * in Coverage Index order */
   public:
-  DEFINE_SIZE_VAR (4, OffsetTo<AttachPoint>);
+  DEFINE_SIZE_ARRAY (4, attachPoint);
 };
 
 /*
@@ -228,7 +228,7 @@
 					 * --from beginning of LigGlyph table
 					 * --in increasing coordinate order */
   public:
-  DEFINE_SIZE_VAR (2, OffsetTo<CaretValue>);
+  DEFINE_SIZE_ARRAY (2, carets);
 };
 
 struct LigCaretList
@@ -264,7 +264,7 @@
 		ligGlyph;		/* Array of LigGlyph tables
 					 * in Coverage Index order */
   public:
-  DEFINE_SIZE_VAR (4, OffsetTo<LigGlyph>);
+  DEFINE_SIZE_ARRAY (4, ligGlyph);
 };
 
 
@@ -284,7 +284,7 @@
 		coverage;		/* Array of long offsets to mark set
 					 * coverage tables */
   public:
-  DEFINE_SIZE_VAR (4, LongOffsetTo<Coverage>);
+  DEFINE_SIZE_ARRAY (4, coverage);
 };
 
 struct MarkGlyphSets
@@ -394,7 +394,7 @@
 					 * header (may be NULL).  Introduced
 					 * in version 00010002. */
   public:
-  DEFINE_SIZE_VAR (12, OffsetTo<MarkGlyphSets>);
+  DEFINE_SIZE_ARRAY (12, markGlyphSetsDef);
 };
 
 
diff --git a/src/hb-ot-layout-gpos-private.hh b/src/hb-ot-layout-gpos-private.hh
index 5a29c0a..fbbcea2 100644
--- a/src/hb-ot-layout-gpos-private.hh
+++ b/src/hb-ot-layout-gpos-private.hh
@@ -40,7 +40,7 @@
 
 typedef USHORT Value;
 
-typedef Value ValueRecord[VAR0];
+typedef Value ValueRecord[VAR];
 
 struct ValueFormat : USHORT
 {
@@ -364,7 +364,7 @@
 		matrix[VAR];		/* Matrix of offsets to Anchor tables--
 					 * from beginning of AnchorMatrix table */
   public:
-  DEFINE_SIZE_VAR (2, OffsetTo<Anchor>);
+  DEFINE_SIZE_ARRAY (2, matrix);
 };
 
 
@@ -462,7 +462,7 @@
 					 * value(s)--applied to all glyphs in
 					 * the Coverage table */
   public:
-  DEFINE_SIZE_VAR (6, Value);
+  DEFINE_SIZE_ARRAY (6, values);
 };
 
 struct SinglePosFormat2
@@ -506,7 +506,7 @@
   ValueRecord	values;			/* Array of ValueRecords--positioning
 					 * values applied to glyphs */
   public:
-  DEFINE_SIZE_VAR (8, Value);
+  DEFINE_SIZE_ARRAY (8, values);
 };
 
 struct SinglePos
@@ -554,7 +554,7 @@
   ValueRecord	values;			/* Positioning data for the first glyph
 					 * followed by for second glyph */
   public:
-  DEFINE_SIZE_VAR (2, Value);
+  DEFINE_SIZE_ARRAY (2, values);
 };
 
 struct PairSet
@@ -571,11 +571,10 @@
 
   private:
   USHORT	len;			/* Number of PairValueRecords */
-  PairValueRecord
-		array[VAR];		/* Array of PairValueRecords--ordered
+  USHORT	array[VAR];		/* Array of PairValueRecords--ordered
 					 * by GlyphID of the second glyph */
   public:
-  DEFINE_SIZE_VAR (2, PairValueRecord);
+  DEFINE_SIZE_ARRAY (2, array);
 };
 
 struct PairPosFormat1
@@ -608,7 +607,7 @@
 
     const PairSet &pair_set = this+pairSet[index];
     unsigned int count = pair_set.len;
-    const PairValueRecord *record = pair_set.array;
+    const PairValueRecord *record = CastP<PairValueRecord> (pair_set.array);
     for (unsigned int i = 0; i < count; i++)
     {
       if (IN_GLYPH (j) == record->secondGlyph)
@@ -645,7 +644,7 @@
       PairSet &pair_set = const_cast<PairSet &> (this+pairSet[i]); /* XXX clean this up */
 
       unsigned int count2 = pair_set.len;
-      PairValueRecord *record = pair_set.array;
+      PairValueRecord *record = CastP<PairValueRecord> (pair_set.array);
       if (!(valueFormat1.sanitize_values_stride_unsafe (context, this, &record->values[0], count2, stride) &&
 	    valueFormat2.sanitize_values_stride_unsafe (context, this, &record->values[len1], count2, stride)))
         return false;
@@ -669,7 +668,7 @@
 		pairSet;		/* Array of PairSet tables
 					 * ordered by Coverage Index */
   public:
-  DEFINE_SIZE_VAR (10, OffsetTo<PairSet>);
+  DEFINE_SIZE_ARRAY (10, pairSet);
 };
 
 struct PairPosFormat2
@@ -760,7 +759,7 @@
 					 * class1-major, class2-minor,
 					 * Each entry has value1 and value2 */
   public:
-  DEFINE_SIZE_VAR (16, ValueRecord);
+  DEFINE_SIZE_ARRAY (16, values);
 };
 
 struct PairPos
@@ -1015,7 +1014,7 @@
 		entryExitRecord;	/* Array of EntryExit records--in
 					 * Coverage Index order */
   public:
-  DEFINE_SIZE_VAR (6, EntryExitRecord);
+  DEFINE_SIZE_ARRAY (6, entryExitRecord);
 };
 
 struct CursivePos
diff --git a/src/hb-ot-layout-gsub-private.hh b/src/hb-ot-layout-gsub-private.hh
index 25e2b3a..868503c 100644
--- a/src/hb-ot-layout-gsub-private.hh
+++ b/src/hb-ot-layout-gsub-private.hh
@@ -117,7 +117,7 @@
 		substitute;		/* Array of substitute
 					 * GlyphIDs--ordered by Coverage Index */
   public:
-  DEFINE_SIZE_VAR (6, GlyphID);
+  DEFINE_SIZE_ARRAY (6, substitute);
 };
 
 struct SingleSubst
@@ -195,7 +195,7 @@
   ArrayOf<GlyphID>
 		substitute;		/* String of GlyphIDs to substitute */
   public:
-  DEFINE_SIZE_VAR (2, GlyphID);
+  DEFINE_SIZE_ARRAY (2, substitute);
 };
 
 struct MultipleSubstFormat1
@@ -230,7 +230,7 @@
 		sequence;		/* Array of Sequence tables
 					 * ordered by Coverage Index */
   public:
-  DEFINE_SIZE_VAR (6, OffsetTo<Sequence>);
+  DEFINE_SIZE_ARRAY (6, sequence);
 };
 
 struct MultipleSubst
@@ -326,7 +326,7 @@
 		alternateSet;		/* Array of AlternateSet tables
 					 * ordered by Coverage Index */
   public:
-  DEFINE_SIZE_VAR (6, OffsetTo<AlternateSet>);
+  DEFINE_SIZE_ARRAY (6, alternateSet);
 };
 
 struct AlternateSubst
@@ -443,7 +443,7 @@
 					 * with the second  component--ordered
 					 * in writing direction */
   public:
-  DEFINE_SIZE_VAR (4, GlyphID);
+  DEFINE_SIZE_ARRAY (4, component);
 };
 
 struct LigatureSet
@@ -476,7 +476,7 @@
 		ligature;		/* Array LigatureSet tables
 					 * ordered by preference */
   public:
-  DEFINE_SIZE_VAR (2, OffsetTo<Ligature>);
+  DEFINE_SIZE_ARRAY (2, ligature);
 };
 
 struct LigatureSubstFormat1
@@ -514,7 +514,7 @@
 		ligatureSet;		/* Array LigatureSet tables
 					 * ordered by Coverage Index */
   public:
-  DEFINE_SIZE_VAR (6, OffsetTo<LigatureSet>);
+  DEFINE_SIZE_ARRAY (6, ligatureSet);
 };
 
 struct LigatureSubst
diff --git a/src/hb-ot-layout-gsubgpos-private.hh b/src/hb-ot-layout-gsubgpos-private.hh
index 0814e21..521d682 100644
--- a/src/hb-ot-layout-gsubgpos-private.hh
+++ b/src/hb-ot-layout-gsubgpos-private.hh
@@ -303,7 +303,7 @@
   LookupRecord	lookupRecordX[VAR];	/* Array of LookupRecords--in
 					 * design order */
   public:
-  DEFINE_SIZE_VAR2 (4, input, lookupRecordX);
+  DEFINE_SIZE_ARRAY2 (4, input, lookupRecordX);
 };
 
 struct RuleSet
@@ -331,7 +331,7 @@
 		rule;			/* Array of Rule tables
 					 * ordered by preference */
   public:
-  DEFINE_SIZE_VAR (2, OffsetTo<Rule>);
+  DEFINE_SIZE_ARRAY (2, rule);
 };
 
 
@@ -370,7 +370,7 @@
 		ruleSet;		/* Array of RuleSet tables
 					 * ordered by Coverage Index */
   public:
-  DEFINE_SIZE_VAR (6, OffsetTo<RuleSet>);
+  DEFINE_SIZE_ARRAY (6, ruleSet);
 };
 
 
@@ -418,7 +418,7 @@
 		ruleSet;		/* Array of RuleSet tables
 					 * ordered by class */
   public:
-  DEFINE_SIZE_VAR (8, OffsetTo<RuleSet>);
+  DEFINE_SIZE_ARRAY (8, ruleSet);
 };
 
 
@@ -467,7 +467,7 @@
   LookupRecord	lookupRecordX[VAR];	/* Array of LookupRecords--in
 					 * design order */
   public:
-  DEFINE_SIZE_VAR2 (6, coverage, lookupRecordX);
+  DEFINE_SIZE_ARRAY2 (6, coverage, lookupRecordX);
 };
 
 struct Context
@@ -623,7 +623,7 @@
 		rule;			/* Array of ChainRule tables
 					 * ordered by preference */
   public:
-  DEFINE_SIZE_VAR (2, OffsetTo<ChainRule>);
+  DEFINE_SIZE_ARRAY (2, rule);
 };
 
 struct ChainContextFormat1
@@ -661,7 +661,7 @@
 		ruleSet;		/* Array of ChainRuleSet tables
 					 * ordered by Coverage Index */
   public:
-  DEFINE_SIZE_VAR (6, OffsetTo<ChainRuleSet>);
+  DEFINE_SIZE_ARRAY (6, ruleSet);
 };
 
 struct ChainContextFormat2
@@ -724,7 +724,7 @@
 		ruleSet;		/* Array of ChainRuleSet tables
 					 * ordered by class */
   public:
-  DEFINE_SIZE_VAR (12, OffsetTo<ChainRuleSet>);
+  DEFINE_SIZE_ARRAY (12, ruleSet);
 };
 
 struct ChainContextFormat3