[HarfBuzz] harfbuzz-ng: Branch 'master' - 21 commits

Behdad Esfahbod behdad at kemper.freedesktop.org
Mon May 10 17:58:41 PDT 2010


 src/hb-font.cc                       |    2 
 src/hb-open-file-private.hh          |   39 ++---
 src/hb-open-type-private.hh          |  186 ++++++++++++++----------
 src/hb-ot-layout-common-private.hh   |  100 +++++++------
 src/hb-ot-layout-gdef-private.hh     |   53 ++++---
 src/hb-ot-layout-gpos-private.hh     |  263 +++++++++++++++++------------------
 src/hb-ot-layout-gsub-private.hh     |  136 +++++++++---------
 src/hb-ot-layout-gsubgpos-private.hh |  148 ++++++++++---------
 src/hb-ot-layout.cc                  |    6 
 src/hb-private.h                     |   10 -
 10 files changed, 514 insertions(+), 429 deletions(-)

New commits:
commit 48146e5612f6d272d6962f6829c6d64a31edef89
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Mon May 10 20:07:56 2010 -0400

    Don't fail sanitize on NULL data

diff --git a/src/hb-open-type-private.hh b/src/hb-open-type-private.hh
index 3f05bf7..c7b087e 100644
--- a/src/hb-open-type-private.hh
+++ b/src/hb-open-type-private.hh
@@ -290,6 +290,11 @@ struct Sanitizer
 
     context->init (blob);
 
+    if (unlikely (!context->start)) {
+      context->finish ();
+      return blob;
+    }
+
     Type *t = CastP<Type> (const_cast<char *> (context->start));
 
     sane = t->sanitize (context);
commit d2c2ca8faf62fc380d4717d286556139a62d2356
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Mon May 10 19:58:25 2010 -0400

    Fix comment

diff --git a/src/hb-open-type-private.hh b/src/hb-open-type-private.hh
index 8c3e8a4..3f05bf7 100644
--- a/src/hb-open-type-private.hh
+++ b/src/hb-open-type-private.hh
@@ -119,7 +119,7 @@ inline Type& StructAfter(TObject &X)
 /* Global nul-content Null pool.  Enlarge as necessary. */
 static const void *_NullPool[32 / sizeof (void *)];
 
-/* Generic template for nul-content sizeof-sized Null objects. */
+/* Generic nul-content Null objects. */
 template <typename Type>
 static inline const Type& Null () {
   ASSERT_STATIC (Type::min_size <= sizeof (_NullPool));
commit b435ab7e29c388e3b100f729957319931625a3a8
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Mon May 10 19:51:57 2010 -0400

    Fix accessing tables from NULL pointer

diff --git a/src/hb-font.cc b/src/hb-font.cc
index b8b151b..20aeb16 100644
--- a/src/hb-font.cc
+++ b/src/hb-font.cc
@@ -297,7 +297,7 @@ _hb_face_for_data_get_table (hb_tag_t tag, void *user_data)
 {
   hb_face_for_data_closure_t *data = (hb_face_for_data_closure_t *) user_data;
 
-  const OpenTypeFontFile &ot_file = *CastP<OpenTypeFontFile> (hb_blob_lock (data->blob));
+  const OpenTypeFontFile &ot_file = *Sanitizer<OpenTypeFontFile>::lock_instance (data->blob);
   const OpenTypeFontFace &ot_face = ot_file.get_face (data->index);
 
   const OpenTypeTable &table = ot_face.get_table_by_tag (tag);
diff --git a/src/hb-open-type-private.hh b/src/hb-open-type-private.hh
index 023df83..8c3e8a4 100644
--- a/src/hb-open-type-private.hh
+++ b/src/hb-open-type-private.hh
@@ -330,6 +330,11 @@ struct Sanitizer
       return hb_blob_create_empty ();
     }
   }
+
+  static const Type* lock_instance (hb_blob_t *blob) {
+    const char *base = hb_blob_lock (blob);
+    return unlikely (!base) ? &Null(Type) : CastP<Type> (base);
+  }
 };
 
 
diff --git a/src/hb-ot-layout.cc b/src/hb-ot-layout.cc
index 04cc982..91f9fe9 100644
--- a/src/hb-ot-layout.cc
+++ b/src/hb-ot-layout.cc
@@ -47,13 +47,13 @@ _hb_ot_layout_init (hb_face_t *face)
   memset (layout, 0, sizeof (*layout));
 
   layout->gdef_blob = Sanitizer<GDEF>::sanitize (hb_face_get_table (face, HB_OT_TAG_GDEF));
-  layout->gdef = CastP<GDEF> (hb_blob_lock (layout->gdef_blob));
+  layout->gdef = Sanitizer<GDEF>::lock_instance (layout->gdef_blob);
 
   layout->gsub_blob = Sanitizer<GSUB>::sanitize (hb_face_get_table (face, HB_OT_TAG_GSUB));
-  layout->gsub = CastP<GSUB> (hb_blob_lock (layout->gsub_blob));
+  layout->gsub = Sanitizer<GSUB>::lock_instance (layout->gsub_blob);
 
   layout->gpos_blob = Sanitizer<GPOS>::sanitize (hb_face_get_table (face, HB_OT_TAG_GPOS));
-  layout->gpos = CastP<GPOS> (hb_blob_lock (layout->gpos_blob));
+  layout->gpos = Sanitizer<GPOS>::lock_instance (layout->gpos_blob);
 }
 
 void
commit dacebcadae36b35531d635d81df2afb937677b7a
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Mon May 10 19:45:41 2010 -0400

    Simplify unions

diff --git a/src/hb-open-file-private.hh b/src/hb-open-file-private.hh
index f9fede3..066c3b2 100644
--- a/src/hb-open-file-private.hh
+++ b/src/hb-open-file-private.hh
@@ -153,7 +153,7 @@ struct TTCHeader
   {
     switch (u.header.version) {
     case 2: /* version 2 is compatible with version 1 */
-    case 1: return u.version1->get_face_count ();
+    case 1: return u.version1.get_face_count ();
     default:return 0;
     }
   }
@@ -161,7 +161,7 @@ struct TTCHeader
   {
     switch (u.header.version) {
     case 2: /* version 2 is compatible with version 1 */
-    case 1: return u.version1->get_face (i);
+    case 1: return u.version1.get_face (i);
     default:return Null(OpenTypeFontFace);
     }
   }
@@ -171,7 +171,7 @@ struct TTCHeader
     if (!u.header.version.sanitize (context)) return false;
     switch (u.header.version) {
     case 2: /* version 2 is compatible with version 1 */
-    case 1: return u.version1->sanitize (context);
+    case 1: return u.version1.sanitize (context);
     default:return true;
     }
   }
@@ -183,7 +183,7 @@ struct TTCHeader
   FixedVersion	version;	/* Version of the TTC Header (1.0 or 2.0),
 				 * 0x00010000 or 0x00020000 */
   }			header;
-  TTCHeaderVersion1	version1[VAR];
+  TTCHeaderVersion1	version1;
   } u;
 };
 
@@ -209,7 +209,7 @@ struct OpenTypeFontFile
     case TrueTag:
     case Typ1Tag:
     case TrueTypeTag:	return 1;
-    case TTCTag:	return u.ttcHeader->get_face_count ();
+    case TTCTag:	return u.ttcHeader.get_face_count ();
     default:		return 0;
     }
   }
@@ -222,8 +222,8 @@ struct OpenTypeFontFile
     case CFFTag:	/* All the non-collection tags */
     case TrueTag:
     case Typ1Tag:
-    case TrueTypeTag:	return u.fontFace[0];
-    case TTCTag:	return u.ttcHeader->get_face (i);
+    case TrueTypeTag:	return u.fontFace;
+    case TTCTag:	return u.ttcHeader.get_face (i);
     default:		return Null(OpenTypeFontFace);
     }
   }
@@ -235,8 +235,8 @@ struct OpenTypeFontFile
     case CFFTag:	/* All the non-collection tags */
     case TrueTag:
     case Typ1Tag:
-    case TrueTypeTag:	return u.fontFace->sanitize (context);
-    case TTCTag:	return u.ttcHeader->sanitize (context);
+    case TrueTypeTag:	return u.fontFace.sanitize (context);
+    case TTCTag:	return u.ttcHeader.sanitize (context);
     default:		return true;
     }
   }
@@ -244,9 +244,11 @@ struct OpenTypeFontFile
   private:
   union {
   Tag			tag;		/* 4-byte identifier. */
-  OpenTypeFontFace	fontFace[VAR];
-  TTCHeader		ttcHeader[VAR];
+  OpenTypeFontFace	fontFace;
+  TTCHeader		ttcHeader;
   } u;
+  public:
+  DEFINE_SIZE_UNION (4, tag);
 };
 
 
diff --git a/src/hb-ot-layout-common-private.hh b/src/hb-ot-layout-common-private.hh
index 7fadc2d..e5ecc8f 100644
--- a/src/hb-ot-layout-common-private.hh
+++ b/src/hb-ot-layout-common-private.hh
@@ -420,8 +420,8 @@ struct Coverage
   inline unsigned int get_coverage (hb_codepoint_t glyph_id) const
   {
     switch (u.format) {
-    case 1: return u.format1->get_coverage(glyph_id);
-    case 2: return u.format2->get_coverage(glyph_id);
+    case 1: return u.format1.get_coverage(glyph_id);
+    case 2: return u.format2.get_coverage(glyph_id);
     default:return NOT_COVERED;
     }
   }
@@ -430,8 +430,8 @@ struct Coverage
     TRACE_SANITIZE ();
     if (!u.format.sanitize (context)) return false;
     switch (u.format) {
-    case 1: return u.format1->sanitize (context);
-    case 2: return u.format2->sanitize (context);
+    case 1: return u.format1.sanitize (context);
+    case 2: return u.format2.sanitize (context);
     default:return true;
     }
   }
@@ -439,8 +439,8 @@ struct Coverage
   private:
   union {
   USHORT		format;		/* Format identifier */
-  CoverageFormat1	format1[VAR];
-  CoverageFormat2	format2[VAR];
+  CoverageFormat1	format1;
+  CoverageFormat2	format2;
   } u;
   public:
   DEFINE_SIZE_UNION (2, format);
@@ -542,8 +542,8 @@ struct ClassDef
   inline hb_ot_layout_class_t get_class (hb_codepoint_t glyph_id) const
   {
     switch (u.format) {
-    case 1: return u.format1->get_class(glyph_id);
-    case 2: return u.format2->get_class(glyph_id);
+    case 1: return u.format1.get_class(glyph_id);
+    case 2: return u.format2.get_class(glyph_id);
     default:return 0;
     }
   }
@@ -552,8 +552,8 @@ struct ClassDef
     TRACE_SANITIZE ();
     if (!u.format.sanitize (context)) return false;
     switch (u.format) {
-    case 1: return u.format1->sanitize (context);
-    case 2: return u.format2->sanitize (context);
+    case 1: return u.format1.sanitize (context);
+    case 2: return u.format2.sanitize (context);
     default:return true;
     }
   }
@@ -561,8 +561,8 @@ struct ClassDef
   private:
   union {
   USHORT		format;		/* Format identifier */
-  ClassDefFormat1	format1[VAR];
-  ClassDefFormat2	format2[VAR];
+  ClassDefFormat1	format1;
+  ClassDefFormat2	format2;
   } u;
   public:
   DEFINE_SIZE_UNION (2, format);
diff --git a/src/hb-ot-layout-gdef-private.hh b/src/hb-ot-layout-gdef-private.hh
index cfad57a..517f9ef 100644
--- a/src/hb-ot-layout-gdef-private.hh
+++ b/src/hb-ot-layout-gdef-private.hh
@@ -170,9 +170,9 @@ struct CaretValue
   inline int get_caret_value (hb_ot_layout_context_t *context, hb_codepoint_t glyph_id) const
   {
     switch (u.format) {
-    case 1: return u.format1->get_caret_value (context, glyph_id);
-    case 2: return u.format2->get_caret_value (context, glyph_id);
-    case 3: return u.format3->get_caret_value (context, glyph_id);
+    case 1: return u.format1.get_caret_value (context, glyph_id);
+    case 2: return u.format2.get_caret_value (context, glyph_id);
+    case 3: return u.format3.get_caret_value (context, glyph_id);
     default:return 0;
     }
   }
@@ -181,9 +181,9 @@ struct CaretValue
     TRACE_SANITIZE ();
     if (!u.format.sanitize (context)) return false;
     switch (u.format) {
-    case 1: return u.format1->sanitize (context);
-    case 2: return u.format2->sanitize (context);
-    case 3: return u.format3->sanitize (context);
+    case 1: return u.format1.sanitize (context);
+    case 2: return u.format2.sanitize (context);
+    case 3: return u.format3.sanitize (context);
     default:return true;
     }
   }
@@ -191,9 +191,9 @@ struct CaretValue
   private:
   union {
   USHORT		format;		/* Format identifier */
-  CaretValueFormat1	format1[VAR];
-  CaretValueFormat2	format2[VAR];
-  CaretValueFormat3	format3[VAR];
+  CaretValueFormat1	format1;
+  CaretValueFormat2	format2;
+  CaretValueFormat3	format3;
   } u;
   public:
   DEFINE_SIZE_UNION (2, format);
@@ -292,7 +292,7 @@ struct MarkGlyphSets
   inline bool covers (unsigned int set_index, hb_codepoint_t glyph_id) const
   {
     switch (u.format) {
-    case 1: return u.format1->covers (set_index, glyph_id);
+    case 1: return u.format1.covers (set_index, glyph_id);
     default:return false;
     }
   }
@@ -301,7 +301,7 @@ struct MarkGlyphSets
     TRACE_SANITIZE ();
     if (!u.format.sanitize (context)) return false;
     switch (u.format) {
-    case 1: return u.format1->sanitize (context);
+    case 1: return u.format1.sanitize (context);
     default:return true;
     }
   }
@@ -309,7 +309,7 @@ struct MarkGlyphSets
   private:
   union {
   USHORT		format;		/* Format identifier */
-  MarkGlyphSetsFormat1	format1[VAR];
+  MarkGlyphSetsFormat1	format1;
   } u;
   public:
   DEFINE_SIZE_UNION (2, format);
diff --git a/src/hb-ot-layout-gpos-private.hh b/src/hb-ot-layout-gpos-private.hh
index fbbcea2..bbb0dca 100644
--- a/src/hb-ot-layout-gpos-private.hh
+++ b/src/hb-ot-layout-gpos-private.hh
@@ -310,9 +310,9 @@ struct Anchor
   {
     *x = *y = 0;
     switch (u.format) {
-    case 1: u.format1->get_anchor (layout, glyph_id, x, y); return;
-    case 2: u.format2->get_anchor (layout, glyph_id, x, y); return;
-    case 3: u.format3->get_anchor (layout, glyph_id, x, y); return;
+    case 1: u.format1.get_anchor (layout, glyph_id, x, y); return;
+    case 2: u.format2.get_anchor (layout, glyph_id, x, y); return;
+    case 3: u.format3.get_anchor (layout, glyph_id, x, y); return;
     default:						    return;
     }
   }
@@ -321,9 +321,9 @@ struct Anchor
     TRACE_SANITIZE ();
     if (!u.format.sanitize (context)) return false;
     switch (u.format) {
-    case 1: return u.format1->sanitize (context);
-    case 2: return u.format2->sanitize (context);
-    case 3: return u.format3->sanitize (context);
+    case 1: return u.format1.sanitize (context);
+    case 2: return u.format2.sanitize (context);
+    case 3: return u.format3.sanitize (context);
     default:return true;
     }
   }
@@ -331,9 +331,9 @@ struct Anchor
   private:
   union {
   USHORT		format;		/* Format identifier */
-  AnchorFormat1		format1[VAR];
-  AnchorFormat2		format2[VAR];
-  AnchorFormat3		format3[VAR];
+  AnchorFormat1		format1;
+  AnchorFormat2		format2;
+  AnchorFormat3		format3;
   } u;
   public:
   DEFINE_SIZE_UNION (2, format);
@@ -518,8 +518,8 @@ struct SinglePos
   {
     TRACE_APPLY ();
     switch (u.format) {
-    case 1: return u.format1->apply (context);
-    case 2: return u.format2->apply (context);
+    case 1: return u.format1.apply (context);
+    case 2: return u.format2.apply (context);
     default:return false;
     }
   }
@@ -528,8 +528,8 @@ struct SinglePos
     TRACE_SANITIZE ();
     if (!u.format.sanitize (context)) return false;
     switch (u.format) {
-    case 1: return u.format1->sanitize (context);
-    case 2: return u.format2->sanitize (context);
+    case 1: return u.format1.sanitize (context);
+    case 2: return u.format2.sanitize (context);
     default:return true;
     }
   }
@@ -537,8 +537,8 @@ struct SinglePos
   private:
   union {
   USHORT		format;		/* Format identifier */
-  SinglePosFormat1	format1[VAR];
-  SinglePosFormat2	format2[VAR];
+  SinglePosFormat1	format1;
+  SinglePosFormat2	format2;
   } u;
 };
 
@@ -771,8 +771,8 @@ struct PairPos
   {
     TRACE_APPLY ();
     switch (u.format) {
-    case 1: return u.format1->apply (context);
-    case 2: return u.format2->apply (context);
+    case 1: return u.format1.apply (context);
+    case 2: return u.format2.apply (context);
     default:return false;
     }
   }
@@ -781,8 +781,8 @@ struct PairPos
     TRACE_SANITIZE ();
     if (!u.format.sanitize (context)) return false;
     switch (u.format) {
-    case 1: return u.format1->sanitize (context);
-    case 2: return u.format2->sanitize (context);
+    case 1: return u.format1.sanitize (context);
+    case 2: return u.format2.sanitize (context);
     default:return true;
     }
   }
@@ -790,8 +790,8 @@ struct PairPos
   private:
   union {
   USHORT		format;		/* Format identifier */
-  PairPosFormat1	format1[VAR];
-  PairPosFormat2	format2[VAR];
+  PairPosFormat1	format1;
+  PairPosFormat2	format2;
   } u;
 };
 
@@ -1026,7 +1026,7 @@ struct CursivePos
   {
     TRACE_APPLY ();
     switch (u.format) {
-    case 1: return u.format1->apply (context);
+    case 1: return u.format1.apply (context);
     default:return false;
     }
   }
@@ -1035,7 +1035,7 @@ struct CursivePos
     TRACE_SANITIZE ();
     if (!u.format.sanitize (context)) return false;
     switch (u.format) {
-    case 1: return u.format1->sanitize (context);
+    case 1: return u.format1.sanitize (context);
     default:return true;
     }
   }
@@ -1043,7 +1043,7 @@ struct CursivePos
   private:
   union {
   USHORT		format;		/* Format identifier */
-  CursivePosFormat1	format1[VAR];
+  CursivePosFormat1	format1;
   } u;
 };
 
@@ -1123,7 +1123,7 @@ struct MarkBasePos
   {
     TRACE_APPLY ();
     switch (u.format) {
-    case 1: return u.format1->apply (context);
+    case 1: return u.format1.apply (context);
     default:return false;
     }
   }
@@ -1132,7 +1132,7 @@ struct MarkBasePos
     TRACE_SANITIZE ();
     if (!u.format.sanitize (context)) return false;
     switch (u.format) {
-    case 1: return u.format1->sanitize (context);
+    case 1: return u.format1.sanitize (context);
     default:return true;
     }
   }
@@ -1140,7 +1140,7 @@ struct MarkBasePos
   private:
   union {
   USHORT		format;		/* Format identifier */
-  MarkBasePosFormat1	format1[VAR];
+  MarkBasePosFormat1	format1;
   } u;
 };
 
@@ -1247,7 +1247,7 @@ struct MarkLigPos
   {
     TRACE_APPLY ();
     switch (u.format) {
-    case 1: return u.format1->apply (context);
+    case 1: return u.format1.apply (context);
     default:return false;
     }
   }
@@ -1256,7 +1256,7 @@ struct MarkLigPos
     TRACE_SANITIZE ();
     if (!u.format.sanitize (context)) return false;
     switch (u.format) {
-    case 1: return u.format1->sanitize (context);
+    case 1: return u.format1.sanitize (context);
     default:return true;
     }
   }
@@ -1264,7 +1264,7 @@ struct MarkLigPos
   private:
   union {
   USHORT		format;		/* Format identifier */
-  MarkLigPosFormat1	format1[VAR];
+  MarkLigPosFormat1	format1;
   } u;
 };
 
@@ -1352,7 +1352,7 @@ struct MarkMarkPos
   {
     TRACE_APPLY ();
     switch (u.format) {
-    case 1: return u.format1->apply (context);
+    case 1: return u.format1.apply (context);
     default:return false;
     }
   }
