Move layout_context into apply_context
diff --git a/src/hb-ot-layout-gpos-private.hh b/src/hb-ot-layout-gpos-private.hh
index 8c75c9f..8fe93eb 100644
--- a/src/hb-ot-layout-gpos-private.hh
+++ b/src/hb-ot-layout-gpos-private.hh
@@ -87,7 +87,7 @@
   inline unsigned int get_size () const
   { return get_len () * Value::get_size (); }
 
-  void apply_value (hb_ot_layout_context_t       *layout_context,
+  void apply_value (hb_ot_layout_context_t       *layout,
 		    const char                   *base,
 		    const Value                  *values,
 		    hb_internal_glyph_position_t *glyph_pos) const
@@ -98,8 +98,8 @@
 
     if (!format) return;
 
-    x_scale = layout_context->font->x_scale;
-    y_scale = layout_context->font->y_scale;
+    x_scale = layout->font->x_scale;
+    y_scale = layout->font->y_scale;
     /* design units -> fractional pixel */
     if (format & xPlacement) glyph_pos->x_offset  += _hb_16dot16_mul_round (x_scale, *(SHORT*)values++);
     if (format & yPlacement) glyph_pos->y_offset  += _hb_16dot16_mul_round (y_scale, *(SHORT*)values++);
@@ -108,8 +108,8 @@
 
     if (!has_device ()) return;
 
-    x_ppem = layout_context->font->x_ppem;
-    y_ppem = layout_context->font->y_ppem;
+    x_ppem = layout->font->x_ppem;
+    y_ppem = layout->font->y_ppem;
 
     if (!x_ppem && !y_ppem) return;
 
@@ -199,11 +199,11 @@
   friend struct Anchor;
 
   private:
-  inline void get_anchor (hb_ot_layout_context_t *layout_context, hb_codepoint_t glyph_id HB_UNUSED,
+  inline void get_anchor (hb_ot_layout_context_t *layout, hb_codepoint_t glyph_id HB_UNUSED,
 			  hb_position_t *x, hb_position_t *y) const
   {
-      *x = _hb_16dot16_mul_round (layout_context->font->x_scale, xCoordinate);
-      *y = _hb_16dot16_mul_round (layout_context->font->y_scale, yCoordinate);
+      *x = _hb_16dot16_mul_round (layout->font->x_scale, xCoordinate);
+      *y = _hb_16dot16_mul_round (layout->font->y_scale, yCoordinate);
   }
 
   inline bool sanitize (hb_sanitize_context_t *context) {
@@ -223,18 +223,18 @@
   friend struct Anchor;
 
   private:
-  inline void get_anchor (hb_ot_layout_context_t *layout_context, hb_codepoint_t glyph_id,
+  inline void get_anchor (hb_ot_layout_context_t *layout, hb_codepoint_t glyph_id,
 			  hb_position_t *x, hb_position_t *y) const
   {
-      unsigned int x_ppem = layout_context->font->x_ppem;
-      unsigned int y_ppem = layout_context->font->y_ppem;
+      unsigned int x_ppem = layout->font->x_ppem;
+      unsigned int y_ppem = layout->font->y_ppem;
       hb_position_t cx, cy;
       hb_bool_t ret;
 
       if (x_ppem || y_ppem)
-	ret = hb_font_get_contour_point (layout_context->font, layout_context->face, anchorPoint, glyph_id, &cx, &cy);
-      *x = x_ppem && ret ? cx : _hb_16dot16_mul_round (layout_context->font->x_scale, xCoordinate);
-      *y = y_ppem && ret ? cy : _hb_16dot16_mul_round (layout_context->font->y_scale, yCoordinate);
+	ret = hb_font_get_contour_point (layout->font, layout->face, anchorPoint, glyph_id, &cx, &cy);
+      *x = x_ppem && ret ? cx : _hb_16dot16_mul_round (layout->font->x_scale, xCoordinate);
+      *y = y_ppem && ret ? cy : _hb_16dot16_mul_round (layout->font->y_scale, yCoordinate);
   }
 
   inline bool sanitize (hb_sanitize_context_t *context) {
@@ -255,17 +255,17 @@
   friend struct Anchor;
 
   private:
-  inline void get_anchor (hb_ot_layout_context_t *layout_context, hb_codepoint_t glyph_id HB_UNUSED,
+  inline void get_anchor (hb_ot_layout_context_t *layout, hb_codepoint_t glyph_id HB_UNUSED,
 			  hb_position_t *x, hb_position_t *y) const
   {
-      *x = _hb_16dot16_mul_round (layout_context->font->x_scale, xCoordinate);
-      *y = _hb_16dot16_mul_round (layout_context->font->y_scale, yCoordinate);
+      *x = _hb_16dot16_mul_round (layout->font->x_scale, xCoordinate);
+      *y = _hb_16dot16_mul_round (layout->font->y_scale, yCoordinate);
 
       /* pixel -> fractional pixel */
-      if (layout_context->font->x_ppem)
-	*x += (this+xDeviceTable).get_delta (layout_context->font->x_ppem) << 16;
-      if (layout_context->font->y_ppem)
-	*y += (this+yDeviceTable).get_delta (layout_context->font->y_ppem) << 16;
+      if (layout->font->x_ppem)
+	*x += (this+xDeviceTable).get_delta (layout->font->x_ppem) << 16;
+      if (layout->font->y_ppem)
+	*y += (this+yDeviceTable).get_delta (layout->font->y_ppem) << 16;
   }
 
   inline bool sanitize (hb_sanitize_context_t *context) {
@@ -292,15 +292,15 @@
 
 struct Anchor
 {
-  inline void get_anchor (hb_ot_layout_context_t *layout_context, hb_codepoint_t glyph_id,
+  inline void get_anchor (hb_ot_layout_context_t *layout, 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_context, glyph_id, x, y); return;
-    case 2: u.format2->get_anchor (layout_context, glyph_id, x, y); return;
-    case 3: u.format3->get_anchor (layout_context, glyph_id, x, y); return;
-    default:							    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;
     }
   }
 
@@ -388,8 +388,8 @@
 
     hb_position_t mark_x, mark_y, base_x, base_y;
 
-    mark_anchor.get_anchor (layout_context, IN_CURGLYPH (), &mark_x, &mark_y);
-    glyph_anchor.get_anchor (layout_context, IN_GLYPH (glyph_pos), &base_x, &base_y);
+    mark_anchor.get_anchor (context->layout, IN_CURGLYPH (), &mark_x, &mark_y);
+    glyph_anchor.get_anchor (context->layout, IN_GLYPH (glyph_pos), &base_x, &base_y);
 
     hb_internal_glyph_position_t *o = POSITION (buffer->in_pos);
     o->x_advance = 0;
@@ -428,7 +428,7 @@
     if (likely (index == NOT_COVERED))
       return false;
 
-    valueFormat.apply_value (layout_context, CharP(this), values, CURPOSITION ());
+    valueFormat.apply_value (context->layout, CharP(this), values, CURPOSITION ());
 
     buffer->in_pos++;
     return true;
@@ -469,7 +469,7 @@
     if (likely (index >= valueCount))
       return false;
 
-    valueFormat.apply_value (layout_context, CharP(this),
+    valueFormat.apply_value (context->layout, CharP(this),
 			     &values[index * valueFormat.get_len ()],
 			     CURPOSITION ());
 
@@ -581,7 +581,7 @@
       return false;
 
     unsigned int j = buffer->in_pos + 1;
-    while (_hb_ot_layout_skip_mark (layout_context->face, IN_INFO (j), context->lookup_flag, NULL))
+    while (_hb_ot_layout_skip_mark (context->layout->face, IN_INFO (j), context->lookup_flag, NULL))
     {
       if (unlikely (j == end))
 	return false;
@@ -599,8 +599,8 @@
     {
       if (IN_GLYPH (j) == record->secondGlyph)
       {
-	valueFormat1.apply_value (layout_context, CharP(this), &record->values[0], CURPOSITION ());
-	valueFormat2.apply_value (layout_context, CharP(this), &record->values[len1], POSITION (j));
+	valueFormat1.apply_value (context->layout, CharP(this), &record->values[0], CURPOSITION ());
+	valueFormat2.apply_value (context->layout, CharP(this), &record->values[len1], POSITION (j));
 	if (len2)
 	  j++;
 	buffer->in_pos = j;
@@ -674,7 +674,7 @@
       return false;
 
     unsigned int j = buffer->in_pos + 1;
-    while (_hb_ot_layout_skip_mark (layout_context->face, IN_INFO (j), context->lookup_flag, NULL))
+    while (_hb_ot_layout_skip_mark (context->layout->face, IN_INFO (j), context->lookup_flag, NULL))
     {
       if (unlikely (j == end))
 	return false;
@@ -691,8 +691,8 @@
       return false;
 
     const Value *v = &values[record_len * (klass1 * class2Count + klass2)];
-    valueFormat1.apply_value (layout_context, CharP(this), v, CURPOSITION ());
-    valueFormat2.apply_value (layout_context, CharP(this), v + len1, POSITION (j));
+    valueFormat1.apply_value (context->layout, CharP(this), v, CURPOSITION ());
+    valueFormat2.apply_value (context->layout, CharP(this), v + len1, POSITION (j));
 
     if (len2)
       j++;
@@ -927,7 +927,7 @@
        Since horizontal advance widths or vertical advance heights
        can be used alone but not together, no ambiguity occurs.        */
 
-    struct hb_ot_layout_context_t::info_t::gpos_t *gpi = &layout_context->info.gpos;
+    struct hb_ot_layout_context_t::info_t::gpos_t *gpi = &context->layout->info.gpos;
     hb_codepoint_t last_pos = gpi->last;
     gpi->last = HB_OT_LAYOUT_GPOS_NO_LAST;
 
@@ -945,7 +945,7 @@
       goto end;
 
     hb_position_t entry_x, entry_y;
-    (this+record.entryAnchor).get_anchor (layout_context, IN_CURGLYPH (), &entry_x, &entry_y);
+    (this+record.entryAnchor).get_anchor (context->layout, IN_CURGLYPH (), &entry_x, &entry_y);
 
     /* TODO vertical */
 
@@ -975,7 +975,7 @@
     if (record.exitAnchor)
     {
       gpi->last = buffer->in_pos;
-      (this+record.exitAnchor).get_anchor (layout_context, IN_CURGLYPH (), &gpi->anchor_x, &gpi->anchor_y);
+      (this+record.exitAnchor).get_anchor (context->layout, IN_CURGLYPH (), &gpi->anchor_x, &gpi->anchor_y);
     }
 
     buffer->in_pos++;
@@ -1055,7 +1055,7 @@
       if (unlikely (!j))
 	return false;
       j--;
-    } while (_hb_ot_layout_skip_mark (layout_context->face, IN_INFO (j), LookupFlag::IgnoreMarks, &property));
+    } while (_hb_ot_layout_skip_mark (context->layout->face, IN_INFO (j), LookupFlag::IgnoreMarks, &property));
 
 #if 0
     /* The following assertion is too strong. */
@@ -1158,7 +1158,7 @@
       if (unlikely (!j))
 	return false;
       j--;
-    } while (_hb_ot_layout_skip_mark (layout_context->face, IN_INFO (j), LookupFlag::IgnoreMarks, &property));
+    } while (_hb_ot_layout_skip_mark (context->layout->face, IN_INFO (j), LookupFlag::IgnoreMarks, &property));
 
 #if 0
     /* The following assertion is too strong. */
@@ -1278,7 +1278,7 @@
       if (unlikely (!j))
 	return false;
       j--;
-    } while (_hb_ot_layout_skip_mark (layout_context->face, IN_INFO (j), context->lookup_flag, &property));
+    } while (_hb_ot_layout_skip_mark (context->layout->face, IN_INFO (j), context->lookup_flag, &property));
 
     if (!(property & HB_OT_LAYOUT_GLYPH_CLASS_MARK))
       return false;
@@ -1479,7 +1479,7 @@
   inline const PosLookupSubTable& get_subtable (unsigned int i) const
   { return this+CastR<OffsetArrayOf<PosLookupSubTable> > (subTable)[i]; }
 
-  inline bool apply_once (hb_ot_layout_context_t *layout_context,
+  inline bool apply_once (hb_ot_layout_context_t *layout,
 			  hb_buffer_t    *buffer,
 			  unsigned int    context_length,
 			  unsigned int    nesting_level_left,
@@ -1488,10 +1488,11 @@
     unsigned int lookup_type = get_type ();
     hb_apply_context_t context[1];
 
+    context->layout = layout;
     context->nesting_level_left = nesting_level_left;
     context->lookup_flag = get_flag ();
 
-    if (!_hb_ot_layout_check_glyph_property (layout_context->face, IN_CURINFO (), context->lookup_flag, &context->property))
+    if (!_hb_ot_layout_check_glyph_property (context->layout->face, IN_CURINFO (), context->lookup_flag, &context->property))
       return false;
 
     for (unsigned int i = 0; i < get_subtable_count (); i++)
@@ -1501,7 +1502,7 @@
     return false;
   }
 
-   inline bool apply_string (hb_ot_layout_context_t *layout_context,
+   inline bool apply_string (hb_ot_layout_context_t *layout,
 			     hb_buffer_t *buffer,
 			     hb_mask_t    mask) const
   {
@@ -1510,7 +1511,7 @@
     if (unlikely (!buffer->in_length))
       return false;
 
-    layout_context->info.gpos.last = HB_OT_LAYOUT_GPOS_NO_LAST; /* no last valid glyph for cursive pos. */
+    layout->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)
@@ -1518,7 +1519,7 @@
       bool done;
       if (~IN_MASK (buffer->in_pos) & mask)
       {
-	  done = apply_once (layout_context, buffer, NO_CONTEXT, MAX_NESTING_LEVEL, 0);
+	  done = apply_once (layout, buffer, NO_CONTEXT, MAX_NESTING_LEVEL, 0);
 	  ret |= done;
       }
       else
@@ -1526,7 +1527,7 @@
           done = false;
 	  /* Contrary to properties defined in GDEF, user-defined properties
 	     will always stop a possible cursive positioning.                */
-	  layout_context->info.gpos.last = HB_OT_LAYOUT_GPOS_NO_LAST;
+	  layout->info.gpos.last = HB_OT_LAYOUT_GPOS_NO_LAST;
       }
 
       if (!done)
@@ -1558,11 +1559,11 @@
   inline const PosLookup& get_lookup (unsigned int i) const
   { return CastR<PosLookup> (GSUBGPOS::get_lookup (i)); }
 
-  inline bool position_lookup (hb_ot_layout_context_t *layout_context,
+  inline bool position_lookup (hb_ot_layout_context_t *layout,
 			       hb_buffer_t  *buffer,
 			       unsigned int  lookup_index,
 			       hb_mask_t     mask) const
-  { return get_lookup (lookup_index).apply_string (layout_context, buffer, mask); }
+  { return get_lookup (lookup_index).apply_string (layout, buffer, mask); }
 
   inline bool sanitize (hb_sanitize_context_t *context) {
     TRACE_SANITIZE ();
@@ -1593,7 +1594,7 @@
 
 static inline bool position_lookup (APPLY_ARG_DEF, unsigned int lookup_index)
 {
-  const GPOS &gpos = *(layout_context->face->ot_layout.gpos);
+  const GPOS &gpos = *(context->layout->face->ot_layout.gpos);
   const PosLookup &l = gpos.get_lookup (lookup_index);
 
   if (unlikely (context->nesting_level_left == 0))
@@ -1602,7 +1603,7 @@
   if (unlikely (context_length < 1))
     return false;
 
-  return l.apply_once (layout_context, buffer, context_length, context->nesting_level_left - 1, apply_depth + 1);
+  return l.apply_once (context->layout, buffer, context_length, context->nesting_level_left - 1, apply_depth + 1);
 }
 
 
diff --git a/src/hb-ot-layout-gsub-private.hh b/src/hb-ot-layout-gsub-private.hh
index 2dfe7c2..f2f8954 100644
--- a/src/hb-ot-layout-gsub-private.hh
+++ b/src/hb-ot-layout-gsub-private.hh
@@ -48,8 +48,8 @@
     _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_context->face))
-      _hb_ot_layout_set_glyph_property (layout_context->face, glyph_id, context->property);
+    if (_hb_ot_layout_has_new_glyph_classes (context->layout->face))
+      _hb_ot_layout_set_glyph_property (context->layout->face, glyph_id, context->property);
 
     return true;
   }
@@ -91,8 +91,8 @@
     _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_context->face))
-      _hb_ot_layout_set_glyph_property (layout_context->face, glyph_id, context->property);
+    if (_hb_ot_layout_has_new_glyph_classes (context->layout->face))
+      _hb_ot_layout_set_glyph_property (context->layout->face, glyph_id, context->property);
 
     return true;
   }
@@ -165,7 +165,7 @@
 				       0xFFFF, 0xFFFF);
 
     /* This is a guess only ... */
-    if (_hb_ot_layout_has_new_glyph_classes (layout_context->face))
+    if (_hb_ot_layout_has_new_glyph_classes (context->layout->face))
     {
       unsigned int property = context->property;
       if (property == HB_OT_LAYOUT_GLYPH_CLASS_LIGATURE)
@@ -173,7 +173,7 @@
 
       unsigned int count = substitute.len;
       for (unsigned int n = 0; n < count; n++)
-	_hb_ot_layout_set_glyph_property (layout_context->face, substitute[n], property);
+	_hb_ot_layout_set_glyph_property (context->layout->face, substitute[n], property);
     }
 
     return true;
@@ -284,8 +284,8 @@
     unsigned int alt_index = 0;
 
     /* XXX callback to user to choose alternate
-    if (layout_context->face->altfunc)
-      alt_index = (layout_context->face->altfunc)(layout_context->layout, buffer,
+    if (context->layout->face->altfunc)
+      alt_index = (context->layout->face->altfunc)(context->layout->layout, buffer,
 				    buffer->out_pos, glyph_id,
 				    alt_set.len, alt_set.array);
 				   */
@@ -298,8 +298,8 @@
     _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_context->face))
