[HarfBuzz] harfbuzz: Branch 'master' - 15 commits

Behdad Esfahbod behdad at kemper.freedesktop.org
Wed Oct 10 03:37:39 UTC 2018


 src/hb-aat-layout-common.hh     |    7 +++-
 src/hb-aat-layout-kerx-table.hh |   63 ++++++++++++++++++++++------------------
 src/hb-aat-layout-morx-table.hh |    8 +++--
 src/hb-aat-layout.cc            |   10 ++++--
 src/hb-aat-layout.hh            |   12 ++++---
 src/hb-machinery.hh             |   13 ++++++++
 src/hb-mutex.hh                 |    4 +-
 src/hb-ot-kern-table.hh         |   27 ++++++++---------
 src/hb-ot-shape.cc              |    2 -
 9 files changed, 89 insertions(+), 57 deletions(-)

New commits:
commit 0537a40193e803d50a99cd6b993d6d9301e84ebf
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Tue Oct 9 23:35:07 2018 -0400

    [kerx] Comment

diff --git a/src/hb-aat-layout-kerx-table.hh b/src/hb-aat-layout-kerx-table.hh
index d6747f9a..e5934c39 100644
--- a/src/hb-aat-layout-kerx-table.hh
+++ b/src/hb-aat-layout-kerx-table.hh
@@ -317,7 +317,7 @@ struct kerx
         goto skip;
 
       if (table->coverage & KerxTable::CrossStream)
-        goto skip; /* We do NOT handle cross-stream kerning. */
+        goto skip; /* We do NOT handle cross-stream kerning.  None of Apple fonts use it. */
 
       reverse = bool (table->coverage & KerxTable::Backwards) !=
 		HB_DIRECTION_IS_BACKWARD (c->buffer->props.direction);
