[HB] Port ot-layout to new public API
authorBehdad Esfahbod <behdad@behdad.org>
Sun, 2 Aug 2009 21:41:36 +0000 (17:41 -0400)
committerBehdad Esfahbod <behdad@behdad.org>
Mon, 2 Nov 2009 19:40:26 +0000 (14:40 -0500)
src/TODO
src/hb-common.h
src/hb-font.c
src/hb-font.h
src/hb-ot-layout-gdef-private.h
src/hb-ot-layout-gpos-private.h
src/hb-ot-layout-gsub-private.h
src/hb-ot-layout-gsubgpos-private.h
src/hb-ot-layout-private.h
src/hb-ot-layout.cc
src/hb-ot-layout.h

index badfa64..997de7c 100644 (file)
--- a/src/TODO
+++ b/src/TODO
@@ -1,3 +1,4 @@
+- Get rid of custom GSUB/GPOS table type enum?
 - Test OpenType 1.6 mark filtering sets
 - When sanitizing, have to do a second round to make sure no toe-stepping
 - HB_OT_LAYOUT_GLYPH_CLASS_BASE_GLYPH vs LookupType::... mess
index 011e865..de94fb2 100644 (file)
@@ -45,6 +45,7 @@ typedef uint32_t hb_tag_t;
                                ((const char *) s)[1], \
                                ((const char *) s)[2], \
                                ((const char *) s)[3]))
+#define HB_TAG_NONE HB_TAG(0,0,0,0)
 
 typedef uint32_t hb_codepoint_t;
 typedef int32_t hb_position_t;
index 2397d77..dbe82ba 100644 (file)
@@ -314,6 +314,15 @@ hb_font_destroy (hb_font_t *font)
   free (font);
 }
 
+hb_face_t *
+hb_font_get_face (hb_font_t *font)
+{
+  if (HB_OBJECT_IS_INERT (font))
+    return &_hb_face_nil;
+
+  return font->face;
+}
+
 void
 hb_font_set_scale (hb_font_t *font,
                   hb_16dot16_t x_scale,
index deab22e..71f7eb7 100644 (file)
@@ -176,6 +176,9 @@ hb_font_get_reference_count (hb_font_t *font);
 void
 hb_font_destroy (hb_font_t *font);
 
+hb_face_t *
+hb_font_get_face (hb_font_t *font);
+
 /*
  * XXX
  * should we decompose this to units_per_EM and font-size?
index a463a41..0ed74a8 100644 (file)
@@ -90,10 +90,10 @@ struct CaretValueFormat1
   friend struct CaretValue;
 
   private:
-  inline int get_caret_value (hb_ot_layout_t *layout, hb_codepoint_t glyph_id) const
+  inline int get_caret_value (hb_ot_layout_context_t *context, hb_codepoint_t glyph_id) const
   {
     /* XXX vertical */
-    return layout->gpos_info.x_scale * coordinate / 0x10000;
+    return context->font->x_scale * coordinate / 0x10000;
   }
 
   private:
@@ -107,7 +107,7 @@ struct CaretValueFormat2
   friend struct CaretValue;
 
   private:
-  inline int get_caret_value (hb_ot_layout_t *layout, hb_codepoint_t glyph_id) const
+  inline int get_caret_value (hb_ot_layout_context_t *context, hb_codepoint_t glyph_id) const
   {
     return /* TODO contour point */ 0;
   }
