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

Behdad Esfahbod behdad at kemper.freedesktop.org
Wed Oct 10 16:14:03 UTC 2018


 src/hb-aat-layout.cc                       |   31 +++++++--
 src/hb-aat-layout.hh                       |    3 
 src/hb-null.hh                             |    2 
 src/hb-ot-layout-gsubgpos.hh               |   91 +++++++++++++++++++++++++++++
 src/hb-ot-layout.cc                        |   86 +++------------------------
 src/hb-ot-layout.hh                        |   20 ------
 src/hb-ot-shape-complex-arabic-fallback.hh |    2 
 src/hb-ot-shape.cc                         |   67 ++++++++++++++-------
 src/hb-ot-shape.hh                         |    2 
 9 files changed, 180 insertions(+), 124 deletions(-)

New commits:
commit b3390990f508def9c375716614b92fc7b0038228
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Wed Oct 10 12:07:49 2018 -0400

    Add per-subtable set-digests
    
    This speeds up Roboto shaping by ~10%.  I was hoping for more.
    Still, good defense against lookups with many subtables.

diff --git a/src/hb-null.hh b/src/hb-null.hh
index 2509296f..bf01b3af 100644
--- a/src/hb-null.hh
+++ b/src/hb-null.hh
@@ -36,7 +36,7 @@
 
 /* Global nul-content Null pool.  Enlarge as necessary. */
 
-#define HB_NULL_POOL_SIZE 512
+#define HB_NULL_POOL_SIZE 1024
 
 extern HB_INTERNAL
 hb_vector_size_impl_t const _hb_NullPool[(HB_NULL_POOL_SIZE + sizeof (hb_vector_size_impl_t) - 1) / sizeof (hb_vector_size_impl_t)];
diff --git a/src/hb-ot-layout-gsubgpos.hh b/src/hb-ot-layout-gsubgpos.hh
index 0ddadcf6..3a09803e 100644
--- a/src/hb-ot-layout-gsubgpos.hh
+++ b/src/hb-ot-layout-gsubgpos.hh
@@ -259,56 +259,6 @@ struct hb_add_coverage_context_t :
 };
 
 
-struct hb_get_subtables_context_t :
-       hb_dispatch_context_t<hb_get_subtables_context_t, hb_void_t, HB_DEBUG_APPLY>
-{
-  template <typename Type>
-  static inline bool apply_to (const void *obj, OT::hb_ot_apply_context_t *c)
-  {
-    const Type *typed_obj = (const Type *) obj;
-    return typed_obj->apply (c);
-  }
-
-  typedef bool (*hb_apply_func_t) (const void *obj, OT::hb_ot_apply_context_t *c);
-
-  struct hb_applicable_t
-  {
-    inline void init (const void *obj_, hb_apply_func_t apply_func_)
-    {
-      obj = obj_;
-      apply_func = apply_func_;
-    }
-
-    inline bool apply (OT::hb_ot_apply_context_t *c) const { return apply_func (obj, c); }
-
-    private:
-    const void *obj;
-    hb_apply_func_t apply_func;
-  };
-
-  typedef hb_vector_t<hb_applicable_t, 2> array_t;
-
-  /* Dispatch interface. */
-  inline const char *get_name (void) { return "GET_SUBTABLES"; }
-  template <typename T>
-  inline return_t dispatch (const T &obj)
-  {
-    hb_applicable_t *entry = array.push();
-    entry->init (&obj, apply_to<T>);
-    return HB_VOID;
-  }
-  static return_t default_return_value (void) { return HB_VOID; }
-  bool stop_sublookup_iteration (return_t r HB_UNUSED) const { return false; }
-
-  hb_get_subtables_context_t (array_t &array_) :
-			      array (array_),
-			      debug_depth (0) {}
-
-  array_t &array;
-  unsigned int debug_depth;
-};
-
-
 struct hb_ot_apply_context_t :
        hb_dispatch_context_t<hb_ot_apply_context_t, bool, HB_DEBUG_APPLY>
 {
@@ -671,6 +621,64 @@ struct hb_ot_apply_context_t :
 };
 
 