diff --git a/src/hb-ot-kern-table.hh b/src/hb-ot-kern-table.hh
index c4e53fa6..ccb666e8 100644
--- a/src/hb-ot-kern-table.hh
+++ b/src/hb-ot-kern-table.hh
@@ -463,6 +463,7 @@ struct kern
 		       hb_buffer_t  *buffer,
 		       hb_mask_t kern_mask) const
     {
+      /* We only apply horizontal kerning in this table. */
       if (!HB_DIRECTION_IS_HORIZONTAL (buffer->props.direction))
         return;
 
commit 362d3241195bb7054c395fb4b029b6d55da4612a
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Tue Oct 9 23:27:00 2018 -0400

    [aat] Rename

diff --git a/src/hb-aat-layout-kerx-table.hh b/src/hb-aat-layout-kerx-table.hh
index c7cb367f..d6747f9a 100644
--- a/src/hb-aat-layout-kerx-table.hh
+++ b/src/hb-aat-layout-kerx-table.hh
@@ -242,7 +242,7 @@ struct KerxTable
     Vertical		= 0x80000000,	/* Set if table has vertical kerning values. */
     CrossStream		= 0x40000000,	/* Set if table has cross-stream kerning values. */
     Variation		= 0x20000000,	/* Set if table has variation kerning values. */
-    ProcessDirection	= 0x10000000,	/* If clear, process the glyphs forwards, that
+    Backwards		= 0x10000000,	/* If clear, process the glyphs forwards, that
 					 * is, from first to last in the glyph stream.
 					 * If we, process them from last to first.
 					 * This flag only applies to state-table based
@@ -319,7 +319,7 @@ struct kerx
       if (table->coverage & KerxTable::CrossStream)
         goto skip; /* We do NOT handle cross-stream kerning. */
 
-      reverse = bool (table->coverage & KerxTable::ProcessDirection) !=
+      reverse = bool (table->coverage & KerxTable::Backwards) !=
 		HB_DIRECTION_IS_BACKWARD (c->buffer->props.direction);
 
       if (!c->buffer->message (c->font, "start kerx subtable %d", c->lookup_index))
diff --git a/src/hb-aat-layout-morx-table.hh b/src/hb-aat-layout-morx-table.hh
index 68d82dd1..0020750c 100644
--- a/src/hb-aat-layout-morx-table.hh
+++ b/src/hb-aat-layout-morx-table.hh
@@ -752,7 +752,7 @@ struct ChainSubtable
     Vertical		= 0x80000000,	/* If set, this subtable will only be applied
 					 * to vertical text. If clear, this subtable
 					 * will only be applied to horizontal text. */
-    Descending		= 0x40000000,	/* If set, this subtable will process glyphs
+    Backwards		= 0x40000000,	/* If set, this subtable will process glyphs
 					 * in descending order. If clear, it will
 					 * process the glyphs in ascending order. */
     AllDirections	= 0x20000000,	/* If set, this subtable will be applied to
@@ -876,8 +876,8 @@ struct Chain
 				may be right-to-left or left-to-right).
        */
       reverse = subtable->coverage & ChainSubtable::Logical ?
-		bool (subtable->coverage & ChainSubtable::Descending) :
-		bool (subtable->coverage & ChainSubtable::Descending) !=
+		bool (subtable->coverage & ChainSubtable::Backwards) :
+		bool (subtable->coverage & ChainSubtable::Backwards) !=
 		HB_DIRECTION_IS_BACKWARD (c->buffer->props.direction);
 
       if (!c->buffer->message (c->font, "start chain subtable %d", c->lookup_index))
commit 54c9ecb92d196e62901eef3f8bc025c024ed16bb
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Tue Oct 9 23:18:19 2018 -0400

    [morx] Use subtable range for embedded sanitizer here as well

diff --git a/src/hb-aat-layout-morx-table.hh b/src/hb-aat-layout-morx-table.hh
index cf08d796..68d82dd1 100644
--- a/src/hb-aat-layout-morx-table.hh
+++ b/src/hb-aat-layout-morx-table.hh
@@ -886,6 +886,8 @@ struct Chain
       if (reverse)
         c->buffer->reverse ();
 
+      c->sanitizer.set_object (*subtable);
+
       subtable->dispatch (c);
 
       if (reverse)
commit d35315cc028e70dd1b3ffc8cb079a2336b22a0c3
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Tue Oct 9 23:17:32 2018 -0400

    [aat] Fixup recent commit
    
    For 329f2401082011007d9ce12b15ce0225cd267c57
    
    max_ops is signed.

diff --git a/src/hb-aat-layout-common.hh b/src/hb-aat-layout-common.hh
index 3d562e79..5845ab51 100644
--- a/src/hb-aat-layout-common.hh
+++ b/src/hb-aat-layout-common.hh
@@ -538,7 +538,7 @@ struct hb_aat_apply_context_t :
     sanitizer.init (table);
     sanitizer.set_num_glyphs (face->get_num_glyphs ());
     sanitizer.start_processing ();
-    sanitizer.set_max_ops ((unsigned int) -1);
+    sanitizer.set_max_ops (HB_SANITIZE_MAX_OPS_MAX);
   }
 
   inline void set_lookup_index (unsigned int i) { lookup_index = i; }
diff --git a/src/hb-machinery.hh b/src/hb-machinery.hh
index 98808894..8feb3773 100644
--- a/src/hb-machinery.hh
+++ b/src/hb-machinery.hh
@@ -217,6 +217,9 @@ struct hb_dispatch_context_t
 #ifndef HB_SANITIZE_MAX_OPS_MIN
 #define HB_SANITIZE_MAX_OPS_MIN 16384
 #endif
+#ifndef HB_SANITIZE_MAX_OPS_MAX
+#define HB_SANITIZE_MAX_OPS_MAX 0x3FFFFFFF
+#endif
 
 struct hb_sanitize_context_t :
        hb_dispatch_context_t<hb_sanitize_context_t, bool, HB_DEBUG_SANITIZE>
@@ -252,7 +255,7 @@ struct hb_sanitize_context_t :
   }
   inline unsigned int get_num_glyphs (void) { return num_glyphs; }
 
-  inline void set_max_ops (unsigned int max_ops_) { max_ops = max_ops_; }
+  inline void set_max_ops (int max_ops_) { max_ops = max_ops_; }
 
   template <typename T>
   inline void set_object (const T& obj)
commit 948f59a13a4c643ae310f5fc643e29fefd6c3787
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Tue Oct 9 23:07:47 2018 -0400

    [kerx] Use subtable range for runtime checks