@@ -122,11 +122,11 @@ struct CaretValueFormat3
 {
   friend struct CaretValue;
 
-  inline int get_caret_value (hb_ot_layout_t *layout, hb_codepoint_t glyph_id) const
+  inline int get_caret_value (hb_ot_layout_context_t *context, hb_codepoint_t glyph_id) const
   {
     /* XXX vertical */
-    return layout->gpos_info.x_scale * coordinate / 0x10000 +
-          (this+deviceTable).get_delta (layout->gpos_info.x_ppem) << 6;
+    return context->font->x_scale * coordinate / 0x10000 +
+          (this+deviceTable).get_delta (context->font->x_ppem) << 6;
   }
 
   private:
@@ -142,12 +142,12 @@ ASSERT_SIZE (CaretValueFormat3, 6);
 struct CaretValue
 {
   /* XXX  we need access to a load-contour-point vfunc here */
-  int get_caret_value (hb_ot_layout_t *layout, hb_codepoint_t glyph_id) const
+  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 (layout, glyph_id);
-    case 2: return u.format2->get_caret_value (layout, glyph_id);
-    case 3: return u.format3->get_caret_value (layout, 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;
     }
   }
@@ -164,7 +164,7 @@ ASSERT_SIZE (CaretValue, 2);
 
 struct LigGlyph
 {
-  inline void get_lig_carets (hb_ot_layout_t *layout,
+  inline void get_lig_carets (hb_ot_layout_context_t *context,
                              hb_codepoint_t glyph_id,
                              unsigned int *caret_count /* IN/OUT */,
                              int *caret_array /* OUT */) const
@@ -172,7 +172,7 @@ struct LigGlyph
 
     unsigned int count = MIN (carets.len, *caret_count);
     for (unsigned int i = 0; i < count; i++)
-      caret_array[i] = (this+carets[i]).get_caret_value (layout, glyph_id);
+      caret_array[i] = (this+carets[i]).get_caret_value (context, glyph_id);
 
     *caret_count = carets.len;
   }
@@ -187,7 +187,7 @@ ASSERT_SIZE (LigGlyph, 2);
 
 struct LigCaretList
 {
-  inline bool get_lig_carets (hb_ot_layout_t *layout,
+  inline bool get_lig_carets (hb_ot_layout_context_t *context,
                              hb_codepoint_t glyph_id,
                              unsigned int *caret_count /* IN/OUT */,
                              int *caret_array /* OUT */) const
@@ -199,7 +199,7 @@ struct LigCaretList
       return false;
     }
     const LigGlyph &lig_glyph = this+ligGlyph[index];
-    lig_glyph.get_lig_carets (layout, glyph_id, caret_count, caret_array);
+    lig_glyph.get_lig_carets (context, glyph_id, caret_count, caret_array);
     return true;
   }
 
@@ -279,11 +279,11 @@ struct GDEF
   { return (this+attachList).get_attach_points (glyph_id, point_count, point_array); }
 
   inline bool has_lig_carets () const { return ligCaretList != 0; }
-  inline bool get_lig_carets (hb_ot_layout_t *layout,
+  inline bool get_lig_carets (hb_ot_layout_context_t *context,
                              hb_codepoint_t glyph_id,
                              unsigned int *caret_count /* IN/OUT */,
                              int *caret_array /* OUT */) const
-  { return (this+ligCaretList).get_lig_carets (layout, glyph_id, caret_count, caret_array); }
+  { return (this+ligCaretList).get_lig_carets (context, glyph_id, caret_count, caret_array); }
 
   inline bool has_mark_sets () const { return version >= 0x00010002 && markGlyphSetsDef[0] != 0; }
   inline bool mark_set_covers (unsigned int set_index, hb_codepoint_t glyph_id) const
index dafd7d7..8bb3f95 100644 (file)
@@ -55,7 +55,7 @@ struct ValueFormat : USHORT
   inline unsigned int get_len () const
   { return _hb_popcount32 ((unsigned int) *this); }
 
-  const void apply_value (hb_ot_layout_t      *layout,
+  const void apply_value (hb_ot_layout_context_t *context,
                          const char          *base,
                          const Value         *values,
                          hb_internal_glyph_position_t *glyph_pos) const
@@ -97,8 +97,8 @@ struct ValueRecord {
 };
 #endif
 
-    x_scale = layout->gpos_info.x_scale;
-    y_scale = layout->gpos_info.y_scale;
+    x_scale = context->font->x_scale;
+    y_scale = context->font->y_scale;
     /* design units -> fractional pixel */
     if (format & xPlacement)
       glyph_pos->x_pos += x_scale * *(SHORT*)values++ / 0x10000;
@@ -109,8 +109,8 @@ struct ValueRecord {
     if (format & yAdvance)
       glyph_pos->y_advance += y_scale * *(SHORT*)values++ / 0x10000;
 
-    x_ppem = layout->gpos_info.x_ppem;
-    y_ppem = layout->gpos_info.y_ppem;
+    x_ppem = context->font->x_ppem;
+    y_ppem = context->font->y_ppem;
     /* pixel -> fractional pixel */
     if (format & xPlaDevice) {
       if (x_ppem)
@@ -146,11 +146,11 @@ struct AnchorFormat1
   friend struct Anchor;
 
   private:
-  inline void get_anchor (hb_ot_layout_t *layout, hb_codepoint_t glyph_id,
+  inline void get_anchor (hb_ot_layout_context_t *context, hb_codepoint_t glyph_id,
                          hb_position_t *x, hb_position_t *y) const
   {
-      *x = layout->gpos_info.x_scale * xCoordinate / 0x10000;
-      *y = layout->gpos_info.y_scale * yCoordinate / 0x10000;
+      *x = context->font->x_scale * xCoordinate / 0x10000;
+      *y = context->font->y_scale * yCoordinate / 0x10000;
   }
 
   private:
@@ -165,12 +165,12 @@ struct AnchorFormat2
   friend struct Anchor;
 
   private:
-  inline void get_anchor (hb_ot_layout_t *layout, hb_codepoint_t glyph_id,
+  inline void get_anchor (hb_ot_layout_context_t *context, hb_codepoint_t glyph_id,
                          hb_position_t *x, hb_position_t *y) const
   {
       /* TODO Contour */
-      *x = layout->gpos_info.x_scale * xCoordinate / 0x10000;
-      *y = layout->gpos_info.y_scale * yCoordinate / 0x10000;
+      *x = context->font->x_scale * xCoordinate / 0x10000;
+      *y = context->font->y_scale * yCoordinate / 0x10000;
   }
 
   private:
@@ -186,16 +186,16 @@ struct AnchorFormat3
   friend struct Anchor;
 
   private:
-  inline void get_anchor (hb_ot_layout_t *layout, hb_codepoint_t glyph_id,
+  inline void get_anchor (hb_ot_layout_context_t *context, hb_codepoint_t glyph_id,
                          hb_position_t *x, hb_position_t *y) const
   {
-      *x = layout->gpos_info.x_scale * xCoordinate / 0x10000;
-      *y = layout->gpos_info.y_scale * yCoordinate / 0x10000;
+      *x = context->font->x_scale * xCoordinate / 0x10000;
+      *y = context->font->y_scale * yCoordinate / 0x10000;
 
-      if (layout->gpos_info.x_ppem)
-       *x += (this+xDeviceTable).get_delta (layout->gpos_info.x_ppem) << 6;
-      if (layout->gpos_info.y_ppem)
-       *y += (this+yDeviceTable).get_delta (layout->gpos_info.y_ppem) << 6;
+      if (context->font->x_ppem)
+       *x += (this+xDeviceTable).get_delta (context->font->x_ppem) << 6;
+      if (context->font->y_ppem)
+       *y += (this+yDeviceTable).get_delta (context->font->y_ppem) << 6;
   }
 
   private:
@@ -215,15 +215,15 @@ ASSERT_SIZE (AnchorFormat3, 10);
 
 struct Anchor
 {
-  inline void get_anchor (hb_ot_layout_t *layout, hb_codepoint_t glyph_id,
+  inline void get_anchor (hb_ot_layout_context_t *context, hb_codepoint_t glyph_id,
                          hb_position_t *x, hb_position_t *y) const
   {
     *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;
-    default:                                               return;
+    case 1: u.format1->get_anchor (context, glyph_id, x, y); return;
+    case 2: u.format2->get_anchor (context, glyph_id, x, y); return;
+    case 3: u.format3->get_anchor (context, glyph_id, x, y); return;
+    default:                                                return;
     }
   }
 
@@ -275,7 +275,7 @@ struct SinglePosFormat1
     if (HB_LIKELY (index == NOT_COVERED))
       return false;
 
-    valueFormat.apply_value (layout, (const char *) this, values, CURPOSITION ());
+    valueFormat.apply_value (context, (const char *) this, values, CURPOSITION ());
 
     buffer->in_pos++;
     return true;
@@ -308,7 +308,7 @@ struct SinglePosFormat2
     if (HB_LIKELY (index >= valueCount))
       return false;
 
-    valueFormat.apply_value (layout, (const char *) this,
+    valueFormat.apply_value (context, (const char *) this,
                             values + index * valueFormat.get_len (),
                             CURPOSITION ());
 
@@ -394,7 +394,7 @@ struct PairPosFormat1
       return false;
 
     unsigned int j = buffer->in_pos + 1;
-    while (_hb_ot_layout_skip_mark (layout, IN_INFO (j), lookup_flag, NULL))
+    while (_hb_ot_layout_skip_mark (context->layout, IN_INFO (j), lookup_flag, NULL))
     {
       if (HB_UNLIKELY (j == end))
        return false;
@@ -413,8 +413,8 @@ struct PairPosFormat1
     {
       if (IN_GLYPH (j) == record->secondGlyph)
       {
-       valueFormat1.apply_value (layout, (const char *) this, record->values, CURPOSITION ());
-       valueFormat2.apply_value (layout, (const char *) this, record->values + len1, POSITION (j));
+       valueFormat1.apply_value (context, (const char *) this, record->values, CURPOSITION ());
+       valueFormat2.apply_value (context, (const char *) this, record->values + len1, POSITION (j));
        if (len2)
          j++;
        buffer->in_pos = j;
@@ -459,7 +459,7 @@ struct PairPosFormat2
       return false;
 
     unsigned int j = buffer->in_pos + 1;
-    while (_hb_ot_layout_skip_mark (layout, IN_INFO (j), lookup_flag, NULL))
+    while (_hb_ot_layout_skip_mark (context->layout, IN_INFO (j), lookup_flag, NULL))
     {
       if (HB_UNLIKELY (j == end))
        return false;
@@ -476,8 +476,8 @@ struct PairPosFormat2
       return false;
 
     const Value *v = values + record_len * (klass1 * class2Count + klass2);
-    valueFormat1.apply_value (layout, (const char *) this, v, CURPOSITION ());
-    valueFormat2.apply_value (layout, (const char *) this, v + len1, POSITION (j));
+    valueFormat1.apply_value (context, (const char *) this, v, CURPOSITION ());
+    valueFormat2.apply_value (context, (const char *) this, v + len1, POSITION (j));
 
     if (len2)
       j++;
@@ -677,7 +677,7 @@ struct CursivePosFormat1
        Since horizontal advance widths or vertical advance heights
        can be used alone but not together, no ambiguity occurs.        */
 
-    struct hb_ot_layout_t::gpos_info_t *gpi = &layout->gpos_info;
+    struct hb_ot_layout_context_t::info_t::gpos_t *gpi = &context->info.gpos;
     hb_codepoint_t last_pos = gpi->last;
     gpi->last = HB_OT_LAYOUT_GPOS_NO_LAST;
 
@@ -695,7 +695,7 @@ struct CursivePosFormat1
       goto end;
 
     hb_position_t entry_x, entry_y;
-    (this+record.entryAnchor).get_anchor (layout, IN_CURGLYPH (), &entry_x, &entry_y);
+    (this+record.entryAnchor).get_anchor (context, IN_CURGLYPH (), &entry_x, &entry_y);
 
     /* TODO vertical */
 
@@ -725,7 +725,7 @@ struct CursivePosFormat1
     if (record.exitAnchor)
     {
       gpi->last = buffer->in_pos;
-      (this+record.exitAnchor).get_anchor (layout, IN_CURGLYPH (), &gpi->anchor_x, &gpi->anchor_y);
+      (this+record.exitAnchor).get_anchor (context, IN_CURGLYPH (), &gpi->anchor_x, &gpi->anchor_y);
     }
 
     buffer->in_pos++;
@@ -794,7 +794,7 @@ struct MarkBasePosFormat1
     /* now we search backwards for a non-mark glyph */
     unsigned int count = buffer->in_pos;
     unsigned int i = 1, j = count - 1;
-    while (_hb_ot_layout_skip_mark (layout, IN_INFO (j), LookupFlag::IgnoreMarks, &property))
+    while (_hb_ot_layout_skip_mark (context->layout, IN_INFO (j), LookupFlag::IgnoreMarks, &property))
     {
       if (HB_UNLIKELY (i == count))
        return false;
@@ -821,9 +821,9 @@ struct MarkBasePosFormat1
 
     hb_position_t mark_x, mark_y, base_x, base_y;
 
-    mark_anchor.get_anchor (layout, IN_CURGLYPH (), &mark_x, &mark_y);
+    mark_anchor.get_anchor (context, IN_CURGLYPH (), &mark_x, &mark_y);
     unsigned int index = base_index * classCount + mark_class;
-    (&base_array+base_array.matrix[index]).get_anchor (layout, IN_GLYPH (j), &base_x, &base_y);
+    (&base_array+base_array.matrix[index]).get_anchor (context, IN_GLYPH (j), &base_x, &base_y);
 
     hb_internal_glyph_position_t *o = POSITION (buffer->in_pos);
     o->x_pos     = base_x - mark_x;
@@ -912,7 +912,7 @@ struct MarkLigPosFormat1
     /* now we search backwards for a non-mark glyph */
     unsigned int count = buffer->in_pos;
     unsigned int i = 1, j = count - 1;
-    while (_hb_ot_layout_skip_mark (layout, IN_INFO (j), LookupFlag::IgnoreMarks, &property))
+    while (_hb_ot_layout_skip_mark (context->layout, IN_INFO (j), LookupFlag::IgnoreMarks, &property))
     {
       if (HB_UNLIKELY (i == count))
        return false;
@@ -958,9 +958,9 @@ struct MarkLigPosFormat1
 
     hb_position_t mark_x, mark_y, lig_x, lig_y;
 
-    mark_anchor.get_anchor (layout, IN_CURGLYPH (), &mark_x, &mark_y);
+    mark_anchor.get_anchor (context, IN_CURGLYPH (), &mark_x, &mark_y);
     unsigned int index = comp_index * classCount + mark_class;
-    (&lig_attach+lig_attach.matrix[index]).get_anchor (layout, IN_GLYPH (j), &lig_x, &lig_y);
+    (&lig_attach+lig_attach.matrix[index]).get_anchor (context, IN_GLYPH (j), &lig_x, &lig_y);
 
     hb_internal_glyph_position_t *o = POSITION (buffer->in_pos);
     o->x_pos     = lig_x - mark_x;
@@ -1043,7 +1043,7 @@ struct MarkMarkPosFormat1
     /* now we search backwards for a suitable mark glyph until a non-mark glyph */
     unsigned int count = buffer->in_pos;
     unsigned int i = 1, j = count - 1;
-    while (_hb_ot_layout_skip_mark (layout, IN_INFO (j), lookup_flag, &property))
+    while (_hb_ot_layout_skip_mark (context->layout, IN_INFO (j), lookup_flag, &property))
     {
       if (HB_UNLIKELY (i == count))
        return false;
@@ -1073,9 +1073,9 @@ struct MarkMarkPosFormat1
 
     hb_position_t mark1_x, mark1_y, mark2_x, mark2_y;
 
-    mark1_anchor.get_anchor (layout, IN_CURGLYPH (), &mark1_x, &mark1_y);
+    mark1_anchor.get_anchor (context, IN_CURGLYPH (), &mark1_x, &mark1_y);
     unsigned int index = mark2_index * classCount + mark1_class;
-    (&mark2_array+mark2_array.matrix[index]).get_anchor (layout, IN_GLYPH (j), &mark2_x, &mark2_y);
+    (&mark2_array+mark2_array.matrix[index]).get_anchor (context, IN_GLYPH (j), &mark2_x, &mark2_y);
 
     hb_internal_glyph_position_t *o = POSITION (buffer->in_pos);
     o->x_pos     = mark2_x - mark1_x;
@@ -1243,7 +1243,7 @@ struct PosLookup : Lookup
     return type;
   }
 
-  inline bool apply_once (hb_ot_layout_t *layout,
+  inline bool apply_once (hb_ot_layout_context_t *context,
                          hb_buffer_t    *buffer,
                          unsigned int    context_length,
                          unsigned int    nesting_level_left) const
@@ -1252,7 +1252,7 @@ struct PosLookup : Lookup
     unsigned int lookup_flag = get_flag ();
     unsigned int property;
 
-    if (!_hb_ot_layout_check_glyph_property (layout, IN_CURINFO (), lookup_flag, &property))
+    if (!_hb_ot_layout_check_glyph_property (context->layout, IN_CURINFO (), lookup_flag, &property))
       return false;
 
     for (unsigned int i = 0; i < get_subtable_count (); i++)
@@ -1262,7 +1262,7 @@ struct PosLookup : Lookup
     return false;
   }
 
-  bool apply_string (hb_ot_layout_t *layout,
+  bool apply_string (hb_ot_layout_context_t *context,
                     hb_buffer_t    *buffer,
                     hb_ot_layout_feature_mask_t mask) const
   {
@@ -1271,7 +1271,7 @@ struct PosLookup : Lookup
     if (HB_UNLIKELY (!buffer->in_length))
       return false;
 
-    layout->gpos_info.last = HB_OT_LAYOUT_GPOS_NO_LAST; /* no last valid glyph for cursive pos. */
+    context->info.gpos.last = HB_OT_LAYOUT_GPOS_NO_LAST; /* no last valid glyph for cursive pos. */
 
     buffer->in_pos = 0;
     while (buffer->in_pos < buffer->in_length)
@@ -1279,7 +1279,7 @@ struct PosLookup : Lookup
       bool done;
       if (~IN_PROPERTIES (buffer->in_pos) & mask)
       {
-         done = apply_once (layout, buffer, NO_CONTEXT, MAX_NESTING_LEVEL);
+         done = apply_once (context, buffer, NO_CONTEXT, MAX_NESTING_LEVEL);
          ret |= done;
       }
       else
@@ -1287,7 +1287,7 @@ struct PosLookup : Lookup
           done = false;
          /* Contrary to properties defined in GDEF, user-defined properties
             will always stop a possible cursive positioning.                */
-         layout->gpos_info.last = HB_OT_LAYOUT_GPOS_NO_LAST;
+         context->info.gpos.last = HB_OT_LAYOUT_GPOS_NO_LAST;
       }
 
       if (!done)
@@ -1314,11 +1314,11 @@ struct GPOS : GSUBGPOS
   inline const PosLookup& get_lookup (unsigned int i) const
   { return (const PosLookup&) GSUBGPOS::get_lookup (i); }
 
-  inline bool position_lookup (hb_ot_layout_t *layout,
+  inline bool position_lookup (hb_ot_layout_context_t *context,
                               hb_buffer_t    *buffer,
                               unsigned int    lookup_index,
                               hb_ot_layout_feature_mask_t  mask) const
-  { return get_lookup (lookup_index).apply_string (layout, buffer, mask); }
+  { return get_lookup (lookup_index).apply_string (context, buffer, mask); }
 
 };
 ASSERT_SIZE (GPOS, 10);
@@ -1338,7 +1338,7 @@ inline bool ExtensionPos::apply (APPLY_ARG_DEF) const
 
 static inline bool position_lookup (APPLY_ARG_DEF, unsigned int lookup_index)
 {
-  const GPOS &gpos = *(layout->gpos);
+  const GPOS &gpos = *(context->layout->gpos);
   const PosLookup &l = gpos.get_lookup (lookup_index);
 
   if (HB_UNLIKELY (nesting_level_left == 0))
@@ -1348,7 +1348,7 @@ static inline bool position_lookup (APPLY_ARG_DEF, unsigned int lookup_index)
   if (HB_UNLIKELY (context_length < 1))
     return false;
 
-  return l.apply_once (layout, buffer, context_length, nesting_level_left);
+  return l.apply_once (context, buffer, context_length, nesting_level_left);
 }
 
 
index 14f69e4..e4c3afb 100644 (file)
@@ -46,8 +46,8 @@ struct SingleSubstFormat1
     _hb_buffer_replace_glyph (buffer, glyph_id);
 
     /* We inherit the old glyph class to the substituted glyph */
-    if (_hb_ot_layout_has_new_glyph_classes (layout))
-      _hb_ot_layout_set_glyph_property (layout, glyph_id, property);
+    if (_hb_ot_layout_has_new_glyph_classes (context->layout))
+      _hb_ot_layout_set_glyph_property (context->layout, glyph_id, property);
 
     return true;
   }
@@ -81,8 +81,8 @@ struct SingleSubstFormat2
     _hb_buffer_replace_glyph (buffer, glyph_id);
 
     /* We inherit the old glyph class to the substituted glyph */
-    if (_hb_ot_layout_has_new_glyph_classes (layout))
-      _hb_ot_layout_set_glyph_property (layout, glyph_id, property);
+    if (_hb_ot_layout_has_new_glyph_classes (context->layout))
+      _hb_ot_layout_set_glyph_property (context->layout, glyph_id, property);
 
     return true;
   }
@@ -137,14 +137,14 @@ struct Sequence
                                  0xFFFF, 0xFFFF);
 
     /* This is a guess only ... */
-    if (_hb_ot_layout_has_new_glyph_classes (layout))
+    if (_hb_ot_layout_has_new_glyph_classes (context->layout))
     {
       if (property == HB_OT_LAYOUT_GLYPH_CLASS_LIGATURE)
         property = HB_OT_LAYOUT_GLYPH_CLASS_BASE_GLYPH;
 
       unsigned int count = substitute.len;
       for (unsigned int n = 0; n < count; n++)
-       _hb_ot_layout_set_glyph_property (layout, substitute[n], property);
+       _hb_ot_layout_set_glyph_property (context->layout, substitute[n], property);
     }
 
     return true;
@@ -229,8 +229,8 @@ struct AlternateSubstFormat1
     unsigned int alt_index = 0;
 
     /* XXX callback to user to choose alternate
-    if (layout->altfunc)
-      alt_index = (layout->altfunc)(layout, buffer,
+    if (context->layout->altfunc)
+      alt_index = (context->layout->altfunc)(context->layout, buffer,
                                    buffer->out_pos, glyph_id,
                                    alt_set.len, alt_set.array);
                                   */
@@ -243,8 +243,8 @@ struct AlternateSubstFormat1
     _hb_buffer_replace_glyph (buffer, glyph_id);
 
     /* We inherit the old glyph class to the substituted glyph */
-    if (_hb_ot_layout_has_new_glyph_classes (layout))
-      _hb_ot_layout_set_glyph_property (layout, glyph_id, property);
+    if (_hb_ot_layout_has_new_glyph_classes (context->layout))
+      _hb_ot_layout_set_glyph_property (context->layout, glyph_id, property);
 
     return true;
   }
@@ -297,7 +297,7 @@ struct Ligature
 
     for (i = 1, j = buffer->in_pos + 1; i < count; i++, j++)
     {
-      while (_hb_ot_layout_skip_mark (layout, IN_INFO (j), lookup_flag, &property))
+      while (_hb_ot_layout_skip_mark (context->layout, IN_INFO (j), lookup_flag, &property))
       {
        if (HB_UNLIKELY (j + count - i == end))
          return false;
@@ -311,10 +311,10 @@ struct Ligature
         return false;
     }
     /* This is just a guess ... */
-    if (_hb_ot_layout_has_new_glyph_classes (layout))
-      hb_ot_layout_set_glyph_class (layout, ligGlyph,
-                                   is_mark ? HB_OT_LAYOUT_GLYPH_CLASS_MARK
-                                           : HB_OT_LAYOUT_GLYPH_CLASS_LIGATURE);
+    if (_hb_ot_layout_has_new_glyph_classes (context->layout))
+      _hb_ot_layout_set_glyph_class (context->layout, ligGlyph,
+                                    is_mark ? HB_OT_LAYOUT_GLYPH_CLASS_MARK
+                                            : HB_OT_LAYOUT_GLYPH_CLASS_LIGATURE);
 
     if (j == buffer->in_pos + i) /* No input glyphs skipped */
       /* We don't use a new ligature ID if there are no skipped
@@ -338,7 +338,7 @@ struct Ligature
 
       for ( i = 1; i < count; i++ )
       {
-       while (_hb_ot_layout_skip_mark (layout, IN_CURINFO (), lookup_flag, NULL))
+       while (_hb_ot_layout_skip_mark (context->layout, IN_CURINFO (), lookup_flag, NULL))
          _hb_buffer_add_output_glyph (buffer, IN_CURGLYPH (), i - 1, lig_id);
 
        (buffer->in_pos)++;
@@ -627,7 +627,7 @@ struct SubstLookup : Lookup
   inline bool is_reverse (void) const
   { return HB_UNLIKELY (get_effective_type () == SubstLookupSubTable::ReverseChainSingle); }
 
-  inline bool apply_once (hb_ot_layout_t *layout,
+  inline bool apply_once (hb_ot_layout_context_t *context,
                          hb_buffer_t    *buffer,
                          unsigned int    context_length,
                          unsigned int    nesting_level_left) const
@@ -636,7 +636,7 @@ struct SubstLookup : Lookup
     unsigned int lookup_flag = get_flag ();
     unsigned int property;
 
-    if (!_hb_ot_layout_check_glyph_property (layout, IN_CURINFO (), lookup_flag, &property))
+    if (!_hb_ot_layout_check_glyph_property (context->layout, IN_CURINFO (), lookup_flag, &property))
       return false;
 
     for (unsigned int i = 0; i < get_subtable_count (); i++)
@@ -646,7 +646,7 @@ struct SubstLookup : Lookup
     return false;
   }
 
-  bool apply_string (hb_ot_layout_t *layout,
+  bool apply_string (hb_ot_layout_context_t *context,
                     hb_buffer_t    *buffer,
                     hb_ot_layout_feature_mask_t mask) const
   {
@@ -663,7 +663,7 @@ struct SubstLookup : Lookup
        while (buffer->in_pos < buffer->in_length)
        {
          if ((~IN_PROPERTIES (buffer->in_pos) & mask) &&
-             apply_once (layout, buffer, NO_CONTEXT, MAX_NESTING_LEVEL))
+             apply_once (context, buffer, NO_CONTEXT, MAX_NESTING_LEVEL))
            ret = true;
          else
            _hb_buffer_next_glyph (buffer);
@@ -681,7 +681,7 @@ struct SubstLookup : Lookup
        do
        {
          if ((~IN_PROPERTIES (buffer->in_pos) & mask) &&
-             apply_once (layout, buffer, NO_CONTEXT, MAX_NESTING_LEVEL))
+             apply_once (context, buffer, NO_CONTEXT, MAX_NESTING_LEVEL))
            ret = true;
          else
            buffer->in_pos--;
@@ -710,11 +710,11 @@ struct GSUB : GSUBGPOS
   inline const SubstLookup& get_lookup (unsigned int i) const
   { return (const SubstLookup&) GSUBGPOS::get_lookup (i); }
 
-  inline bool substitute_lookup (hb_ot_layout_t *layout,
+  inline bool substitute_lookup (hb_ot_layout_context_t *context,
                                 hb_buffer_t    *buffer,
                                 unsigned int    lookup_index,
                                 hb_ot_layout_feature_mask_t  mask) const
-  { return get_lookup (lookup_index).apply_string (layout, buffer, mask); }
+  { return get_lookup (lookup_index).apply_string (context, buffer, mask); }
 
 };
 ASSERT_SIZE (GSUB, 10);
@@ -734,7 +734,7 @@ inline bool ExtensionSubst::apply (APPLY_ARG_DEF) const
 
 static inline bool substitute_lookup (APPLY_ARG_DEF, unsigned int lookup_index)
 {
-  const GSUB &gsub = *(layout->gsub);
+  const GSUB &gsub = *(context->layout->gsub);
   const SubstLookup &l = gsub.get_lookup (lookup_index);
 
   if (HB_UNLIKELY (nesting_level_left == 0))
@@ -744,7 +744,7 @@ static inline bool substitute_lookup (APPLY_ARG_DEF, unsigned int lookup_index)
   if (HB_UNLIKELY (context_length < 1))
     return false;
 
-  return l.apply_once (layout, buffer, context_length, nesting_level_left);
+  return l.apply_once (context, buffer, context_length, nesting_level_left);
 }
 
 
index ccbbeb8..35d8f8c 100644 (file)
 
 
 #define APPLY_ARG_DEF \
-       hb_ot_layout_t *layout, \
+       hb_ot_layout_context_t *context, \
        hb_buffer_t    *buffer, \
        unsigned int    context_length HB_GNUC_UNUSED, \
        unsigned int    nesting_level_left HB_GNUC_UNUSED, \
        unsigned int    lookup_flag, \
        unsigned int    property HB_GNUC_UNUSED /* propety of first glyph */
 #define APPLY_ARG \
-       layout, \
+       context, \
        buffer, \
        context_length, \
        nesting_level_left, \
@@ -89,7 +89,7 @@ static inline bool match_input (APPLY_ARG_DEF,
 
   for (i = 1, j = buffer->in_pos + 1; i < count; i++, j++)
   {
-    while (_hb_ot_layout_skip_mark (layout, IN_INFO (j), lookup_flag, NULL))
+    while (_hb_ot_layout_skip_mark (context->layout, IN_INFO (j), lookup_flag, NULL))
     {
       if (HB_UNLIKELY (j + count - i == end))
        return false;
@@ -116,7 +116,7 @@ static inline bool match_backtrack (APPLY_ARG_DEF,
 
   for (unsigned int i = 0, j = buffer->out_pos - 1; i < count; i++, j--)
   {
-    while (_hb_ot_layout_skip_mark (layout, OUT_INFO (j), lookup_flag, NULL))
+    while (_hb_ot_layout_skip_mark (context->layout, OUT_INFO (j), lookup_flag, NULL))
     {
       if (HB_UNLIKELY (j + 1 == count - i))
        return false;
@@ -144,7 +144,7 @@ static inline bool match_lookahead (APPLY_ARG_DEF,
 
   for (i = 0, j = buffer->in_pos + offset; i < count; i++, j++)
   {
-    while (_hb_ot_layout_skip_mark (layout, OUT_INFO (j), lookup_flag, NULL))
+    while (_hb_ot_layout_skip_mark (context->layout, OUT_INFO (j), lookup_flag, NULL))
     {
       if (HB_UNLIKELY (j + count - i == end))
        return false;
@@ -182,7 +182,7 @@ static inline bool apply_lookup (APPLY_ARG_DEF,
    *      Should be easy for in_place ones at least. */
   for (unsigned int i = 0; i < count; i++)
   {
-    while (_hb_ot_layout_skip_mark (layout, IN_CURINFO (), lookup_flag, NULL))
+    while (_hb_ot_layout_skip_mark (context->layout, IN_CURINFO (), lookup_flag, NULL))
     {
       if (HB_UNLIKELY (buffer->in_pos == end))
        return true;
index 3fdd428..447c750 100644 (file)
 
 #include "hb-ot-layout.h"
 
+#include "hb-font-private.h"
 #include "hb-buffer-private.h"
 
 
 typedef unsigned int hb_ot_layout_class_t;
 
+/*
+ * hb_ot_layout_t
+ */
+
+typedef struct _hb_ot_layout_t hb_ot_layout_t;
+
 struct _hb_ot_layout_t
 {
   const struct GDEF *gdef;
@@ -47,17 +54,23 @@ struct _hb_ot_layout_t
     unsigned char *klasses;
     unsigned int len;
   } new_gdef;
+};
 
-  /* TODO full-matrix transformation? */
-  struct gpos_info_t
-  {
-    unsigned int x_ppem, y_ppem;
-    hb_16dot16_t x_scale, y_scale;
+typedef struct _hb_ot_layout_context_t hb_ot_layout_context_t;
+struct _hb_ot_layout_context_t
+{
+  hb_ot_layout_t *layout;
+  hb_font_t *font;
 
-    unsigned int last;        /* the last valid glyph--used with cursive positioning */
-    hb_position_t anchor_x;   /* the coordinates of the anchor point */
-    hb_position_t anchor_y;   /* of the last valid glyph */
-  } gpos_info;
+  union info_t
+  {
+    struct gpos_t
+    {
+      unsigned int last;        /* the last valid glyph--used with cursive positioning */
+      hb_position_t anchor_x;   /* the coordinates of the anchor point */
+      hb_position_t anchor_y;   /* of the last valid glyph */
+    } gpos;
+  } info;
 };
 
 
@@ -79,6 +92,11 @@ _hb_ot_layout_set_glyph_property (hb_ot_layout_t *layout,
                                  hb_codepoint_t  glyph,
                                  unsigned int    property);
 
+HB_INTERNAL void
+_hb_ot_layout_set_glyph_class (hb_ot_layout_t             *layout,
+                              hb_codepoint_t              glyph,
+                              hb_ot_layout_glyph_class_t  klass);
+
 HB_INTERNAL hb_bool_t
 _hb_ot_layout_check_glyph_property (hb_ot_layout_t  *layout,
                                    hb_internal_glyph_info_t *ginfo,
index 7e0539a..a1fcdbe 100644 (file)
 #include <string.h>
 
 
-hb_ot_layout_t *
-hb_ot_layout_create (void)
+void
+_hb_ot_layout_init (hb_ot_layout_t *layout,
+                   hb_face_t      *face)
 {
-  hb_ot_layout_t *layout = (hb_ot_layout_t *) calloc (1, sizeof (hb_ot_layout_t));
-
   layout->gdef = &Null(GDEF);
   layout->gsub = &Null(GSUB);
   layout->gpos = &Null(GPOS);
-
-  return layout;
-}
-
-hb_bool_t
-hb_ot_layout_has_substitution (hb_ot_layout_t *layout)
-{
-  return layout->gsub != &Null(GSUB);
-}
-
-hb_bool_t
-hb_ot_layout_has_positioning (hb_ot_layout_t *layout)
-{
-  return layout->gpos != &Null(GPOS);
 }
 
+#if 0
 hb_ot_layout_t *
 hb_ot_layout_create_for_data (const char *font_data,
                              int         face_index)
@@ -103,30 +89,20 @@ hb_ot_layout_create_for_tables (const char *gdef_data,
 
   return layout;
 }
+#endif
 
 void
-hb_ot_layout_destroy (hb_ot_layout_t *layout)
+_hb_ot_layout_fini (hb_ot_layout_t *layout,
+                   hb_face_t      *face)
 {
-  free (layout);
 }
 
-void
-hb_ot_layout_set_scale (hb_ot_layout_t *layout,
-                       hb_16dot16_t x_scale, hb_16dot16_t y_scale)
+static hb_ot_layout_t *
+_hb_ot_face_get_layout (hb_face_t *face)
 {
-  layout->gpos_info.x_scale = x_scale;
-  layout->gpos_info.y_scale = y_scale;
+  return NULL; /* XXX */
 }
 
-void
-hb_ot_layout_set_ppem (hb_ot_layout_t *layout,
-                      unsigned int x_ppem, unsigned int y_ppem)
-{
-  layout->gpos_info.x_ppem = x_ppem;
-  layout->gpos_info.y_ppem = y_ppem;
-}
-
-
 /*
  * GDEF
  */
@@ -134,8 +110,9 @@ hb_ot_layout_set_ppem (hb_ot_layout_t *layout,
 /* TODO the public class_t is a mess */
 
 hb_bool_t
-hb_ot_layout_has_font_glyph_classes (hb_ot_layout_t *layout)
+hb_ot_layout_has_font_glyph_classes (hb_face_t *face)
 {
+  hb_ot_layout_t *layout = _hb_ot_face_get_layout (face);
   return layout->gdef->has_glyph_classes ();
 }
 
@@ -243,21 +220,9 @@ _hb_ot_layout_skip_mark (hb_ot_layout_t  *layout,
 }
 
 HB_INTERNAL void
-_hb_ot_layout_set_glyph_property (hb_ot_layout_t *layout,
-                                 hb_codepoint_t  glyph,
-                                 unsigned int    property)
-{ hb_ot_layout_set_glyph_class (layout, glyph, (hb_ot_layout_glyph_class_t) (property & 0xff)); }
-
-
-hb_ot_layout_glyph_class_t
-hb_ot_layout_get_glyph_class (hb_ot_layout_t *layout,
-                             hb_codepoint_t  glyph)
-{ return (hb_ot_layout_glyph_class_t) (_hb_ot_layout_get_glyph_property (layout, glyph) & 0xff); }
-
-void
-hb_ot_layout_set_glyph_class (hb_ot_layout_t             *layout,
-                             hb_codepoint_t              glyph,
-                             hb_ot_layout_glyph_class_t  klass)
+_hb_ot_layout_set_glyph_class (hb_ot_layout_t             *layout,
+                              hb_codepoint_t              glyph,
+                              hb_ot_layout_glyph_class_t  klass)
 {
   /* TODO optimize this? similar to old harfbuzz code for example */
 
@@ -299,13 +264,39 @@ hb_ot_layout_set_glyph_class (hb_ot_layout_t             *layout,
   return;
 }
 
+HB_INTERNAL void
+_hb_ot_layout_set_glyph_property (hb_ot_layout_t *layout,
+                                 hb_codepoint_t  glyph,
+                                 unsigned int    property)
+{ _hb_ot_layout_set_glyph_class (layout, glyph, (hb_ot_layout_glyph_class_t) (property & 0xff)); }
+
+
+hb_ot_layout_glyph_class_t
+hb_ot_layout_get_glyph_class (hb_face_t      *face,
+                             hb_codepoint_t  glyph)
+{
+  hb_ot_layout_t *layout = _hb_ot_face_get_layout (face);
+  return (hb_ot_layout_glyph_class_t) (_hb_ot_layout_get_glyph_property (layout, glyph) & 0xff);
+}
+
 void
-hb_ot_layout_build_glyph_classes (hb_ot_layout_t *layout,
+hb_ot_layout_set_glyph_class (hb_face_t                 *face,
+                             hb_codepoint_t             glyph,
+                             hb_ot_layout_glyph_class_t klass)
+{
+  hb_ot_layout_t *layout = _hb_ot_face_get_layout (face);
+  _hb_ot_layout_set_glyph_class (layout, glyph, klass);
+}
+
+void
+hb_ot_layout_build_glyph_classes (hb_face_t      *face,
                                  uint16_t        num_total_glyphs,
                                  hb_codepoint_t *glyphs,
                                  unsigned char  *klasses,
                                  uint16_t        count)
 {
+  hb_ot_layout_t *layout = _hb_ot_face_get_layout (face);
+
   if (HB_UNLIKELY (!count || !glyphs || !klasses))
     return;
 
@@ -315,25 +306,30 @@ hb_ot_layout_build_glyph_classes (hb_ot_layout_t *layout,
   }
 
   for (unsigned int i = 0; i < count; i++)
-    hb_ot_layout_set_glyph_class (layout, glyphs[i], (hb_ot_layout_glyph_class_t) klasses[i]);
+    _hb_ot_layout_set_glyph_class (layout, glyphs[i], (hb_ot_layout_glyph_class_t) klasses[i]);
 }
 
 hb_bool_t
-hb_ot_layout_get_attach_points (hb_ot_layout_t *layout,
+hb_ot_layout_get_attach_points (hb_face_t      *face,
                                hb_codepoint_t  glyph,
                                unsigned int   *point_count /* IN/OUT */,
                                unsigned int   *point_array /* OUT */)
 {
+  hb_ot_layout_t *layout = _hb_ot_face_get_layout (face);
   return layout->gdef->get_attach_points (glyph, point_count, point_array);
 }
 
 hb_bool_t
-hb_ot_layout_get_lig_carets (hb_ot_layout_t *layout,
+hb_ot_layout_get_lig_carets (hb_face_t      *face,
+                            hb_font_t      *font,
                             hb_codepoint_t  glyph,
                             unsigned int   *caret_count /* IN/OUT */,
                             int            *caret_array /* OUT */)
 {
-  return layout->gdef->get_lig_carets (layout, glyph, caret_count, caret_array);
+  hb_ot_layout_context_t context;
+  context.font = font;
+  context.layout = _hb_ot_face_get_layout (face);
+  return context.layout->gdef->get_lig_carets (&context, glyph, caret_count, caret_array);
 }
 
 /*
@@ -341,44 +337,47 @@ hb_ot_layout_get_lig_carets (hb_ot_layout_t *layout,
  */
 
 static const GSUBGPOS&
-get_gsubgpos_table (hb_ot_layout_t            *layout,
-                   hb_ot_layout_table_type_t  table_type)
+get_gsubgpos_table (hb_ot_layout_t *layout,
+                   hb_tag_t        table_tag)
 {
-  switch (table_type) {
-    case HB_OT_LAYOUT_TABLE_TYPE_GSUB: return *(layout->gsub);
-    case HB_OT_LAYOUT_TABLE_TYPE_GPOS: return *(layout->gpos);
-    default:                           return Null(GSUBGPOS);
+  switch (table_tag) {
+    case HB_OT_TAG_GSUB: return *(layout->gsub);
+    case HB_OT_TAG_GPOS: return *(layout->gpos);
+    default:             return Null(GSUBGPOS);
   }
 }
 
 
 unsigned int
-hb_ot_layout_table_get_script_count (hb_ot_layout_t            *layout,
-                                    hb_ot_layout_table_type_t  table_type)
+hb_ot_layout_table_get_script_count (hb_face_t *face,
+                                    hb_tag_t   table_tag)
 {
-  const GSUBGPOS &g = get_gsubgpos_table (layout, table_type);
+  hb_ot_layout_t *layout = _hb_ot_face_get_layout (face);
+  const GSUBGPOS &g = get_gsubgpos_table (layout, table_tag);
 
   return g.get_script_count ();
 }
 
 hb_tag_t
-hb_ot_layout_table_get_script_tag (hb_ot_layout_t            *layout,
-                                  hb_ot_layout_table_type_t  table_type,
-                                  unsigned int               script_index)
+hb_ot_layout_table_get_script_tag (hb_face_t    *face,
+                                  hb_tag_t      table_tag,
+                                  unsigned int  script_index)
 {
-  const GSUBGPOS &g = get_gsubgpos_table (layout, table_type);
+  hb_ot_layout_t *layout = _hb_ot_face_get_layout (face);
+  const GSUBGPOS &g = get_gsubgpos_table (layout, table_tag);
 
   return g.get_script_tag (script_index);
 }
 
 hb_bool_t
-hb_ot_layout_table_find_script (hb_ot_layout_t            *layout,
-                               hb_ot_layout_table_type_t  table_type,
-                               hb_tag_t                   script_tag,
-                               unsigned int              *script_index)
+hb_ot_layout_table_find_script (hb_face_t    *face,
+                               hb_tag_t      table_tag,
+                               hb_tag_t      script_tag,
+                               unsigned int *script_index)
 {
   ASSERT_STATIC (NO_INDEX == HB_OT_LAYOUT_NO_SCRIPT_INDEX);
-  const GSUBGPOS &g = get_gsubgpos_table (layout, table_type);
+  hb_ot_layout_t *layout = _hb_ot_face_get_layout (face);
+  const GSUBGPOS &g = get_gsubgpos_table (layout, table_tag);
 
   if (g.find_script_index (script_tag, script_index))
     return TRUE;
@@ -396,32 +395,35 @@ hb_ot_layout_table_find_script (hb_ot_layout_t            *layout,
 }
 
 unsigned int
-hb_ot_layout_table_get_feature_count (hb_ot_layout_t            *layout,
-                                     hb_ot_layout_table_type_t  table_type)
+hb_ot_layout_table_get_feature_count (hb_face_t *face,
+                                     hb_tag_t   table_tag)
 {
-  const GSUBGPOS &g = get_gsubgpos_table (layout, table_type);
+  hb_ot_layout_t *layout = _hb_ot_face_get_layout (face);
+  const GSUBGPOS &g = get_gsubgpos_table (layout, table_tag);
 
   return g.get_feature_count ();
 }
 
 hb_tag_t
-hb_ot_layout_table_get_feature_tag (hb_ot_layout_t            *layout,
-                                   hb_ot_layout_table_type_t  table_type,
-                                   unsigned int               feature_index)
+hb_ot_layout_table_get_feature_tag (hb_face_t    *face,
+                                   hb_tag_t      table_tag,
+                                   unsigned int  feature_index)
 {
-  const GSUBGPOS &g = get_gsubgpos_table (layout, table_type);
+  hb_ot_layout_t *layout = _hb_ot_face_get_layout (face);
+  const GSUBGPOS &g = get_gsubgpos_table (layout, table_tag);
 
   return g.get_feature_tag (feature_index);
 }
 
 hb_bool_t
-hb_ot_layout_table_find_feature (hb_ot_layout_t            *layout,
-                                hb_ot_layout_table_type_t  table_type,
-                                hb_tag_t                   feature_tag,
-                                unsigned int              *feature_index)
+hb_ot_layout_table_find_feature (hb_face_t    *face,
+                                hb_tag_t      table_tag,
+                                hb_tag_t      feature_tag,
+                                unsigned int *feature_index)
 {
   ASSERT_STATIC (NO_INDEX == HB_OT_LAYOUT_NO_FEATURE_INDEX);
-  const GSUBGPOS &g = get_gsubgpos_table (layout, table_type);
+  hb_ot_layout_t *layout = _hb_ot_face_get_layout (face);
+  const GSUBGPOS &g = get_gsubgpos_table (layout, table_tag);
 
   if (g.find_feature_index (feature_tag, feature_index))
     return TRUE;
@@ -431,45 +433,49 @@ hb_ot_layout_table_find_feature (hb_ot_layout_t            *layout,
 }
 
 unsigned int
-hb_ot_layout_table_get_lookup_count (hb_ot_layout_t            *layout,
-                                    hb_ot_layout_table_type_t  table_type)
+hb_ot_layout_table_get_lookup_count (hb_face_t *face,
+                                    hb_tag_t   table_tag)
 {
-  const GSUBGPOS &g = get_gsubgpos_table (layout, table_type);
+  hb_ot_layout_t *layout = _hb_ot_face_get_layout (face);
+  const GSUBGPOS &g = get_gsubgpos_table (layout, table_tag);
 
   return g.get_lookup_count ();
 }
 
 
 unsigned int
-hb_ot_layout_script_get_language_count (hb_ot_layout_t            *layout,
-                                       hb_ot_layout_table_type_t  table_type,
-                                       unsigned int               script_index)
+hb_ot_layout_script_get_language_count (hb_face_t    *face,
+                                       hb_tag_t      table_tag,
+                                       unsigned int  script_index)
 {
-  const Script &s = get_gsubgpos_table (layout, table_type).get_script (script_index);
+  hb_ot_layout_t *layout = _hb_ot_face_get_layout (face);
+  const Script &s = get_gsubgpos_table (layout, table_tag).get_script (script_index);
 
   return s.get_lang_sys_count ();
 }
 
 hb_tag_t
-hb_ot_layout_script_get_language_tag (hb_ot_layout_t            *layout,
-                                     hb_ot_layout_table_type_t  table_type,
-                                     unsigned int               script_index,
-                                     unsigned int               language_index)
+hb_ot_layout_script_get_language_tag (hb_face_t    *face,
+                                     hb_tag_t      table_tag,
+                                     unsigned int  script_index,
+                                     unsigned int  language_index)
 {
-  const Script &s = get_gsubgpos_table (layout, table_type).get_script (script_index);
+  hb_ot_layout_t *layout = _hb_ot_face_get_layout (face);
+  const Script &s = get_gsubgpos_table (layout, table_tag).get_script (script_index);
 
   return s.get_lang_sys_tag (language_index);
 }
 
 hb_bool_t
-hb_ot_layout_script_find_language (hb_ot_layout_t            *layout,
-                                  hb_ot_layout_table_type_t  table_type,
-                                  unsigned int               script_index,
-                                  hb_tag_t                   language_tag,
-                                  unsigned int              *language_index)
+hb_ot_layout_script_find_language (hb_face_t    *face,
+                                  hb_tag_t      table_tag,
+                                  unsigned int  script_index,
+                                  hb_tag_t      language_tag,
+                                  unsigned int *language_index)
 {
   ASSERT_STATIC (NO_INDEX == HB_OT_LAYOUT_DEFAULT_LANGUAGE_INDEX);
-  const Script &s = get_gsubgpos_table (layout, table_type).get_script (script_index);
+  hb_ot_layout_t *layout = _hb_ot_face_get_layout (face);
+  const Script &s = get_gsubgpos_table (layout, table_tag).get_script (script_index);
 
   if (s.find_lang_sys_index (language_tag, language_index))
     return TRUE;
@@ -483,13 +489,14 @@ hb_ot_layout_script_find_language (hb_ot_layout_t            *layout,
 }
 
 hb_bool_t
-hb_ot_layout_language_get_required_feature_index (hb_ot_layout_t            *layout,
-                                                 hb_ot_layout_table_type_t  table_type,
-                                                 unsigned int               script_index,
-                                                 unsigned int               language_index,
-                                                 unsigned int              *feature_index)
+hb_ot_layout_language_get_required_feature_index (hb_face_t    *face,
+                                                 hb_tag_t      table_tag,
+                                                 unsigned int  script_index,
+                                                 unsigned int  language_index,
+                                                 unsigned int *feature_index)
 {
-  const LangSys &l = get_gsubgpos_table (layout, table_type).get_script (script_index).get_lang_sys (language_index);
+  hb_ot_layout_t *layout = _hb_ot_face_get_layout (face);
+  const LangSys &l = get_gsubgpos_table (layout, table_tag).get_script (script_index).get_lang_sys (language_index);
 
   if (feature_index) *feature_index = l.get_required_feature_index ();
 
@@ -497,37 +504,40 @@ hb_ot_layout_language_get_required_feature_index (hb_ot_layout_t            *lay
 }
 
 unsigned int
-hb_ot_layout_language_get_feature_count (hb_ot_layout_t            *layout,
-                                        hb_ot_layout_table_type_t  table_type,
-                                        unsigned int               script_index,
-                                        unsigned int               language_index)
+hb_ot_layout_language_get_feature_count (hb_face_t    *face,
+                                        hb_tag_t      table_tag,
+                                        unsigned int  script_index,
+                                        unsigned int  language_index)
 {
-  const LangSys &l = get_gsubgpos_table (layout, table_type).get_script (script_index).get_lang_sys (language_index);
+  hb_ot_layout_t *layout = _hb_ot_face_get_layout (face);
+  const LangSys &l = get_gsubgpos_table (layout, table_tag).get_script (script_index).get_lang_sys (language_index);
 
   return l.get_feature_count ();
 }
 
 unsigned int
-hb_ot_layout_language_get_feature_index (hb_ot_layout_t            *layout,
-                                        hb_ot_layout_table_type_t  table_type,
-                                        unsigned int               script_index,
-                                        unsigned int               language_index,
-                                        unsigned int               num_feature)
-{
-  const GSUBGPOS &g = get_gsubgpos_table (layout, table_type);
+hb_ot_layout_language_get_feature_index (hb_face_t    *face,
+                                        hb_tag_t      table_tag,
+                                        unsigned int  script_index,
+                                        unsigned int  language_index,
+                                        unsigned int  num_feature)
+{
+  hb_ot_layout_t *layout = _hb_ot_face_get_layout (face);
+  const GSUBGPOS &g = get_gsubgpos_table (layout, table_tag);
   const LangSys &l = g.get_script (script_index).get_lang_sys (language_index);
 
   return l.get_feature_index (num_feature);
 }
 
 hb_tag_t
-hb_ot_layout_language_get_feature_tag (hb_ot_layout_t            *layout,
-                                      hb_ot_layout_table_type_t  table_type,
-                                      unsigned int               script_index,
-                                      unsigned int               language_index,
-                                      unsigned int               num_feature)
-{
-  const GSUBGPOS &g = get_gsubgpos_table (layout, table_type);
+hb_ot_layout_language_get_feature_tag (hb_face_t    *face,
+                                      hb_tag_t      table_tag,
+                                      unsigned int  script_index,
+                                      unsigned int  language_index,
+                                      unsigned int  num_feature)
+{
+  hb_ot_layout_t *layout = _hb_ot_face_get_layout (face);
+  const GSUBGPOS &g = get_gsubgpos_table (layout, table_tag);
   const LangSys &l = g.get_script (script_index).get_lang_sys (language_index);
   unsigned int feature_index = l.get_feature_index (num_feature);
 
@@ -536,15 +546,16 @@ hb_ot_layout_language_get_feature_tag (hb_ot_layout_t            *layout,
 
 
 hb_bool_t
-hb_ot_layout_language_find_feature (hb_ot_layout_t            *layout,
-                                   hb_ot_layout_table_type_t  table_type,
-                                   unsigned int               script_index,
-                                   unsigned int               language_index,
-                                   hb_tag_t                   feature_tag,
-                                   unsigned int              *feature_index)
+hb_ot_layout_language_find_feature (hb_face_t    *face,
+                                   hb_tag_t      table_tag,
+                                   unsigned int  script_index,
+                                   unsigned int  language_index,
+                                   hb_tag_t      feature_tag,
+                                   unsigned int *feature_index)
 {
   ASSERT_STATIC (NO_INDEX == HB_OT_LAYOUT_NO_FEATURE_INDEX);
-  const GSUBGPOS &g = get_gsubgpos_table (layout, table_type);
+  hb_ot_layout_t *layout = _hb_ot_face_get_layout (face);
+  const GSUBGPOS &g = get_gsubgpos_table (layout, table_tag);
   const LangSys &l = g.get_script (script_index).get_lang_sys (language_index);
 
   unsigned int num_features = l.get_feature_count ();
@@ -562,23 +573,25 @@ hb_ot_layout_language_find_feature (hb_ot_layout_t            *layout,
 }
 
 unsigned int
-hb_ot_layout_feature_get_lookup_count (hb_ot_layout_t            *layout,
-                                      hb_ot_layout_table_type_t  table_type,
-                                      unsigned int               feature_index)
+hb_ot_layout_feature_get_lookup_count (hb_face_t    *face,
+                                      hb_tag_t      table_tag,
+                                      unsigned int  feature_index)
 {
-  const GSUBGPOS &g = get_gsubgpos_table (layout, table_type);
+  hb_ot_layout_t *layout = _hb_ot_face_get_layout (face);
+  const GSUBGPOS &g = get_gsubgpos_table (layout, table_tag);
   const Feature &f = g.get_feature (feature_index);
 
   return f.get_lookup_count ();
 }
 
 unsigned int
-hb_ot_layout_feature_get_lookup_index (hb_ot_layout_t            *layout,
-                                      hb_ot_layout_table_type_t  table_type,
-                                      unsigned int               feature_index,
-                                      unsigned int               num_lookup)
+hb_ot_layout_feature_get_lookup_index (hb_face_t    *face,
+                                      hb_tag_t      table_tag,
+                                      unsigned int  feature_index,
+                                      unsigned int  num_lookup)
 {
-  const GSUBGPOS &g = get_gsubgpos_table (layout, table_type);
+  hb_ot_layout_t *layout = _hb_ot_face_get_layout (face);
+  const GSUBGPOS &g = get_gsubgpos_table (layout, table_tag);
   const Feature &f = g.get_feature (feature_index);
 
   return f.get_lookup_index (num_lookup);
@@ -589,12 +602,22 @@ hb_ot_layout_feature_get_lookup_index (hb_ot_layout_t            *layout,
  */
 
 hb_bool_t
-hb_ot_layout_substitute_lookup (hb_ot_layout_t              *layout,
+hb_ot_layout_has_substitution (hb_face_t *face)
+{
+  hb_ot_layout_t *layout = _hb_ot_face_get_layout (face);
+  return layout->gsub != &Null(GSUB);
+}
+
+hb_bool_t
+hb_ot_layout_substitute_lookup (hb_face_t                   *face,
                                hb_buffer_t                 *buffer,
-                               unsigned int                 lookup_index,
+                               unsigned int                 lookup_index,
                                hb_ot_layout_feature_mask_t  mask)
 {
-  return layout->gsub->substitute_lookup (layout, buffer, lookup_index, mask);
+  hb_ot_layout_context_t context;
+  context.font = NULL;
+  context.layout = _hb_ot_face_get_layout (face);
+  return context.layout->gsub->substitute_lookup (&context, buffer, lookup_index, mask);
 }
 
 /*
@@ -602,10 +625,21 @@ hb_ot_layout_substitute_lookup (hb_ot_layout_t              *layout,
  */
 
 hb_bool_t
-hb_ot_layout_position_lookup   (hb_ot_layout_t              *layout,
+hb_ot_layout_has_positioning (hb_face_t *face)
+{
+  hb_ot_layout_t *layout = _hb_ot_face_get_layout (face);
+  return layout->gpos != &Null(GPOS);
+}
+
+hb_bool_t
+hb_ot_layout_position_lookup   (hb_face_t                   *face,
+                               hb_font_t                   *font,
                                hb_buffer_t                 *buffer,
-                               unsigned int                 lookup_index,
+                               unsigned int                 lookup_index,
                                hb_ot_layout_feature_mask_t  mask)
 {
-  return layout->gpos->position_lookup (layout, buffer, lookup_index, mask);
+  hb_ot_layout_context_t context;
+  context.font = font;
+  context.layout = _hb_ot_face_get_layout (font->face);
+  return context.layout->gpos->position_lookup (&context, buffer, lookup_index, mask);
 }
index d19f558..889a2bd 100644 (file)
 
 #include "hb-common.h"
 #include "hb-buffer.h"
+#include "hb-font.h"
 
 HB_BEGIN_DECLS
 
-/*
- * hb_ot_layout_t
- */
-
-typedef struct _hb_ot_layout_t hb_ot_layout_t;
-
-hb_ot_layout_t *
-hb_ot_layout_create (void);
-
-hb_ot_layout_t *
-hb_ot_layout_create_for_data (const char *font_data,
-                             int         face_index);
-
-hb_ot_layout_t *
-hb_ot_layout_create_for_tables (const char *gdef_data,
-                               const char *gsub_data,
-                               const char *gpos_data);
-
-void
-hb_ot_layout_destroy (hb_ot_layout_t *layout);
-
-void
-hb_ot_layout_set_scale (hb_ot_layout_t *layout,
-                       hb_16dot16_t x_scale, hb_16dot16_t y_scale);
-
-void
-hb_ot_layout_set_ppem (hb_ot_layout_t *layout,
-                      unsigned int x_ppem, unsigned int y_ppem);
-
-/* TODO sanitizing API/constructor (make_writable_func_t) */
-/* TODO get_table_func_t constructor */
+#define HB_OT_TAG_GDEF HB_TAG('G','D','E','F')
+#define HB_OT_TAG_GSUB HB_TAG('G','S','U','B')
+#define HB_OT_TAG_GPOS HB_TAG('G','P','O','S')
 
 /*
  * GDEF
@@ -76,33 +49,37 @@ typedef enum {
   HB_OT_LAYOUT_GLYPH_CLASS_COMPONENT   = 0x0010
 } hb_ot_layout_glyph_class_t;
 
+/* XXX These should eventually be removed as we move synthesized glyph
+ * classes in harfbuzz. */
+
 hb_bool_t
-hb_ot_layout_has_font_glyph_classes (hb_ot_layout_t *layout);
+hb_ot_layout_has_font_glyph_classes (hb_face_t *face);
 
 hb_ot_layout_glyph_class_t
-hb_ot_layout_get_glyph_class (hb_ot_layout_t *layout,
+hb_ot_layout_get_glyph_class (hb_face_t      *face,
                              hb_codepoint_t  glyph);
 
 void
-hb_ot_layout_set_glyph_class (hb_ot_layout_t            *layout,
+hb_ot_layout_set_glyph_class (hb_face_t                 *face,
                              hb_codepoint_t             glyph,
                              hb_ot_layout_glyph_class_t klass);
 
 void
-hb_ot_layout_build_glyph_classes (hb_ot_layout_t *layout,
-                                 uint16_t        num_total_glyphs,
-                                 hb_codepoint_t *glyphs,
-                                 unsigned char  *klasses,
-                                 uint16_t        count);
+hb_ot_layout_build_glyph_classes (hb_face_t      *face,
+                               uint16_t        num_total_glyphs,
+                               hb_codepoint_t *glyphs,
+                               unsigned char  *klasses,
+                               uint16_t        count);
 
 hb_bool_t
-hb_ot_layout_get_attach_points (hb_ot_layout_t *layout,
+hb_ot_layout_get_attach_points (hb_face_t      *face,
                                hb_codepoint_t  glyph,
                                unsigned int   *point_count /* IN/OUT */,
                                unsigned int   *point_array /* OUT */);
 
 hb_bool_t
-hb_ot_layout_get_lig_carets (hb_ot_layout_t *layout,
+hb_ot_layout_get_lig_carets (hb_face_t      *face,
+                            hb_font_t      *font,
                             hb_codepoint_t  glyph,
                             unsigned int   *caret_count /* IN/OUT */,
                             int            *caret_array /* OUT */);
@@ -111,12 +88,6 @@ hb_ot_layout_get_lig_carets (hb_ot_layout_t *layout,
  * GSUB/GPOS
  */
 
-typedef enum {
-  HB_OT_LAYOUT_TABLE_TYPE_GSUB,
-  HB_OT_LAYOUT_TABLE_TYPE_GPOS,
-  HB_OT_LAYOUT_TABLE_TYPE_NONE
-} hb_ot_layout_table_type_t;
-
 typedef uint32_t hb_ot_layout_feature_mask_t;
 
 #define HB_OT_LAYOUT_NO_SCRIPT_INDEX           ((unsigned int) 0xFFFF)
@@ -126,114 +97,115 @@ typedef uint32_t hb_ot_layout_feature_mask_t;
 #define HB_OT_LAYOUT_TAG_DEFAULT_LANGUAGE      HB_TAG ('d', 'f', 'l', 't')
 
 unsigned int
-hb_ot_layout_table_get_script_count (hb_ot_layout_t            *layout,
-                                    hb_ot_layout_table_type_t  table_type);
+hb_ot_layout_table_get_script_count (hb_face_t *face,
+                                    hb_tag_t   table_tag);
 
 hb_tag_t
-hb_ot_layout_table_get_script_tag (hb_ot_layout_t            *layout,
-                                  hb_ot_layout_table_type_t  table_type,
-                                  unsigned int               script_index);
+hb_ot_layout_table_get_script_tag (hb_face_t    *face,
+                                  hb_tag_t      table_tag,
+                                  unsigned int  script_index);
 
 hb_bool_t
-hb_ot_layout_table_find_script (hb_ot_layout_t            *layout,
-                               hb_ot_layout_table_type_t  table_type,
-                               hb_tag_t                   script_tag,
-                               unsigned int              *script_index);
+hb_ot_layout_table_find_script (hb_face_t    *face,
+                               hb_tag_t      table_tag,
+                               hb_tag_t      script_tag,
+                               unsigned int *script_index);
 
 unsigned int
-hb_ot_layout_table_get_feature_count (hb_ot_layout_t            *layout,
-                                     hb_ot_layout_table_type_t  table_type);
+hb_ot_layout_table_get_feature_count (hb_face_t *face,
+                                     hb_tag_t   table_tag);
 
 hb_tag_t
-hb_ot_layout_table_get_feature_tag (hb_ot_layout_t            *layout,
-                                   hb_ot_layout_table_type_t  table_type,
-                                   unsigned int               feature_index);
+hb_ot_layout_table_get_feature_tag (hb_face_t    *face,
+                                   hb_tag_t      table_tag,
+                                   unsigned int  feature_index);
 
 hb_bool_t
-hb_ot_layout_table_find_feature (hb_ot_layout_t            *layout,
-                                hb_ot_layout_table_type_t  table_type,
-                                hb_tag_t                   feature_tag,
-                                unsigned int              *feature_index);
+hb_ot_layout_table_find_feature (hb_face_t    *face,
+                                hb_tag_t      table_tag,
+                                hb_tag_t      feature_tag,
+                                unsigned int *feature_index);
 
 unsigned int
-hb_ot_layout_table_get_lookup_count (hb_ot_layout_t            *layout,
-                                    hb_ot_layout_table_type_t  table_type);
+hb_ot_layout_table_get_lookup_count (hb_face_t  *face,
+                                    hb_tag_t    table_tag);
 
 unsigned int
-hb_ot_layout_script_get_language_count (hb_ot_layout_t            *layout,
-                                       hb_ot_layout_table_type_t  table_type,
-                                       unsigned int               script_index);
+hb_ot_layout_script_get_language_count (hb_face_t    *face,
+                                       hb_tag_t      table_tag,
+                                       unsigned int  script_index);
 
 hb_tag_t
-hb_ot_layout_script_get_language_tag (hb_ot_layout_t            *layout,
-                                     hb_ot_layout_table_type_t  table_type,
-                                     unsigned int               script_index,
-                                     unsigned int               language_index);
+hb_ot_layout_script_get_language_tag (hb_face_t    *face,
+                                     hb_tag_t      table_tag,
+                                     unsigned int  script_index,
+                                     unsigned int  language_index);
 
 hb_bool_t
-hb_ot_layout_script_find_language (hb_ot_layout_t            *layout,
-                                  hb_ot_layout_table_type_t  table_type,
-                                  unsigned int               script_index,
-                                  hb_tag_t                   language_tag,
-                                  unsigned int              *language_index);
+hb_ot_layout_script_find_language (hb_face_t    *face,
+                                  hb_tag_t      table_tag,
+                                  unsigned int  script_index,
+                                  hb_tag_t      language_tag,
+                                  unsigned int *language_index);
 
 hb_bool_t
-hb_ot_layout_language_get_required_feature_index (hb_ot_layout_t            *layout,
-                                                 hb_ot_layout_table_type_t  table_type,
-                                                 unsigned int               script_index,
-                                                 unsigned int               language_index,
-                                                 unsigned int              *feature_index);
+hb_ot_layout_language_get_required_feature_index (hb_face_t    *face,
+                                                 hb_tag_t      table_tag,
+                                                 unsigned int  script_index,
+                                                 unsigned int  language_index,
+                                                 unsigned int *feature_index);
 
 unsigned int
-hb_ot_layout_language_get_feature_count (hb_ot_layout_t            *layout,
-                                        hb_ot_layout_table_type_t  table_type,
-                                        unsigned int               script_index,
-                                        unsigned int               language_index);
+hb_ot_layout_language_get_feature_count (hb_face_t    *face,
+                                        hb_tag_t      table_tag,
+                                        unsigned int  script_index,
+                                        unsigned int  language_index);
 
 unsigned int
-hb_ot_layout_language_get_feature_index (hb_ot_layout_t            *layout,
-                                        hb_ot_layout_table_type_t  table_type,
-                                        unsigned int               script_index,
-                                        unsigned int               language_index,
-                                        unsigned int               num_feature);
+hb_ot_layout_language_get_feature_index (hb_face_t    *face,
+                                        hb_tag_t      table_tag,
+                                        unsigned int  script_index,
+                                        unsigned int  language_index,
+                                        unsigned int  num_feature);
 
 hb_tag_t
-hb_ot_layout_language_get_feature_tag (hb_ot_layout_t            *layout,
-                                      hb_ot_layout_table_type_t  table_type,
-                                      unsigned int               script_index,
-                                      unsigned int               language_index,
-                                      unsigned int               num_feature);
+hb_ot_layout_language_get_feature_tag (hb_face_t    *face,
+                                      hb_tag_t      table_tag,
+                                      unsigned int  script_index,
+                                      unsigned int  language_index,
+                                      unsigned int  num_feature);
 
 hb_bool_t
-hb_ot_layout_language_find_feature (hb_ot_layout_t            *layout,
-                                   hb_ot_layout_table_type_t  table_type,
-                                   unsigned int               script_index,
-                                   unsigned int               language_index,
-                                   hb_tag_t                   feature_tag,
-                                   unsigned int              *feature_index);
+hb_ot_layout_language_find_feature (hb_face_t    *face,
+                                   hb_tag_t      table_tag,
+                                   unsigned int  script_index,
+                                   unsigned int  language_index,
+                                   hb_tag_t      feature_tag,
+                                   unsigned int *feature_index);
 
 unsigned int
-hb_ot_layout_feature_get_lookup_count (hb_ot_layout_t            *layout,
-                                      hb_ot_layout_table_type_t  table_type,
-                                      unsigned int               feature_index);
+hb_ot_layout_feature_get_lookup_count (hb_face_t    *face,
+                                      hb_tag_t      table_tag,
+                                      unsigned int  feature_index);
 
 unsigned int
-hb_ot_layout_feature_get_lookup_index (hb_ot_layout_t            *layout,
-                                      hb_ot_layout_table_type_t  table_type,
-                                      unsigned int               feature_index,
-                                      unsigned int               num_lookup);
+hb_ot_layout_feature_get_lookup_index (hb_face_t    *face,
+                                      hb_tag_t      table_tag,
+                                      unsigned int  feature_index,
+                                      unsigned int  num_lookup);
 
 /*
  * GSUB
  */
 
 hb_bool_t
-hb_ot_layout_has_substitution (hb_ot_layout_t *layout);
+hb_ot_layout_has_substitution (hb_face_t *face);
 
+/* GSUB is not font-size dependent, so we apply on face */
 hb_bool_t
-hb_ot_layout_substitute_lookup (hb_ot_layout_t              *layout,
+hb_ot_layout_substitute_lookup (hb_face_t                   *face,
                                hb_buffer_t                 *buffer,
-                               unsigned int                 lookup_index,
+                               unsigned int                 lookup_index,
                                hb_ot_layout_feature_mask_t  mask);
 
 /*
@@ -241,12 +213,13 @@ hb_ot_layout_substitute_lookup (hb_ot_layout_t              *layout,
  */
 
 hb_bool_t
-hb_ot_layout_has_positioning (hb_ot_layout_t *layout);
+hb_ot_layout_has_positioning (hb_face_t *face);
 
 hb_bool_t
-hb_ot_layout_position_lookup   (hb_ot_layout_t              *layout,
+hb_ot_layout_position_lookup   (hb_face_t                   *face,
+                               hb_font_t                   *font,
                                hb_buffer_t                 *buffer,
-                               unsigned int                 lookup_index,
+                               unsigned int                 lookup_index,
                                hb_ot_layout_feature_mask_t  mask);