Imported Upstream version 2.3.1
[platform/upstream/harfbuzz.git] / src / hb-aat-layout-ankr-table.hh
index d0453bd..236e4aa 100644 (file)
 #ifndef HB_AAT_LAYOUT_ANKR_TABLE_HH
 #define HB_AAT_LAYOUT_ANKR_TABLE_HH
 
-#include "hb-aat-layout-common-private.hh"
+#include "hb-aat-layout-common.hh"
 
+/*
+ * ankr -- Anchor Point
+ * https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6ankr.html
+ */
 #define HB_AAT_TAG_ankr HB_TAG('a','n','k','r')
 
 
 namespace AAT {
 
+using namespace OT;
 
-/*
- * ankr -- Anchor point
- */
 
 struct Anchor
 {
-  inline bool sanitize (hb_sanitize_context_t *c) const
+  bool sanitize (hb_sanitize_context_t *c) const
   {
     TRACE_SANITIZE (this);
     return_trace (c->check_struct (this));
   }
 
+  public:
   FWORD                xCoordinate;
   FWORD                yCoordinate;
   public:
   DEFINE_SIZE_STATIC (4);
 };
 
+typedef LArrayOf<Anchor> GlyphAnchors;
+
 struct ankr
 {
-  static const hb_tag_t tableTag = HB_AAT_TAG_ankr;
+  static constexpr hb_tag_t tableTag = HB_AAT_TAG_ankr;
+
+  const Anchor &get_anchor (hb_codepoint_t glyph_id,
+                           unsigned int i,
+                           unsigned int num_glyphs) const
+  {
+    const NNOffsetTo<GlyphAnchors> *offset = (this+lookupTable).get_value (glyph_id, num_glyphs);
+    if (!offset)
+      return Null(Anchor);
+    const GlyphAnchors &anchors = &(this+anchorData) + *offset;
+    return anchors[i];
+  }
 
-  inline bool sanitize (hb_sanitize_context_t *c) const
+  bool sanitize (hb_sanitize_context_t *c) const
   {
     TRACE_SANITIZE (this);
-    return_trace (c->check_struct (this) && version == 0 &&
-                 lookupTable.sanitize (c, this) &&
-                 anchors.sanitize (c, this));
+    return_trace (likely (c->check_struct (this) &&
+                         version == 0 &&
+                         lookupTable.sanitize (c, this, &(this+anchorData))));
   }
 
   protected:
-  HBUINT16                     version;        /* Version number (set to zero) */
-  HBUINT16                     flags;          /* Flags (currently unused; set to zero) */
-  LOffsetTo<Lookup<HBUINT16> > lookupTable;    /* Offset to the table's lookup table */
-  LOffsetTo<ArrayOf<Anchor, HBUINT32> >
-                               anchors;        /* Offset to the glyph data table */
+  HBUINT16     version;        /* Version number (set to zero) */
+  HBUINT16     flags;          /* Flags (currently unused; set to zero) */
+  LOffsetTo<Lookup<NNOffsetTo<GlyphAnchors> > >
+               lookupTable;    /* Offset to the table's lookup table */
+  LNNOffsetTo<HBUINT8>
+               anchorData;     /* Offset to the glyph data table */
 
   public:
   DEFINE_SIZE_STATIC (12);