@@ -1361,7 +1361,7 @@ struct MarkMarkPos
     TRACE_SANITIZE ();
     if (!u.format.sanitize (context)) return false;
     switch (u.format) {
-    case 1: return u.format1->sanitize (context);
+    case 1: return u.format1.sanitize (context);
     default:return true;
     }
   }
@@ -1369,7 +1369,7 @@ struct MarkMarkPos
   private:
   union {
   USHORT		format;		/* Format identifier */
-  MarkMarkPosFormat1	format1[VAR];
+  MarkMarkPosFormat1	format1;
   } u;
 };
 
@@ -1445,15 +1445,15 @@ struct PosLookupSubTable
   {
     TRACE_APPLY ();
     switch (lookup_type) {
-    case Single:		return u.single->apply (context);
-    case Pair:			return u.pair->apply (context);
-    case Cursive:		return u.cursive->apply (context);
-    case MarkBase:		return u.markBase->apply (context);
-    case MarkLig:		return u.markLig->apply (context);
-    case MarkMark:		return u.markMark->apply (context);
-    case Context:		return u.context->apply (context);
-    case ChainContext:		return u.chainContext->apply (context);
-    case Extension:		return u.extension->apply (context);
+    case Single:		return u.single.apply (context);
+    case Pair:			return u.pair.apply (context);
+    case Cursive:		return u.cursive.apply (context);
+    case MarkBase:		return u.markBase.apply (context);
+    case MarkLig:		return u.markLig.apply (context);
+    case MarkMark:		return u.markMark.apply (context);
+    case Context:		return u.context.apply (context);
+    case ChainContext:		return u.chainContext.apply (context);
+    case Extension:		return u.extension.apply (context);
     default:return false;
     }
   }
@@ -1462,15 +1462,15 @@ struct PosLookupSubTable
     TRACE_SANITIZE ();
     if (!u.format.sanitize (context)) return false;
     switch (u.format) {
-    case Single:		return u.single->sanitize (context);
-    case Pair:			return u.pair->sanitize (context);
-    case Cursive:		return u.cursive->sanitize (context);
-    case MarkBase:		return u.markBase->sanitize (context);
-    case MarkLig:		return u.markLig->sanitize (context);
-    case MarkMark:		return u.markMark->sanitize (context);
-    case Context:		return u.context->sanitize (context);
-    case ChainContext:		return u.chainContext->sanitize (context);
-    case Extension:		return u.extension->sanitize (context);
+    case Single:		return u.single.sanitize (context);
+    case Pair:			return u.pair.sanitize (context);
+    case Cursive:		return u.cursive.sanitize (context);
+    case MarkBase:		return u.markBase.sanitize (context);
+    case MarkLig:		return u.markLig.sanitize (context);
+    case MarkMark:		return u.markMark.sanitize (context);
+    case Context:		return u.context.sanitize (context);
+    case ChainContext:		return u.chainContext.sanitize (context);
+    case Extension:		return u.extension.sanitize (context);
     default:return true;
     }
   }
@@ -1478,15 +1478,15 @@ struct PosLookupSubTable
   private:
   union {
   USHORT		format;
-  SinglePos		single[VAR];
-  PairPos		pair[VAR];
-  CursivePos		cursive[VAR];
-  MarkBasePos		markBase[VAR];
-  MarkLigPos		markLig[VAR];
-  MarkMarkPos		markMark[VAR];
-  ContextPos		context[VAR];
-  ChainContextPos	chainContext[VAR];
-  ExtensionPos		extension[VAR];
+  SinglePos		single;
+  PairPos		pair;
+  CursivePos		cursive;
+  MarkBasePos		markBase;
+  MarkLigPos		markLig;
+  MarkMarkPos		markMark;
+  ContextPos		context;
+  ChainContextPos	chainContext;
+  ExtensionPos		extension;
   } u;
   public:
   DEFINE_SIZE_UNION (2, format);
diff --git a/src/hb-ot-layout-gsub-private.hh b/src/hb-ot-layout-gsub-private.hh
index 868503c..513913e 100644
--- a/src/hb-ot-layout-gsub-private.hh
+++ b/src/hb-ot-layout-gsub-private.hh
@@ -130,8 +130,8 @@ struct SingleSubst
   {
     TRACE_APPLY ();
     switch (u.format) {
-    case 1: return u.format1->apply (context);
-    case 2: return u.format2->apply (context);
+    case 1: return u.format1.apply (context);
+    case 2: return u.format2.apply (context);
     default:return false;
     }
   }
@@ -140,8 +140,8 @@ struct SingleSubst
     TRACE_SANITIZE ();
     if (!u.format.sanitize (context)) return false;
     switch (u.format) {
-    case 1: return u.format1->sanitize (context);
-    case 2: return u.format2->sanitize (context);
+    case 1: return u.format1.sanitize (context);
+    case 2: return u.format2.sanitize (context);
     default:return true;
     }
   }
@@ -149,8 +149,8 @@ struct SingleSubst
   private:
   union {
   USHORT		format;		/* Format identifier */
-  SingleSubstFormat1	format1[VAR];
-  SingleSubstFormat2	format2[VAR];
+  SingleSubstFormat1	format1;
+  SingleSubstFormat2	format2;
   } u;
 };
 
@@ -243,7 +243,7 @@ struct MultipleSubst
   {
     TRACE_APPLY ();
     switch (u.format) {
-    case 1: return u.format1->apply (context);
+    case 1: return u.format1.apply (context);
     default:return false;
     }
   }
@@ -252,7 +252,7 @@ struct MultipleSubst
     TRACE_SANITIZE ();
     if (!u.format.sanitize (context)) return false;
     switch (u.format) {
-    case 1: return u.format1->sanitize (context);
+    case 1: return u.format1.sanitize (context);
     default:return true;
     }
   }
@@ -260,7 +260,7 @@ struct MultipleSubst
   private:
   union {
   USHORT		format;		/* Format identifier */
-  MultipleSubstFormat1	format1[VAR];
+  MultipleSubstFormat1	format1;
   } u;
 };
 
@@ -339,7 +339,7 @@ struct AlternateSubst
   {
     TRACE_APPLY ();
     switch (u.format) {
-    case 1: return u.format1->apply (context);
+    case 1: return u.format1.apply (context);
     default:return false;
     }
   }
@@ -348,7 +348,7 @@ struct AlternateSubst
     TRACE_SANITIZE ();
     if (!u.format.sanitize (context)) return false;
     switch (u.format) {
-    case 1: return u.format1->sanitize (context);
+    case 1: return u.format1.sanitize (context);
     default:return true;
     }
   }
@@ -356,7 +356,7 @@ struct AlternateSubst
   private:
   union {
   USHORT		format;		/* Format identifier */
-  AlternateSubstFormat1	format1[VAR];
+  AlternateSubstFormat1	format1;
   } u;
 };
 
@@ -526,7 +526,7 @@ struct LigatureSubst
   {
     TRACE_APPLY ();
     switch (u.format) {
-    case 1: return u.format1->apply (context);
+    case 1: return u.format1.apply (context);
     default:return false;
     }
   }
@@ -535,7 +535,7 @@ struct LigatureSubst
     TRACE_SANITIZE ();
     if (!u.format.sanitize (context)) return false;
     switch (u.format) {
-    case 1: return u.format1->sanitize (context);
+    case 1: return u.format1.sanitize (context);
     default:return true;
     }
   }
@@ -543,7 +543,7 @@ struct LigatureSubst
   private:
   union {
   USHORT		format;		/* Format identifier */
-  LigatureSubstFormat1	format1[VAR];
+  LigatureSubstFormat1	format1;
   } u;
 };
 
@@ -672,7 +672,7 @@ struct ReverseChainSingleSubst
   {
     TRACE_APPLY ();
     switch (u.format) {
-    case 1: return u.format1->apply (context);
+    case 1: return u.format1.apply (context);
     default:return false;
     }
   }
@@ -681,7 +681,7 @@ struct ReverseChainSingleSubst
     TRACE_SANITIZE ();
     if (!u.format.sanitize (context)) return false;
     switch (u.format) {
-    case 1: return u.format1->sanitize (context);
+    case 1: return u.format1.sanitize (context);
     default:return true;
     }
   }
@@ -689,7 +689,7 @@ struct ReverseChainSingleSubst
   private:
   union {
   USHORT				format;		/* Format identifier */
-  ReverseChainSingleSubstFormat1	format1[VAR];
+  ReverseChainSingleSubstFormat1	format1;
   } u;
 };
 
@@ -718,14 +718,14 @@ struct SubstLookupSubTable
   {
     TRACE_APPLY ();
     switch (lookup_type) {
-    case Single:		return u.single->apply (context);
-    case Multiple:		return u.multiple->apply (context);
-    case Alternate:		return u.alternate->apply (context);
-    case Ligature:		return u.ligature->apply (context);
-    case Context:		return u.context->apply (context);
-    case ChainContext:		return u.chainContext->apply (context);
-    case Extension:		return u.extension->apply (context);
-    case ReverseChainSingle:	return u.reverseChainContextSingle->apply (context);
+    case Single:		return u.single.apply (context);
+    case Multiple:		return u.multiple.apply (context);
+    case Alternate:		return u.alternate.apply (context);
+    case Ligature:		return u.ligature.apply (context);
+    case Context:		return u.context.apply (context);
+    case ChainContext:		return u.chainContext.apply (context);
+    case Extension:		return u.extension.apply (context);
+    case ReverseChainSingle:	return u.reverseChainContextSingle.apply (context);
     default:return false;
     }
   }
@@ -734,14 +734,14 @@ struct SubstLookupSubTable
     TRACE_SANITIZE ();
     if (!u.format.sanitize (context)) return false;
     switch (u.format) {
-    case Single:		return u.single->sanitize (context);
-    case Multiple:		return u.multiple->sanitize (context);
-    case Alternate:		return u.alternate->sanitize (context);
-    case Ligature:		return u.ligature->sanitize (context);
-    case Context:		return u.context->sanitize (context);
-    case ChainContext:		return u.chainContext->sanitize (context);
-    case Extension:		return u.extension->sanitize (context);
-    case ReverseChainSingle:	return u.reverseChainContextSingle->sanitize (context);
+    case Single:		return u.single.sanitize (context);
+    case Multiple:		return u.multiple.sanitize (context);
+    case Alternate:		return u.alternate.sanitize (context);
+    case Ligature:		return u.ligature.sanitize (context);
+    case Context:		return u.context.sanitize (context);
+    case ChainContext:		return u.chainContext.sanitize (context);
+    case Extension:		return u.extension.sanitize (context);
+    case ReverseChainSingle:	return u.reverseChainContextSingle.sanitize (context);
     default:return true;
     }
   }
@@ -749,14 +749,14 @@ struct SubstLookupSubTable
   private:
   union {
   USHORT			format;
-  SingleSubst			single[VAR];
-  MultipleSubst			multiple[VAR];
-  AlternateSubst		alternate[VAR];
-  LigatureSubst			ligature[VAR];
-  ContextSubst			context[VAR];
-  ChainContextSubst		chainContext[VAR];
-  ExtensionSubst		extension[VAR];
-  ReverseChainSingleSubst	reverseChainContextSingle[VAR];
+  SingleSubst			single;
+  MultipleSubst			multiple;
+  AlternateSubst		alternate;
+  LigatureSubst			ligature;
+  ContextSubst			context;
+  ChainContextSubst		chainContext;
+  ExtensionSubst		extension;
+  ReverseChainSingleSubst	reverseChainContextSingle;
   } u;
   public:
   DEFINE_SIZE_UNION (2, format);
@@ -805,9 +805,9 @@ struct SubstLookup : Lookup
        * This is rather slow to do this here for every glyph,
        * but it's easiest, and who uses extension lookups anyway?!*/
       unsigned int count = get_subtable_count ();
-      unsigned int type = get_subtable(0).u.extension->get_type ();
+      unsigned int type = get_subtable(0).u.extension.get_type ();
       for (unsigned int i = 1; i < count; i++)
-        if (get_subtable(i).u.extension->get_type () != type)
+        if (get_subtable(i).u.extension.get_type () != type)
 	  return false;
     }
 
diff --git a/src/hb-ot-layout-gsubgpos-private.hh b/src/hb-ot-layout-gsubgpos-private.hh
index 521d682..488ab1d 100644
--- a/src/hb-ot-layout-gsubgpos-private.hh
+++ b/src/hb-ot-layout-gsubgpos-private.hh
@@ -477,9 +477,9 @@ struct Context
   {
     TRACE_APPLY ();
     switch (u.format) {
-    case 1: return u.format1->apply (context, apply_func);
-    case 2: return u.format2->apply (context, apply_func);
-    case 3: return u.format3->apply (context, apply_func);
+    case 1: return u.format1.apply (context, apply_func);
+    case 2: return u.format2.apply (context, apply_func);
+    case 3: return u.format3.apply (context, apply_func);
     default:return false;
     }
   }
@@ -488,9 +488,9 @@ struct Context
     TRACE_SANITIZE ();
     if (!u.format.sanitize (context)) return false;
     switch (u.format) {
-    case 1: return u.format1->sanitize (context);
-    case 2: return u.format2->sanitize (context);
-    case 3: return u.format3->sanitize (context);
+    case 1: return u.format1.sanitize (context);
+    case 2: return u.format2.sanitize (context);
+    case 3: return u.format3.sanitize (context);
     default:return true;
     }
   }
@@ -498,9 +498,9 @@ struct Context
   private:
   union {
   USHORT		format;		/* Format identifier */
-  ContextFormat1	format1[VAR];
-  ContextFormat2	format2[VAR];
-  ContextFormat3	format3[VAR];
+  ContextFormat1	format1;
+  ContextFormat2	format2;
+  ContextFormat3	format3;
   } u;
 };
 
@@ -796,9 +796,9 @@ struct ChainContext
   {
     TRACE_APPLY ();
     switch (u.format) {
-    case 1: return u.format1->apply (context, apply_func);
-    case 2: return u.format2->apply (context, apply_func);
-    case 3: return u.format3->apply (context, apply_func);
+    case 1: return u.format1.apply (context, apply_func);
+    case 2: return u.format2.apply (context, apply_func);
+    case 3: return u.format3.apply (context, apply_func);
     default:return false;
     }
   }
@@ -807,9 +807,9 @@ struct ChainContext
     TRACE_SANITIZE ();
     if (!u.format.sanitize (context)) return false;
     switch (u.format) {
-    case 1: return u.format1->sanitize (context);
-    case 2: return u.format2->sanitize (context);
-    case 3: return u.format3->sanitize (context);
+    case 1: return u.format1.sanitize (context);
+    case 2: return u.format2.sanitize (context);
+    case 3: return u.format3.sanitize (context);
     default:return true;
     }
   }
@@ -817,9 +817,9 @@ struct ChainContext
   private:
   union {
   USHORT		format;	/* Format identifier */
-  ChainContextFormat1	format1[VAR];
-  ChainContextFormat2	format2[VAR];
-  ChainContextFormat3	format3[VAR];
+  ChainContextFormat1	format1;
+  ChainContextFormat2	format2;
+  ChainContextFormat3	format3;
   } u;
 };
 
@@ -853,14 +853,14 @@ struct Extension
   inline unsigned int get_type (void) const
   {
     switch (u.format) {
-    case 1: return u.format1->get_type ();
+    case 1: return u.format1.get_type ();
     default:return 0;
     }
   }
   inline unsigned int get_offset (void) const
   {
     switch (u.format) {
-    case 1: return u.format1->get_offset ();
+    case 1: return u.format1.get_offset ();
     default:return 0;
     }
   }
@@ -869,7 +869,7 @@ struct Extension
     TRACE_SANITIZE ();
     if (!u.format.sanitize (context)) return false;
     switch (u.format) {
-    case 1: return u.format1->sanitize (context);
+    case 1: return u.format1.sanitize (context);
     default:return true;
     }
   }
@@ -877,7 +877,7 @@ struct Extension
   private:
   union {
   USHORT		format;		/* Format identifier */
-  ExtensionFormat1	format1[VAR];
+  ExtensionFormat1	format1;
   } u;
 };
 
commit fd671e02433bcbc1fd07901fa2d6065020f41ba8
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Mon May 10 19:02:32 2010 -0400

    Remove unused macro

diff --git a/src/hb-open-type-private.hh b/src/hb-open-type-private.hh
index 17a037b..023df83 100644
--- a/src/hb-open-type-private.hh
+++ b/src/hb-open-type-private.hh
@@ -93,7 +93,6 @@ inline Type& StructAfter(TObject &X)
 
 /* Size signifying variable-sized array */
 #define VAR 1
-#define VAR0 (VAR+0)
 
 #define DEFINE_SIZE_UNION(size, _member) \
   _DEFINE_SIZE_ASSERTION (this->u._member.static_size == (size)); \
commit 0eb9fc6e37935707dba2bf4b3705de2161a08cb7
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Mon May 10 19:01:17 2010 -0400

    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 @@ typedef struct OffsetTable
   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 @@ struct TTCHeaderVersion1
 		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 @@ inline Type& StructAfter(TObject &X)
   _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 @@ struct GenericArrayOf
   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 @@ struct HeadlessArrayOf
   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 RecordListOf : RecordArrayOf<Type>
 
 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 @@ struct LangSys
 				 * = 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 @@ struct Script
 		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 @@ struct Feature
 				 * 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 @@ struct Lookup
 					 * 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 @@ struct CoverageFormat1
   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 @@ struct CoverageFormat2
 				 * Start GlyphID. rangeCount entries
 				 * long */
   public:
-  DEFINE_SIZE_VAR (4, CoverageRangeRecord);
+  DEFINE_SIZE_ARRAY (4, rangeRecord);
 };
 
 struct Coverage
@@ -471,7 +474,7 @@ struct ClassDefFormat1
   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 @@ struct ClassDefFormat2
 		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 @@ struct Device
 					 */
   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 @@ struct AttachList
 		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 @@ struct LigGlyph
 					 * --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 @@ struct LigCaretList
 		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 @@ struct MarkGlyphSetsFormat1
 		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 @@ struct GDEF
 					 * 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 @@ struct AnchorMatrix
 		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 @@ struct SinglePosFormat1
 					 * 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 @@ struct SinglePosFormat2
   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 @@ struct PairValueRecord
   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 @@ struct PairSet
 
   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 @@ struct PairPosFormat1
 
     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 @@ struct PairPosFormat1
       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 @@ struct PairPosFormat1
 		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 @@ struct PairPosFormat2
 					 * 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 @@ struct CursivePosFormat1
 		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 @@ struct SingleSubstFormat2
 		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 @@ struct Sequence
   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 @@ struct MultipleSubstFormat1
 		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 @@ struct AlternateSubstFormat1
 		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 @@ struct Ligature
 					 * 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 @@ struct LigatureSet
 		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 @@ struct LigatureSubstFormat1
 		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 @@ struct Rule
   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 @@ struct RuleSet
 		rule;			/* Array of Rule tables
 					 * ordered by preference */
   public:
-  DEFINE_SIZE_VAR (2, OffsetTo<Rule>);
+  DEFINE_SIZE_ARRAY (2, rule);
 };
 
 
@@ -370,7 +370,7 @@ struct ContextFormat1
 		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 @@ struct ContextFormat2
 		ruleSet;		/* Array of RuleSet tables
 					 * ordered by class */
   public:
-  DEFINE_SIZE_VAR (8, OffsetTo<RuleSet>);
+  DEFINE_SIZE_ARRAY (8, ruleSet);
 };
 
 
@@ -467,7 +467,7 @@ struct ContextFormat3
   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 @@ struct ChainRuleSet
 		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 @@ struct ChainContextFormat1
 		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 @@ struct ChainContextFormat2
 		ruleSet;		/* Array of ChainRuleSet tables
 					 * ordered by class */
   public:
-  DEFINE_SIZE_VAR (12, OffsetTo<ChainRuleSet>);
+  DEFINE_SIZE_ARRAY (12, ruleSet);
 };
 
 struct ChainContextFormat3
commit 596e471aa5053d955fb5d5b5923088c8814469b1
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Mon May 10 18:47:48 2010 -0400

    Cleanup DEFINE_SIZE_VAR2

diff --git a/src/hb-open-type-private.hh b/src/hb-open-type-private.hh
index 311f74b..5194771 100644
--- a/src/hb-open-type-private.hh
+++ b/src/hb-open-type-private.hh
@@ -81,13 +81,13 @@ inline Type& StructAfter(TObject &X)
  * Size checking
  */
 
-#define _DEFINE_SIZE_ASSERTION(_compare) \
+#define _DEFINE_SIZE_ASSERTION(_assertion) \
   inline void _size_assertion (void) const \