diff --git a/src/hb-aat-layout-kerx-table.hh b/src/hb-aat-layout-kerx-table.hh
index dd6e8176..c7cb367f 100644
--- a/src/hb-aat-layout-kerx-table.hh
+++ b/src/hb-aat-layout-kerx-table.hh
@@ -124,7 +124,7 @@ struct KerxSubTableFormat2
     TRACE_APPLY (this);
 
     accelerator_t accel (*this,
-			 c->sanitizer.end, /* XXX Use SubTable length? */
+			 c->sanitizer.end,
 			 c->face->get_num_glyphs ());
     hb_kern_machine_t<accelerator_t> machine (accel);
     machine.kern (c->font, c->buffer, c->plan->kern_mask);
@@ -328,6 +328,8 @@ struct kerx
       if (reverse)
         c->buffer->reverse ();
 
+      c->sanitizer.set_object (*table);
+
       /* XXX Reverse-kern is not working yet...
        * hb_kern_machine_t would need to know that it's reverse-kerning.
        * Or better yet, make it work in reverse as well, so we don't have
diff --git a/src/hb-machinery.hh b/src/hb-machinery.hh
index 5eaec759..98808894 100644
--- a/src/hb-machinery.hh
+++ b/src/hb-machinery.hh
@@ -254,6 +254,14 @@ struct hb_sanitize_context_t :
 
   inline void set_max_ops (unsigned int max_ops_) { max_ops = max_ops_; }
 
+  template <typename T>
+  inline void set_object (const T& obj)
+  {
+    this->start = (const char *) &obj;
+    this->end = (const char *) &obj + obj.get_size ();
+    assert (this->start <= this->end); /* Must not overflow. */
+  }
+
   inline void start_processing (void)
   {
     this->start = this->blob->data;
commit 329f2401082011007d9ce12b15ce0225cd267c57
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Tue Oct 9 23:02:53 2018 -0400

    [aat] Set embedded sanitizer max ops really high
    
    Since we consume it legitimately during shaping.

diff --git a/src/hb-aat-layout-common.hh b/src/hb-aat-layout-common.hh
index 22c84255..3d562e79 100644
--- a/src/hb-aat-layout-common.hh
+++ b/src/hb-aat-layout-common.hh
@@ -538,6 +538,7 @@ struct hb_aat_apply_context_t :
     sanitizer.init (table);
     sanitizer.set_num_glyphs (face->get_num_glyphs ());
     sanitizer.start_processing ();
+    sanitizer.set_max_ops ((unsigned int) -1);
   }
 
   inline void set_lookup_index (unsigned int i) { lookup_index = i; }
diff --git a/src/hb-machinery.hh b/src/hb-machinery.hh
index 9c73df2c..5eaec759 100644
--- a/src/hb-machinery.hh
+++ b/src/hb-machinery.hh
@@ -252,6 +252,8 @@ struct hb_sanitize_context_t :
   }
   inline unsigned int get_num_glyphs (void) { return num_glyphs; }
 
+  inline void set_max_ops (unsigned int max_ops_) { max_ops = max_ops_; }
+
   inline void start_processing (void)
   {
     this->start = this->blob->data;
commit ad763074861da60ed51211931788ca5b27fc1512
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Tue Oct 9 22:57:00 2018 -0400

    [kerx] Comment

diff --git a/src/hb-aat-layout-kerx-table.hh b/src/hb-aat-layout-kerx-table.hh
index 590ec491..dd6e8176 100644
--- a/src/hb-aat-layout-kerx-table.hh
+++ b/src/hb-aat-layout-kerx-table.hh
@@ -328,7 +328,10 @@ struct kerx
       if (reverse)
         c->buffer->reverse ();
 
-      /* XXX Reverse-kern is not working yet... */
+      /* XXX Reverse-kern is not working yet...
+       * hb_kern_machine_t would need to know that it's reverse-kerning.
+       * Or better yet, make it work in reverse as well, so we don't have
+       * to reverse and reverse back? */
       table->dispatch (c);
 
       if (reverse)
commit db9600bbe15035cea6c2d4e8e9d184a5e23e357e
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Tue Oct 9 22:55:47 2018 -0400

    [kerx] Remove junk

diff --git a/src/hb-aat-layout-kerx-table.hh b/src/hb-aat-layout-kerx-table.hh
index 2c84758b..590ec491 100644
--- a/src/hb-aat-layout-kerx-table.hh
+++ b/src/hb-aat-layout-kerx-table.hh
@@ -292,22 +292,6 @@ public:
   DEFINE_SIZE_MIN (12);
 };
 