+struct hb_get_subtables_context_t :
+       hb_dispatch_context_t<hb_get_subtables_context_t, hb_void_t, HB_DEBUG_APPLY>
+{
+  template <typename Type>
+  static inline bool apply_to (const void *obj, OT::hb_ot_apply_context_t *c)
+  {
+    const Type *typed_obj = (const Type *) obj;
+    return typed_obj->apply (c);
+  }
+
+  typedef bool (*hb_apply_func_t) (const void *obj, OT::hb_ot_apply_context_t *c);
+
+  struct hb_applicable_t
+  {
+    template <typename T>
+    inline void init (const T &obj_, hb_apply_func_t apply_func_)
+    {
+      obj = &obj_;
+      apply_func = apply_func_;
+      digest.init ();
+      obj_.get_coverage ().add_coverage (&digest);
+    }
+
+    inline bool apply (OT::hb_ot_apply_context_t *c) const
+    {
+      return digest.may_have (c->buffer->cur().codepoint) && apply_func (obj, c);
+    }
+
+    private:
+    const void *obj;
+    hb_apply_func_t apply_func;
+    hb_set_digest_t digest;
+  };
+
+  typedef hb_vector_t<hb_applicable_t, 2> array_t;
+
+  /* Dispatch interface. */
+  inline const char *get_name (void) { return "GET_SUBTABLES"; }
+  template <typename T>
+  inline return_t dispatch (const T &obj)
+  {
+    hb_applicable_t *entry = array.push();
+    entry->init (obj, apply_to<T>);
+    return HB_VOID;
+  }
+  static return_t default_return_value (void) { return HB_VOID; }
+  bool stop_sublookup_iteration (return_t r HB_UNUSED) const { return false; }
+
+  hb_get_subtables_context_t (array_t &array_) :
+			      array (array_),
+			      debug_depth (0) {}
+
+  array_t &array;
+  unsigned int debug_depth;
+};
+
+
+
 
 typedef bool (*intersects_func_t) (const hb_set_t *glyphs, const HBUINT16 &value, const void *data);
 typedef void (*collect_glyphs_func_t) (hb_set_t *glyphs, const HBUINT16 &value, const void *data);
commit e78549edfb4df617128a5f5ddd12692f1d0af4bf
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Wed Oct 10 11:54:48 2018 -0400

    Move apply down into subtables accel

diff --git a/src/hb-ot-layout-gsubgpos.hh b/src/hb-ot-layout-gsubgpos.hh
index 21a45d50..0ddadcf6 100644
--- a/src/hb-ot-layout-gsubgpos.hh
+++ b/src/hb-ot-layout-gsubgpos.hh
@@ -2632,7 +2632,15 @@ struct hb_ot_layout_lookup_accelerator_t
   inline bool may_have (hb_codepoint_t g) const
   { return digest.may_have (g); }
 
-  public:
+  inline bool apply (hb_ot_apply_context_t *c) const
+  {
+     for (unsigned int i = 0; i < subtables.len; i++)
+       if (subtables[i].apply (c))
+         return true;
+     return false;
+  }
+
+  private:
   hb_set_digest_t digest;
   hb_get_subtables_context_t::array_t subtables;
 };