-  { ASSERT_STATIC ((sizeof (*this)) _compare); }
+  { ASSERT_STATIC (_assertion); }
 
 
 #define DEFINE_SIZE_STATIC(size) \
-  _DEFINE_SIZE_ASSERTION (== (size)); \
+  _DEFINE_SIZE_ASSERTION (sizeof (*this) == (size)); \
   static const unsigned int static_size = (size); \
   static const unsigned int min_size = (size)
 
@@ -95,16 +95,20 @@ inline Type& StructAfter(TObject &X)
 #define VAR 1
 #define VAR0 (VAR+0)
 
+#define DEFINE_SIZE_UNION(size, _member) \
+  _DEFINE_SIZE_ASSERTION (this->u._member.static_size == (size)); \
+  static const unsigned int min_size = (size)
+
 #define DEFINE_SIZE_MIN(size) \
-  _DEFINE_SIZE_ASSERTION (>= (size)); \
+  _DEFINE_SIZE_ASSERTION (sizeof (*this) >= (size)); \
   static const unsigned int min_size = (size)
 
 #define DEFINE_SIZE_VAR(size, _var_type) \
-  _DEFINE_SIZE_ASSERTION (== (size) + VAR0 * sizeof (_var_type)); \
+  _DEFINE_SIZE_ASSERTION (sizeof (*this) == (size) + VAR0 * sizeof (_var_type)); \
   static const unsigned int min_size = (size)
 
-#define DEFINE_SIZE_VAR2(size, _var_type1, _var_type2) \
-  _DEFINE_SIZE_ASSERTION (== (size) + VAR0 * sizeof (_var_type1) + VAR0 * sizeof (_var_type2)); \
+#define DEFINE_SIZE_VAR2(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)
 
 
diff --git a/src/hb-ot-layout-common-private.hh b/src/hb-ot-layout-common-private.hh
index 6542e5f..d0ab1d1 100644
--- a/src/hb-ot-layout-common-private.hh
+++ b/src/hb-ot-layout-common-private.hh
@@ -307,7 +307,7 @@ struct Lookup
 					 * structure. This field is only present if bit
 					 * UseMarkFilteringSet of lookup flags is set. */
   public:
-  DEFINE_SIZE_VAR2 (6, Offset, USHORT);
+  DEFINE_SIZE_VAR2 (6, subTable, markFilteringSetX);
 };
 
 typedef OffsetListOf<Lookup> LookupList;
@@ -440,7 +440,7 @@ struct Coverage
   CoverageFormat2	format2[VAR];
   } u;
   public:
-  DEFINE_SIZE_MIN (2);
+  DEFINE_SIZE_UNION (2, format);
 };
 
 
@@ -562,7 +562,7 @@ struct ClassDef
   ClassDefFormat2	format2[VAR];
   } u;
   public:
-  DEFINE_SIZE_MIN (2);
+  DEFINE_SIZE_UNION (2, format);
 };
 
 
diff --git a/src/hb-ot-layout-gdef-private.hh b/src/hb-ot-layout-gdef-private.hh
index 456efca..85782b0 100644
--- a/src/hb-ot-layout-gdef-private.hh
+++ b/src/hb-ot-layout-gdef-private.hh
@@ -196,7 +196,7 @@ struct CaretValue
   CaretValueFormat3	format3[VAR];
   } u;
   public:
-  DEFINE_SIZE_MIN (2);
+  DEFINE_SIZE_UNION (2, format);
 };
 
 struct LigGlyph
@@ -312,7 +312,7 @@ struct MarkGlyphSets
   MarkGlyphSetsFormat1	format1[VAR];
   } u;
   public:
-  DEFINE_SIZE_MIN (2);
+  DEFINE_SIZE_UNION (2, format);
 };
 
 
diff --git a/src/hb-ot-layout-gpos-private.hh b/src/hb-ot-layout-gpos-private.hh
index a84210a..5a29c0a 100644
--- a/src/hb-ot-layout-gpos-private.hh
+++ b/src/hb-ot-layout-gpos-private.hh
@@ -336,7 +336,7 @@ struct Anchor
   AnchorFormat3		format3[VAR];
   } u;
   public:
-  DEFINE_SIZE_MIN (2);
+  DEFINE_SIZE_UNION (2, format);
 };
 
 
@@ -1490,7 +1490,7 @@ struct PosLookupSubTable
   ExtensionPos		extension[VAR];
   } u;
   public:
-  DEFINE_SIZE_MIN (2);
+  DEFINE_SIZE_UNION (2, format);
 };
 
 
diff --git a/src/hb-ot-layout-gsub-private.hh b/src/hb-ot-layout-gsub-private.hh
index 707ee61..25e2b3a 100644
--- a/src/hb-ot-layout-gsub-private.hh
+++ b/src/hb-ot-layout-gsub-private.hh
@@ -759,7 +759,7 @@ struct SubstLookupSubTable
   ReverseChainSingleSubst	reverseChainContextSingle[VAR];
   } u;
   public:
-  DEFINE_SIZE_MIN (2);
+  DEFINE_SIZE_UNION (2, format);
 };
 
 
diff --git a/src/hb-ot-layout-gsubgpos-private.hh b/src/hb-ot-layout-gsubgpos-private.hh
index b3af2de..0814e21 100644
--- a/src/hb-ot-layout-gsubgpos-private.hh
+++ b/src/hb-ot-layout-gsubgpos-private.hh
@@ -303,7 +303,7 @@ struct Rule
   LookupRecord	lookupRecordX[VAR];	/* Array of LookupRecords--in
 					 * design order */
   public:
-  DEFINE_SIZE_VAR2 (4, USHORT, LookupRecord);
+  DEFINE_SIZE_VAR2 (4, input, lookupRecordX);
 };
 
 struct RuleSet
@@ -467,7 +467,7 @@ struct ContextFormat3
   LookupRecord	lookupRecordX[VAR];	/* Array of LookupRecords--in
 					 * design order */
   public:
-  DEFINE_SIZE_VAR2 (6, OffsetTo<Coverage>, LookupRecord);
+  DEFINE_SIZE_VAR2 (6, coverage, lookupRecordX);
 };
 
 struct Context
commit 33afa4e2dc352f08cc094703e3f01d3ecd83b354
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Mon May 10 18:35:02 2010 -0400

    Minor

diff --git a/src/hb-open-type-private.hh b/src/hb-open-type-private.hh
index 107b2d1..311f74b 100644
--- a/src/hb-open-type-private.hh
+++ b/src/hb-open-type-private.hh
@@ -81,14 +81,13 @@ inline Type& StructAfter(TObject &X)
  * Size checking
  */
 
-#define ASSERT_SIZE(_thing, _size) ASSERT_STATIC (sizeof (_thing) == (_size))
-
-#define _DEFINE_SIZE_ASSERTION(_size) \
-  inline void _size_assertion (void) const { ASSERT_SIZE (*this, _size); }
+#define _DEFINE_SIZE_ASSERTION(_compare) \
+  inline void _size_assertion (void) const \
+  { ASSERT_STATIC ((sizeof (*this)) _compare); }
 
 
 #define DEFINE_SIZE_STATIC(size) \
-  _DEFINE_SIZE_ASSERTION (size); \
+  _DEFINE_SIZE_ASSERTION (== (size)); \
   static const unsigned int static_size = (size); \
   static const unsigned int min_size = (size)
 
@@ -97,14 +96,15 @@ inline Type& StructAfter(TObject &X)
 #define VAR0 (VAR+0)
 
 #define DEFINE_SIZE_MIN(size) \
+  _DEFINE_SIZE_ASSERTION (>= (size)); \
   static const unsigned int min_size = (size)
 
 #define DEFINE_SIZE_VAR(size, _var_type) \
-  _DEFINE_SIZE_ASSERTION ((size) + VAR0 * sizeof (_var_type)); \
+  _DEFINE_SIZE_ASSERTION (== (size) + VAR0 * sizeof (_var_type)); \
   static const unsigned int min_size = (size)
 
 #define DEFINE_SIZE_VAR2(size, _var_type1, _var_type2) \
-  _DEFINE_SIZE_ASSERTION ((size) + VAR0 * sizeof (_var_type1) + VAR0 * sizeof (_var_type2)); \
+  _DEFINE_SIZE_ASSERTION (== (size) + VAR0 * sizeof (_var_type1) + VAR0 * sizeof (_var_type2)); \
   static const unsigned int min_size = (size)
 
 
commit b961518b9611471ff7060e97686e5625974847eb
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Mon May 10 18:20:54 2010 -0400

    Simplify array access

diff --git a/src/hb-open-type-private.hh b/src/hb-open-type-private.hh
index 7a79477..107b2d1 100644
--- a/src/hb-open-type-private.hh
+++ b/src/hb-open-type-private.hh
@@ -89,7 +89,6 @@ inline Type& StructAfter(TObject &X)
 
 #define DEFINE_SIZE_STATIC(size) \
   _DEFINE_SIZE_ASSERTION (size); \
-  static inline unsigned int get_size (void) { return (size); } \
   static const unsigned int static_size = (size); \
   static const unsigned int min_size = (size)
 
@@ -515,9 +514,6 @@ struct LongOffsetTo : GenericOffsetTo<LongOffset, Type> {};
 template <typename LenType, typename Type>
 struct GenericArrayOf
 {
-  const Type *array(void) const { return &StructAfter<Type> (len); }
-  Type *array(void) { return &StructAfter<Type> (len); }
-
   const Type *sub_array (unsigned int start_offset, unsigned int *pcount /* IN/OUT */) const
   {
     unsigned int count = len;
@@ -527,13 +523,13 @@ struct GenericArrayOf
       count -= start_offset;
     count = MIN (count, *pcount);
     *pcount = count;
-    return array() + start_offset;
+    return array + start_offset;
   }
 
   inline const Type& operator [] (unsigned int i) const
   {
     if (unlikely (i >= len)) return Null(Type);
-    return array()[i];
+    return array[i];
   }
   inline unsigned int get_size () const
   { return len.static_size + len * Type::static_size; }
@@ -551,7 +547,7 @@ struct GenericArrayOf
      * other structs. */
     unsigned int count = len;
     for (unsigned int i = 0; i < count; i++)
-      if (array()[i].sanitize (context))
+      if (array[i].sanitize (context))
         return false;
     return true;
   }
@@ -560,7 +556,7 @@ struct GenericArrayOf
     if (!likely (sanitize_shallow (context))) return false;
     unsigned int count = len;
     for (unsigned int i = 0; i < count; i++)
-      if (!array()[i].sanitize (context, base))
+      if (!array[i].sanitize (context, base))
         return false;
     return true;
   }
@@ -570,7 +566,7 @@ struct GenericArrayOf
     if (!likely (sanitize_shallow (context))) return false;
     unsigned int count = len;
     for (unsigned int i = 0; i < count; i++)
-      if (!array()[i].sanitize (context, base, user_data))
+      if (!array[i].sanitize (context, base, user_data))
         return false;
     return true;
   }
@@ -584,8 +580,7 @@ struct GenericArrayOf
 
   public:
   LenType len;
-  private:
-  Type arrayX[VAR];
+  Type array[VAR];
   public:
   DEFINE_SIZE_VAR (sizeof (LenType), Type);
 };
@@ -617,7 +612,7 @@ struct OffsetListOf : OffsetArrayOf<Type>
   inline const Type& operator [] (unsigned int i) const
   {
     if (unlikely (i >= this->len)) return Null(Type);
-    return this+this->array()[i];
+    return this+this->array[i];
   }
 
   inline bool sanitize (hb_sanitize_context_t *context) {
@@ -637,13 +632,10 @@ struct OffsetListOf : OffsetArrayOf<Type>
 template <typename Type>
 struct HeadlessArrayOf
 {
-  const Type *array(void) const { return &StructAfter<Type> (len); }
-  Type *array(void) { return &StructAfter<Type> (len); }
-
   inline const Type& operator [] (unsigned int i) const
   {
     if (unlikely (i >= len || !i)) return Null(Type);
-    return array()[i-1];
+    return array[i-1];
   }
   inline unsigned int get_size () const
   { return len.static_size + (len ? len - 1 : 0) * Type::static_size; }
@@ -665,7 +657,7 @@ struct HeadlessArrayOf
      * to do have a simple sanitize(), ie. they do not reference
      * other structs. */
     unsigned int count = len ? len - 1 : 0;
-    Type *a = array();
+    Type *a = array;
     for (unsigned int i = 0; i < count; i++)
       if (!a[i].sanitize (context))
         return false;
@@ -673,8 +665,7 @@ struct HeadlessArrayOf
   }
 
   USHORT len;
-  private:
-  Type arrayX[VAR];
+  Type array[VAR];
   public:
   DEFINE_SIZE_VAR (sizeof (USHORT), Type);
 };
diff --git a/src/hb-ot-layout-common-private.hh b/src/hb-ot-layout-common-private.hh
index 324b7bd..6542e5f 100644
--- a/src/hb-ot-layout-common-private.hh
+++ b/src/hb-ot-layout-common-private.hh
@@ -89,7 +89,7 @@ struct RecordArrayOf : ArrayOf<Record<Type> > {
     Tag t;
     t.set (tag);
     /* TODO: bsearch (need to sort in sanitize) */
-    const Record<Type> *a = this->array();
+    const Record<Type> *a = this->array;
     unsigned int count = this->len;
     for (unsigned int i = 0; i < count; i++)
     {
@@ -123,7 +123,7 @@ struct IndexArray : ArrayOf<USHORT>
   {
     if (unlikely (i >= this->len))
       return NO_INDEX;
-    return this->array()[i];
+    return this->array[i];
   }
   inline unsigned int get_indexes (unsigned int start_offset,
 				   unsigned int *_count /* IN/OUT */,
@@ -600,8 +600,8 @@ struct Device
   inline unsigned int get_size () const
   {
     unsigned int f = deltaFormat;
-    if (unlikely (f < 1 || f > 3 || startSize > endSize)) return 3 * USHORT::get_size ();
-    return USHORT::get_size () * (4 + ((endSize - startSize) >> (4 - f)));
+    if (unlikely (f < 1 || f > 3 || startSize > endSize)) return 3 * USHORT::static_size;
+    return USHORT::static_size * (4 + ((endSize - startSize) >> (4 - f)));
   }
 
   inline bool sanitize (hb_sanitize_context_t *context) {
diff --git a/src/hb-ot-layout-gsub-private.hh b/src/hb-ot-layout-gsub-private.hh
index c562dea..707ee61 100644
--- a/src/hb-ot-layout-gsub-private.hh
+++ b/src/hb-ot-layout-gsub-private.hh
@@ -167,7 +167,7 @@ struct Sequence
       return false;
 
     _hb_buffer_add_output_glyphs_be16 (context->buffer, 1,
-				       substitute.len, (const uint16_t *) substitute.array(),
+				       substitute.len, (const uint16_t *) substitute.array,
 				       0xFFFF, 0xFFFF);
 
     /* This is a guess only ... */
@@ -616,10 +616,10 @@ struct ReverseChainSingleSubstFormat1
     const ArrayOf<GlyphID> &substitute = StructAfter<ArrayOf<GlyphID> > (lookahead);
 
     if (match_backtrack (context,
-			 backtrack.len, (USHORT *) backtrack.array(),
+			 backtrack.len, (USHORT *) backtrack.array,
 			 match_coverage, this) &&
         match_lookahead (context,
-			 lookahead.len, (USHORT *) lookahead.array(),
+			 lookahead.len, (USHORT *) lookahead.array,
 			 match_coverage, this,
 			 1))
     {
diff --git a/src/hb-ot-layout-gsubgpos-private.hh b/src/hb-ot-layout-gsubgpos-private.hh
index 92521c5..b3af2de 100644
--- a/src/hb-ot-layout-gsubgpos-private.hh
+++ b/src/hb-ot-layout-gsubgpos-private.hh
@@ -560,10 +560,10 @@ struct ChainRule
     const ArrayOf<USHORT> &lookahead = StructAfter<ArrayOf<USHORT> > (input);
     const ArrayOf<LookupRecord> &lookup = StructAfter<ArrayOf<LookupRecord> > (lookahead);
     return chain_context_lookup (context,
-				 backtrack.len, backtrack.array(),
-				 input.len, input.array(),
-				 lookahead.len, lookahead.array(),
-				 lookup.len, lookup.array(),
+				 backtrack.len, backtrack.array,
+				 input.len, input.array,
+				 lookahead.len, lookahead.array,
+				 lookup.len, lookup.array,
 				 lookup_context);
     return false;
   }
@@ -749,10 +749,10 @@ struct ChainContextFormat3
       {this, this, this}
     };
     return chain_context_lookup (context,
-				 backtrack.len, (const USHORT *) backtrack.array(),
-				 input.len, (const USHORT *) input.array() + 1,
-				 lookahead.len, (const USHORT *) lookahead.array(),
-				 lookup.len, lookup.array(),
+				 backtrack.len, (const USHORT *) backtrack.array,
+				 input.len, (const USHORT *) input.array + 1,
+				 lookahead.len, (const USHORT *) lookahead.array,
+				 lookup.len, lookup.array,
 				 lookup_context);
     return false;
   }
commit 54842374c2b291ef208c51ae1d853ec0403ccf84
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Mon May 10 18:13:32 2010 -0400

    Fix check_struct to check min_size instead of sizeof

diff --git a/src/hb-open-type-private.hh b/src/hb-open-type-private.hh
index c6c9811..7a79477 100644
--- a/src/hb-open-type-private.hh
+++ b/src/hb-open-type-private.hh
@@ -243,7 +243,7 @@ struct hb_sanitize_context_t
   template <typename Type>
   inline bool check_struct (const Type *obj) const
   {
-    return likely (this->check_range (obj, sizeof (*obj)));
+    return likely (this->check_range (obj, obj->min_size));
   }
 
   inline bool can_edit (const void *base HB_UNUSED, unsigned int len HB_UNUSED)
commit ed07422c33bbb52ff4d79e65986171e3f07697d8
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Mon May 10 18:08:46 2010 -0400

    Further cleanup of sizeof

diff --git a/src/hb-open-type-private.hh b/src/hb-open-type-private.hh
index 45ed801..c6c9811 100644
--- a/src/hb-open-type-private.hh
+++ b/src/hb-open-type-private.hh
@@ -120,7 +120,7 @@ static const void *_NullPool[32 / sizeof (void *)];
 /* Generic template for nul-content sizeof-sized Null objects. */
 template <typename Type>
 static inline const Type& Null () {
-  ASSERT_STATIC (sizeof (Type) <= sizeof (_NullPool));
+  ASSERT_STATIC (Type::min_size <= sizeof (_NullPool));
   return *CastP<Type> (_NullPool);
 }
 
@@ -673,7 +673,10 @@ struct HeadlessArrayOf
   }
 
   USHORT len;
-/*Type array[VAR];*/
+  private:
+  Type arrayX[VAR];
+  public:
+  DEFINE_SIZE_VAR (sizeof (USHORT), Type);
 };
 
 
diff --git a/src/hb-ot-layout-common-private.hh b/src/hb-ot-layout-common-private.hh
index 094f3a8..324b7bd 100644
--- a/src/hb-ot-layout-common-private.hh
+++ b/src/hb-ot-layout-common-private.hh
@@ -439,6 +439,8 @@ struct Coverage
   CoverageFormat1	format1[VAR];
   CoverageFormat2	format2[VAR];
   } u;
+  public:
+  DEFINE_SIZE_MIN (2);
 };
 
 
@@ -559,6 +561,8 @@ struct ClassDef
   ClassDefFormat1	format1[VAR];
   ClassDefFormat2	format2[VAR];
   } u;
+  public:
+  DEFINE_SIZE_MIN (2);
 };
 
 
diff --git a/src/hb-ot-layout-gdef-private.hh b/src/hb-ot-layout-gdef-private.hh
index 20d6b92..456efca 100644
--- a/src/hb-ot-layout-gdef-private.hh
+++ b/src/hb-ot-layout-gdef-private.hh
@@ -195,6 +195,8 @@ struct CaretValue
   CaretValueFormat2	format2[VAR];
   CaretValueFormat3	format3[VAR];
   } u;
+  public:
+  DEFINE_SIZE_MIN (2);
 };
 
 struct LigGlyph
@@ -309,6 +311,8 @@ struct MarkGlyphSets
   USHORT		format;		/* Format identifier */
   MarkGlyphSetsFormat1	format1[VAR];
   } u;
+  public:
+  DEFINE_SIZE_MIN (2);
 };
 
 
diff --git a/src/hb-ot-layout-gpos-private.hh b/src/hb-ot-layout-gpos-private.hh
index c890585..a84210a 100644
--- a/src/hb-ot-layout-gpos-private.hh
+++ b/src/hb-ot-layout-gpos-private.hh
@@ -335,6 +335,8 @@ struct Anchor
   AnchorFormat2		format2[VAR];
   AnchorFormat3		format3[VAR];
   } u;