-struct SubtableXXX
-{
-  inline bool sanitize (hb_sanitize_context_t *c) const
-  {
-    TRACE_SANITIZE (this);
-    return_trace (likely (c->check_struct (this)));
-  }
-
-  protected:
-  HBUINT32	length;
-  HBUINT32	coverage;
-  HBUINT32	tupleCount;
-  public:
-  DEFINE_SIZE_STATIC (12);
-};
-
 
 /*
  * The 'kerx' Table
commit 27db859416c0362f211e2b42dc9a2ebb53b0e0f4
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Tue Oct 9 22:52:41 2018 -0400

    [kern/kerx] Adjust bounds check

diff --git a/src/hb-aat-layout-kerx-table.hh b/src/hb-aat-layout-kerx-table.hh
index feaee708..2c84758b 100644
--- a/src/hb-aat-layout-kerx-table.hh
+++ b/src/hb-aat-layout-kerx-table.hh
@@ -112,11 +112,9 @@ struct KerxSubTableFormat2
     unsigned int l = *(this+leftClassTable).get_value (left, num_glyphs);
     unsigned int r = *(this+rightClassTable).get_value (right, num_glyphs);
     unsigned int offset = l + r;
-    const FWORD *arr = &(this+array);
-    if (unlikely ((const void *) arr < (const void *) this || (const void *) arr >= (const void *) end))
-      return 0;
-    const FWORD *v = &StructAtOffset<FWORD> (arr, offset);
-    if (unlikely ((const void *) v < (const void *) arr || (const void *) (v + 1) > (const void *) end))
+    const FWORD *v = &StructAtOffset<FWORD> (&(this+array), offset);
+    if (unlikely ((const char *) v < (const char *) &array ||
+		  (const char *) v > (const char *) end - 2))
       return 0;
     return *v;
   }
diff --git a/src/hb-ot-kern-table.hh b/src/hb-ot-kern-table.hh
index f9aec05e..c4e53fa6 100644
--- a/src/hb-ot-kern-table.hh
+++ b/src/hb-ot-kern-table.hh
@@ -194,11 +194,9 @@ struct KernSubTableFormat2
     unsigned int l = (this+leftClassTable).get_class (left);
     unsigned int r = (this+rightClassTable).get_class (right);
     unsigned int offset = l + r;
-    const FWORD *arr = &(this+array);
-    if (unlikely ((const void *) arr < (const void *) this || (const void *) arr >= (const void *) end))
-      return 0;
-    const FWORD *v = &StructAtOffset<FWORD> (arr, offset);
-    if (unlikely ((const void *) v < (const void *) arr || (const void *) (v + 1) > (const void *) end))
+    const FWORD *v = &StructAtOffset<FWORD> (&(this+array), offset);
+    if (unlikely ((const char *) v < (const char *) &array ||
+		  (const char *) v > (const char *) end - 2))
       return 0;
     return *v;
   }
commit c66f7f8c5deaac109e34bf65fc16cff92b74e69a
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Tue Oct 9 22:49:33 2018 -0400

    [kerx] Implement Format2 apply()
    
    Still, not hooked.

diff --git a/src/hb-aat-layout-kerx-table.hh b/src/hb-aat-layout-kerx-table.hh
index c7318347..feaee708 100644
--- a/src/hb-aat-layout-kerx-table.hh
+++ b/src/hb-aat-layout-kerx-table.hh
@@ -125,14 +125,11 @@ struct KerxSubTableFormat2
   {
     TRACE_APPLY (this);
 
-    /* TODO */
-#if 0
     accelerator_t accel (*this,
-			 c->blob->data + c->blob->len,
+			 c->sanitizer.end, /* XXX Use SubTable length? */
 			 c->face->get_num_glyphs ());
     hb_kern_machine_t<accelerator_t> machine (accel);
     machine.kern (c->font, c->buffer, c->plan->kern_mask);
-#endif
 
     return_trace (true);
   }
commit 4b461785bdf356e4b5586cb6e5b226f47da04b7d
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Tue Oct 9 22:46:30 2018 -0400

    Fix check

diff --git a/src/hb-aat-layout-kerx-table.hh b/src/hb-aat-layout-kerx-table.hh
index 42181bf6..c7318347 100644
--- a/src/hb-aat-layout-kerx-table.hh
+++ b/src/hb-aat-layout-kerx-table.hh
@@ -113,6 +113,8 @@ struct KerxSubTableFormat2
     unsigned int r = *(this+rightClassTable).get_value (right, num_glyphs);
     unsigned int offset = l + r;
     const FWORD *arr = &(this+array);