diff --git a/src/hb-ot-layout.cc b/src/hb-ot-layout.cc
index adb1da28..4908076e 100644
--- a/src/hb-ot-layout.cc
+++ b/src/hb-ot-layout.cc
@@ -1118,7 +1118,6 @@ apply_forward (OT::hb_ot_apply_context_t *c,
 {
   bool ret = false;
   hb_buffer_t *buffer = c->buffer;
-  const OT::hb_get_subtables_context_t::array_t &subtables = accel.subtables;
   while (buffer->idx < buffer->len && buffer->successful)
   {
     bool applied = false;
@@ -1126,12 +1125,7 @@ apply_forward (OT::hb_ot_apply_context_t *c,
 	(buffer->cur().mask & c->lookup_mask) &&
 	c->check_glyph_property (&buffer->cur(), c->lookup_props))
      {
-       for (unsigned int i = 0; i < subtables.len; i++)
-         if (subtables[i].apply (c))
-	 {
-	   applied = true;
-	   break;
-	 }
+       applied = accel.apply (c);
      }
 
     if (applied)
@@ -1148,19 +1142,14 @@ apply_backward (OT::hb_ot_apply_context_t *c,
 {
   bool ret = false;
   hb_buffer_t *buffer = c->buffer;
-  const OT::hb_get_subtables_context_t::array_t &subtables = accel.subtables;
   do
   {
     if (accel.may_have (buffer->cur().codepoint) &&
 	(buffer->cur().mask & c->lookup_mask) &&
 	c->check_glyph_property (&buffer->cur(), c->lookup_props))
     {
-     for (unsigned int i = 0; i < subtables.len; i++)
-       if (subtables[i].apply (c))
-       {
-	 ret = true;
-	 break;
-       }
+     if (accel.apply (c))
+       ret = true;
     }
     /* The reverse lookup doesn't "advance" cursor (for good reason). */
     buffer->idx--;
commit 78c09bf21335a0f2b538b37de6647af08e3b1161
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Wed Oct 10 11:50:46 2018 -0400

    Move subtable array into lookup accel

diff --git a/src/hb-null.hh b/src/hb-null.hh
index 88c1c9cb..2509296f 100644
--- a/src/hb-null.hh
+++ b/src/hb-null.hh
@@ -36,7 +36,7 @@
 
 /* Global nul-content Null pool.  Enlarge as necessary. */
 
-#define HB_NULL_POOL_SIZE 264
+#define HB_NULL_POOL_SIZE 512
 
 extern HB_INTERNAL
 hb_vector_size_impl_t const _hb_NullPool[(HB_NULL_POOL_SIZE + sizeof (hb_vector_size_impl_t) - 1) / sizeof (hb_vector_size_impl_t)];
diff --git a/src/hb-ot-layout-gsubgpos.hh b/src/hb-ot-layout-gsubgpos.hh
index a11d5dcc..21a45d50 100644
--- a/src/hb-ot-layout-gsubgpos.hh
+++ b/src/hb-ot-layout-gsubgpos.hh
@@ -286,7 +286,7 @@ struct hb_get_subtables_context_t :
     hb_apply_func_t apply_func;
   };
 
-  typedef hb_auto_t<hb_vector_t<hb_applicable_t> > array_t;
+  typedef hb_vector_t<hb_applicable_t, 2> array_t;
 
   /* Dispatch interface. */
   inline const char *get_name (void) { return "GET_SUBTABLES"; }
@@ -2619,14 +2619,22 @@ struct hb_ot_layout_lookup_accelerator_t
   {
     digest.init ();
     lookup.add_coverage (&digest);
+
+    subtables.init ();
+    OT::hb_get_subtables_context_t c_get_subtables (subtables);
+    lookup.dispatch (&c_get_subtables);
+  }
+  inline void fini (void)
+  {
+    subtables.fini ();
   }
-  inline void fini (void) {}
 
   inline bool may_have (hb_codepoint_t g) const
   { return digest.may_have (g); }
 
-  private:
+  public:
   hb_set_digest_t digest;
+  hb_get_subtables_context_t::array_t subtables;
 };
 
 struct GSUBGPOS
diff --git a/src/hb-ot-layout.cc b/src/hb-ot-layout.cc
index 572e4cb9..adb1da28 100644
--- a/src/hb-ot-layout.cc
+++ b/src/hb-ot-layout.cc
@@ -1114,11 +1114,11 @@ struct GPOSProxy
 
 static inline bool
 apply_forward (OT::hb_ot_apply_context_t *c,
-	       const OT::hb_ot_layout_lookup_accelerator_t &accel,
-	       const OT::hb_get_subtables_context_t::array_t &subtables)
+	       const OT::hb_ot_layout_lookup_accelerator_t &accel)
 {
   bool ret = false;
   hb_buffer_t *buffer = c->buffer;
+  const OT::hb_get_subtables_context_t::array_t &subtables = accel.subtables;
   while (buffer->idx < buffer->len && buffer->successful)
   {
     bool applied = false;
@@ -1144,11 +1144,11 @@ apply_forward (OT::hb_ot_apply_context_t *c,
 
 static inline bool
 apply_backward (OT::hb_ot_apply_context_t *c,
-	       const OT::hb_ot_layout_lookup_accelerator_t &accel,
-	       const OT::hb_get_subtables_context_t::array_t &subtables)
+	       const OT::hb_ot_layout_lookup_accelerator_t &accel)
 {
   bool ret = false;
   hb_buffer_t *buffer = c->buffer;
+  const OT::hb_get_subtables_context_t::array_t &subtables = accel.subtables;
   do
   {
     if (accel.may_have (buffer->cur().codepoint) &&
@@ -1183,10 +1183,6 @@ apply_string (OT::hb_ot_apply_context_t *c,
 
   c->set_lookup_props (lookup.get_props ());
 
-  OT::hb_get_subtables_context_t::array_t subtables;
-  OT::hb_get_subtables_context_t c_get_subtables (subtables);
-  lookup.dispatch (&c_get_subtables);
-
   if (likely (!lookup.is_reverse ()))
   {
     /* in/out forward substitution/positioning */
@@ -1195,7 +1191,7 @@ apply_string (OT::hb_ot_apply_context_t *c,
     buffer->idx = 0;
 
     bool ret;
-    ret = apply_forward (c, accel, subtables);
+    ret = apply_forward (c, accel);
     if (ret)
     {
       if (!Proxy::inplace)
@@ -1211,7 +1207,7 @@ apply_string (OT::hb_ot_apply_context_t *c,
       buffer->remove_output ();
     buffer->idx = buffer->len - 1;
 
-    apply_backward (c, accel, subtables);
+    apply_backward (c, accel);
   }
 }
 
commit 97e5913d5ac2cd313fb3923e9602358d7f75f11d
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Wed Oct 10 11:41:05 2018 -0400

    Move more code

diff --git a/src/hb-ot-layout-gsubgpos.hh b/src/hb-ot-layout-gsubgpos.hh
index 07744aef..a11d5dcc 100644
--- a/src/hb-ot-layout-gsubgpos.hh
+++ b/src/hb-ot-layout-gsubgpos.hh
@@ -2612,6 +2612,23 @@ struct Extension
  * GSUB/GPOS Common
  */
 
+struct hb_ot_layout_lookup_accelerator_t
+{
+  template <typename TLookup>
+  inline void init (const TLookup &lookup)
+  {
+    digest.init ();
+    lookup.add_coverage (&digest);
+  }
+  inline void fini (void) {}
+
+  inline bool may_have (hb_codepoint_t g) const
+  { return digest.may_have (g); }
+
+  private:
+  hb_set_digest_t digest;
+};
+
 struct GSUBGPOS
 {
   inline bool has_data (void) const { return version.to_int () != 0; }
diff --git a/src/hb-ot-layout.cc b/src/hb-ot-layout.cc
index fc83873c..572e4cb9 100644
--- a/src/hb-ot-layout.cc
+++ b/src/hb-ot-layout.cc
@@ -1094,7 +1094,7 @@ struct GSUBProxy
     accels (hb_ot_face_data (face)->GSUB->accels) {}
 
   const OT::GSUB &table;
-  const hb_ot_layout_lookup_accelerator_t *accels;
+  const OT::hb_ot_layout_lookup_accelerator_t *accels;
 };
 
 struct GPOSProxy
@@ -1108,13 +1108,13 @@ struct GPOSProxy
     accels (hb_ot_face_data (face)->GPOS->accels) {}
 
   const OT::GPOS &table;
-  const hb_ot_layout_lookup_accelerator_t *accels;
+  const OT::hb_ot_layout_lookup_accelerator_t *accels;
 };
 
 
 static inline bool
 apply_forward (OT::hb_ot_apply_context_t *c,
-	       const hb_ot_layout_lookup_accelerator_t &accel,
+	       const OT::hb_ot_layout_lookup_accelerator_t &accel,
 	       const OT::hb_get_subtables_context_t::array_t &subtables)
 {
   bool ret = false;
@@ -1144,7 +1144,7 @@ apply_forward (OT::hb_ot_apply_context_t *c,
 
 static inline bool
 apply_backward (OT::hb_ot_apply_context_t *c,
-	       const hb_ot_layout_lookup_accelerator_t &accel,
+	       const OT::hb_ot_layout_lookup_accelerator_t &accel,
 	       const OT::hb_get_subtables_context_t::array_t &subtables)
 {
   bool ret = false;
@@ -1174,7 +1174,7 @@ template <typename Proxy>
 static inline void
 apply_string (OT::hb_ot_apply_context_t *c,
 	      const typename Proxy::Lookup &lookup,
-	      const hb_ot_layout_lookup_accelerator_t &accel)
+	      const OT::hb_ot_layout_lookup_accelerator_t &accel)
 {
   hb_buffer_t *buffer = c->buffer;
 
@@ -1270,7 +1270,7 @@ void hb_ot_map_t::position (const hb_ot_shape_plan_t *plan, hb_font_t *font, hb_
 void
 hb_ot_layout_substitute_lookup (OT::hb_ot_apply_context_t *c,
 				const OT::SubstLookup &lookup,
-				const hb_ot_layout_lookup_accelerator_t &accel)
+				const OT::hb_ot_layout_lookup_accelerator_t &accel)
 {
   apply_string<GSUBProxy> (c, lookup, accel);
 }
diff --git a/src/hb-ot-layout.hh b/src/hb-ot-layout.hh
index f5ffe311..64b3d748 100644
--- a/src/hb-ot-layout.hh
+++ b/src/hb-ot-layout.hh
@@ -112,32 +112,16 @@ hb_ot_layout_substitute_start (hb_font_t    *font,
 			       hb_buffer_t  *buffer);
 
 
-struct hb_ot_layout_lookup_accelerator_t
-{
-  template <typename TLookup>
-  inline void init (const TLookup &lookup)
-  {
-    digest.init ();
-    lookup.add_coverage (&digest);
-  }
-  inline void fini (void) {}
-
-  inline bool may_have (hb_codepoint_t g) const
-  { return digest.may_have (g); }
-
-  private:
-  hb_set_digest_t digest;
-};
-
 namespace OT {
   struct hb_ot_apply_context_t;
   struct SubstLookup;
+  struct hb_ot_layout_lookup_accelerator_t;
 }
 
 HB_INTERNAL void
 hb_ot_layout_substitute_lookup (OT::hb_ot_apply_context_t *c,
 				const OT::SubstLookup &lookup,
-				const hb_ot_layout_lookup_accelerator_t &accel);
+				const OT::hb_ot_layout_lookup_accelerator_t &accel);
 
 
 /* Should be called before all the position_lookup's are done. */
diff --git a/src/hb-ot-shape-complex-arabic-fallback.hh b/src/hb-ot-shape-complex-arabic-fallback.hh
index 0ef60f64..2aa03672 100644
--- a/src/hb-ot-shape-complex-arabic-fallback.hh
+++ b/src/hb-ot-shape-complex-arabic-fallback.hh
@@ -201,7 +201,7 @@ struct arabic_fallback_plan_t
 
   hb_mask_t mask_array[ARABIC_FALLBACK_MAX_LOOKUPS];
   OT::SubstLookup *lookup_array[ARABIC_FALLBACK_MAX_LOOKUPS];
-  hb_ot_layout_lookup_accelerator_t accel_array[ARABIC_FALLBACK_MAX_LOOKUPS];
+  OT::hb_ot_layout_lookup_accelerator_t accel_array[ARABIC_FALLBACK_MAX_LOOKUPS];
 };
 
 #if (defined(_WIN32) || defined(__CYGWIN__)) && !defined(HB_NO_WIN1256)
commit c8f2d9334c0f91ec30f1c7821eb44bb5149bd31c
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Wed Oct 10 11:36:28 2018 -0400

    Move code
    
    In preparation to move add per-subtable set digests...

diff --git a/src/hb-ot-layout-gsubgpos.hh b/src/hb-ot-layout-gsubgpos.hh
index bdaf35a9..07744aef 100644
--- a/src/hb-ot-layout-gsubgpos.hh
+++ b/src/hb-ot-layout-gsubgpos.hh
@@ -259,6 +259,56 @@ struct hb_add_coverage_context_t :
 };
 
 
+struct hb_get_subtables_context_t :
+       hb_dispatch_context_t<hb_get_subtables_context_t, hb_void_t, HB_DEBUG_APPLY>
+{
+  template <typename Type>
+  static inline bool apply_to (const void *obj, OT::hb_ot_apply_context_t *c)
+  {
+    const Type *typed_obj = (const Type *) obj;
+    return typed_obj->apply (c);
+  }
+
+  typedef bool (*hb_apply_func_t) (const void *obj, OT::hb_ot_apply_context_t *c);
+
+  struct hb_applicable_t
+  {
+    inline void init (const void *obj_, hb_apply_func_t apply_func_)
+    {
+      obj = obj_;
+      apply_func = apply_func_;
+    }
+
+    inline bool apply (OT::hb_ot_apply_context_t *c) const { return apply_func (obj, c); }
+
+    private:
+    const void *obj;
+    hb_apply_func_t apply_func;
+  };
+
+  typedef hb_auto_t<hb_vector_t<hb_applicable_t> > array_t;
+
+  /* Dispatch interface. */
+  inline const char *get_name (void) { return "GET_SUBTABLES"; }
+  template <typename T>
+  inline return_t dispatch (const T &obj)
+  {
+    hb_applicable_t *entry = array.push();
+    entry->init (&obj, apply_to<T>);
+    return HB_VOID;
+  }
+  static return_t default_return_value (void) { return HB_VOID; }
+  bool stop_sublookup_iteration (return_t r HB_UNUSED) const { return false; }
+
+  hb_get_subtables_context_t (array_t &array_) :
+			      array (array_),
+			      debug_depth (0) {}
+
+  array_t &array;
+  unsigned int debug_depth;
+};
+
+
 struct hb_ot_apply_context_t :
        hb_dispatch_context_t<hb_ot_apply_context_t, bool, HB_DEBUG_APPLY>
 {
diff --git a/src/hb-ot-layout.cc b/src/hb-ot-layout.cc
index 975b7f8d..fc83873c 100644
--- a/src/hb-ot-layout.cc
+++ b/src/hb-ot-layout.cc
@@ -1112,59 +1112,10 @@ struct GPOSProxy
 };
 
 
-struct hb_get_subtables_context_t :
-       hb_dispatch_context_t<hb_get_subtables_context_t, hb_void_t, HB_DEBUG_APPLY>
-{
-  template <typename Type>
-  static inline bool apply_to (const void *obj, OT::hb_ot_apply_context_t *c)
-  {
-    const Type *typed_obj = (const Type *) obj;
-    return typed_obj->apply (c);
-  }
-
-  typedef bool (*hb_apply_func_t) (const void *obj, OT::hb_ot_apply_context_t *c);
-
-  struct hb_applicable_t
-  {
-    inline void init (const void *obj_, hb_apply_func_t apply_func_)
-    {
-      obj = obj_;
-      apply_func = apply_func_;
-    }
-
-    inline bool apply (OT::hb_ot_apply_context_t *c) const { return apply_func (obj, c); }
-
-    private:
-    const void *obj;
-    hb_apply_func_t apply_func;
-  };
-
-  typedef hb_auto_t<hb_vector_t<hb_applicable_t> > array_t;
-
-  /* Dispatch interface. */
-  inline const char *get_name (void) { return "GET_SUBTABLES"; }
-  template <typename T>
-  inline return_t dispatch (const T &obj)
-  {
-    hb_applicable_t *entry = array.push();
-    entry->init (&obj, apply_to<T>);
-    return HB_VOID;
-  }
-  static return_t default_return_value (void) { return HB_VOID; }
-  bool stop_sublookup_iteration (return_t r HB_UNUSED) const { return false; }
-
-  hb_get_subtables_context_t (array_t &array_) :
-			      array (array_),
-			      debug_depth (0) {}
-
-  array_t &array;
-  unsigned int debug_depth;
-};
-
 static inline bool
 apply_forward (OT::hb_ot_apply_context_t *c,
 	       const hb_ot_layout_lookup_accelerator_t &accel,
-	       const hb_get_subtables_context_t::array_t &subtables)
+	       const OT::hb_get_subtables_context_t::array_t &subtables)
 {
   bool ret = false;
   hb_buffer_t *buffer = c->buffer;
@@ -1194,7 +1145,7 @@ apply_forward (OT::hb_ot_apply_context_t *c,
 static inline bool
 apply_backward (OT::hb_ot_apply_context_t *c,
 	       const hb_ot_layout_lookup_accelerator_t &accel,
-	       const hb_get_subtables_context_t::array_t &subtables)
+	       const OT::hb_get_subtables_context_t::array_t &subtables)
 {
   bool ret = false;
   hb_buffer_t *buffer = c->buffer;
@@ -1232,8 +1183,8 @@ apply_string (OT::hb_ot_apply_context_t *c,
 
   c->set_lookup_props (lookup.get_props ());
 
-  hb_get_subtables_context_t::array_t subtables;
-  hb_get_subtables_context_t c_get_subtables (subtables);
+  OT::hb_get_subtables_context_t::array_t subtables;
+  OT::hb_get_subtables_context_t c_get_subtables (subtables);
   lookup.dispatch (&c_get_subtables);
 
   if (likely (!lookup.is_reverse ()))
commit a03850a3567d532c3a4d7655aa71bfe73dfb0e33
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Wed Oct 10 10:57:28 2018 -0400

    Fix GPOS/kern interaction
    
    Oops.  Was checking for kern feature in GSUB, not GPOS.

diff --git a/src/hb-ot-shape.cc b/src/hb-ot-shape.cc
index 936b01fd..21e06938 100644
--- a/src/hb-ot-shape.cc
+++ b/src/hb-ot-shape.cc
@@ -61,7 +61,7 @@ hb_ot_shape_planner_t::compile (hb_ot_shape_plan_t &plan,
   plan.kern_mask = plan.map.get_mask (kern_tag);
 
   bool kerning_requested = !!plan.kern_mask;
-  bool has_gpos_kern = plan.map.get_feature_index (0, kern_tag) != HB_OT_LAYOUT_NO_FEATURE_INDEX;
+  bool has_gpos_kern = plan.map.get_feature_index (1, kern_tag) != HB_OT_LAYOUT_NO_FEATURE_INDEX;
   bool disable_gpos = plan.shaper->gpos_tag &&
 		      plan.shaper->gpos_tag != plan.map.chosen_script[1];
 
commit d1be805e784dfaadf2ce9caa830a3f851fdd67da
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Wed Oct 10 10:49:45 2018 -0400

    More rewriting plan compile
    
    Hopefully more clear.

diff --git a/src/hb-ot-shape.cc b/src/hb-ot-shape.cc
index 0d2a3b96..936b01fd 100644
--- a/src/hb-ot-shape.cc
+++ b/src/hb-ot-shape.cc
@@ -59,29 +59,54 @@ hb_ot_shape_planner_t::compile (hb_ot_shape_plan_t &plan,
   hb_tag_t kern_tag = HB_DIRECTION_IS_HORIZONTAL (plan.props.direction) ?
 		      HB_TAG ('k','e','r','n') : HB_TAG ('v','k','r','n');
   plan.kern_mask = plan.map.get_mask (kern_tag);
-  plan.kerning_requested = !!plan.kern_mask;
 
+  bool kerning_requested = !!plan.kern_mask;
   bool has_gpos_kern = plan.map.get_feature_index (0, kern_tag) != HB_OT_LAYOUT_NO_FEATURE_INDEX;
   bool disable_gpos = plan.shaper->gpos_tag &&
 		      plan.shaper->gpos_tag != plan.map.chosen_script[1];
 
-  /* Decide who provides glyph classes. GDEF or Unicode. */
-  plan.fallback_glyph_classes = !hb_ot_layout_has_glyph_classes (face);
+  /*
+   * Decide who provides glyph classes. GDEF or Unicode.
+   */
+
+  if (!hb_ot_layout_has_glyph_classes (face))
+    plan.fallback_glyph_classes = true;
+
+  /*
+   * Decide who does substitutions. GSUB, morx, or fallback.
+   */
 
-  /* Decide who does substitutions. GSUB, morx, or fallback. */
-  plan.apply_morx = !hb_ot_layout_has_substitution (face) &&
-		     hb_aat_layout_has_substitution (face);
+  if (!hb_ot_layout_has_substitution (face))
+  { /* No GSUB. */
+    if (hb_aat_layout_has_substitution (face))
+      plan.apply_morx = true;
+  }
 
-  /* Decide who does positioning. GPOS, kerx, kern, or fallback. */
-  plan.apply_gpos = !disable_gpos && hb_ot_layout_has_positioning (face);
-  plan.apply_kerx = !plan.apply_gpos &&
-		     hb_aat_layout_has_positioning (face);
+  /*
+   * Decide who does positioning. GPOS, kerx, kern, or fallback.
+   */
 
-  plan.apply_kern = !has_gpos_kern && !plan.apply_kerx && hb_ot_layout_has_kerning (face);
-  plan.fallback_kerning = !has_gpos_kern && !plan.apply_kerx && !plan.apply_kern;
+  if (!disable_gpos && hb_ot_layout_has_positioning (face))
+    plan.apply_gpos = true;
+  else if (hb_aat_layout_has_positioning (face))
+    plan.apply_kerx = true;
+
+  if (kerning_requested)
+  {
+    if (plan.apply_kerx)
+      ;/* kerx supercedes kern. */
+    else if (!has_gpos_kern)
+    {
+      if (hb_ot_layout_has_kerning (face))
+        plan.apply_kern = true;
+      else
+	plan.fallback_kerning = true;
+    }
+  }
 
   plan.has_gpos_mark = !!plan.map.get_1_mask (HB_TAG ('m','a','r','k'));
-  plan.fallback_mark_positioning = !plan.apply_gpos;
+  if (!plan.apply_gpos)
+    plan.fallback_mark_positioning = true;
 }
 
 
@@ -844,9 +869,7 @@ hb_ot_position (const hb_ot_shape_context_t *c)
 
   /* Visual fallback goes here. */
 
-  if (!c->plan->kerning_requested)
-    ;
-  else if (c->plan->apply_kern)
+  if (c->plan->apply_kern)
     hb_ot_layout_kern (c->font, c->buffer, c->plan->kern_mask);
   else if (c->plan->fallback_kerning)
     _hb_ot_shape_fallback_kern (c->plan, c->font, c->buffer);
diff --git a/src/hb-ot-shape.hh b/src/hb-ot-shape.hh
index 7b76a5d5..fc444b25 100644
--- a/src/hb-ot-shape.hh
+++ b/src/hb-ot-shape.hh
@@ -44,7 +44,6 @@ struct hb_ot_shape_plan_t
   hb_mask_t kern_mask;
 
   bool has_frac : 1;
-  bool kerning_requested : 1;
   bool has_gpos_mark : 1;
   bool fallback_glyph_classes : 1;
   bool fallback_kerning : 1;
commit 961ab46b24ca9f3ef42a56398646191f106bf5bd
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Wed Oct 10 10:42:10 2018 -0400

    More reshuffle plan compile

diff --git a/src/hb-ot-shape.cc b/src/hb-ot-shape.cc
index 8f665d37..0d2a3b96 100644
--- a/src/hb-ot-shape.cc
+++ b/src/hb-ot-shape.cc
@@ -52,11 +52,18 @@ hb_ot_shape_planner_t::compile (hb_ot_shape_plan_t &plan,
   map.compile (plan.map, coords, num_coords);
 
   plan.rtlm_mask = plan.map.get_1_mask (HB_TAG ('r','t','l','m'));
-
   plan.frac_mask = plan.map.get_1_mask (HB_TAG ('f','r','a','c'));
   plan.numr_mask = plan.map.get_1_mask (HB_TAG ('n','u','m','r'));
   plan.dnom_mask = plan.map.get_1_mask (HB_TAG ('d','n','o','m'));
   plan.has_frac = plan.frac_mask || (plan.numr_mask && plan.dnom_mask);
+  hb_tag_t kern_tag = HB_DIRECTION_IS_HORIZONTAL (plan.props.direction) ?
+		      HB_TAG ('k','e','r','n') : HB_TAG ('v','k','r','n');
+  plan.kern_mask = plan.map.get_mask (kern_tag);
+  plan.kerning_requested = !!plan.kern_mask;
+
+  bool has_gpos_kern = plan.map.get_feature_index (0, kern_tag) != HB_OT_LAYOUT_NO_FEATURE_INDEX;
+  bool disable_gpos = plan.shaper->gpos_tag &&
+		      plan.shaper->gpos_tag != plan.map.chosen_script[1];
 
   /* Decide who provides glyph classes. GDEF or Unicode. */
   plan.fallback_glyph_classes = !hb_ot_layout_has_glyph_classes (face);
@@ -66,17 +73,10 @@ hb_ot_shape_planner_t::compile (hb_ot_shape_plan_t &plan,
 		     hb_aat_layout_has_substitution (face);
 
   /* Decide who does positioning. GPOS, kerx, kern, or fallback. */
-  bool disable_gpos = plan.shaper->gpos_tag &&
-		      plan.shaper->gpos_tag != plan.map.chosen_script[1];
   plan.apply_gpos = !disable_gpos && hb_ot_layout_has_positioning (face);
   plan.apply_kerx = !plan.apply_gpos &&
 		     hb_aat_layout_has_positioning (face);
 
-  hb_tag_t kern_tag = HB_DIRECTION_IS_HORIZONTAL (plan.props.direction) ?
-		      HB_TAG ('k','e','r','n') : HB_TAG ('v','k','r','n');
-  plan.kern_mask = plan.map.get_mask (kern_tag);
-  plan.kerning_requested = !!plan.kern_mask;
-  bool has_gpos_kern = plan.map.get_feature_index (0, kern_tag) != HB_OT_LAYOUT_NO_FEATURE_INDEX;
   plan.apply_kern = !has_gpos_kern && !plan.apply_kerx && hb_ot_layout_has_kerning (face);
   plan.fallback_kerning = !has_gpos_kern && !plan.apply_kerx && !plan.apply_kern;
 
commit 2091b509e3e3b7fb7315539679fae81da2879280
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Wed Oct 10 10:41:08 2018 -0400

    [kerx] Hook up to shaper

diff --git a/src/hb-aat-layout.cc b/src/hb-aat-layout.cc
index 71932e79..3fd4f9f8 100644
--- a/src/hb-aat-layout.cc
+++ b/src/hb-aat-layout.cc
@@ -54,6 +54,21 @@ _get_morx (hb_face_t *face, hb_blob_t **blob = nullptr)
     *blob = hb_ot_face_data (face)->morx.get_blob ();
   return morx;
 }
+static inline const AAT::kerx&
+_get_kerx (hb_face_t *face, hb_blob_t **blob = nullptr)
+{
+  if (unlikely (!hb_ot_shaper_face_data_ensure (face)))
+  {
+    if (blob)
+      *blob = hb_blob_get_empty ();
+    return Null(AAT::kerx);
+  }
+  const AAT::kerx& kerx = *(hb_ot_face_data (face)->kerx.get ());
+  if (blob)
+    *blob = hb_ot_face_data (face)->kerx.get_blob ();
+  return kerx;
+}
+
 
 hb_bool_t
 hb_aat_layout_has_substitution (hb_face_t *face)
@@ -73,19 +88,21 @@ hb_aat_layout_substitute (hb_ot_shape_plan_t *plan,
   morx.apply (&c);
 }
 
+
+hb_bool_t
+hb_aat_layout_has_positioning (hb_face_t *face)
+{
+  return _get_kerx (face).has_data ();
+}
+
 void
 hb_aat_layout_position (hb_ot_shape_plan_t *plan,
 			hb_font_t *font,
 			hb_buffer_t *buffer)
 {
-#if 0
   hb_blob_t *blob;
-  const AAT::ankr& ankr = _get_ankr (font->face, &blob);
   const AAT::kerx& kerx = _get_kerx (font->face, &blob);
-  const AAT::trak& trak = _get_trak (font->face, &blob);
 
-  AAT::hb_aat_apply_context_t c (font, buffer, blob);
-  kerx.apply (&c, &ankr);
-  trak.apply (&c);
-#endif
+  AAT::hb_aat_apply_context_t c (plan, font, buffer, blob);
+  kerx.apply (&c);
 }
diff --git a/src/hb-aat-layout.hh b/src/hb-aat-layout.hh
index 8b12833d..aafc3278 100644
--- a/src/hb-aat-layout.hh
+++ b/src/hb-aat-layout.hh
@@ -39,6 +39,9 @@ hb_aat_layout_substitute (hb_ot_shape_plan_t *plan,
 			  hb_font_t *font,
 			  hb_buffer_t *buffer);
 
+HB_INTERNAL hb_bool_t
+hb_aat_layout_has_positioning (hb_face_t *face);
+
 HB_INTERNAL void
 hb_aat_layout_position (hb_ot_shape_plan_t *plan,
 			hb_font_t *font,
diff --git a/src/hb-ot-shape.cc b/src/hb-ot-shape.cc
index 5555327b..8f665d37 100644
--- a/src/hb-ot-shape.cc
+++ b/src/hb-ot-shape.cc
@@ -69,14 +69,16 @@ hb_ot_shape_planner_t::compile (hb_ot_shape_plan_t &plan,
   bool disable_gpos = plan.shaper->gpos_tag &&
 		      plan.shaper->gpos_tag != plan.map.chosen_script[1];
   plan.apply_gpos = !disable_gpos && hb_ot_layout_has_positioning (face);
+  plan.apply_kerx = !plan.apply_gpos &&
+		     hb_aat_layout_has_positioning (face);
 
   hb_tag_t kern_tag = HB_DIRECTION_IS_HORIZONTAL (plan.props.direction) ?
 		      HB_TAG ('k','e','r','n') : HB_TAG ('v','k','r','n');
   plan.kern_mask = plan.map.get_mask (kern_tag);
   plan.kerning_requested = !!plan.kern_mask;
   bool has_gpos_kern = plan.map.get_feature_index (0, kern_tag) != HB_OT_LAYOUT_NO_FEATURE_INDEX;
-  plan.apply_kern = !has_gpos_kern && hb_ot_layout_has_kerning (face);
-  plan.fallback_kerning = !has_gpos_kern && !plan.apply_kern;
+  plan.apply_kern = !has_gpos_kern && !plan.apply_kerx && hb_ot_layout_has_kerning (face);
+  plan.fallback_kerning = !has_gpos_kern && !plan.apply_kerx && !plan.apply_kern;
 
   plan.has_gpos_mark = !!plan.map.get_1_mask (HB_TAG ('m','a','r','k'));
   plan.fallback_mark_positioning = !plan.apply_gpos;
diff --git a/src/hb-ot-shape.hh b/src/hb-ot-shape.hh
index 43852d8f..7b76a5d5 100644
--- a/src/hb-ot-shape.hh
+++ b/src/hb-ot-shape.hh
@@ -51,6 +51,7 @@ struct hb_ot_shape_plan_t
   bool fallback_mark_positioning : 1;
 
   bool apply_morx : 1;
+  bool apply_kerx : 1;
   bool apply_kern : 1;
   bool apply_gpos : 1;
 


More information about the HarfBuzz mailing list