+  public:
+  DEFINE_SIZE_MIN (2);
 };
 
 
@@ -460,7 +462,7 @@ struct SinglePosFormat1
 					 * value(s)--applied to all glyphs in
 					 * the Coverage table */
   public:
-  DEFINE_SIZE_VAR (6, ValueRecord);
+  DEFINE_SIZE_VAR (6, Value);
 };
 
 struct SinglePosFormat2
@@ -504,7 +506,7 @@ struct SinglePosFormat2
   ValueRecord	values;			/* Array of ValueRecords--positioning
 					 * values applied to glyphs */
   public:
-  DEFINE_SIZE_VAR (8, ValueRecord);
+  DEFINE_SIZE_VAR (8, Value);
 };
 
 struct SinglePos
@@ -552,7 +554,7 @@ struct PairValueRecord
   ValueRecord	values;			/* Positioning data for the first glyph
 					 * followed by for second glyph */
   public:
-  DEFINE_SIZE_VAR (2, ValueRecord);
+  DEFINE_SIZE_VAR (2, Value);
 };
 
 struct PairSet
@@ -1487,6 +1489,8 @@ struct PosLookupSubTable
   ChainContextPos	chainContext[VAR];
   ExtensionPos		extension[VAR];
   } u;
+  public:
+  DEFINE_SIZE_MIN (2);
 };
 
 
diff --git a/src/hb-ot-layout-gsub-private.hh b/src/hb-ot-layout-gsub-private.hh
index da32cb1..c562dea 100644
--- a/src/hb-ot-layout-gsub-private.hh
+++ b/src/hb-ot-layout-gsub-private.hh
@@ -443,7 +443,7 @@ struct Ligature
 					 * with the second  component--ordered
 					 * in writing direction */
   public:
-  DEFINE_SIZE_STATIC (4);
+  DEFINE_SIZE_VAR (4, GlyphID);
 };
 
 struct LigatureSet
@@ -758,6 +758,8 @@ struct SubstLookupSubTable
   ExtensionSubst		extension[VAR];
   ReverseChainSingleSubst	reverseChainContextSingle[VAR];
   } u;
+  public:
+  DEFINE_SIZE_MIN (2);
 };
 
 
diff --git a/src/hb-ot-layout-gsubgpos-private.hh b/src/hb-ot-layout-gsubgpos-private.hh
index cc04de0..92521c5 100644
--- a/src/hb-ot-layout-gsubgpos-private.hh
+++ b/src/hb-ot-layout-gsubgpos-private.hh
@@ -330,6 +330,8 @@ struct RuleSet
   OffsetArrayOf<Rule>
 		rule;			/* Array of Rule tables
 					 * ordered by preference */
+  public:
+  DEFINE_SIZE_VAR (2, OffsetTo<Rule>);
 };
 
 
commit a82ef7a893b773a17f7548375de9f588dfc83aba
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Mon May 10 17:55:03 2010 -0400

    Remove CastP completely

diff --git a/src/hb-open-type-private.hh b/src/hb-open-type-private.hh
index fcc8c80..45ed801 100644
--- a/src/hb-open-type-private.hh
+++ b/src/hb-open-type-private.hh
@@ -41,14 +41,6 @@
  * Casts
  */
 
-/* Cast to "const char *" and "char *" */
-template <typename Type>
-inline const char * CharP (const Type* X)
-{ return reinterpret_cast<const char *>(X); }
-template <typename Type>
-inline char * CharP (Type* X)
-{ return reinterpret_cast<char *>(X); }
-
 /* Cast to struct T, reference to reference */
 template<typename Type, typename TObject>
 inline const Type& CastR(const TObject &X)
@@ -69,10 +61,10 @@ inline Type* CastP(TObject *X)
  * location pointed to by P plus Ofs bytes. */
 template<typename Type>
 inline const Type& StructAtOffset(const void *P, unsigned int offset)
-{ return * reinterpret_cast<const Type*> (CharP(P) + offset); }
+{ return * reinterpret_cast<const Type*> ((const char *) P + offset); }
 template<typename Type>
 inline Type& StructAtOffset(void *P, unsigned int offset)
-{ return * reinterpret_cast<Type*> (CharP(P) + offset); }
+{ return * reinterpret_cast<Type*> ((char *) P + offset); }
 
 /* StructAfter<T>(X) returns the struct T& that is placed after X.
  * Works with X of variable size also.  X must implement get_size() */
@@ -216,15 +208,16 @@ struct hb_sanitize_context_t
 
   inline bool check_range (const void *base, unsigned int len) const
   {
-    bool ret = this->start <= base &&
-	       base <= this->end &&
-	       (unsigned int) (this->end - CharP(base)) >= len;
+    const char *p = (const char *) base;
+    bool ret = this->start <= p &&
+	       p <= this->end &&
+	       (unsigned int) (this->end - p) >= len;
 
     if (HB_DEBUG_SANITIZE && (int) this->debug_depth < (int) HB_DEBUG_SANITIZE) \
       fprintf (stderr, "SANITIZE(%p) %-*d-> range [%p..%p] (%d bytes) in [%p..%p] -> %s\n", \
-	       base,
+	       p,
 	       this->debug_depth, this->debug_depth,
-	       base, CharP(base) + len, len,
+	       p, p + len, len,
 	       this->start, this->end,
 	       ret ? "pass" : "FAIL");
 
@@ -233,13 +226,14 @@ struct hb_sanitize_context_t
 
   inline bool check_array (const void *base, unsigned int record_size, unsigned int len) const
   {
+    const char *p = (const char *) base;
     bool overflows = len >= ((unsigned int) -1) / record_size;
 
     if (HB_DEBUG_SANITIZE && (int) this->debug_depth < (int) HB_DEBUG_SANITIZE)
       fprintf (stderr, "SANITIZE(%p) %-*d-> array [%p..%p] (%d*%d=%ld bytes) in [%p..%p] -> %s\n", \
-	       base,
+	       p,
 	       this->debug_depth, this->debug_depth,
-	       base, CharP(base) + (record_size * len), record_size, len, (unsigned long) record_size * len,
+	       p, p + (record_size * len), record_size, len, (unsigned long) record_size * len,
 	       this->start, this->end,
 	       !overflows ? "does not overflow" : "OVERFLOWS FAIL");
 
@@ -254,14 +248,15 @@ struct hb_sanitize_context_t
 
   inline bool can_edit (const void *base HB_UNUSED, unsigned int len HB_UNUSED)
   {
+    const char *p = (const char *) base;
     this->edit_count++;
 
     if (HB_DEBUG_SANITIZE && (int) this->debug_depth < (int) HB_DEBUG_SANITIZE)
       fprintf (stderr, "SANITIZE(%p) %-*d-> edit(%u) [%p..%p] (%d bytes) in [%p..%p] -> %s\n", \
-	       base,
+	       p,
 	       this->debug_depth, this->debug_depth,
 	       this->edit_count,
-	       base, CharP(base)+len, len,
+	       p, p + len, len,
 	       this->start, this->end,
 	       this->writable ? "granted" : "REJECTED");
 
@@ -389,7 +384,7 @@ struct IntType
     TRACE_SANITIZE ();
     return context->check_struct (this);
   }
-  private:
+  protected:
   BEInt<Type, sizeof (Type)> v;
   public:
   DEFINE_SIZE_STATIC (sizeof (Type));
@@ -405,8 +400,8 @@ typedef IntType<int32_t>  LONG;		/* 32-bit signed integer. */
 struct Tag : ULONG
 {
   /* What the char* converters return is NOT nul-terminated.  Print using "%.4s" */
-  inline operator const char* (void) const { return CharP(this); }
-  inline operator char* (void) { return CharP(this); }
+  inline operator const char* (void) const { return reinterpret_cast<const char *> (&this->v); }
+  inline operator char* (void) { return reinterpret_cast<char *> (&this->v); }
   public:
   DEFINE_SIZE_STATIC (4);
 };
commit 40cbefe858192531ed64dd51d402f7ca7b8153a3
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Mon May 10 17:47:22 2010 -0400

    Remove unnecessary casts

diff --git a/src/hb-open-type-private.hh b/src/hb-open-type-private.hh
index 5b51fa7..fcc8c80 100644
--- a/src/hb-open-type-private.hh
+++ b/src/hb-open-type-private.hh
@@ -224,7 +224,7 @@ struct hb_sanitize_context_t
       fprintf (stderr, "SANITIZE(%p) %-*d-> range [%p..%p] (%d bytes) in [%p..%p] -> %s\n", \
 	       base,
 	       this->debug_depth, this->debug_depth,
-	       base, CharP(base)+len, len,
+	       base, CharP(base) + len, len,
 	       this->start, this->end,
 	       ret ? "pass" : "FAIL");
 
@@ -252,7 +252,7 @@ struct hb_sanitize_context_t
     return likely (this->check_range (obj, sizeof (*obj)));
   }
 
-  inline bool can_edit (const char *base HB_UNUSED, unsigned int len HB_UNUSED)
+  inline bool can_edit (const void *base HB_UNUSED, unsigned int len HB_UNUSED)
   {
     this->edit_count++;
 
@@ -261,7 +261,7 @@ struct hb_sanitize_context_t
 	       base,
 	       this->debug_depth, this->debug_depth,
 	       this->edit_count,
-	       base, base+len, len,
+	       base, CharP(base)+len, len,
 	       this->start, this->end,
 	       this->writable ? "granted" : "REJECTED");
 
@@ -496,7 +496,7 @@ struct GenericOffsetTo : OffsetType
   private:
   /* Set the offset to Null */
   inline bool neuter (hb_sanitize_context_t *context) {
-    if (context->can_edit (CharP(this), this->static_size)) {
+    if (context->can_edit (this, this->static_size)) {
       this->set (0); /* 0 is Null offset */
       return true;
     }
@@ -627,12 +627,12 @@ struct OffsetListOf : OffsetArrayOf<Type>
 
   inline bool sanitize (hb_sanitize_context_t *context) {
     TRACE_SANITIZE ();
-    return OffsetArrayOf<Type>::sanitize (context, CharP(this));
+    return OffsetArrayOf<Type>::sanitize (context, this);
   }
   template <typename T>
   inline bool sanitize (hb_sanitize_context_t *context, T user_data) {
     TRACE_SANITIZE ();
-    return OffsetArrayOf<Type>::sanitize (context, CharP(this), user_data);
+    return OffsetArrayOf<Type>::sanitize (context, this, user_data);
   }
 };
 
diff --git a/src/hb-ot-layout-common-private.hh b/src/hb-ot-layout-common-private.hh
index 8cfbdc4..094f3a8 100644
--- a/src/hb-ot-layout-common-private.hh
+++ b/src/hb-ot-layout-common-private.hh
@@ -112,7 +112,7 @@ struct RecordListOf : RecordArrayOf<Type>
 
   inline bool sanitize (hb_sanitize_context_t *context) {
     TRACE_SANITIZE ();
-    return RecordArrayOf<Type>::sanitize (context, CharP(this));
+    return RecordArrayOf<Type>::sanitize (context, this);
   }
 };
 
diff --git a/src/hb-ot-layout-gpos-private.hh b/src/hb-ot-layout-gpos-private.hh
index b18264d..c890585 100644
--- a/src/hb-ot-layout-gpos-private.hh
+++ b/src/hb-ot-layout-gpos-private.hh
@@ -92,7 +92,7 @@ struct ValueFormat : USHORT
   { return get_len () * Value::static_size; }
 
   void apply_value (hb_ot_layout_context_t       *layout,
-		    const char                   *base,
+		    const void                   *base,
 		    const Value                  *values,
 		    hb_internal_glyph_position_t *glyph_pos) const
   {
@@ -436,7 +436,7 @@ struct SinglePosFormat1
     if (likely (index == NOT_COVERED))
       return false;
 
-    valueFormat.apply_value (context->layout, CharP(this), values, CURPOSITION ());
+    valueFormat.apply_value (context->layout, this, values, CURPOSITION ());
 
     context->buffer->in_pos++;
     return true;
@@ -446,7 +446,7 @@ struct SinglePosFormat1
     TRACE_SANITIZE ();
     return context->check_struct (this)
 	&& coverage.sanitize (context, this)
-	&& valueFormat.sanitize_value (context, CharP(this), values);
+	&& valueFormat.sanitize_value (context, this, values);
   }
 
   private:
@@ -478,7 +478,7 @@ struct SinglePosFormat2
     if (likely (index >= valueCount))
       return false;
 
-    valueFormat.apply_value (context->layout, CharP(this),
+    valueFormat.apply_value (context->layout, this,
 			     &values[index * valueFormat.get_len ()],
 			     CURPOSITION ());
 
@@ -490,7 +490,7 @@ struct SinglePosFormat2
     TRACE_SANITIZE ();
     return context->check_struct (this)
 	&& coverage.sanitize (context, this)
-	&& valueFormat.sanitize_values (context, CharP(this), values, valueCount);
+	&& valueFormat.sanitize_values (context, this, values, valueCount);
   }
 
   private:
@@ -611,8 +611,8 @@ struct PairPosFormat1
     {
       if (IN_GLYPH (j) == record->secondGlyph)
       {
-	valueFormat1.apply_value (context->layout, CharP(this), &record->values[0], CURPOSITION ());
-	valueFormat2.apply_value (context->layout, CharP(this), &record->values[len1], POSITION (j));
+	valueFormat1.apply_value (context->layout, this, &record->values[0], CURPOSITION ());
+	valueFormat2.apply_value (context->layout, this, &record->values[len1], POSITION (j));
 	if (len2)
 	  j++;
 	context->buffer->in_pos = j;
@@ -632,7 +632,7 @@ struct PairPosFormat1
 
     if (!(context->check_struct (this)
        && coverage.sanitize (context, this)
-       && likely (pairSet.sanitize (context, CharP(this), len1 + len2)))) return false;
+       && likely (pairSet.sanitize (context, this, len1 + len2)))) return false;
 
     if (!(valueFormat1.has_device () || valueFormat2.has_device ())) return true;
 
@@ -644,8 +644,8 @@ struct PairPosFormat1
 
       unsigned int count2 = pair_set.len;
       PairValueRecord *record = pair_set.array;
-      if (!(valueFormat1.sanitize_values_stride_unsafe (context, CharP(this), &record->values[0], count2, stride) &&
-	    valueFormat2.sanitize_values_stride_unsafe (context, CharP(this), &record->values[len1], count2, stride)))
+      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;
     }
 
@@ -704,8 +704,8 @@ struct PairPosFormat2
       return false;
 
     const Value *v = &values[record_len * (klass1 * class2Count + klass2)];
-    valueFormat1.apply_value (context->layout, CharP(this), v, CURPOSITION ());
-    valueFormat2.apply_value (context->layout, CharP(this), v + len1, POSITION (j));
+    valueFormat1.apply_value (context->layout, this, v, CURPOSITION ());
+    valueFormat2.apply_value (context->layout, this, v + len1, POSITION (j));
 
     if (len2)
       j++;
@@ -727,8 +727,8 @@ struct PairPosFormat2
     unsigned int record_size = valueFormat1.get_size () + valueFormat2.get_size ();
     unsigned int count = (unsigned int) class1Count * (unsigned int) class2Count;
     return context->check_array (values, record_size, count) &&
-	   valueFormat1.sanitize_values_stride_unsafe (context, CharP(this), &values[0], count, stride) &&
-	   valueFormat2.sanitize_values_stride_unsafe (context, CharP(this), &values[len1], count, stride);
+	   valueFormat1.sanitize_values_stride_unsafe (context, this, &values[0], count, stride) &&
+	   valueFormat2.sanitize_values_stride_unsafe (context, this, &values[len1], count, stride);
   }
 
   private:
@@ -1091,7 +1091,7 @@ struct MarkBasePosFormat1
         && markCoverage.sanitize (context, this)
 	&& baseCoverage.sanitize (context, this)
 	&& markArray.sanitize (context, this)
-	&& likely (baseArray.sanitize (context, CharP(this), (unsigned int) classCount));
+	&& likely (baseArray.sanitize (context, this, (unsigned int) classCount));
   }
 
   private:
@@ -1214,7 +1214,7 @@ struct MarkLigPosFormat1
         && markCoverage.sanitize (context, this)
 	&& ligatureCoverage.sanitize (context, this)
 	&& markArray.sanitize (context, this)
-	&& likely (ligatureArray.sanitize (context, CharP(this), (unsigned int) classCount));
+	&& likely (ligatureArray.sanitize (context, this, (unsigned int) classCount));
   }
 
   private:
@@ -1318,7 +1318,7 @@ struct MarkMarkPosFormat1
 	&& mark1Coverage.sanitize (context, this)
 	&& mark2Coverage.sanitize (context, this)
 	&& mark1Array.sanitize (context, this)
-	&& likely (mark2Array.sanitize (context, CharP(this), (unsigned int) classCount));
+	&& likely (mark2Array.sanitize (context, this, (unsigned int) classCount));
   }
 
   private:
diff --git a/src/hb-ot-layout-gsub-private.hh b/src/hb-ot-layout-gsub-private.hh
index ccc51e7..da32cb1 100644
--- a/src/hb-ot-layout-gsub-private.hh
+++ b/src/hb-ot-layout-gsub-private.hh
@@ -617,10 +617,10 @@ struct ReverseChainSingleSubstFormat1
 
     if (match_backtrack (context,
 			 backtrack.len, (USHORT *) backtrack.array(),
-			 match_coverage, CharP(this)) &&
+			 match_coverage, this) &&
         match_lookahead (context,
 			 lookahead.len, (USHORT *) lookahead.array(),
-			 match_coverage, CharP(this),
+			 match_coverage, this,
 			 1))
     {
       IN_CURGLYPH () = substitute[index];
diff --git a/src/hb-ot-layout-gsubgpos-private.hh b/src/hb-ot-layout-gsubgpos-private.hh
index 32ece00..cc04de0 100644
--- a/src/hb-ot-layout-gsubgpos-private.hh
+++ b/src/hb-ot-layout-gsubgpos-private.hh
@@ -58,7 +58,7 @@ struct hb_apply_context_t
 #define BUFFER context->buffer
 
 
-typedef bool (*match_func_t) (hb_codepoint_t glyph_id, const USHORT &value, const char *data);
+typedef bool (*match_func_t) (hb_codepoint_t glyph_id, const USHORT &value, const void *data);
 typedef bool (*apply_lookup_func_t) (hb_apply_context_t *context, unsigned int lookup_index);
 
 struct ContextFuncs
@@ -68,18 +68,18 @@ struct ContextFuncs
 };
 
 
-static inline bool match_glyph (hb_codepoint_t glyph_id, const USHORT &value, const char *data HB_UNUSED)
+static inline bool match_glyph (hb_codepoint_t glyph_id, const USHORT &value, const void *data HB_UNUSED)
 {
   return glyph_id == value;
 }
 
-static inline bool match_class (hb_codepoint_t glyph_id, const USHORT &value, const char *data)
+static inline bool match_class (hb_codepoint_t glyph_id, const USHORT &value, const void *data)
 {
   const ClassDef &class_def = *reinterpret_cast<const ClassDef *>(data);
   return class_def.get_class (glyph_id) == value;
 }
 