+    if (unlikely ((const void *) arr < (const void *) this || (const void *) arr >= (const void *) end))
+      return 0;
     const FWORD *v = &StructAtOffset<FWORD> (arr, offset);
     if (unlikely ((const void *) v < (const void *) arr || (const void *) (v + 1) > (const void *) end))
       return 0;
diff --git a/src/hb-aat-layout.cc b/src/hb-aat-layout.cc
index 5cd9621f..71932e79 100644
--- a/src/hb-aat-layout.cc
+++ b/src/hb-aat-layout.cc
@@ -74,7 +74,9 @@ hb_aat_layout_substitute (hb_ot_shape_plan_t *plan,
 }
 
 void
-hb_aat_layout_position (hb_font_t *font, hb_buffer_t *buffer)
+hb_aat_layout_position (hb_ot_shape_plan_t *plan,
+			hb_font_t *font,
+			hb_buffer_t *buffer)
 {
 #if 0
   hb_blob_t *blob;
commit 4df8eb200def767d342762654b96d5d9314e5b21
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Tue Oct 9 22:46:12 2018 -0400

    [kern] Use kern subtable length for sanitizing in the accelerator

diff --git a/src/hb-ot-kern-table.hh b/src/hb-ot-kern-table.hh
index 04be9827..f9aec05e 100644
--- a/src/hb-ot-kern-table.hh
+++ b/src/hb-ot-kern-table.hh
@@ -294,7 +294,7 @@ struct KernTable
   /* https://en.wikipedia.org/wiki/Curiously_recurring_template_pattern */
   inline const T* thiz (void) const { return static_cast<const T *> (this); }
 
-  inline int get_h_kerning (hb_codepoint_t left, hb_codepoint_t right, unsigned int table_length) const
+  inline int get_h_kerning (hb_codepoint_t left, hb_codepoint_t right) const
   {
     int v = 0;
     const typename T::SubTableWrapper *st = CastP<typename T::SubTableWrapper> (&thiz()->dataZ);
@@ -303,7 +303,7 @@ struct KernTable
     {
       if (st->is_override ())
         v = 0;
-      v += st->get_h_kerning (left, right, table_length + (const char *) this);
+      v += st->get_h_kerning (left, right, st->length + (const char *) st);
       st = &StructAfter<typename T::SubTableWrapper> (*st);
     }
     return v;
@@ -337,6 +337,7 @@ struct KernOT : KernTable<KernOT>
 
   struct SubTableWrapper : KernSubTableWrapper<SubTableWrapper>
   {
+    friend struct KernTable<KernOT>;
     friend struct KernSubTableWrapper<SubTableWrapper>;
 
     enum Coverage
@@ -378,6 +379,7 @@ struct KernAAT : KernTable<KernAAT>
 
   struct SubTableWrapper : KernSubTableWrapper<SubTableWrapper>
   {
+    friend struct KernTable<KernAAT>;
     friend struct KernSubTableWrapper<SubTableWrapper>;
 
     enum Coverage
@@ -418,11 +420,11 @@ struct kern
   inline bool has_data (void) const
   { return u.version32 != 0; }
 
-  inline int get_h_kerning (hb_codepoint_t left, hb_codepoint_t right, unsigned int table_length) const
+  inline int get_h_kerning (hb_codepoint_t left, hb_codepoint_t right) const
   {
     switch (u.major) {
-    case 0: return u.ot.get_h_kerning (left, right, table_length);
-    case 1: return u.aat.get_h_kerning (left, right, table_length);
+    case 0: return u.ot.get_h_kerning (left, right);
+    case 1: return u.aat.get_h_kerning (left, right);
     default:return 0;
     }
   }
@@ -444,7 +446,6 @@ struct kern
     {
       blob = hb_sanitize_context_t().reference_table<kern> (face);
       table = blob->as<kern> ();
-      table_length = blob->length;
     }
     inline void fini (void)
     {
@@ -455,7 +456,7 @@ struct kern
     { return table->has_data (); }
 
     inline int get_h_kerning (hb_codepoint_t left, hb_codepoint_t right) const
-    { return table->get_h_kerning (left, right, table_length); }
+    { return table->get_h_kerning (left, right); }
 
     inline int get_kerning (hb_codepoint_t first, hb_codepoint_t second) const
     { return get_h_kerning (first, second); }
@@ -475,7 +476,6 @@ struct kern
     private:
     hb_blob_t *blob;
     const kern *table;
-    unsigned int table_length;
   };
 
   protected:
commit 8bff1d2994876a5202c8605d1cc37522431c6c84
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Tue Oct 9 22:39:31 2018 -0400

    [kern] Minor

diff --git a/src/hb-ot-kern-table.hh b/src/hb-ot-kern-table.hh
index ee237020..04be9827 100644
--- a/src/hb-ot-kern-table.hh
+++ b/src/hb-ot-kern-table.hh
@@ -283,7 +283,7 @@ struct KernSubTableWrapper
     TRACE_SANITIZE (this);
     return_trace (c->check_struct (thiz()) &&
 		  thiz()->length >= T::min_size &&
-		  c->check_array (thiz(), thiz()->length, 1) &&
+		  c->check_range (thiz(), thiz()->length) &&
 		  thiz()->subtable.sanitize (c, thiz()->format));
   }
 };
commit 53e55945000347fb19168bb4c13a470d30d46251
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Tue Oct 9 22:35:22 2018 -0400

    [kerx] Implement Format0 apply()
    
    Not hooked up to be called yet.

diff --git a/src/hb-aat-layout-common.hh b/src/hb-aat-layout-common.hh
index d6e597a4..22c84255 100644
--- a/src/hb-aat-layout-common.hh
+++ b/src/hb-aat-layout-common.hh
@@ -518,6 +518,7 @@ struct hb_aat_apply_context_t :
   static return_t default_return_value (void) { return false; }
   bool stop_sublookup_iteration (return_t r) const { return r; }
 
+  hb_ot_shape_plan_t *plan;
   hb_font_t *font;
   hb_face_t *face;
   hb_buffer_t *buffer;
@@ -527,10 +528,11 @@ struct hb_aat_apply_context_t :
   unsigned int lookup_index;
   unsigned int debug_depth;
 
-  inline hb_aat_apply_context_t (hb_font_t *font_,
+  inline hb_aat_apply_context_t (hb_ot_shape_plan_t *plan_,
+				 hb_font_t *font_,
 				 hb_buffer_t *buffer_,
 				 hb_blob_t *table) :
-		font (font_), face (font->face), buffer (buffer_),
+		plan (plan_), font (font_), face (font->face), buffer (buffer_),
 		sanitizer (), lookup_index (0), debug_depth (0)
   {
     sanitizer.init (table);
diff --git a/src/hb-aat-layout-kerx-table.hh b/src/hb-aat-layout-kerx-table.hh
index 49d188c3..42181bf6 100644
--- a/src/hb-aat-layout-kerx-table.hh
+++ b/src/hb-aat-layout-kerx-table.hh
@@ -59,7 +59,9 @@ struct KerxSubTableFormat0
   {
     TRACE_APPLY (this);
 
-    /* TODO */
+    hb_kern_machine_t<KerxSubTableFormat0> machine (*this);
+
+    machine.kern (c->font, c->buffer, c->plan->kern_mask);
 
     return_trace (true);
   }
@@ -111,8 +113,6 @@ struct KerxSubTableFormat2
     unsigned int r = *(this+rightClassTable).get_value (right, num_glyphs);
     unsigned int offset = l + r;
     const FWORD *arr = &(this+array);
-    if (unlikely ((const void *) arr < (const void *) this || (const void *) arr >= (const void *) end))
-      return 0;
     const FWORD *v = &StructAtOffset<FWORD> (arr, offset);
     if (unlikely ((const void *) v < (const void *) arr || (const void *) (v + 1) > (const void *) end))
       return 0;
@@ -124,6 +124,13 @@ struct KerxSubTableFormat2
     TRACE_APPLY (this);
 
     /* TODO */
+#if 0
+    accelerator_t accel (*this,
+			 c->blob->data + c->blob->len,
+			 c->face->get_num_glyphs ());
+    hb_kern_machine_t<accelerator_t> machine (accel);
+    machine.kern (c->font, c->buffer, c->plan->kern_mask);
+#endif
 
     return_trace (true);
   }
@@ -138,6 +145,22 @@ struct KerxSubTableFormat2
 			  array.sanitize (c, this)));
   }
 
