Imported Upstream version 1.4.6
[platform/upstream/harfbuzz.git] / src / hb-ot-layout-gdef-table.hh
index 7a6c04d..552df0f 100644 (file)
@@ -74,7 +74,7 @@ struct AttachList
   inline bool sanitize (hb_sanitize_context_t *c) const
   {
     TRACE_SANITIZE (this);
-    return TRACE_RETURN (coverage.sanitize (c, this) && attachPoint.sanitize (c, this));
+    return_trace (coverage.sanitize (c, this) && attachPoint.sanitize (c, this));
   }
 
   protected:
@@ -97,7 +97,7 @@ struct CaretValueFormat1
   friend struct CaretValue;
 
   private:
-  inline hb_position_t get_caret_value (hb_font_t *font, hb_direction_t direction, hb_codepoint_t glyph_id HB_UNUSED) const
+  inline hb_position_t get_caret_value (hb_font_t *font, hb_direction_t direction) const
   {
     return HB_DIRECTION_IS_HORIZONTAL (direction) ? font->em_scale_x (coordinate) : font->em_scale_y (coordinate);
   }
@@ -105,7 +105,7 @@ struct CaretValueFormat1
   inline bool sanitize (hb_sanitize_context_t *c) const
   {
     TRACE_SANITIZE (this);
-    return TRACE_RETURN (c->check_struct (this));
+    return_trace (c->check_struct (this));
   }
 
   protected:
@@ -132,7 +132,7 @@ struct CaretValueFormat2
   inline bool sanitize (hb_sanitize_context_t *c) const
   {
     TRACE_SANITIZE (this);
-    return TRACE_RETURN (c->check_struct (this));
+    return_trace (c->check_struct (this));
   }
 
   protected:
@@ -146,17 +146,17 @@ struct CaretValueFormat3
 {
   friend struct CaretValue;
 
-  inline hb_position_t get_caret_value (hb_font_t *font, hb_direction_t direction, hb_codepoint_t glyph_id HB_UNUSED) const
+  inline hb_position_t get_caret_value (hb_font_t *font, hb_direction_t direction, const VariationStore &var_store) const
   {
     return HB_DIRECTION_IS_HORIZONTAL (direction) ?
-           font->em_scale_x (coordinate) + (this+deviceTable).get_x_delta (font) :
-           font->em_scale_y (coordinate) + (this+deviceTable).get_y_delta (font);
+           font->em_scale_x (coordinate) + (this+deviceTable).get_x_delta (font, var_store) :
+           font->em_scale_y (coordinate) + (this+deviceTable).get_y_delta (font, var_store);
   }
 
   inline bool sanitize (hb_sanitize_context_t *c) const
   {
     TRACE_SANITIZE (this);
-    return TRACE_RETURN (c->check_struct (this) && deviceTable.sanitize (c, this));
+    return_trace (c->check_struct (this) && deviceTable.sanitize (c, this));
   }
 
   protected:
@@ -172,12 +172,15 @@ struct CaretValueFormat3
 
 struct CaretValue
 {
-  inline hb_position_t get_caret_value (hb_font_t *font, hb_direction_t direction, hb_codepoint_t glyph_id) const
+  inline hb_position_t get_caret_value (hb_font_t *font,
+                                       hb_direction_t direction,
+                                       hb_codepoint_t glyph_id,
+                                       const VariationStore &var_store) const
   {
     switch (u.format) {
-    case 1: return u.format1.get_caret_value (font, direction, glyph_id);
+    case 1: return u.format1.get_caret_value (font, direction);
     case 2: return u.format2.get_caret_value (font, direction, glyph_id);
-    case 3: return u.format3.get_caret_value (font, direction, glyph_id);
+    case 3: return u.format3.get_caret_value (font, direction, var_store);
     default:return 0;
     }
   }
@@ -185,12 +188,12 @@ struct CaretValue
   inline bool sanitize (hb_sanitize_context_t *c) const
   {
     TRACE_SANITIZE (this);
-    if (!u.format.sanitize (c)) return TRACE_RETURN (false);
+    if (!u.format.sanitize (c)) return_trace (false);
     switch (u.format) {
-    case 1: return TRACE_RETURN (u.format1.sanitize (c));
-    case 2: return TRACE_RETURN (u.format2.sanitize (c));
-    case 3: return TRACE_RETURN (u.format3.sanitize (c));
-    default:return TRACE_RETURN (true);
+    case 1: return_trace (u.format1.sanitize (c));
+    case 2: return_trace (u.format2.sanitize (c));
+    case 3: return_trace (u.format3.sanitize (c));
+    default:return_trace (true);
     }
   }
 
@@ -210,6 +213,7 @@ struct LigGlyph
   inline unsigned int get_lig_carets (hb_font_t *font,
                                      hb_direction_t direction,
                                      hb_codepoint_t glyph_id,
+                                     const VariationStore &var_store,
                                      unsigned int start_offset,
                                      unsigned int *caret_count /* IN/OUT */,
                                      hb_position_t *caret_array /* OUT */) const
@@ -218,7 +222,7 @@ struct LigGlyph
       const OffsetTo<CaretValue> *array = carets.sub_array (start_offset, caret_count);
       unsigned int count = *caret_count;
       for (unsigned int i = 0; i < count; i++)
-       caret_array[i] = (this+array[i]).get_caret_value (font, direction, glyph_id);
+       caret_array[i] = (this+array[i]).get_caret_value (font, direction, glyph_id, var_store);
     }
 
     return carets.len;
@@ -227,7 +231,7 @@ struct LigGlyph
   inline bool sanitize (hb_sanitize_context_t *c) const
   {
     TRACE_SANITIZE (this);
-    return TRACE_RETURN (carets.sanitize (c, this));
+    return_trace (carets.sanitize (c, this));
   }
 
   protected:
@@ -244,6 +248,7 @@ struct LigCaretList
   inline unsigned int get_lig_carets (hb_font_t *font,
                                      hb_direction_t direction,
                                      hb_codepoint_t glyph_id,
+                                     const VariationStore &var_store,
                                      unsigned int start_offset,
                                      unsigned int *caret_count /* IN/OUT */,
                                      hb_position_t *caret_array /* OUT */) const
@@ -256,13 +261,13 @@ struct LigCaretList
       return 0;
     }
     const LigGlyph &lig_glyph = this+ligGlyph[index];
-    return lig_glyph.get_lig_carets (font, direction, glyph_id, start_offset, caret_count, caret_array);
+    return lig_glyph.get_lig_carets (font, direction, glyph_id, var_store, start_offset, caret_count, caret_array);
   }
 
   inline bool sanitize (hb_sanitize_context_t *c) const
   {
     TRACE_SANITIZE (this);
-    return TRACE_RETURN (coverage.sanitize (c, this) && ligGlyph.sanitize (c, this));
+    return_trace (coverage.sanitize (c, this) && ligGlyph.sanitize (c, this));
   }
 
   protected:
@@ -285,12 +290,12 @@ struct MarkGlyphSetsFormat1
   inline bool sanitize (hb_sanitize_context_t *c) const
   {
     TRACE_SANITIZE (this);
-    return TRACE_RETURN (coverage.sanitize (c, this));
+    return_trace (coverage.sanitize (c, this));
   }
 
   protected:
   USHORT       format;                 /* Format identifier--format = 1 */
-  ArrayOf<OffsetTo<Coverage, ULONG> >
+  ArrayOf<LOffsetTo<Coverage> >
                coverage;               /* Array of long offsets to mark set
                                         * coverage tables */
   public:
@@ -310,10 +315,10 @@ struct MarkGlyphSets
   inline bool sanitize (hb_sanitize_context_t *c) const
   {
     TRACE_SANITIZE (this);
-    if (!u.format.sanitize (c)) return TRACE_RETURN (false);
+    if (!u.format.sanitize (c)) return_trace (false);
     switch (u.format) {
-    case 1: return TRACE_RETURN (u.format1.sanitize (c));
-    default:return TRACE_RETURN (true);
+    case 1: return_trace (u.format1.sanitize (c));
+    default:return_trace (true);
     }
   }
 