-static inline bool match_coverage (hb_codepoint_t glyph_id, const USHORT &value, const char *data)
+static inline bool match_coverage (hb_codepoint_t glyph_id, const USHORT &value, const void *data)
 {
   const OffsetTo<Coverage> &coverage = (const OffsetTo<Coverage>&)value;
   return (data+coverage) (glyph_id) != NOT_COVERED;
@@ -90,7 +90,7 @@ static inline bool match_input (hb_apply_context_t *context,
 				unsigned int count, /* Including the first glyph (not matched) */
 				const USHORT input[], /* Array of input values--start with second glyph */
 				match_func_t match_func,
-				const char *match_data,
+				const void *match_data,
 				unsigned int *context_length_out)
 {
   unsigned int i, j;
@@ -120,7 +120,7 @@ static inline bool match_backtrack (hb_apply_context_t *context,
 				    unsigned int count,
 				    const USHORT backtrack[],
 				    match_func_t match_func,
-				    const char *match_data)
+				    const void *match_data)
 {
   if (unlikely (context->buffer->out_pos < count))
     return false;
@@ -145,7 +145,7 @@ static inline bool match_lookahead (hb_apply_context_t *context,
 				    unsigned int count,
 				    const USHORT lookahead[],
 				    match_func_t match_func,
-				    const char *match_data,
+				    const void *match_data,
 				    unsigned int offset)
 {
   unsigned int i, j;
@@ -247,7 +247,7 @@ static inline bool apply_lookup (hb_apply_context_t *context,
 struct ContextLookupContext
 {
   ContextFuncs funcs;
-  const char *match_data;
+  const void *match_data;
 };
 
 static inline bool context_lookup (hb_apply_context_t *context,
@@ -391,8 +391,8 @@ struct ContextFormat2
      * them across subrule lookups.  Not sure it's worth it.
      */
     struct ContextLookupContext lookup_context = {
-     {match_class, apply_func},
-      CharP(&class_def)
+      {match_class, apply_func},
+      &class_def
     };
     return rule_set.apply (context, lookup_context);
   }
@@ -435,7 +435,7 @@ struct ContextFormat3
     const LookupRecord *lookupRecord = &StructAtOffset<LookupRecord> (coverage, coverage[0].static_size * glyphCount);
     struct ContextLookupContext lookup_context = {
       {match_coverage, apply_func},
-       CharP(this)
+      this
     };
     return context_lookup (context,
 			   glyphCount, (const USHORT *) (coverage + 1),
@@ -508,7 +508,7 @@ struct Context
 struct ChainContextLookupContext
 {
   ContextFuncs funcs;
-  const char *match_data[3];
+  const void *match_data[3];
 };
 
 static inline bool chain_context_lookup (hb_apply_context_t *context,
@@ -684,10 +684,10 @@ struct ChainContextFormat2
      * them across subrule lookups.  Not sure it's worth it.
      */
     struct ChainContextLookupContext lookup_context = {
-     {match_class, apply_func},
-     {CharP(&backtrack_class_def),
-      CharP(&input_class_def),
-      CharP(&lookahead_class_def)}
+      {match_class, apply_func},
+      {&backtrack_class_def,
+       &input_class_def,
+       &lookahead_class_def}
     };
     return rule_set.apply (context, lookup_context);
   }
@@ -744,7 +744,7 @@ struct ChainContextFormat3
     const ArrayOf<LookupRecord> &lookup = StructAfter<ArrayOf<LookupRecord> > (lookahead);
     struct ChainContextLookupContext lookup_context = {
       {match_coverage, apply_func},
-      {CharP(this), CharP(this), CharP(this)}
+      {this, this, this}
     };
     return chain_context_lookup (context,
 				 backtrack.len, (const USHORT *) backtrack.array(),
commit 09766b1ec5ec55a61edbcd7a89ed3613cc92d4cb
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Mon May 10 17:36:03 2010 -0400

    Make StructAtOffset take a pointer
    
    Is safer.

diff --git a/src/hb-open-type-private.hh b/src/hb-open-type-private.hh
index 00ad434..5b51fa7 100644
--- a/src/hb-open-type-private.hh
+++ b/src/hb-open-type-private.hh
@@ -65,23 +65,23 @@ template<typename Type, typename TObject>
 inline Type* CastP(TObject *X)
 { return reinterpret_cast<Type*> (X); }
 
-/* StructAtOffset<T>(X,Ofs) returns the struct T& that is placed at memory
- * location of X plus Ofs bytes. */
-template<typename Type, typename TObject>
-inline const Type& StructAtOffset(const TObject &X, unsigned int offset)
-{ return * reinterpret_cast<const Type*> (CharP(&X) + offset); }
-template<typename Type, typename TObject>
-inline Type& StructAtOffset(TObject &X, unsigned int offset)
-{ return * reinterpret_cast<Type*> (CharP(&X) + offset); }
+/* StructAtOffset<T>(P,Ofs) returns the struct T& that is placed at memory
+ * location pointed to by P plus Ofs bytes. */
+template<typename Type>
+inline const Type& StructAtOffset(const void *P, unsigned int offset)
+{ return * reinterpret_cast<const Type*> (CharP(P) + offset); }
+template<typename Type>
+inline Type& StructAtOffset(void *P, unsigned int offset)
+{ return * reinterpret_cast<Type*> (CharP(P) + offset); }
 
 /* StructAfter<T>(X) returns the struct T& that is placed after X.
  * Works with X of variable size also.  X must implement get_size() */
 template<typename Type, typename TObject>
 inline const Type& StructAfter(const TObject &X)
-{ return StructAtOffset<Type>(X, X.get_size()); }
+{ return StructAtOffset<Type>(&X, X.get_size()); }
 template<typename Type, typename TObject>
 inline Type& StructAfter(TObject &X)
-{ return StructAtOffset<Type>(X, X.get_size()); }
+{ return StructAtOffset<Type>(&X, X.get_size()); }
 
 
 
@@ -472,7 +472,7 @@ struct GenericOffsetTo : OffsetType
   {
     unsigned int offset = *this;
     if (unlikely (!offset)) return Null(Type);
-    return StructAtOffset<Type> (*CharP(base), offset);
+    return StructAtOffset<Type> (base, offset);
   }
 
   inline bool sanitize (hb_sanitize_context_t *context, void *base) {
@@ -480,7 +480,7 @@ struct GenericOffsetTo : OffsetType
     if (!context->check_struct (this)) return false;
     unsigned int offset = *this;
     if (unlikely (!offset)) return true;
-    Type &obj = StructAtOffset<Type> (*CharP(base), offset);
+    Type &obj = StructAtOffset<Type> (base, offset);
     return likely (obj.sanitize (context)) || neuter (context);
   }
   template <typename T>
@@ -489,7 +489,7 @@ struct GenericOffsetTo : OffsetType
     if (!context->check_struct (this)) return false;
     unsigned int offset = *this;
     if (unlikely (!offset)) return true;
-    Type &obj = StructAtOffset<Type> (*CharP(base), offset);
+    Type &obj = StructAtOffset<Type> (base, offset);
     return likely (obj.sanitize (context, user_data)) || neuter (context);
   }
 
diff --git a/src/hb-ot-layout-gpos-private.hh b/src/hb-ot-layout-gpos-private.hh
index a438116..b18264d 100644
--- a/src/hb-ot-layout-gpos-private.hh
+++ b/src/hb-ot-layout-gpos-private.hh
@@ -618,7 +618,7 @@ struct PairPosFormat1
 	context->buffer->in_pos = j;
 	return true;
       }
-      record = &StructAtOffset<PairValueRecord> (*record, record_size);
+      record = &StructAtOffset<PairValueRecord> (record, record_size);
     }
 
     return false;
@@ -1409,7 +1409,7 @@ struct ExtensionPos : Extension
   {
     unsigned int offset = get_offset ();
     if (unlikely (!offset)) return Null(PosLookupSubTable);
-    return StructAtOffset<PosLookupSubTable> (*this, offset);
+    return StructAtOffset<PosLookupSubTable> (this, offset);
   }
 
   inline bool apply (hb_apply_context_t *context) const;
@@ -1608,7 +1608,7 @@ inline bool ExtensionPos::sanitize (hb_sanitize_context_t *context)
   if (unlikely (!Extension::sanitize (context))) return false;
   unsigned int offset = get_offset ();
   if (unlikely (!offset)) return true;
-  return StructAtOffset<PosLookupSubTable> (*this, offset).sanitize (context);
+  return StructAtOffset<PosLookupSubTable> (this, offset).sanitize (context);
 }
 
 static inline bool position_lookup (hb_apply_context_t *context, unsigned int lookup_index)
diff --git a/src/hb-ot-layout-gsub-private.hh b/src/hb-ot-layout-gsub-private.hh
index ba933de..ccc51e7 100644
--- a/src/hb-ot-layout-gsub-private.hh
+++ b/src/hb-ot-layout-gsub-private.hh
@@ -586,7 +586,7 @@ struct ExtensionSubst : Extension
   {
     unsigned int offset = get_offset ();
     if (unlikely (!offset)) return Null(SubstLookupSubTable);
-    return StructAtOffset<SubstLookupSubTable> (*this, offset);
+    return StructAtOffset<SubstLookupSubTable> (this, offset);
   }
 
   inline bool apply (hb_apply_context_t *context) const;
@@ -916,7 +916,7 @@ inline bool ExtensionSubst::sanitize (hb_sanitize_context_t *context)
   if (unlikely (!Extension::sanitize (context))) return false;
   unsigned int offset = get_offset ();
   if (unlikely (!offset)) return true;
-  return StructAtOffset<SubstLookupSubTable> (*this, offset).sanitize (context);
+  return StructAtOffset<SubstLookupSubTable> (this, offset).sanitize (context);
 }
 
 inline bool ExtensionSubst::is_reverse (void) const
commit bea34c7cbb583cf7660776e95cab3171590b8427
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Mon May 10 17:28:16 2010 -0400

    Further cleanup of DEFINE_SIZE

diff --git a/src/hb-open-file-private.hh b/src/hb-open-file-private.hh
index d8d70e5..ffe8ba7 100644
--- a/src/hb-open-file-private.hh
+++ b/src/hb-open-file-private.hh
@@ -140,7 +140,7 @@ struct TTCHeaderVersion1
 		table;		/* Array of offsets to the OffsetTable for each font
 				 * from the beginning of the file */
   public:
-  DEFINE_SIZE_STATIC (12);
+  DEFINE_SIZE_VAR (12, LongOffset);
 };
 
 struct TTCHeader
diff --git a/src/hb-open-type-private.hh b/src/hb-open-type-private.hh
index f45351e..00ad434 100644
--- a/src/hb-open-type-private.hh
+++ b/src/hb-open-type-private.hh
@@ -105,8 +105,7 @@ inline Type& StructAfter(TObject &X)
 #define VAR 1
 #define VAR0 (VAR+0)
 
-#define DEFINE_SIZE_VAR0(size) \
-  _DEFINE_SIZE_ASSERTION (size); \
+#define DEFINE_SIZE_MIN(size) \
   static const unsigned int min_size = (size)
 
 #define DEFINE_SIZE_VAR(size, _var_type) \
@@ -140,7 +139,7 @@ template <> \
 inline const Type& Null<Type> () { \
   return *CastP<Type> (_Null##Type); \
 } /* The following line really exists such that we end in a place needing semicolon */ \
-ASSERT_STATIC (sizeof (Type) + 1 <= sizeof (_Null##Type))
+ASSERT_STATIC (Type::min_size + 1 <= sizeof (_Null##Type))
 
 /* Accessor macro. */
 #define Null(Type) Null<Type>()
@@ -590,9 +589,10 @@ struct GenericArrayOf
 
   public:
   LenType len;
-/*Type array[VAR];*/
+  private:
+  Type arrayX[VAR];
   public:
-  DEFINE_SIZE_VAR0 (sizeof (LenType));
+  DEFINE_SIZE_VAR (sizeof (LenType), Type);
 };
 
 /* An array with a USHORT number of elements. */
diff --git a/src/hb-ot-layout-common-private.hh b/src/hb-ot-layout-common-private.hh
index dc1229f..8cfbdc4 100644
--- a/src/hb-ot-layout-common-private.hh
+++ b/src/hb-ot-layout-common-private.hh
@@ -177,7 +177,7 @@ struct LangSys
 				 * = 0xFFFF */
   IndexArray	featureIndex;	/* Array of indices into the FeatureList */
   public:
-  DEFINE_SIZE_STATIC (6);
+  DEFINE_SIZE_VAR (6, USHORT);
 };
 DEFINE_NULL_DATA (LangSys, "\0\0\xFF\xFF");
 
@@ -217,7 +217,7 @@ struct Script
 		langSys;	/* Array of LangSysRecords--listed
 				 * alphabetically by LangSysTag */
   public:
-  DEFINE_SIZE_STATIC (4);
+  DEFINE_SIZE_VAR (4, Record<LangSys>);
 };
 
 typedef RecordListOf<Script> ScriptList;
@@ -248,7 +248,7 @@ struct Feature
 				 * if not required */
   IndexArray	 lookupIndex;	/* Array of LookupList indices */
   public:
-  DEFINE_SIZE_STATIC (4);
+  DEFINE_SIZE_VAR (4, USHORT);
 };
 
 typedef RecordListOf<Feature> FeatureList;
@@ -307,7 +307,7 @@ struct Lookup
 					 * structure. This field is only present if bit
 					 * UseMarkFilteringSet of lookup flags is set. */
   public:
-  DEFINE_SIZE_VAR (6, USHORT);
+  DEFINE_SIZE_VAR2 (6, Offset, USHORT);
 };
 
 typedef OffsetListOf<Lookup> LookupList;
@@ -346,7 +346,7 @@ struct CoverageFormat1
   ArrayOf<GlyphID>
 		glyphArray;	/* Array of GlyphIDs--in numerical order */
   public:
-  DEFINE_SIZE_STATIC (4);
+  DEFINE_SIZE_VAR (4, GlyphID);
 };
 
 struct CoverageRangeRecord
@@ -407,7 +407,7 @@ struct CoverageFormat2
 				 * Start GlyphID. rangeCount entries
 				 * long */
   public:
-  DEFINE_SIZE_STATIC (4);
+  DEFINE_SIZE_VAR (4, CoverageRangeRecord);
 };
 
 struct Coverage
@@ -469,7 +469,7 @@ struct ClassDefFormat1
   ArrayOf<USHORT>
 		classValue;		/* Array of Class Values--one per GlyphID */
   public:
-  DEFINE_SIZE_STATIC (6);
+  DEFINE_SIZE_VAR (6, USHORT);
 };
 
 struct ClassRangeRecord
@@ -527,7 +527,7 @@ struct ClassDefFormat2
 		rangeRecord;	/* Array of glyph ranges--ordered by
 				 * Start GlyphID */
   public:
-  DEFINE_SIZE_STATIC (4);
+  DEFINE_SIZE_VAR (4, ClassRangeRecord);
 };
 
 struct ClassDef
diff --git a/src/hb-ot-layout-gdef-private.hh b/src/hb-ot-layout-gdef-private.hh
index 4e06673..20d6b92 100644
--- a/src/hb-ot-layout-gdef-private.hh
+++ b/src/hb-ot-layout-gdef-private.hh
@@ -80,7 +80,7 @@ struct AttachList
 		attachPoint;		/* Array of AttachPoint tables
 					 * in Coverage Index order */
   public:
-  DEFINE_SIZE_STATIC (4);
+  DEFINE_SIZE_VAR (4, OffsetTo<AttachPoint>);
 };
 
 /*
@@ -226,7 +226,7 @@ struct LigGlyph
 					 * --from beginning of LigGlyph table
 					 * --in increasing coordinate order */
   public:
-  DEFINE_SIZE_STATIC (2);
+  DEFINE_SIZE_VAR (2, OffsetTo<CaretValue>);
 };
 
 struct LigCaretList
@@ -262,7 +262,7 @@ struct LigCaretList
 		ligGlyph;		/* Array of LigGlyph tables
 					 * in Coverage Index order */
   public:
-  DEFINE_SIZE_STATIC (4);
+  DEFINE_SIZE_VAR (4, OffsetTo<LigGlyph>);
 };
 
 
@@ -282,7 +282,7 @@ struct MarkGlyphSetsFormat1
 		coverage;		/* Array of long offsets to mark set
 					 * coverage tables */
   public:
-  DEFINE_SIZE_STATIC (4);
+  DEFINE_SIZE_VAR (4, LongOffsetTo<Coverage>);
 };
 
 struct MarkGlyphSets
diff --git a/src/hb-ot-layout-gpos-private.hh b/src/hb-ot-layout-gpos-private.hh
index 65e26eb..a438116 100644
--- a/src/hb-ot-layout-gpos-private.hh
+++ b/src/hb-ot-layout-gpos-private.hh
@@ -385,7 +385,7 @@ struct MarkRecord
   DEFINE_SIZE_STATIC (4);
 };
 
-struct MarkArray
+struct MarkArray : ArrayOf<MarkRecord>	/* Array of MarkRecords--in Coverage order */
 {
   inline bool apply (hb_apply_context_t *context,
 		     unsigned int mark_index, unsigned int glyph_index,
@@ -393,7 +393,7 @@ struct MarkArray
 		     unsigned int glyph_pos) const
   {
     TRACE_APPLY ();
-    const MarkRecord &record = markRecord[mark_index];
+    const MarkRecord &record = ArrayOf<MarkRecord>::operator[](mark_index);
     unsigned int mark_class = record.klass;
 
     const Anchor& mark_anchor = this + record.markAnchor;
@@ -417,14 +417,8 @@ struct MarkArray
 
   inline bool sanitize (hb_sanitize_context_t *context) {
     TRACE_SANITIZE ();
-    return markRecord.sanitize (context, this);
+    return ArrayOf<MarkRecord>::sanitize (context, this);
   }
-
-  private:
-  ArrayOf<MarkRecord>
-		markRecord;	/* Array of MarkRecords--in Coverage order */
-  public:
-  DEFINE_SIZE_STATIC (2);
 };
 
 
@@ -673,7 +667,7 @@ struct PairPosFormat1
 		pairSet;		/* Array of PairSet tables
 					 * ordered by Coverage Index */
   public:
-  DEFINE_SIZE_STATIC (10);
+  DEFINE_SIZE_VAR (10, OffsetTo<PairSet>);
 };
 
 struct PairPosFormat2
@@ -1019,7 +1013,7 @@ struct CursivePosFormat1
 		entryExitRecord;	/* Array of EntryExit records--in
 					 * Coverage Index order */
   public:
-  DEFINE_SIZE_STATIC (6);
+  DEFINE_SIZE_VAR (6, EntryExitRecord);
 };
 
 struct CursivePos
diff --git a/src/hb-ot-layout-gsub-private.hh b/src/hb-ot-layout-gsub-private.hh
index 4a464b6..ba933de 100644
--- a/src/hb-ot-layout-gsub-private.hh
+++ b/src/hb-ot-layout-gsub-private.hh
@@ -117,7 +117,7 @@ struct SingleSubstFormat2
 		substitute;		/* Array of substitute
 					 * GlyphIDs--ordered by Coverage Index */
   public:
-  DEFINE_SIZE_STATIC (6);
+  DEFINE_SIZE_VAR (6, GlyphID);
 };
 
 struct SingleSubst
@@ -195,7 +195,7 @@ struct Sequence
   ArrayOf<GlyphID>
 		substitute;		/* String of GlyphIDs to substitute */
   public:
-  DEFINE_SIZE_STATIC (2);
+  DEFINE_SIZE_VAR (2, GlyphID);
 };
 
 struct MultipleSubstFormat1
@@ -230,7 +230,7 @@ struct MultipleSubstFormat1
 		sequence;		/* Array of Sequence tables
 					 * ordered by Coverage Index */
   public:
-  DEFINE_SIZE_STATIC (6);
+  DEFINE_SIZE_VAR (6, OffsetTo<Sequence>);
 };
 
 struct MultipleSubst
@@ -326,7 +326,7 @@ struct AlternateSubstFormat1
 		alternateSet;		/* Array of AlternateSet tables
 					 * ordered by Coverage Index */
   public:
-  DEFINE_SIZE_STATIC (6);
+  DEFINE_SIZE_VAR (6, OffsetTo<AlternateSet>);
 };
 
 struct AlternateSubst
@@ -476,7 +476,7 @@ struct LigatureSet
 		ligature;		/* Array LigatureSet tables
 					 * ordered by preference */
   public:
-  DEFINE_SIZE_STATIC (2);
+  DEFINE_SIZE_VAR (2, OffsetTo<Ligature>);
 };
 
 struct LigatureSubstFormat1
@@ -514,7 +514,7 @@ struct LigatureSubstFormat1
 		ligatureSet;		/* Array LigatureSet tables
 					 * ordered by Coverage Index */
   public:
-  DEFINE_SIZE_STATIC (6);
+  DEFINE_SIZE_VAR (6, OffsetTo<LigatureSet>);
 };
 
 struct LigatureSubst
@@ -660,7 +660,7 @@ struct ReverseChainSingleSubstFormat1
 		substituteX;		/* Array of substitute
 					 * GlyphIDs--ordered by Coverage Index */
   public:
-  DEFINE_SIZE_STATIC (10);
+  DEFINE_SIZE_MIN (10);
 };
 
 struct ReverseChainSingleSubst
diff --git a/src/hb-ot-layout-gsubgpos-private.hh b/src/hb-ot-layout-gsubgpos-private.hh
index 86285d1..32ece00 100644
--- a/src/hb-ot-layout-gsubgpos-private.hh
+++ b/src/hb-ot-layout-gsubgpos-private.hh
@@ -368,7 +368,7 @@ struct ContextFormat1
 		ruleSet;		/* Array of RuleSet tables
 					 * ordered by Coverage Index */
   public:
-  DEFINE_SIZE_STATIC (6);
+  DEFINE_SIZE_VAR (6, OffsetTo<RuleSet>);
 };
 
 
@@ -416,7 +416,7 @@ struct ContextFormat2
 		ruleSet;		/* Array of RuleSet tables
 					 * ordered by class */
   public:
-  DEFINE_SIZE_STATIC (8);
+  DEFINE_SIZE_VAR (8, OffsetTo<RuleSet>);
 };
 
 