+  struct accelerator_t
+  {
+    const KerxSubTableFormat2 &table;
+    const char *end;
+    unsigned int num_glyphs;
+
+    inline accelerator_t (const KerxSubTableFormat2 &table_,
+			  const char *end_, unsigned int num_glyphs_)
+			  : table (table_), end (end_), num_glyphs (num_glyphs_) {}
+
+    inline int get_kerning (hb_codepoint_t left, hb_codepoint_t right) const
+    {
+      return table.get_kerning (left, right, end, num_glyphs);
+    }
+  };
+
   protected:
   HBUINT32	rowWidth;	/* The width, in bytes, of a row in the table. */
   LOffsetTo<Lookup<HBUINT16> >
diff --git a/src/hb-aat-layout.cc b/src/hb-aat-layout.cc
index faf418d6..5cd9621f 100644
--- a/src/hb-aat-layout.cc
+++ b/src/hb-aat-layout.cc
@@ -62,12 +62,14 @@ hb_aat_layout_has_substitution (hb_face_t *face)
 }
 
 void
-hb_aat_layout_substitute (hb_font_t *font, hb_buffer_t *buffer)
+hb_aat_layout_substitute (hb_ot_shape_plan_t *plan,
+			  hb_font_t *font,
+			  hb_buffer_t *buffer)
 {
   hb_blob_t *blob;
   const AAT::morx& morx = _get_morx (font->face, &blob);
 
-  AAT::hb_aat_apply_context_t c (font, buffer, blob);
+  AAT::hb_aat_apply_context_t c (plan, font, buffer, blob);
   morx.apply (&c);
 }
 