-      _hb_ot_layout_set_glyph_property (layout_context->face, glyph_id, context->property);
+    if (_hb_ot_layout_has_new_glyph_classes (context->layout->face))
+      _hb_ot_layout_set_glyph_property (context->layout->face, glyph_id, context->property);
 
     return true;
   }
@@ -370,7 +370,7 @@
     for (i = 1, j = buffer->in_pos + 1; i < count; i++, j++)
     {
       unsigned int property;
-      while (_hb_ot_layout_skip_mark (layout_context->face, IN_INFO (j), context->lookup_flag, &property))
+      while (_hb_ot_layout_skip_mark (context->layout->face, IN_INFO (j), context->lookup_flag, &property))
       {
 	if (unlikely (j + count - i == end))
 	  return false;
@@ -384,8 +384,8 @@
         return false;
     }
     /* This is just a guess ... */
-    if (_hb_ot_layout_has_new_glyph_classes (layout_context->face))
-      _hb_ot_layout_set_glyph_class (layout_context->face, ligGlyph,
+    if (_hb_ot_layout_has_new_glyph_classes (context->layout->face))
+      _hb_ot_layout_set_glyph_class (context->layout->face, ligGlyph,
 				     is_mark ? HB_OT_LAYOUT_GLYPH_CLASS_MARK
 					     : HB_OT_LAYOUT_GLYPH_CLASS_LIGATURE);
 
@@ -411,7 +411,7 @@
 
       for ( i = 1; i < count; i++ )
       {
-	while (_hb_ot_layout_skip_mark (layout_context->face, IN_CURINFO (), context->lookup_flag, NULL))
+	while (_hb_ot_layout_skip_mark (context->layout->face, IN_CURINFO (), context->lookup_flag, NULL))
 	  _hb_buffer_add_output_glyph (buffer, IN_CURGLYPH (), i, lig_id);
 
 	(buffer->in_pos)++;
@@ -765,7 +765,7 @@
   }
 
 
-  inline bool apply_once ( hb_ot_layout_context_t *layout_context,
+  inline bool apply_once (hb_ot_layout_context_t *layout,
 			  hb_buffer_t *buffer,
 			  unsigned int context_length,
 			  unsigned int nesting_level_left,
@@ -774,10 +774,11 @@
     unsigned int lookup_type = get_type ();
     hb_apply_context_t context[1];
 
+    context->layout = layout;
     context->nesting_level_left = nesting_level_left;
     context->lookup_flag = get_flag ();
 
-    if (!_hb_ot_layout_check_glyph_property (layout_context->face, IN_CURINFO (), context->lookup_flag, &context->property))
+    if (!_hb_ot_layout_check_glyph_property (context->layout->face, IN_CURINFO (), context->lookup_flag, &context->property))
       return false;
 
     if (unlikely (lookup_type == SubstLookupSubTable::Extension))
@@ -802,7 +803,7 @@
     return false;
   }
 
-  inline bool apply_string (hb_ot_layout_context_t *layout_context,
+  inline bool apply_string (hb_ot_layout_context_t *layout,
 			    hb_buffer_t *buffer,
 			    hb_mask_t    mask) const
   {
@@ -819,7 +820,7 @@
 	while (buffer->in_pos < buffer->in_length)
 	{
 	  if ((~IN_MASK (buffer->in_pos) & mask) &&
-	      apply_once (layout_context, buffer, NO_CONTEXT, MAX_NESTING_LEVEL, 0))
+	      apply_once (layout, buffer, NO_CONTEXT, MAX_NESTING_LEVEL, 0))
 	    ret = true;
 	  else
 	    _hb_buffer_next_glyph (buffer);
@@ -835,7 +836,7 @@
 	do
 	{
 	  if ((~IN_MASK (buffer->in_pos) & mask) &&
-	      apply_once (layout_context, buffer, NO_CONTEXT, MAX_NESTING_LEVEL, 0))
+	      apply_once (layout, buffer, NO_CONTEXT, MAX_NESTING_LEVEL, 0))
 	    ret = true;
 	  else
 	    buffer->in_pos--;
@@ -869,11 +870,11 @@
   inline const SubstLookup& get_lookup (unsigned int i) const
   { return CastR<SubstLookup> (GSUBGPOS::get_lookup (i)); }
 
-  inline bool substitute_lookup (hb_ot_layout_context_t *layout_context,
+  inline bool substitute_lookup (hb_ot_layout_context_t *layout,
 				 hb_buffer_t  *buffer,
 			         unsigned int  lookup_index,
 				 hb_mask_t     mask) const
-  { return get_lookup (lookup_index).apply_string (layout_context, buffer, mask); }
+  { return get_lookup (lookup_index).apply_string (layout, buffer, mask); }
 
 
   inline bool sanitize (hb_sanitize_context_t *context) {
@@ -913,7 +914,7 @@
 
 static inline bool substitute_lookup (APPLY_ARG_DEF, unsigned int lookup_index)
 {
-  const GSUB &gsub = *(layout_context->face->ot_layout.gsub);
+  const GSUB &gsub = *(context->layout->face->ot_layout.gsub);
   const SubstLookup &l = gsub.get_lookup (lookup_index);
 
   if (unlikely (context->nesting_level_left == 0))
@@ -922,7 +923,7 @@
   if (unlikely (context_length < 1))
     return false;
 
-  return l.apply_once (layout_context, buffer, context_length, context->nesting_level_left - 1, apply_depth + 1);
+  return l.apply_once (context->layout, buffer, context_length, context->nesting_level_left - 1, apply_depth + 1);
 }
 
 
diff --git a/src/hb-ot-layout-gsubgpos-private.hh b/src/hb-ot-layout-gsubgpos-private.hh
index e542481..e91bae5 100644
--- a/src/hb-ot-layout-gsubgpos-private.hh
+++ b/src/hb-ot-layout-gsubgpos-private.hh
@@ -44,19 +44,18 @@
 
 #define APPLY_ARG_DEF \
 	hb_apply_context_t *context, \
-	hb_ot_layout_context_t *layout_context, \
 	hb_buffer_t *buffer, \
 	unsigned int context_length HB_UNUSED, \
 	unsigned int apply_depth HB_UNUSED
 #define APPLY_ARG \
 	context, \
-	layout_context, \
 	buffer, \
 	context_length, \
 	(HB_DEBUG_APPLY ? apply_depth + 1 : 0)
 
 struct hb_apply_context_t
 {
+  hb_ot_layout_context_t *layout;
   unsigned int nesting_level_left;
   unsigned int lookup_flag;
   unsigned int property; /* propety of first glyph (TODO remove) */
@@ -105,7 +104,7 @@
 
   for (i = 1, j = buffer->in_pos + 1; i < count; i++, j++)
   {
-    while (_hb_ot_layout_skip_mark (layout_context->face, IN_INFO (j), context->lookup_flag, NULL))
+    while (_hb_ot_layout_skip_mark (context->layout->face, IN_INFO (j), context->lookup_flag, NULL))
     {
       if (unlikely (j + count - i == end))
 	return false;
@@ -132,7 +131,7 @@
 
   for (unsigned int i = 0, j = buffer->out_pos - 1; i < count; i++, j--)
   {
-    while (_hb_ot_layout_skip_mark (layout_context->face, OUT_INFO (j), context->lookup_flag, NULL))
+    while (_hb_ot_layout_skip_mark (context->layout->face, OUT_INFO (j), context->lookup_flag, NULL))
     {
       if (unlikely (j + 1 == count - i))
 	return false;
@@ -160,7 +159,7 @@
 
   for (i = 0, j = buffer->in_pos + offset; i < count; i++, j++)
   {
-    while (_hb_ot_layout_skip_mark (layout_context->face, OUT_INFO (j), context->lookup_flag, NULL))
+    while (_hb_ot_layout_skip_mark (context->layout->face, OUT_INFO (j), context->lookup_flag, NULL))
     {
       if (unlikely (j + count - i == end))
 	return false;
@@ -210,7 +209,7 @@
    */
   for (unsigned int i = 0; i < count; /* NOP */)
   {
-    while (_hb_ot_layout_skip_mark (layout_context->face, IN_CURINFO (), context->lookup_flag, NULL))
+    while (_hb_ot_layout_skip_mark (context->layout->face, IN_CURINFO (), context->lookup_flag, NULL))
     {
       if (unlikely (buffer->in_pos == end))
 	return true;