@@ -593,7 +593,7 @@ struct ChainRule
 		lookupX;		/* Array of LookupRecords--in
 					 * design order) */
   public:
-  DEFINE_SIZE_STATIC (8);
+  DEFINE_SIZE_MIN (8);
 };
 
 struct ChainRuleSet
@@ -621,7 +621,7 @@ struct ChainRuleSet
 		rule;			/* Array of ChainRule tables
 					 * ordered by preference */
   public:
-  DEFINE_SIZE_STATIC (2);
+  DEFINE_SIZE_VAR (2, OffsetTo<ChainRule>);
 };
 
 struct ChainContextFormat1
@@ -659,7 +659,7 @@ struct ChainContextFormat1
 		ruleSet;		/* Array of ChainRuleSet tables
 					 * ordered by Coverage Index */
   public:
-  DEFINE_SIZE_STATIC (6);
+  DEFINE_SIZE_VAR (6, OffsetTo<ChainRuleSet>);
 };
 
 struct ChainContextFormat2
@@ -722,7 +722,7 @@ struct ChainContextFormat2
 		ruleSet;		/* Array of ChainRuleSet tables
 					 * ordered by class */
   public:
-  DEFINE_SIZE_STATIC (12);
+  DEFINE_SIZE_VAR (12, OffsetTo<ChainRuleSet>);
 };
 
 struct ChainContextFormat3
@@ -784,7 +784,7 @@ struct ChainContextFormat3
 		lookupX;		/* Array of LookupRecords--in
 					 * design order) */
   public:
-  DEFINE_SIZE_STATIC (10);
+  DEFINE_SIZE_MIN (10);
 };
 
 struct ChainContext
commit 0abcc3b48cfd51a22695c9e988938b2f45cb19d8
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Mon May 10 17:04:20 2010 -0400

    Cleanup

diff --git a/src/hb-open-type-private.hh b/src/hb-open-type-private.hh
index 56a8bae..f45351e 100644
--- a/src/hb-open-type-private.hh
+++ b/src/hb-open-type-private.hh
@@ -89,9 +89,14 @@ inline Type& StructAfter(TObject &X)
  * Size checking
  */
 
+#define ASSERT_SIZE(_thing, _size) ASSERT_STATIC (sizeof (_thing) == (_size))
+
+#define _DEFINE_SIZE_ASSERTION(_size) \
+  inline void _size_assertion (void) const { ASSERT_SIZE (*this, _size); }
+
+
 #define DEFINE_SIZE_STATIC(size) \
-  inline void _size_assertion (void) const \
-  { ASSERT_STATIC (sizeof (*this) == (size)); } \
+  _DEFINE_SIZE_ASSERTION (size); \
   static inline unsigned int get_size (void) { return (size); } \
   static const unsigned int static_size = (size); \
   static const unsigned int min_size = (size)
@@ -101,18 +106,15 @@ inline Type& StructAfter(TObject &X)
 #define VAR0 (VAR+0)
 
 #define DEFINE_SIZE_VAR0(size) \
-  inline void _size_assertion (void) const \
-  { ASSERT_STATIC (sizeof (*this) == (size)); } \
+  _DEFINE_SIZE_ASSERTION (size); \
   static const unsigned int min_size = (size)
 
 #define DEFINE_SIZE_VAR(size, _var_type) \
-  inline void _size_assertion (void) const \
-  { ASSERT_STATIC (sizeof (*this) == (size) + VAR0 * sizeof (_var_type)); } \
+  _DEFINE_SIZE_ASSERTION ((size) + VAR0 * sizeof (_var_type)); \
   static const unsigned int min_size = (size)
 
 #define DEFINE_SIZE_VAR2(size, _var_type1, _var_type2) \
-  inline void _size_assertion (void) const \
-  { ASSERT_STATIC (sizeof (*this) == (size) + VAR0 * sizeof (_var_type1) + VAR0 * sizeof (_var_type2)); } \
+  _DEFINE_SIZE_ASSERTION ((size) + VAR0 * sizeof (_var_type1) + VAR0 * sizeof (_var_type2)); \
   static const unsigned int min_size = (size)
 
 
commit b3651231bf80bb7009214547a75ed90e21815c68
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Mon May 10 16:57:29 2010 -0400

    Remove ASSERT_SIZE in favor of the safer DEFINE_SIZE_STATIC

diff --git a/src/hb-open-file-private.hh b/src/hb-open-file-private.hh
index 53e947a..d8d70e5 100644
--- a/src/hb-open-file-private.hh
+++ b/src/hb-open-file-private.hh
@@ -139,8 +139,9 @@ struct TTCHeaderVersion1
   LongOffsetLongArrayOf<OffsetTable>
 		table;		/* Array of offsets to the OffsetTable for each font
 				 * from the beginning of the file */
+  public:
+  DEFINE_SIZE_STATIC (12);
 };
-ASSERT_SIZE (TTCHeaderVersion1, 12);
 
 struct TTCHeader
 {
diff --git a/src/hb-open-type-private.hh b/src/hb-open-type-private.hh
index aab85fd..56a8bae 100644
--- a/src/hb-open-type-private.hh
+++ b/src/hb-open-type-private.hh
@@ -96,6 +96,15 @@ inline Type& StructAfter(TObject &X)
   static const unsigned int static_size = (size); \
   static const unsigned int min_size = (size)
 
+/* Size signifying variable-sized array */
+#define VAR 1
+#define VAR0 (VAR+0)
+
+#define DEFINE_SIZE_VAR0(size) \
+  inline void _size_assertion (void) const \
+  { ASSERT_STATIC (sizeof (*this) == (size)); } \
+  static const unsigned int min_size = (size)
+
 #define DEFINE_SIZE_VAR(size, _var_type) \
   inline void _size_assertion (void) const \
   { ASSERT_STATIC (sizeof (*this) == (size) + VAR0 * sizeof (_var_type)); } \
@@ -397,8 +406,9 @@ struct Tag : ULONG
   /* What the char* converters return is NOT nul-terminated.  Print using "%.4s" */
   inline operator const char* (void) const { return CharP(this); }
   inline operator char* (void) { return CharP(this); }
+  public:
+  DEFINE_SIZE_STATIC (4);
 };
-ASSERT_SIZE (Tag, 4);
 DEFINE_NULL_DATA (Tag, "    ");
 
 /* Glyph index number, same as uint16 (length = 16 bits) */
@@ -423,8 +433,9 @@ struct CheckSum : ULONG
       Sum += *Table++;
     return Sum;
   }
+  public:
+  DEFINE_SIZE_STATIC (4);
 };
-ASSERT_SIZE (CheckSum, 4);
 
 
 /*
@@ -442,8 +453,9 @@ struct FixedVersion
 
   USHORT major;
   USHORT minor;
+  public:
+  DEFINE_SIZE_STATIC (4);
 };
-ASSERT_SIZE (FixedVersion, 4);
 
 
 
@@ -577,6 +589,8 @@ struct GenericArrayOf
   public:
   LenType len;
 /*Type array[VAR];*/
+  public:
+  DEFINE_SIZE_VAR0 (sizeof (LenType));
 };
 
 /* An array with a USHORT number of elements. */
diff --git a/src/hb-ot-layout-common-private.hh b/src/hb-ot-layout-common-private.hh
index 7215415..dc1229f 100644
--- a/src/hb-ot-layout-common-private.hh
+++ b/src/hb-ot-layout-common-private.hh
@@ -216,11 +216,11 @@ struct Script
   RecordArrayOf<LangSys>
 		langSys;	/* Array of LangSysRecords--listed
 				 * alphabetically by LangSysTag */
+  public:
+  DEFINE_SIZE_STATIC (4);
 };
-ASSERT_SIZE (Script, 4);
 
 typedef RecordListOf<Script> ScriptList;
-ASSERT_SIZE (ScriptList, 2);
 
 
 struct Feature
@@ -247,11 +247,11 @@ struct Feature
 				 * to the beginning of the Feature Table; = Null
 				 * if not required */
   IndexArray	 lookupIndex;	/* Array of LookupList indices */
+  public:
+  DEFINE_SIZE_STATIC (4);
 };
-ASSERT_SIZE (Feature, 4);
 
 typedef RecordListOf<Feature> FeatureList;
-ASSERT_SIZE (FeatureList, 2);
 
 
 struct LookupFlag : USHORT
@@ -266,8 +266,9 @@ struct LookupFlag : USHORT
     Reserved		= 0x00E0u,
     MarkAttachmentType	= 0xFF00u
   };
+  public:
+  DEFINE_SIZE_STATIC (2);
 };
-ASSERT_SIZE (LookupFlag, 2);
 
 struct Lookup
 {
@@ -310,7 +311,6 @@ struct Lookup
 };
 
 typedef OffsetListOf<Lookup> LookupList;
-ASSERT_SIZE (LookupList, 2);
 
 
 /*
@@ -345,8 +345,9 @@ struct CoverageFormat1
   USHORT	coverageFormat;	/* Format identifier--format = 1 */
   ArrayOf<GlyphID>
 		glyphArray;	/* Array of GlyphIDs--in numerical order */
+  public:
+  DEFINE_SIZE_STATIC (4);
 };
-ASSERT_SIZE (CoverageFormat1, 4);
 
 struct CoverageRangeRecord
 {
@@ -405,8 +406,9 @@ struct CoverageFormat2
 		rangeRecord;	/* Array of glyph ranges--ordered by
 				 * Start GlyphID. rangeCount entries
 				 * long */
+  public:
+  DEFINE_SIZE_STATIC (4);
 };
-ASSERT_SIZE (CoverageFormat2, 4);
 
 struct Coverage
 {
@@ -466,8 +468,9 @@ struct ClassDefFormat1
   GlyphID	startGlyph;		/* First GlyphID of the classValueArray */
   ArrayOf<USHORT>
 		classValue;		/* Array of Class Values--one per GlyphID */
+  public:
+  DEFINE_SIZE_STATIC (6);
 };
-ASSERT_SIZE (ClassDefFormat1, 6);
 
 struct ClassRangeRecord
 {
@@ -523,8 +526,9 @@ struct ClassDefFormat2
   ArrayOf<ClassRangeRecord>
 		rangeRecord;	/* Array of glyph ranges--ordered by
 				 * Start GlyphID */
+  public:
+  DEFINE_SIZE_STATIC (4);
 };
-ASSERT_SIZE (ClassDefFormat2, 4);
 
 struct ClassDef
 {
diff --git a/src/hb-ot-layout-gdef-private.hh b/src/hb-ot-layout-gdef-private.hh
index e6cf7b8..4e06673 100644
--- a/src/hb-ot-layout-gdef-private.hh
+++ b/src/hb-ot-layout-gdef-private.hh
@@ -38,7 +38,6 @@
 
 typedef ArrayOf<USHORT> AttachPoint;	/* Array of contour point indices--in
 					 * increasing numerical order */
-ASSERT_SIZE (AttachPoint, 2);
 
 struct AttachList
 {
@@ -80,8 +79,9 @@ struct AttachList
   OffsetArrayOf<AttachPoint>
 		attachPoint;		/* Array of AttachPoint tables
 					 * in Coverage Index order */
+  public:
+  DEFINE_SIZE_STATIC (4);
 };
-ASSERT_SIZE (AttachList, 4);
 
 /*
  * Ligature Caret Table
@@ -106,8 +106,9 @@ struct CaretValueFormat1
   private:
   USHORT	caretValueFormat;	/* Format identifier--format = 1 */
   SHORT		coordinate;		/* X or Y value, in design units */
+  public:
+  DEFINE_SIZE_STATIC (4);
 };
-ASSERT_SIZE (CaretValueFormat1, 4);
 
 struct CaretValueFormat2
 {
@@ -132,8 +133,9 @@ struct CaretValueFormat2
   private:
   USHORT	caretValueFormat;	/* Format identifier--format = 2 */
   USHORT	caretValuePoint;	/* Contour point index on glyph */
+  public:
+  DEFINE_SIZE_STATIC (4);
 };
-ASSERT_SIZE (CaretValueFormat2, 4);
 
 struct CaretValueFormat3
 {
@@ -159,8 +161,9 @@ struct CaretValueFormat3
 		deviceTable;		/* Offset to Device table for X or Y
 					 * value--from beginning of CaretValue
 					 * table */
+  public:
+  DEFINE_SIZE_STATIC (6);
 };
-ASSERT_SIZE (CaretValueFormat3, 6);
 
 struct CaretValue
 {
@@ -222,8 +225,9 @@ struct LigGlyph
 		carets;			/* Offset array of CaretValue tables
 					 * --from beginning of LigGlyph table
 					 * --in increasing coordinate order */
+  public:
+  DEFINE_SIZE_STATIC (2);
 };
-ASSERT_SIZE (LigGlyph, 2);
 
 struct LigCaretList
 {
@@ -257,8 +261,9 @@ struct LigCaretList
   OffsetArrayOf<LigGlyph>
 		ligGlyph;		/* Array of LigGlyph tables
 					 * in Coverage Index order */
+  public:
+  DEFINE_SIZE_STATIC (4);
 };
-ASSERT_SIZE (LigCaretList, 4);
 
 
 struct MarkGlyphSetsFormat1
@@ -276,8 +281,9 @@ struct MarkGlyphSetsFormat1
   LongOffsetArrayOf<Coverage>
 		coverage;		/* Array of long offsets to mark set
 					 * coverage tables */
+  public:
+  DEFINE_SIZE_STATIC (4);
 };
-ASSERT_SIZE (MarkGlyphSetsFormat1, 4);
 
 struct MarkGlyphSets
 {
diff --git a/src/hb-ot-layout-gpos-private.hh b/src/hb-ot-layout-gpos-private.hh
index eb53ac1..65e26eb 100644
--- a/src/hb-ot-layout-gpos-private.hh
+++ b/src/hb-ot-layout-gpos-private.hh
@@ -202,7 +202,6 @@ struct ValueFormat : USHORT
     return true;
   }
 };
-ASSERT_SIZE (ValueFormat, 2);
 
 
 struct AnchorFormat1
@@ -226,8 +225,9 @@ struct AnchorFormat1
   USHORT	format;			/* Format identifier--format = 1 */
   SHORT		xCoordinate;		/* Horizontal value--in design units */
   SHORT		yCoordinate;		/* Vertical value--in design units */
+  public:
+  DEFINE_SIZE_STATIC (6);
 };
-ASSERT_SIZE (AnchorFormat1, 6);
 
 struct AnchorFormat2
 {
@@ -258,8 +258,9 @@ struct AnchorFormat2
   SHORT		xCoordinate;		/* Horizontal value--in design units */
   SHORT		yCoordinate;		/* Vertical value--in design units */
   USHORT	anchorPoint;		/* Index to glyph contour point */
+  public:
+  DEFINE_SIZE_STATIC (8);
 };
-ASSERT_SIZE (AnchorFormat2, 8);
 
 struct AnchorFormat3
 {
@@ -298,8 +299,9 @@ struct AnchorFormat3
 		yDeviceTable;		/* Offset to Device table for Y
 					 * coordinate-- from beginning of
 					 * Anchor table (may be NULL) */
+  public:
+  DEFINE_SIZE_STATIC (10);
 };
-ASSERT_SIZE (AnchorFormat3, 10);
 
 struct Anchor
 {
@@ -421,8 +423,9 @@ struct MarkArray
   private:
   ArrayOf<MarkRecord>
 		markRecord;	/* Array of MarkRecords--in Coverage order */
+  public:
+  DEFINE_SIZE_STATIC (2);
 };
-ASSERT_SIZE (MarkArray, 2);
 
 
 /* Lookups */
@@ -669,8 +672,9 @@ struct PairPosFormat1
   OffsetArrayOf<PairSet>
 		pairSet;		/* Array of PairSet tables
 					 * ordered by Coverage Index */
+  public:
+  DEFINE_SIZE_STATIC (10);
 };
-ASSERT_SIZE (PairPosFormat1, 10);
 
 struct PairPosFormat2
 {
@@ -1014,8 +1018,9 @@ struct CursivePosFormat1
   ArrayOf<EntryExitRecord>
 		entryExitRecord;	/* Array of EntryExit records--in
 					 * Coverage Index order */
+  public:
+  DEFINE_SIZE_STATIC (6);
 };
-ASSERT_SIZE (CursivePosFormat1, 6);
 
 struct CursivePos
 {
@@ -1075,11 +1080,9 @@ struct MarkBasePosFormat1
       j--;
     } while (_hb_ot_layout_skip_mark (context->layout->face, IN_INFO (j), LookupFlag::IgnoreMarks, &property));
 
-#if 0
-    /* The following assertion is too strong. */
-    if (!(property & HB_OT_LAYOUT_GLYPH_CLASS_BASE_GLYPH))
+    /* The following assertion is too strong, so we've disabled it. */
+    if (false && !(property & HB_OT_LAYOUT_GLYPH_CLASS_BASE_GLYPH))
       return false;
-#endif
 
     unsigned int base_index = (this+baseCoverage) (IN_GLYPH (j));
     if (base_index == NOT_COVERED)
@@ -1112,8 +1115,9 @@ struct MarkBasePosFormat1
   OffsetTo<BaseArray>
 		baseArray;		/* Offset to BaseArray table--from
 					 * beginning of MarkBasePos subtable */
+  public:
+  DEFINE_SIZE_STATIC (12);
 };
-ASSERT_SIZE (MarkBasePosFormat1, 12);
 
 struct MarkBasePos
 {
@@ -1178,11 +1182,9 @@ struct MarkLigPosFormat1
       j--;
     } while (_hb_ot_layout_skip_mark (context->layout->face, IN_INFO (j), LookupFlag::IgnoreMarks, &property));
 
-#if 0
-    /* The following assertion is too strong. */
-    if (!(property & HB_OT_LAYOUT_GLYPH_CLASS_LIGATURE))
+    /* The following assertion is too strong, so we've disabled it. */
+    if (false && !(property & HB_OT_LAYOUT_GLYPH_CLASS_LIGATURE))
       return false;
-#endif
 
     unsigned int lig_index = (this+ligatureCoverage) (IN_GLYPH (j));
     if (lig_index == NOT_COVERED)
@@ -1237,8 +1239,9 @@ struct MarkLigPosFormat1
   OffsetTo<LigatureArray>
 		ligatureArray;		/* Offset to LigatureArray table--from
 					 * beginning of MarkLigPos subtable */
+  public:
+  DEFINE_SIZE_STATIC (12);
 };
-ASSERT_SIZE (MarkLigPosFormat1, 12);
 
 struct MarkLigPos
 {
@@ -1341,8 +1344,9 @@ struct MarkMarkPosFormat1
   OffsetTo<Mark2Array>
 		mark2Array;		/* Offset to Mark2Array table--from
 					 * beginning of MarkMarkPos subtable */
+  public:
+  DEFINE_SIZE_STATIC (12);
 };
-ASSERT_SIZE (MarkMarkPosFormat1, 12);
 
 struct MarkMarkPos
 {
@@ -1567,7 +1571,6 @@ struct PosLookup : Lookup
 };
 
 typedef OffsetListOf<PosLookup> PosLookupList;
-ASSERT_SIZE (PosLookupList, 2);
 
 /*
  * GPOS
@@ -1592,8 +1595,9 @@ struct GPOS : GSUBGPOS
     OffsetTo<PosLookupList> &list = CastR<OffsetTo<PosLookupList> > (lookupList);
     return list.sanitize (context, this);
   }
+  public:
+  DEFINE_SIZE_STATIC (10);
 };
-ASSERT_SIZE (GPOS, 10);
 
 
 /* Out-of-class implementation for methods recursing */
diff --git a/src/hb-ot-layout-gsub-private.hh b/src/hb-ot-layout-gsub-private.hh
index 5585409..4a464b6 100644
--- a/src/hb-ot-layout-gsub-private.hh
+++ b/src/hb-ot-layout-gsub-private.hh
@@ -71,8 +71,9 @@ struct SingleSubstFormat1
 					 * beginning of Substitution table */
   SHORT		deltaGlyphID;		/* Add to original GlyphID to get
 					 * substitute GlyphID */
+  public:
+  DEFINE_SIZE_STATIC (6);
 };
-ASSERT_SIZE (SingleSubstFormat1, 6);
 
 struct SingleSubstFormat2
 {
@@ -115,8 +116,9 @@ struct SingleSubstFormat2
   ArrayOf<GlyphID>
 		substitute;		/* Array of substitute
 					 * GlyphIDs--ordered by Coverage Index */
+  public:
+  DEFINE_SIZE_STATIC (6);
 };
-ASSERT_SIZE (SingleSubstFormat2, 6);
 
 struct SingleSubst
 {
@@ -192,8 +194,9 @@ struct Sequence
   private:
   ArrayOf<GlyphID>
 		substitute;		/* String of GlyphIDs to substitute */
+  public:
+  DEFINE_SIZE_STATIC (2);
 };