@@ -367,25 +372,31 @@ struct GDEF
                                      unsigned int start_offset,
                                      unsigned int *caret_count /* IN/OUT */,
                                      hb_position_t *caret_array /* OUT */) const
-  { return (this+ligCaretList).get_lig_carets (font, direction, glyph_id, start_offset, caret_count, caret_array); }
+  { return (this+ligCaretList).get_lig_carets (font,
+                                              direction, glyph_id, get_var_store(),
+                                              start_offset, caret_count, caret_array); }
 
-  inline bool has_mark_sets (void) const { return version.to_int () >= 0x00010002u && markGlyphSetsDef[0] != 0; }
+  inline bool has_mark_sets (void) const { return version.to_int () >= 0x00010002u && markGlyphSetsDef != 0; }
   inline bool mark_set_covers (unsigned int set_index, hb_codepoint_t glyph_id) const
-  { return version.to_int () >= 0x00010002u && (this+markGlyphSetsDef[0]).covers (set_index, glyph_id); }
+  { return version.to_int () >= 0x00010002u && (this+markGlyphSetsDef).covers (set_index, glyph_id); }
+
+  inline bool has_var_store (void) const { return version.to_int () >= 0x00010003u && varStore != 0; }
+  inline const VariationStore &get_var_store (void) const
+  { return version.to_int () >= 0x00010003u ? this+varStore : Null(VariationStore); }
 
   inline bool sanitize (hb_sanitize_context_t *c) const
   {
     TRACE_SANITIZE (this);
-    return TRACE_RETURN (version.sanitize (c) &&
-                        likely (version.major == 1) &&
-                        glyphClassDef.sanitize (c, this) &&
-                        attachList.sanitize (c, this) &&
-                        ligCaretList.sanitize (c, this) &&
-                        markAttachClassDef.sanitize (c, this) &&
-                        (version.to_int () < 0x00010002u || markGlyphSetsDef[0].sanitize (c, this)));
+    return_trace (version.sanitize (c) &&
+                 likely (version.major == 1) &&
+                 glyphClassDef.sanitize (c, this) &&
+                 attachList.sanitize (c, this) &&
+                 ligCaretList.sanitize (c, this) &&
+                 markAttachClassDef.sanitize (c, this) &&
+                 (version.to_int () < 0x00010002u || markGlyphSetsDef.sanitize (c, this)) &&
+                 (version.to_int () < 0x00010003u || varStore.sanitize (c, this)));
   }
 
-
   /* glyph_props is a 16-bit integer where the lower 8-bit have bits representing
    * glyph class and other bits, and high 8-bit gthe mark attachment type (if any).
    * Not to be confused with lookup_props which is very similar. */
@@ -409,8 +420,8 @@ struct GDEF
 
 
   protected:
-  FixedVersion version;                /* Version of the GDEF table--currently
-                                        * 0x00010002u */
+  FixedVersion<>version;               /* Version of the GDEF table--currently
+                                        * 0x00010003u */
   OffsetTo<ClassDef>
                glyphClassDef;          /* Offset to class definition table
                                         * for glyph type--from beginning of
@@ -428,12 +439,17 @@ struct GDEF
                                         * mark attachment type--from beginning
                                         * of GDEF header (may be Null) */
   OffsetTo<MarkGlyphSets>
-               markGlyphSetsDef[VAR];  /* Offset to the table of mark set
+               markGlyphSetsDef;       /* Offset to the table of mark set
                                         * definitions--from beginning of GDEF
                                         * header (may be NULL).  Introduced
-                                        * in version 00010002. */
+                                        * in version 0x00010002. */
+  LOffsetTo<VariationStore>
+               varStore;               /* Offset to the table of Item Variation
+                                        * Store--from beginning of GDEF
+                                        * header (may be NULL).  Introduced
+                                        * in version 0x00010003. */
   public:
-  DEFINE_SIZE_ARRAY (12, markGlyphSetsDef);
+  DEFINE_SIZE_MIN (12);
 };