diff --git a/src/hb-aat-layout.hh b/src/hb-aat-layout.hh
index 553832f1..8b12833d 100644
--- a/src/hb-aat-layout.hh
+++ b/src/hb-aat-layout.hh
@@ -29,17 +29,19 @@
 
 #include "hb.hh"
 
-#include "hb-font.hh"
-#include "hb-buffer.hh"
-#include "hb-open-type.hh"
+#include "hb-ot-shape.hh"
 
 HB_INTERNAL hb_bool_t
 hb_aat_layout_has_substitution (hb_face_t *face);
 
 HB_INTERNAL void
-hb_aat_layout_substitute (hb_font_t *font, hb_buffer_t *buffer);
+hb_aat_layout_substitute (hb_ot_shape_plan_t *plan,
+			  hb_font_t *font,
+			  hb_buffer_t *buffer);
 
 HB_INTERNAL void
-hb_aat_layout_position (hb_font_t *font, hb_buffer_t *buffer);
+hb_aat_layout_position (hb_ot_shape_plan_t *plan,
+			hb_font_t *font,
+			hb_buffer_t *buffer);
 
 #endif /* HB_AAT_LAYOUT_HH */
diff --git a/src/hb-ot-shape.cc b/src/hb-ot-shape.cc
index a9c0844e..6753ceb2 100644
--- a/src/hb-ot-shape.cc
+++ b/src/hb-ot-shape.cc
@@ -668,7 +668,7 @@ hb_ot_substitute_complex (const hb_ot_shape_context_t *c)
     hb_synthesize_glyph_classes (c);
 
   if (unlikely (c->plan->apply_morx))
-    hb_aat_layout_substitute (c->font, c->buffer);
+    hb_aat_layout_substitute (c->plan, c->font, c->buffer);
   else
     c->plan->substitute (c->font, buffer);
 }
commit 60318f87153b559e5da103f0bfcce6bad8bab3b0
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Tue Oct 9 22:25:53 2018 -0400

    Minor

diff --git a/src/hb-mutex.hh b/src/hb-mutex.hh
index c49d7a9e..75b89add 100644
--- a/src/hb-mutex.hh
+++ b/src/hb-mutex.hh
@@ -139,8 +139,8 @@ struct hb_mutex_t
 
 struct hb_lock_t
 {
-  hb_lock_t (hb_mutex_t &mutex_) : mutex (mutex_) { mutex.lock (); }
-  ~hb_lock_t (void) { mutex.unlock (); }
+  inline hb_lock_t (hb_mutex_t &mutex_) : mutex (mutex_) { mutex.lock (); }
+  inline ~hb_lock_t (void) { mutex.unlock (); }
   private:
   hb_mutex_t &mutex;
 };


More information about the HarfBuzz mailing list