-ASSERT_SIZE (Sequence, 2);
 
 struct MultipleSubstFormat1
 {
@@ -226,8 +229,9 @@ struct MultipleSubstFormat1
   OffsetArrayOf<Sequence>
 		sequence;		/* Array of Sequence tables
 					 * ordered by Coverage Index */
+  public:
+  DEFINE_SIZE_STATIC (6);
 };
-ASSERT_SIZE (MultipleSubstFormat1, 6);
 
 struct MultipleSubst
 {
@@ -263,7 +267,6 @@ struct MultipleSubst
 
 typedef ArrayOf<GlyphID> AlternateSet;	/* Array of alternate GlyphIDs--in
 					 * arbitrary order */
-ASSERT_SIZE (AlternateSet, 2);
 
 struct AlternateSubstFormat1
 {
@@ -322,8 +325,9 @@ struct AlternateSubstFormat1
   OffsetArrayOf<AlternateSet>
 		alternateSet;		/* Array of AlternateSet tables
 					 * ordered by Coverage Index */
+  public:
+  DEFINE_SIZE_STATIC (6);
 };
-ASSERT_SIZE (AlternateSubstFormat1, 6);
 
 struct AlternateSubst
 {
@@ -438,8 +442,9 @@ struct Ligature
 		component;		/* Array of component GlyphIDs--start
 					 * with the second  component--ordered
 					 * in writing direction */
+  public:
+  DEFINE_SIZE_STATIC (4);
 };
-ASSERT_SIZE (Ligature, 4);
 
 struct LigatureSet
 {
@@ -470,8 +475,9 @@ struct LigatureSet
   OffsetArrayOf<Ligature>
 		ligature;		/* Array LigatureSet tables
 					 * ordered by preference */
+  public:
+  DEFINE_SIZE_STATIC (2);
 };
-ASSERT_SIZE (LigatureSet, 2);
 
 struct LigatureSubstFormat1
 {
@@ -507,8 +513,9 @@ struct LigatureSubstFormat1
   OffsetArrayOf<LigatureSet>
 		ligatureSet;		/* Array LigatureSet tables
 					 * ordered by Coverage Index */
+  public:
+  DEFINE_SIZE_STATIC (6);
 };
-ASSERT_SIZE (LigatureSubstFormat1, 6);
 
 struct LigatureSubst
 {
@@ -652,8 +659,9 @@ struct ReverseChainSingleSubstFormat1
   ArrayOf<GlyphID>
 		substituteX;		/* Array of substitute
 					 * GlyphIDs--ordered by Coverage Index */
+  public:
+  DEFINE_SIZE_STATIC (10);
 };
-ASSERT_SIZE (ReverseChainSingleSubstFormat1, 10);
 
 struct ReverseChainSingleSubst
 {
@@ -865,7 +873,6 @@ struct SubstLookup : Lookup
 };
 
 typedef OffsetListOf<SubstLookup> SubstLookupList;
-ASSERT_SIZE (SubstLookupList, 2);
 
 /*
  * GSUB
@@ -890,8 +897,9 @@ struct GSUB : GSUBGPOS
     OffsetTo<SubstLookupList> &list = CastR<OffsetTo<SubstLookupList> > (lookupList);
     return list.sanitize (context, this);
   }
+  public:
+  DEFINE_SIZE_STATIC (10);
 };
-ASSERT_SIZE (GSUB, 10);
 
 
 /* Out-of-class implementation for methods recursing */
diff --git a/src/hb-ot-layout-gsubgpos-private.hh b/src/hb-ot-layout-gsubgpos-private.hh
index 0b59748..86285d1 100644
--- a/src/hb-ot-layout-gsubgpos-private.hh
+++ b/src/hb-ot-layout-gsubgpos-private.hh
@@ -367,8 +367,9 @@ struct ContextFormat1
   OffsetArrayOf<RuleSet>
 		ruleSet;		/* Array of RuleSet tables
 					 * ordered by Coverage Index */
+  public:
+  DEFINE_SIZE_STATIC (6);
 };
-ASSERT_SIZE (ContextFormat1, 6);
 
 
 struct ContextFormat2
@@ -414,8 +415,9 @@ struct ContextFormat2
   OffsetArrayOf<RuleSet>
 		ruleSet;		/* Array of RuleSet tables
 					 * ordered by class */
+  public:
+  DEFINE_SIZE_STATIC (8);
 };
-ASSERT_SIZE (ContextFormat2, 8);
 
 
 struct ContextFormat3
@@ -590,8 +592,9 @@ struct ChainRule
   ArrayOf<LookupRecord>
 		lookupX;		/* Array of LookupRecords--in
 					 * design order) */
+  public:
+  DEFINE_SIZE_STATIC (8);
 };
-ASSERT_SIZE (ChainRule, 8);
 
 struct ChainRuleSet
 {
@@ -617,8 +620,9 @@ struct ChainRuleSet
   OffsetArrayOf<ChainRule>
 		rule;			/* Array of ChainRule tables
 					 * ordered by preference */
+  public:
+  DEFINE_SIZE_STATIC (2);
 };
-ASSERT_SIZE (ChainRuleSet, 2);
 
 struct ChainContextFormat1
 {
@@ -654,8 +658,9 @@ struct ChainContextFormat1
   OffsetArrayOf<ChainRuleSet>
 		ruleSet;		/* Array of ChainRuleSet tables
 					 * ordered by Coverage Index */
+  public:
+  DEFINE_SIZE_STATIC (6);
 };
-ASSERT_SIZE (ChainContextFormat1, 6);
 
 struct ChainContextFormat2
 {
@@ -716,8 +721,9 @@ struct ChainContextFormat2
   OffsetArrayOf<ChainRuleSet>
 		ruleSet;		/* Array of ChainRuleSet tables
 					 * ordered by class */
+  public:
+  DEFINE_SIZE_STATIC (12);
 };
-ASSERT_SIZE (ChainContextFormat2, 12);
 
 struct ChainContextFormat3
 {
@@ -777,8 +783,9 @@ struct ChainContextFormat3
   ArrayOf<LookupRecord>
 		lookupX;		/* Array of LookupRecords--in
 					 * design order) */
+  public:
+  DEFINE_SIZE_STATIC (10);
 };
-ASSERT_SIZE (ChainContextFormat3, 10);
 
 struct ChainContext
 {
@@ -835,8 +842,9 @@ struct ExtensionFormat1
 					 * extension subtable). */
   ULONG		extensionOffset;	/* Offset to the extension subtable,
 					 * of lookup type subtable. */
+  public:
+  DEFINE_SIZE_STATIC (8);
 };
-ASSERT_SIZE (ExtensionFormat1, 8);
 
 struct Extension
 {
@@ -929,8 +937,9 @@ struct GSUBGPOS
 		featureList; 	/* FeatureList table */
   OffsetTo<LookupList>
 		lookupList; 	/* LookupList table */
+  public:
+  DEFINE_SIZE_STATIC (10);
 };
-ASSERT_SIZE (GSUBGPOS, 10);
 
 
 #endif /* HB_OT_LAYOUT_GSUBGPOS_PRIVATE_HH */
diff --git a/src/hb-private.h b/src/hb-private.h
index 3f8515b..8a323de 100644
--- a/src/hb-private.h
+++ b/src/hb-private.h
@@ -83,8 +83,6 @@
 
 /* Misc */
 
-#define ASSERT_SIZE(_type, _size) ASSERT_STATIC (sizeof (_type) == (_size))
-
 
 #if defined(__GNUC__) && (__GNUC__ > 2) && defined(__OPTIMIZE__)
 #define _HB_BOOLEAN_EXPR(expr) \
commit 569da92bc6956f42d9b2d65c784e184fb6380efe
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Mon May 10 16:38:32 2010 -0400

    Cleanup ASSERT_SIZE_VAR

diff --git a/src/hb-open-file-private.hh b/src/hb-open-file-private.hh
index c531c29..53e947a 100644
--- a/src/hb-open-file-private.hh
+++ b/src/hb-open-file-private.hh
@@ -45,6 +45,7 @@ struct OpenTypeFontFile;
 struct OffsetTable;
 struct TTCHeader;
 
+
 typedef struct TableDirectory
 {
   inline bool sanitize (hb_sanitize_context_t *context) {
@@ -52,13 +53,13 @@ typedef struct TableDirectory
     return context->check_struct (this);
   }
 
-  DEFINE_SIZE_STATIC (16);
-
   Tag		tag;		/* 4-byte identifier. */
   CheckSum	checkSum;	/* CheckSum for this table. */
   ULONG		offset;		/* Offset from beginning of TrueType font
 				 * file. */
   ULONG		length;		/* Length of this table. */
+  public:
+  DEFINE_SIZE_STATIC (16);
 } OpenTypeTable;
 
 typedef struct OffsetTable
@@ -110,8 +111,10 @@ typedef struct OffsetTable
   USHORT	entrySelector;	/* Log2(maximum power of 2 <= numTables). */
   USHORT	rangeShift;	/* NumTables x 16-searchRange. */
   TableDirectory tableDir[VAR];	/* TableDirectory entries. numTables items */
+  public:
+  DEFINE_SIZE_VAR (12, TableDirectory);
 } OpenTypeFontFace;
-ASSERT_SIZE_VAR (OffsetTable, 12, TableDirectory);
+
 
 /*
  * TrueType Collections
diff --git a/src/hb-open-type-private.hh b/src/hb-open-type-private.hh
index c4f2709..aab85fd 100644
--- a/src/hb-open-type-private.hh
+++ b/src/hb-open-type-private.hh
@@ -101,7 +101,7 @@ inline Type& StructAfter(TObject &X)
   { ASSERT_STATIC (sizeof (*this) == (size) + VAR0 * sizeof (_var_type)); } \
   static const unsigned int min_size = (size)
 
-#define DEFINE_SIZE_VAR2(_type, size, _var_type1, _var_type2) \
+#define DEFINE_SIZE_VAR2(size, _var_type1, _var_type2) \
   inline void _size_assertion (void) const \
   { ASSERT_STATIC (sizeof (*this) == (size) + VAR0 * sizeof (_var_type1) + VAR0 * sizeof (_var_type2)); } \
   static const unsigned int min_size = (size)
@@ -379,8 +379,10 @@ struct IntType
     TRACE_SANITIZE ();
     return context->check_struct (this);
   }
+  private:
+  BEInt<Type, sizeof (Type)> v;
+  public:
   DEFINE_SIZE_STATIC (sizeof (Type));
-  private: BEInt<Type, sizeof (Type)> v;
 };
 
 typedef IntType<uint16_t> USHORT;	/* 16-bit unsigned integer. */
diff --git a/src/hb-ot-layout-common-private.hh b/src/hb-ot-layout-common-private.hh
index d73a21a..7215415 100644
--- a/src/hb-ot-layout-common-private.hh
+++ b/src/hb-ot-layout-common-private.hh
@@ -57,12 +57,12 @@ struct Record
 	&& offset.sanitize (context, base);
   }
 
-  DEFINE_SIZE_STATIC (6);
-
   Tag		tag;		/* 4-byte Tag identifier */
   OffsetTo<Type>
 		offset;		/* Offset from beginning of object holding
 				 * the Record */
+  public:
+  DEFINE_SIZE_STATIC (6);
 };
 
 template <typename Type>
@@ -170,14 +170,14 @@ struct LangSys
 	&& featureIndex.sanitize (context);
   }
 
-  DEFINE_SIZE_STATIC (6);
-
   Offset	lookupOrder;	/* = Null (reserved for an offset to a
 				 * reordering table) */
   USHORT	reqFeatureIndex;/* Index of a feature required for this
 				 * language system--if no required features
 				 * = 0xFFFF */
   IndexArray	featureIndex;	/* Array of indices into the FeatureList */
+  public:
+  DEFINE_SIZE_STATIC (6);
 };
 DEFINE_NULL_DATA (LangSys, "\0\0\xFF\xFF");
 
@@ -305,8 +305,9 @@ struct Lookup
   USHORT	markFilteringSetX[VAR];	/* Index (base 0) into GDEF mark glyph sets
 					 * structure. This field is only present if bit
 					 * UseMarkFilteringSet of lookup flags is set. */
+  public:
+  DEFINE_SIZE_VAR (6, USHORT);
 };
-ASSERT_SIZE_VAR (Lookup, 6, USHORT);
 
 typedef OffsetListOf<Lookup> LookupList;
 ASSERT_SIZE (LookupList, 2);
@@ -365,13 +366,13 @@ struct CoverageRangeRecord
     return context->check_struct (this);
   }
 
-  DEFINE_SIZE_STATIC (6);
-
   private:
   GlyphID	start;			/* First GlyphID in the range */
   GlyphID	end;			/* Last GlyphID in the range */
   USHORT	startCoverageIndex;	/* Coverage Index of first GlyphID in
 					 * range */
+  public:
+  DEFINE_SIZE_STATIC (6);
 };
 DEFINE_NULL_DATA (CoverageRangeRecord, "\000\001");
 
@@ -486,12 +487,12 @@ struct ClassRangeRecord
     return context->check_struct (this);
   }
 
-  DEFINE_SIZE_STATIC (6);
-
   private:
   GlyphID	start;		/* First GlyphID in the range */
   GlyphID	end;		/* Last GlyphID in the range */
   USHORT	classValue;	/* Applied to all glyphs in the range */
+  public:
+  DEFINE_SIZE_STATIC (6);
 };
 DEFINE_NULL_DATA (ClassRangeRecord, "\000\001");
 
@@ -610,8 +611,9 @@ struct Device
 					 * 3	Signed 8-bit value, 2 values per uint16
 					 */
   USHORT	deltaValue[VAR];	/* Array of compressed data */
+  public:
+  DEFINE_SIZE_VAR (6, USHORT);
 };
-ASSERT_SIZE_VAR (Device, 6, USHORT);
 
 
 #endif /* HB_OT_LAYOUT_COMMON_PRIVATE_HH */
diff --git a/src/hb-ot-layout-gdef-private.hh b/src/hb-ot-layout-gdef-private.hh
index 652561c..e6cf7b8 100644
--- a/src/hb-ot-layout-gdef-private.hh
+++ b/src/hb-ot-layout-gdef-private.hh
@@ -383,8 +383,9 @@ struct GDEF
 					 * definitions--from beginning of GDEF
 					 * header (may be NULL).  Introduced
 					 * in version 00010002. */
+  public:
+  DEFINE_SIZE_VAR (12, OffsetTo<MarkGlyphSets>);
 };
-ASSERT_SIZE_VAR (GDEF, 12, OffsetTo<MarkGlyphSets>);
 
 
 #endif /* HB_OT_LAYOUT_GDEF_PRIVATE_HH */
diff --git a/src/hb-ot-layout-gpos-private.hh b/src/hb-ot-layout-gpos-private.hh
index 8bf2507..eb53ac1 100644
--- a/src/hb-ot-layout-gpos-private.hh
+++ b/src/hb-ot-layout-gpos-private.hh
@@ -41,7 +41,6 @@
 typedef USHORT Value;
 
 typedef Value ValueRecord[VAR0];
-ASSERT_SIZE_VAR (ValueRecord, 0, Value);
 
 struct ValueFormat : USHORT
 {
@@ -360,8 +359,9 @@ struct AnchorMatrix
   OffsetTo<Anchor>
 		matrix[VAR];		/* Matrix of offsets to Anchor tables--
 					 * from beginning of AnchorMatrix table */
+  public:
+  DEFINE_SIZE_VAR (2, OffsetTo<Anchor>);
 };
-ASSERT_SIZE_VAR (AnchorMatrix, 2, OffsetTo<Anchor>);
 
 
 struct MarkRecord
@@ -374,13 +374,13 @@ struct MarkRecord
 	&& markAnchor.sanitize (context, base);
   }
 
-  DEFINE_SIZE_STATIC (4);
-
   private:
   USHORT	klass;			/* Class defined for this mark */
   OffsetTo<Anchor>
 		markAnchor;		/* Offset to Anchor table--from
 					 * beginning of MarkArray table */
+  public:
+  DEFINE_SIZE_STATIC (4);
 };
 
 struct MarkArray
@@ -462,8 +462,9 @@ struct SinglePosFormat1
   ValueRecord	values;			/* Defines positioning
 					 * value(s)--applied to all glyphs in
 					 * the Coverage table */
+  public:
+  DEFINE_SIZE_VAR (6, ValueRecord);
 };
-ASSERT_SIZE_VAR (SinglePosFormat1, 6, ValueRecord);
 
 struct SinglePosFormat2
 {
@@ -505,8 +506,9 @@ struct SinglePosFormat2
   USHORT	valueCount;		/* Number of ValueRecords */
   ValueRecord	values;			/* Array of ValueRecords--positioning
 					 * values applied to glyphs */
+  public:
+  DEFINE_SIZE_VAR (8, ValueRecord);
 };
-ASSERT_SIZE_VAR (SinglePosFormat2, 8, ValueRecord);
 
 struct SinglePos
 {
@@ -552,8 +554,9 @@ struct PairValueRecord
 					 * Coverage table */
   ValueRecord	values;			/* Positioning data for the first glyph
 					 * followed by for second glyph */
+  public:
+  DEFINE_SIZE_VAR (2, ValueRecord);
 };
-ASSERT_SIZE_VAR (PairValueRecord, 2, ValueRecord);
 
 struct PairSet
 {
@@ -572,8 +575,9 @@ struct PairSet
   PairValueRecord
 		array[VAR];		/* Array of PairValueRecords--ordered
 					 * by GlyphID of the second glyph */
+  public:
+  DEFINE_SIZE_VAR (2, PairValueRecord);
 };
-ASSERT_SIZE_VAR (PairSet, 2, PairValueRecord);
 
 struct PairPosFormat1
 {
@@ -755,8 +759,9 @@ struct PairPosFormat2
   ValueRecord	values;			/* Matrix of value pairs:
 					 * class1-major, class2-minor,
 					 * Each entry has value1 and value2 */
+  public:
+  DEFINE_SIZE_VAR (16, ValueRecord);
 };
-ASSERT_SIZE_VAR (PairPosFormat2, 16, ValueRecord);
 
 struct PairPos
 {
@@ -794,14 +799,15 @@ struct PairPos
 
 struct EntryExitRecord
 {
+  friend struct CursivePosFormat1;
+
   inline bool sanitize (hb_sanitize_context_t *context, void *base) {
     TRACE_SANITIZE ();
     return entryAnchor.sanitize (context, base)
 	&& exitAnchor.sanitize (context, base);
   }
 
-  DEFINE_SIZE_STATIC (4);
-
+  private:
   OffsetTo<Anchor>
 		entryAnchor;		/* Offset to EntryAnchor table--from
 					 * beginning of CursivePos
@@ -810,6 +816,8 @@ struct EntryExitRecord
 		exitAnchor;		/* Offset to ExitAnchor table--from
 					 * beginning of CursivePos
 					 * subtable--may be NULL */
+  public:
+  DEFINE_SIZE_STATIC (4);
 };
 
 struct CursivePosFormat1
diff --git a/src/hb-ot-layout-gsubgpos-private.hh b/src/hb-ot-layout-gsubgpos-private.hh
index f389b19..0b59748 100644
--- a/src/hb-ot-layout-gsubgpos-private.hh
+++ b/src/hb-ot-layout-gsubgpos-private.hh
@@ -177,12 +177,12 @@ struct LookupRecord
     return context->check_struct (this);
   }
 
-  DEFINE_SIZE_STATIC (4);
-
   USHORT	sequenceIndex;		/* Index into current glyph
 					 * sequence--first glyph = 0 */
   USHORT	lookupListIndex;	/* Lookup to apply to that
 					 * position--zero--based */
+  public:
+  DEFINE_SIZE_STATIC (4);
 };
 
 static inline bool apply_lookup (hb_apply_context_t *context,
@@ -302,8 +302,9 @@ struct Rule
 					 * second glyph */
   LookupRecord	lookupRecordX[VAR];	/* Array of LookupRecords--in
 					 * design order */
+  public:
+  DEFINE_SIZE_VAR2 (4, USHORT, LookupRecord);
 };
-ASSERT_SIZE_VAR2 (Rule, 4, USHORT, LookupRecord);
 
 struct RuleSet
 {
@@ -461,8 +462,9 @@ struct ContextFormat3
 					 * table in glyph sequence order */
   LookupRecord	lookupRecordX[VAR];	/* Array of LookupRecords--in
 					 * design order */
+  public:
+  DEFINE_SIZE_VAR2 (6, OffsetTo<Coverage>, LookupRecord);
 };
