[pango/harfbuzz-ng] [HB] Check for GDEF/GSUB/GPOS versions



commit d36c93ee99362940c929e20282d2fab440265711
Author: Behdad Esfahbod <behdad behdad org>
Date:   Sun May 24 00:50:27 2009 -0400

    [HB] Check for GDEF/GSUB/GPOS versions
---
 pango/opentype/hb-ot-layout-gdef-private.h     |    3 +--
 pango/opentype/hb-ot-layout-gpos-private.h     |    3 +--
 pango/opentype/hb-ot-layout-gsub-private.h     |    3 +--
 pango/opentype/hb-ot-layout-gsubgpos-private.h |    5 ++---
 pango/opentype/hb-ot-layout-open-private.h     |   11 ++++++++++-
 5 files changed, 15 insertions(+), 10 deletions(-)

diff --git a/pango/opentype/hb-ot-layout-gdef-private.h b/pango/opentype/hb-ot-layout-gdef-private.h
index b41c327..c9c92d6 100644
--- a/pango/opentype/hb-ot-layout-gdef-private.h
+++ b/pango/opentype/hb-ot-layout-gdef-private.h
@@ -195,8 +195,7 @@ struct GDEF
     ComponentGlyph	= 4,
   };
 
-  STATIC_DEFINE_GET_FOR_DATA (GDEF);
-  /* XXX check version here? */
+  STATIC_DEFINE_GET_FOR_DATA_CHECK_MAJOR_VERSION (GDEF, 1);
 
   inline bool has_glyph_classes () const { return glyphClassDef != 0; }
   inline hb_ot_layout_class_t get_glyph_class (hb_codepoint_t glyph) const { return (this+glyphClassDef).get_class (glyph); }
diff --git a/pango/opentype/hb-ot-layout-gpos-private.h b/pango/opentype/hb-ot-layout-gpos-private.h
index 9519678..275a5e8 100644
--- a/pango/opentype/hb-ot-layout-gpos-private.h
+++ b/pango/opentype/hb-ot-layout-gpos-private.h
@@ -1313,8 +1313,7 @@ struct GPOS : GSUBGPOS
 {
   static const hb_tag_t Tag		= HB_TAG ('G','P','O','S');
 
-  STATIC_DEFINE_GET_FOR_DATA (GPOS);
-  /* XXX check version here? */
+  STATIC_DEFINE_GET_FOR_DATA_CHECK_MAJOR_VERSION (GPOS, 1);
 
   inline const PosLookup& get_lookup (unsigned int i) const
   {
diff --git a/pango/opentype/hb-ot-layout-gsub-private.h b/pango/opentype/hb-ot-layout-gsub-private.h
index 38a99a2..757947c 100644
--- a/pango/opentype/hb-ot-layout-gsub-private.h
+++ b/pango/opentype/hb-ot-layout-gsub-private.h
@@ -730,8 +730,7 @@ struct GSUB : GSUBGPOS
 {
   static const hb_tag_t Tag		= HB_TAG ('G','S','U','B');
 
-  STATIC_DEFINE_GET_FOR_DATA (GSUB);
-  /* XXX check version here? */
+  STATIC_DEFINE_GET_FOR_DATA_CHECK_MAJOR_VERSION (GSUB, 1);
 
   inline const SubstLookup& get_lookup (unsigned int i) const
   {
diff --git a/pango/opentype/hb-ot-layout-gsubgpos-private.h b/pango/opentype/hb-ot-layout-gsubgpos-private.h
index 6028351..2f7474a 100644
--- a/pango/opentype/hb-ot-layout-gsubgpos-private.h
+++ b/pango/opentype/hb-ot-layout-gsubgpos-private.h
@@ -747,8 +747,7 @@ struct GSUBGPOS
   static const hb_tag_t GSUBTag		= HB_TAG ('G','S','U','B');
   static const hb_tag_t GPOSTag		= HB_TAG ('G','P','O','S');
 
-  STATIC_DEFINE_GET_FOR_DATA (GSUBGPOS);
-  /* XXX check version here? */
+  STATIC_DEFINE_GET_FOR_DATA_CHECK_MAJOR_VERSION (GSUBGPOS, 1);
 
   DEFINE_TAG_LIST_INTERFACE (Script,  script );	/* get_script_count (), get_script (i), get_script_tag (i) */
   DEFINE_TAG_LIST_INTERFACE (Feature, feature);	/* get_feature_count(), get_feature(i), get_feature_tag(i) */
@@ -758,7 +757,7 @@ struct GSUBGPOS
   DEFINE_TAG_FIND_INTERFACE (Script,  script );	/* find_script_index (), get_script_by_tag (tag) */
   DEFINE_TAG_FIND_INTERFACE (Feature, feature);	/* find_feature_index(), get_feature_by_tag(tag) */
 
-  private:
+  protected:
   Fixed_Version	version;	/* Version of the GSUB/GPOS table--initially set
 				 * to 0x00010000 */
   OffsetTo<ScriptList>
diff --git a/pango/opentype/hb-ot-layout-open-private.h b/pango/opentype/hb-ot-layout-open-private.h
index 08ff152..6975251 100644
--- a/pango/opentype/hb-ot-layout-open-private.h
+++ b/pango/opentype/hb-ot-layout-open-private.h
@@ -172,7 +172,16 @@ struct Null <Type> \
   { \
     if (HB_UNLIKELY (data == NULL)) return Null(Type); \
     return (const Type&)*data; \
-  } \
+  }
+/* Like get_for_data(), but checks major version first. */
+#define STATIC_DEFINE_GET_FOR_DATA_CHECK_MAJOR_VERSION(Type, Major) \
+  static inline const Type& get_for_data (const char *data) \
+  { \
+    if (HB_UNLIKELY (data == NULL)) return Null(Type); \
+    const Type& t = (const Type&)*data; \
+    if (HB_UNLIKELY (t.version.major () != Major)) return Null(Type); \
+    return t; \
+  }
 
 
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]