-ASSERT_SIZE_VAR2 (ContextFormat3, 6, OffsetTo<Coverage>, LookupRecord);
 
 struct Context
 {
diff --git a/src/hb-private.h b/src/hb-private.h
index 3f9ec9d..3f8515b 100644
--- a/src/hb-private.h
+++ b/src/hb-private.h
@@ -85,14 +85,6 @@
 
 #define ASSERT_SIZE(_type, _size) ASSERT_STATIC (sizeof (_type) == (_size))
 
-/* Size signifying variable-sized array */
-#define VAR 1
-
-#define VAR0 (VAR+0)
-#define ASSERT_SIZE_VAR(_type, _size, _var_type) \
-	ASSERT_STATIC (sizeof (_type) == (_size) + VAR0 * sizeof (_var_type))
-#define ASSERT_SIZE_VAR2(_type, _size, _var_type1, _var_type2) \
-	ASSERT_STATIC (sizeof (_type) == (_size) + VAR0 * sizeof (_var_type1) + VAR0 * sizeof (_var_type2))
 
 #if defined(__GNUC__) && (__GNUC__ > 2) && defined(__OPTIMIZE__)
 #define _HB_BOOLEAN_EXPR(expr) \
commit 99bf03459ff2f00cf3fb7fa3c8b8336ec9fcca56
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Thu May 6 19:37:32 2010 -0400

    Whitespace

diff --git a/src/hb-ot-layout-gpos-private.hh b/src/hb-ot-layout-gpos-private.hh
index ab72731..8bf2507 100644
--- a/src/hb-ot-layout-gpos-private.hh
+++ b/src/hb-ot-layout-gpos-private.hh
@@ -375,6 +375,7 @@ struct MarkRecord
   }
 
   DEFINE_SIZE_STATIC (4);
+
   private:
   USHORT	klass;			/* Class defined for this mark */
   OffsetTo<Anchor>
commit 65f46b00333e20ab8a52a4b350747507541ec1db
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Thu May 6 19:35:19 2010 -0400

    Simplify DEFINE_NULL_DATA
    
    Using ::min_size.

diff --git a/src/hb-open-type-private.hh b/src/hb-open-type-private.hh
index b0daf41..c4f2709 100644
--- a/src/hb-open-type-private.hh
+++ b/src/hb-open-type-private.hh
@@ -123,8 +123,8 @@ static inline const Type& Null () {
 }
 
 /* Specializaiton for arbitrary-content arbitrary-sized Null objects. */
-#define DEFINE_NULL_DATA(Type, size, data) \
-static const char _Null##Type[size + 1] = data; /* +1 is for nul-termination in data */ \
+#define DEFINE_NULL_DATA(Type, data) \
+static const char _Null##Type[Type::min_size + 1] = data; /* +1 is for nul-termination in data */ \
 template <> \
 inline const Type& Null<Type> () { \
   return *CastP<Type> (_Null##Type); \
@@ -397,7 +397,7 @@ struct Tag : ULONG
   inline operator char* (void) { return CharP(this); }
 };
 ASSERT_SIZE (Tag, 4);
-DEFINE_NULL_DATA (Tag, 4, "    ");
+DEFINE_NULL_DATA (Tag, "    ");
 
 /* Glyph index number, same as uint16 (length = 16 bits) */
 typedef USHORT GlyphID;
diff --git a/src/hb-ot-layout-common-private.hh b/src/hb-ot-layout-common-private.hh
index 97002cb..d73a21a 100644
--- a/src/hb-ot-layout-common-private.hh
+++ b/src/hb-ot-layout-common-private.hh
@@ -170,6 +170,8 @@ struct LangSys
 	&& featureIndex.sanitize (context);
   }
 
+  DEFINE_SIZE_STATIC (6);
+
   Offset	lookupOrder;	/* = Null (reserved for an offset to a
 				 * reordering table) */
   USHORT	reqFeatureIndex;/* Index of a feature required for this
@@ -177,8 +179,7 @@ struct LangSys
 				 * = 0xFFFF */
   IndexArray	featureIndex;	/* Array of indices into the FeatureList */
 };
-ASSERT_SIZE (LangSys, 6);
-DEFINE_NULL_DATA (LangSys, 6, "\0\0\xFF\xFF");
+DEFINE_NULL_DATA (LangSys, "\0\0\xFF\xFF");
 
 
 struct Script
@@ -372,7 +373,7 @@ struct CoverageRangeRecord
   USHORT	startCoverageIndex;	/* Coverage Index of first GlyphID in
 					 * range */
 };
-DEFINE_NULL_DATA (CoverageRangeRecord, 6, "\000\001");
+DEFINE_NULL_DATA (CoverageRangeRecord, "\000\001");
 
 struct CoverageFormat2
 {
@@ -492,7 +493,7 @@ struct ClassRangeRecord
   GlyphID	end;		/* Last GlyphID in the range */
   USHORT	classValue;	/* Applied to all glyphs in the range */
 };
-DEFINE_NULL_DATA (ClassRangeRecord, 6, "\000\001");
+DEFINE_NULL_DATA (ClassRangeRecord, "\000\001");
 
 struct ClassDefFormat2
 {
commit e45d3f86f9a5f3d29ca35a282de7f98e702878f9
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Thu May 6 19:33:31 2010 -0400

    Start cleaning up get_size()
    
    So we know when the size is static and when dynamic.

diff --git a/src/hb-open-file-private.hh b/src/hb-open-file-private.hh
index cf75df9..c531c29 100644
--- a/src/hb-open-file-private.hh
+++ b/src/hb-open-file-private.hh
@@ -47,20 +47,19 @@ struct TTCHeader;
 
 typedef struct TableDirectory
 {
-  static inline unsigned int get_size () { return sizeof (TableDirectory); }
-
   inline bool sanitize (hb_sanitize_context_t *context) {
     TRACE_SANITIZE ();
     return context->check_struct (this);
   }
 
+  DEFINE_SIZE_STATIC (16);
+
   Tag		tag;		/* 4-byte identifier. */
   CheckSum	checkSum;	/* CheckSum for this table. */
   ULONG		offset;		/* Offset from beginning of TrueType font
 				 * file. */
   ULONG		length;		/* Length of this table. */
 } OpenTypeTable;
-ASSERT_SIZE (TableDirectory, 16);
 
 typedef struct OffsetTable
 {
@@ -101,7 +100,7 @@ typedef struct OffsetTable
   inline bool sanitize (hb_sanitize_context_t *context) {
     TRACE_SANITIZE ();
     return context->check_struct (this)
-	&& context->check_array (tableDir, TableDirectory::get_size (), numTables);
+	&& context->check_array (tableDir, TableDirectory::static_size, numTables);
   }
 
   private:
diff --git a/src/hb-open-type-private.hh b/src/hb-open-type-private.hh
index 82242e9..b0daf41 100644
--- a/src/hb-open-type-private.hh
+++ b/src/hb-open-type-private.hh
@@ -86,6 +86,29 @@ inline Type& StructAfter(TObject &X)
 
 
 /*
+ * Size checking
+ */
+
+#define DEFINE_SIZE_STATIC(size) \
+  inline void _size_assertion (void) const \
+  { ASSERT_STATIC (sizeof (*this) == (size)); } \
+  static inline unsigned int get_size (void) { return (size); } \
+  static const unsigned int static_size = (size); \
+  static const unsigned int min_size = (size)
+
+#define DEFINE_SIZE_VAR(size, _var_type) \
+  inline void _size_assertion (void) const \
+  { ASSERT_STATIC (sizeof (*this) == (size) + VAR0 * sizeof (_var_type)); } \
+  static const unsigned int min_size = (size)
+
+#define DEFINE_SIZE_VAR2(_type, size, _var_type1, _var_type2) \
+  inline void _size_assertion (void) const \
+  { ASSERT_STATIC (sizeof (*this) == (size) + VAR0 * sizeof (_var_type1) + VAR0 * sizeof (_var_type2)); } \
+  static const unsigned int min_size = (size)
+
+
+
+/*
  * Null objects
  */
 
@@ -348,7 +371,6 @@ class BEInt<Type, 4>
 template <typename Type>
 struct IntType
 {
-  static inline unsigned int get_size () { return sizeof (Type); }
   inline void set (Type i) { v = i; }
   inline operator Type(void) const { return v; }
   inline bool operator == (const IntType<Type> &o) const { return v == o.v; }
@@ -357,6 +379,7 @@ struct IntType
     TRACE_SANITIZE ();
     return context->check_struct (this);
   }
+  DEFINE_SIZE_STATIC (sizeof (Type));
   private: BEInt<Type, sizeof (Type)> v;
 };
 
@@ -365,11 +388,6 @@ typedef IntType<int16_t>  SHORT;	/* 16-bit signed integer. */
 typedef IntType<uint32_t> ULONG;	/* 32-bit unsigned integer. */
 typedef IntType<int32_t>  LONG;		/* 32-bit signed integer. */
 
-ASSERT_SIZE (USHORT, 2);
-ASSERT_SIZE (SHORT, 2);
-ASSERT_SIZE (ULONG, 4);
-ASSERT_SIZE (LONG, 4);
-
 /* Array of four uint8s (length = 32 bits) used to identify a script, language
  * system, feature, or baseline */
 struct Tag : ULONG
@@ -397,7 +415,7 @@ struct CheckSum : ULONG
   static uint32_t CalcTableChecksum (ULONG *Table, uint32_t Length)
   {
     uint32_t Sum = 0L;
-    ULONG *EndPtr = Table+((Length+3) & ~3) / ULONG::get_size ();
+    ULONG *EndPtr = Table+((Length+3) & ~3) / ULONG::static_size;
 
     while (Table < EndPtr)
       Sum += *Table++;
@@ -463,7 +481,7 @@ struct GenericOffsetTo : OffsetType
   private:
   /* Set the offset to Null */
   inline bool neuter (hb_sanitize_context_t *context) {
-    if (context->can_edit (CharP(this), this->get_size ())) {
+    if (context->can_edit (CharP(this), this->static_size)) {
       this->set (0); /* 0 is Null offset */
       return true;
     }
@@ -508,7 +526,7 @@ struct GenericArrayOf
     return array()[i];
   }
   inline unsigned int get_size () const
-  { return len.get_size () + len * Type::get_size (); }
+  { return len.static_size + len * Type::static_size; }
 
   inline bool sanitize (hb_sanitize_context_t *context) {
     TRACE_SANITIZE ();
@@ -551,7 +569,7 @@ struct GenericArrayOf
   inline bool sanitize_shallow (hb_sanitize_context_t *context) {
     TRACE_SANITIZE ();
     return context->check_struct (this)
-	&& context->check_array (this, Type::get_size (), len);
+	&& context->check_array (this, Type::static_size, len);
   }
 
   public:
@@ -615,11 +633,11 @@ struct HeadlessArrayOf
     return array()[i-1];
   }
   inline unsigned int get_size () const
-  { return len.get_size () + (len ? len - 1 : 0) * Type::get_size (); }
+  { return len.static_size + (len ? len - 1 : 0) * Type::static_size; }
 
   inline bool sanitize_shallow (hb_sanitize_context_t *context) {
     return context->check_struct (this)
-	&& context->check_array (this, Type::get_size (), len);
+	&& context->check_array (this, Type::static_size, len);
   }
 
   inline bool sanitize (hb_sanitize_context_t *context) {
diff --git a/src/hb-ot-layout-common-private.hh b/src/hb-ot-layout-common-private.hh
index 09a6930..97002cb 100644
--- a/src/hb-ot-layout-common-private.hh
+++ b/src/hb-ot-layout-common-private.hh
@@ -51,14 +51,14 @@
 template <typename Type>
 struct Record
 {
-  static inline unsigned int get_size () { return sizeof (Record<Type>); }
-
   inline bool sanitize (hb_sanitize_context_t *context, void *base) {
     TRACE_SANITIZE ();
     return context->check_struct (this)
 	&& offset.sanitize (context, base);
   }
 
+  DEFINE_SIZE_STATIC (6);
+
   Tag		tag;		/* 4-byte Tag identifier */
   OffsetTo<Type>
 		offset;		/* Offset from beginning of object holding
@@ -350,8 +350,6 @@ struct CoverageRangeRecord
 {
   friend struct CoverageFormat2;
 
-  static inline unsigned int get_size () { return sizeof (CoverageRangeRecord); }
-
   private:
   inline unsigned int get_coverage (hb_codepoint_t glyph_id) const
   {
@@ -366,13 +364,14 @@ struct CoverageRangeRecord
     return context->check_struct (this);
   }
 
+  DEFINE_SIZE_STATIC (6);
+
   private:
   GlyphID	start;			/* First GlyphID in the range */
   GlyphID	end;			/* Last GlyphID in the range */
   USHORT	startCoverageIndex;	/* Coverage Index of first GlyphID in
 					 * range */
 };
-ASSERT_SIZE (CoverageRangeRecord, 6);
 DEFINE_NULL_DATA (CoverageRangeRecord, 6, "\000\001");
 
 struct CoverageFormat2
@@ -472,8 +471,6 @@ struct ClassRangeRecord
 {
   friend struct ClassDefFormat2;
 
-  static inline unsigned int get_size () { return sizeof (ClassRangeRecord); }
-
   private:
   inline hb_ot_layout_class_t get_class (hb_codepoint_t glyph_id) const
   {
@@ -488,12 +485,13 @@ struct ClassRangeRecord
     return context->check_struct (this);
   }
 
+  DEFINE_SIZE_STATIC (6);
+
   private:
   GlyphID	start;		/* First GlyphID in the range */
   GlyphID	end;		/* Last GlyphID in the range */
   USHORT	classValue;	/* Applied to all glyphs in the range */
 };
-ASSERT_SIZE (ClassRangeRecord, 6);
 DEFINE_NULL_DATA (ClassRangeRecord, 6, "\000\001");
 
 struct ClassDefFormat2
diff --git a/src/hb-ot-layout-gpos-private.hh b/src/hb-ot-layout-gpos-private.hh
index 60ee17e..ab72731 100644
--- a/src/hb-ot-layout-gpos-private.hh
+++ b/src/hb-ot-layout-gpos-private.hh
@@ -90,7 +90,7 @@ struct ValueFormat : USHORT
   inline unsigned int get_len () const
   { return _hb_popcount32 ((unsigned int) *this); }
   inline unsigned int get_size () const
-  { return get_len () * Value::get_size (); }
+  { return get_len () * Value::static_size; }
 
   void apply_value (hb_ot_layout_context_t       *layout,
 		    const char                   *base,
@@ -349,7 +349,7 @@ struct AnchorMatrix
     if (!context->check_struct (this)) return false;
     if (unlikely (cols >= ((unsigned int) -1) / rows)) return false;
     unsigned int count = rows * cols;
-    if (!context->check_array (matrix, matrix[0].get_size (), count)) return false;
+    if (!context->check_array (matrix, matrix[0].static_size, count)) return false;
     for (unsigned int i = 0; i < count; i++)
       if (!matrix[i].sanitize (context, this)) return false;
     return true;
@@ -368,21 +368,19 @@ struct MarkRecord
 {
   friend struct MarkArray;
 
-  static inline unsigned int get_size () { return sizeof (MarkRecord); }
-
   inline bool sanitize (hb_sanitize_context_t *context, void *base) {
     TRACE_SANITIZE ();
     return context->check_struct (this)
 	&& markAnchor.sanitize (context, base);
   }
 
+  DEFINE_SIZE_STATIC (4);
   private:
   USHORT	klass;			/* Class defined for this mark */
   OffsetTo<Anchor>
 		markAnchor;		/* Offset to Anchor table--from
 					 * beginning of MarkArray table */
 };
-ASSERT_SIZE (MarkRecord, 4);
 
 struct MarkArray
 {
@@ -565,7 +563,7 @@ struct PairSet
     TRACE_SANITIZE ();
     if (!context->check_struct (this)) return false;
     unsigned int count = (1 + format_len) * len;
-    return context->check_array (array, USHORT::get_size (), count);
+    return context->check_array (array, USHORT::static_size, count);
   }
 
   private:
@@ -602,7 +600,7 @@ struct PairPosFormat1
 
     unsigned int len1 = valueFormat1.get_len ();
     unsigned int len2 = valueFormat2.get_len ();
-    unsigned int record_size = USHORT::get_size () * (1 + len1 + len2);
+    unsigned int record_size = USHORT::static_size * (1 + len1 + len2);
 
     const PairSet &pair_set = this+pairSet[index];
     unsigned int count = pair_set.len;
@@ -795,14 +793,14 @@ struct PairPos
 
 struct EntryExitRecord
 {
-  static inline unsigned int get_size () { return sizeof (EntryExitRecord); }
-
   inline bool sanitize (hb_sanitize_context_t *context, void *base) {
     TRACE_SANITIZE ();
     return entryAnchor.sanitize (context, base)
 	&& exitAnchor.sanitize (context, base);
   }
 
+  DEFINE_SIZE_STATIC (4);
+
   OffsetTo<Anchor>
 		entryAnchor;		/* Offset to EntryAnchor table--from
 					 * beginning of CursivePos
@@ -812,7 +810,6 @@ struct EntryExitRecord
 					 * beginning of CursivePos
 					 * subtable--may be NULL */
 };
-ASSERT_SIZE (EntryExitRecord, 4);
 
 struct CursivePosFormat1
 {
diff --git a/src/hb-ot-layout-gsubgpos-private.hh b/src/hb-ot-layout-gsubgpos-private.hh
index 7777b9c..f389b19 100644
--- a/src/hb-ot-layout-gsubgpos-private.hh
+++ b/src/hb-ot-layout-gsubgpos-private.hh
@@ -172,19 +172,18 @@ static inline bool match_lookahead (hb_apply_context_t *context,
 
 struct LookupRecord
 {
-  static inline unsigned int get_size () { return sizeof (LookupRecord); }
-
   inline bool sanitize (hb_sanitize_context_t *context) {
     TRACE_SANITIZE ();
     return context->check_struct (this);
   }
 
+  DEFINE_SIZE_STATIC (4);
+
   USHORT	sequenceIndex;		/* Index into current glyph
 					 * sequence--first glyph = 0 */
   USHORT	lookupListIndex;	/* Lookup to apply to that
 					 * position--zero--based */
 };
-ASSERT_SIZE (LookupRecord, 4);
 
 static inline bool apply_lookup (hb_apply_context_t *context,
 				 unsigned int count, /* Including the first glyph */
@@ -277,7 +276,7 @@ struct Rule
   inline bool apply (hb_apply_context_t *context, ContextLookupContext &lookup_context) const
   {
     TRACE_APPLY ();
-    const LookupRecord *lookupRecord = &StructAtOffset<LookupRecord> (input, input[0].get_size () * (inputCount ? inputCount - 1 : 0));
+    const LookupRecord *lookupRecord = &StructAtOffset<LookupRecord> (input, input[0].static_size * (inputCount ? inputCount - 1 : 0));
     return context_lookup (context,
 			   inputCount, input,
 			   lookupCount, lookupRecord,
@@ -290,8 +289,8 @@ struct Rule
     return inputCount.sanitize (context)
 	&& lookupCount.sanitize (context)
 	&& context->check_range (input,
-				 input[0].get_size () * inputCount
-				 + lookupRecordX[0].get_size () * lookupCount);
+				 input[0].static_size * inputCount
+				 + lookupRecordX[0].static_size * lookupCount);
   }
 
   private:
@@ -430,7 +429,7 @@ struct ContextFormat3
     if (likely (index == NOT_COVERED))
       return false;
 
-    const LookupRecord *lookupRecord = &StructAtOffset<LookupRecord> (coverage, coverage[0].get_size () * glyphCount);
+    const LookupRecord *lookupRecord = &StructAtOffset<LookupRecord> (coverage, coverage[0].static_size * glyphCount);
     struct ContextLookupContext lookup_context = {
       {match_coverage, apply_func},
        CharP(this)
@@ -445,11 +444,11 @@ struct ContextFormat3
     TRACE_SANITIZE ();
     if (!context->check_struct (this)) return false;
     unsigned int count = glyphCount;
-    if (!context->check_array (coverage, OffsetTo<Coverage>::get_size (), count)) return false;
+    if (!context->check_array (coverage, coverage[0].static_size, count)) return false;
     for (unsigned int i = 0; i < count; i++)
       if (!coverage[i].sanitize (context, this)) return false;
-    LookupRecord *lookupRecord = &StructAtOffset<LookupRecord> (coverage, OffsetTo<Coverage>::get_size () * count);
-    return context->check_array (lookupRecord, LookupRecord::get_size (), lookupCount);
+    LookupRecord *lookupRecord = &StructAtOffset<LookupRecord> (coverage, coverage[0].static_size * count);
+    return context->check_array (lookupRecord, lookupRecord[0].static_size, lookupCount);
   }
 
   private:



More information about the HarfBuzz mailing list