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

Behdad Esfahbod behdad at kemper.freedesktop.org
Wed Oct 10 21:46:36 UTC 2018


 CMakeLists.txt                  |    1 -
 configure.ac                    |    6 ------
 src/Makefile.am                 |    2 --
 src/hb-aat-layout-common.hh     |    6 ++++++
 src/hb-aat-layout-kerx-table.hh |   18 +++++++++---------
 src/hb-common.cc                |   23 +++++++++++++++++++++--
 src/hb-debug.hh                 |    7 ++++---
 src/hb-ot-shape.cc              |   28 ++++++++++++++++++----------
 src/hb-shaper-list.hh           |    2 --
 src/hb.hh                       |    2 --
 test/api/Makefile.am            |    4 +---
 test/api/test-c.c               |    5 +----
 util/Makefile.am                |    4 ----
 util/options.cc                 |    4 ----
 util/options.hh                 |    2 --
 15 files changed, 60 insertions(+), 54 deletions(-)

New commits:
commit 38a7a8a89ed035a1d1fc34a675a1860ad660b6ff
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Wed Oct 10 17:44:46 2018 -0400

    Allow HB_OPTIONS=aat to prefer AAT tables over OT
    
    Fixes https://github.com/harfbuzz/harfbuzz/issues/322

diff --git a/src/hb-common.cc b/src/hb-common.cc
index 41b1601d..f698a440 100644
--- a/src/hb-common.cc
+++ b/src/hb-common.cc
@@ -47,8 +47,27 @@ _hb_options_init (void)
   u.i = 0;
   u.opts.initialized = 1;
 
-  char *c = getenv ("HB_OPTIONS");
-  u.opts.uniscribe_bug_compatible = c && strstr (c, "uniscribe-bug-compatible");
+  const char *c = getenv ("HB_OPTIONS");
+  if (c)
+  {
+    while (*c)
+    {
+      const char *p = strchr (c, ':');
+      if (!p)
+        p = c + strlen (c);
+
+#define OPTION(name, symbol) \
+	if (0 == strncmp (c, name, p - c)) u.opts.symbol = true;
+
+      OPTION ("uniscribe-bug-compatible", uniscribe_bug_compatible);
+      OPTION ("aat", aat);
+
+#undef OPTION
+
+      c = *p ? p + 1 : p;
+    }
+
+  }
 
   /* This is idempotent and threadsafe. */
   _hb_options.set_relaxed (u.i);
diff --git a/src/hb-debug.hh b/src/hb-debug.hh
index 12b6c49a..58c190d2 100644
--- a/src/hb-debug.hh
+++ b/src/hb-debug.hh
@@ -43,9 +43,10 @@
 
 struct hb_options_t
 {
-  unsigned int unused : 1; /* In-case sign bit is here. */
-  unsigned int initialized : 1;
-  unsigned int uniscribe_bug_compatible : 1;
+  bool unused : 1; /* In-case sign bit is here. */
+  bool initialized : 1;
+  bool uniscribe_bug_compatible : 1;
+  bool aat : 1;
 };
 
 union hb_options_union_t {
diff --git a/src/hb-ot-shape.cc b/src/hb-ot-shape.cc
index cf808c2a..7a15d523 100644
--- a/src/hb-ot-shape.cc
+++ b/src/hb-ot-shape.cc
@@ -42,6 +42,17 @@
 #include "hb-aat-layout.hh"
 
 
+static bool
+_hb_apply_morx (hb_face_t *face)
+{
+  if (hb_options ().aat &&
+      hb_aat_layout_has_substitution (face))
+    return true;
+
+  return !hb_ot_layout_has_substitution (face) &&
+	 hb_aat_layout_has_substitution (face);
+}
+
 void
 hb_ot_shape_planner_t::compile (hb_ot_shape_plan_t &plan,
 				const int          *coords,
@@ -76,17 +87,15 @@ hb_ot_shape_planner_t::compile (hb_ot_shape_plan_t &plan,
    * Decide who does substitutions. GSUB, morx, or fallback.
    */
 
-  if (!hb_ot_layout_has_substitution (face))
-  { /* No GSUB. */
-    if (hb_aat_layout_has_substitution (face))
-      plan.apply_morx = true;
-  }
+  plan.apply_morx = _hb_apply_morx (face);
 
   /*
    * Decide who does positioning. GPOS, kerx, kern, or fallback.
    */
 
-  if (!disable_gpos && hb_ot_layout_has_positioning (face))
+  if (hb_options ().aat && hb_aat_layout_has_positioning (face))
+    plan.apply_kerx = true;
+  else 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;
@@ -263,8 +272,7 @@ _hb_ot_shaper_shape_plan_data_create (hb_shape_plan_t    *shape_plan,
 
   /* Ugly that we have to do this here...
    * If we are going to apply morx, choose default shaper. */
-  if (!hb_ot_layout_has_substitution (planner.face) &&
-       hb_aat_layout_has_substitution (planner.face))
+  if (_hb_apply_morx (planner.face))
     planner.shaper = &_hb_ot_complex_shaper_default;
   else
     planner.shaper = hb_ot_shape_complex_categorize (&planner);
commit 44f09afd5bd4f4f1ea47ca54ac9d605219b06910
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Wed Oct 10 17:32:32 2018 -0400

    [kerx] Skip variation subtables

diff --git a/src/hb-aat-layout-kerx-table.hh b/src/hb-aat-layout-kerx-table.hh
index a4a4dab7..005208c6 100644
--- a/src/hb-aat-layout-kerx-table.hh
+++ b/src/hb-aat-layout-kerx-table.hh
@@ -312,21 +312,21 @@ struct kerx
     {
       bool reverse;
 
+      if (table->coverage & (KerxTable::CrossStream | KerxTable::Variation))
+	goto skip; /* We do NOT handle cross-stream or variation kerning. */
+
       if (HB_DIRECTION_IS_VERTICAL (c->buffer->props.direction) !=
 	  bool (table->coverage & KerxTable::Vertical))
-        goto skip;
-
-      if (table->coverage & KerxTable::CrossStream)
-        goto skip; /* We do NOT handle cross-stream kerning.  None of Apple fonts use it. */
+	goto skip;
 
       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))
-        goto skip;
+	goto skip;
 
       if (reverse)
-        c->buffer->reverse ();
+	c->buffer->reverse ();
 
       c->sanitizer.set_object (*table);
 
@@ -337,7 +337,7 @@ struct kerx
       table->dispatch (c);
 
       if (reverse)
-        c->buffer->reverse ();
+	c->buffer->reverse ();
 
       (void) c->buffer->message (c->font, "end kerx subtable %d", c->lookup_index);
 
commit 1e8fdd285f90b7b715b6d9ca9222a3c91cbea6b8
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Wed Oct 10 16:32:35 2018 -0400

    Remove HAVE_OT
    
    We never tested compiling without it.  Just kill it.  We always build
    our own shaper.

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 83ebed7c..760883fd 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -97,7 +97,6 @@ include_directories(AFTER
   ${PROJECT_BINARY_DIR}/src
 )
 
-add_definitions(-DHAVE_OT)
 add_definitions(-DHAVE_FALLBACK)
 
 # We need PYTHON_EXECUTABLE to be set for running the tests...
diff --git a/configure.ac b/configure.ac
index 3aa41ff2..1b9ddfe7 100644
--- a/configure.ac
+++ b/configure.ac
@@ -148,12 +148,6 @@ AM_CONDITIONAL(HAVE_PTHREAD, $have_pthread)
 
 dnl ==========================================================================
 
-have_ot=true
-if $have_ot; then
-	AC_DEFINE(HAVE_OT, 1, [Have native OpenType Layout backend])
-fi
-AM_CONDITIONAL(HAVE_OT, $have_ot)
-
 have_fallback=true
 if $have_fallback; then
 	AC_DEFINE(HAVE_FALLBACK, 1, [Have simple TrueType Layout backend])
diff --git a/src/Makefile.am b/src/Makefile.am
index 2eca356b..c4ae2bcb 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -29,11 +29,9 @@ HBSOURCES =  $(HB_BASE_sources)
 HBSOURCES += $(HB_BASE_RAGEL_GENERATED_sources)
 HBHEADERS = $(HB_BASE_headers)
 
-if HAVE_OT
 HBSOURCES += $(HB_OT_sources)
 HBSOURCES += $(HB_OT_RAGEL_GENERATED_sources)
 HBHEADERS += $(HB_OT_headers)
-endif
 
 if HAVE_FALLBACK
 HBSOURCES += $(HB_FALLBACK_sources)
diff --git a/src/hb-shaper-list.hh b/src/hb-shaper-list.hh
index b0835d31..1fdb6481 100644
--- a/src/hb-shaper-list.hh
+++ b/src/hb-shaper-list.hh
@@ -39,9 +39,7 @@ HB_SHAPER_IMPLEMENT (graphite2)
 HB_SHAPER_IMPLEMENT (coretext_aat)
 #endif
 
-#ifdef HAVE_OT
 HB_SHAPER_IMPLEMENT (ot) /* <--- This is our main OpenType shaper. */
-#endif
 
 #ifdef HAVE_UNISCRIBE
 HB_SHAPER_IMPLEMENT (uniscribe)
diff --git a/src/hb.hh b/src/hb.hh
index 15228522..f37be7ad 100644
--- a/src/hb.hh
+++ b/src/hb.hh
@@ -45,10 +45,8 @@
 
 #include "hb.h"
 #define HB_H_IN
-#ifdef HAVE_OT
 #include "hb-ot.h"
 #define HB_OT_H_IN
-#endif
 
 #include <math.h>
 #include <stdlib.h>
diff --git a/test/api/Makefile.am b/test/api/Makefile.am
index 02e87803..3ff7f5a8 100644
--- a/test/api/Makefile.am
+++ b/test/api/Makefile.am
@@ -69,13 +69,12 @@ test_unicode_LDADD += $(top_builddir)/src/libharfbuzz-icu.la $(ICU_LIBS)
 endif
 
 
-if HAVE_OT
-
 TEST_PROGS += \
 	test-ot-color \
 	test-ot-tag \
 	$(NULL)
 
+
 if HAVE_PTHREAD
 if HAVE_FREETYPE
 TEST_PROGS += test-multithread
@@ -95,7 +94,6 @@ test_ot_math_LDADD = $(LDADD) $(FREETYPE_LIBS)
 test_ot_math_CPPFLAGS = $(AM_CPPFLAGS) $(FREETYPE_CFLAGS)
 endif # HAVE_FREETYPE
 
-endif # HAVE_OT
 
 # Tests for header compilation
 TEST_PROGS += \
diff --git a/test/api/test-c.c b/test/api/test-c.c
index 78d6e974..061f35cd 100644
--- a/test/api/test-c.c
+++ b/test/api/test-c.c
@@ -32,6 +32,7 @@
 #endif
 
 #include <hb.h>
+#include <hb-ot.h>
 
 #ifdef HAVE_GLIB
 #include <hb-glib.h>
@@ -45,10 +46,6 @@
 #include <hb-ft.h>
 #endif
 
-#ifdef HAVE_OT
-#include <hb-ot.h>
-#endif
-
 #ifdef HAVE_UNISCRIBE
 #include <hb-uniscribe.h>
 #endif
diff --git a/util/Makefile.am b/util/Makefile.am
index b8bf8841..85f9edaa 100644
--- a/util/Makefile.am
+++ b/util/Makefile.am
@@ -52,14 +52,11 @@ hb_subset_LDADD = \
 	$(top_builddir)/src/libharfbuzz-subset.la
 bin_PROGRAMS += hb-subset
 
-if HAVE_OT
 hb_ot_shape_closure_SOURCES = $(HB_OT_SHAPE_CLOSURE_sources)
 bin_PROGRAMS += hb-ot-shape-closure
-endif # HAVE_OT
 
 endif # HAVE_GLIB
 
-#if HAVE_OT
 #if HAVE_FONTCONFIG
 #hb_fc_list_SOURCES = \
 #	hb-fc.cc \
@@ -72,6 +69,5 @@ endif # HAVE_GLIB
 #	$(NULL)
 #bin_PROGRAMS += hb-fc-list
 #endif # HAVE_FONTCONFIG
-#endif # HAVE_OT
 
 -include $(top_srcdir)/git.mk
diff --git a/util/options.cc b/util/options.cc
index 090a9c25..26b0bd0a 100644
--- a/util/options.cc
+++ b/util/options.cc
@@ -29,9 +29,7 @@
 #ifdef HAVE_FREETYPE
 #include <hb-ft.h>
 #endif
-#ifdef HAVE_OT
 #include <hb-ot.h>
-#endif
 
 static struct supported_font_funcs_t {
 	char name[4];
@@ -41,9 +39,7 @@ static struct supported_font_funcs_t {
 #ifdef HAVE_FREETYPE
   {"ft",	hb_ft_font_set_funcs},
 #endif
-#ifdef HAVE_OT
   {"ot",	hb_ot_font_set_funcs},
-#endif
 };
 
 
diff --git a/util/options.hh b/util/options.hh
index 5088adab..3749b99b 100644
--- a/util/options.hh
+++ b/util/options.hh
@@ -46,9 +46,7 @@
 #endif
 
 #include <hb.h>
-#ifdef HAVE_OT
 #include <hb-ot.h>
-#endif
 #include <glib.h>
 #include <glib/gprintf.h>
 
commit 7727e737566ddc826647e19fc645b296ad5a0cac
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Wed Oct 10 13:24:51 2018 -0400

    [kerx] Actually hook up, and fix crash

diff --git a/src/hb-aat-layout-common.hh b/src/hb-aat-layout-common.hh
index 5845ab51..37ab5353 100644
--- a/src/hb-aat-layout-common.hh
+++ b/src/hb-aat-layout-common.hh
@@ -260,6 +260,12 @@ struct Lookup
     }
   }
 
+  inline const T& get_value_or_null (hb_codepoint_t glyph_id, unsigned int num_glyphs) const
+  {
+    const T *v = get_value (glyph_id, num_glyphs);
+    return v ? *v : Null(T);
+  }
+
   inline bool sanitize (hb_sanitize_context_t *c) const
   {
     TRACE_SANITIZE (this);
diff --git a/src/hb-aat-layout-kerx-table.hh b/src/hb-aat-layout-kerx-table.hh
index e5934c39..a4a4dab7 100644
--- a/src/hb-aat-layout-kerx-table.hh
+++ b/src/hb-aat-layout-kerx-table.hh
@@ -109,8 +109,8 @@ struct KerxSubTableFormat2
   inline int get_kerning (hb_codepoint_t left, hb_codepoint_t right,
 			  const char *end, unsigned int num_glyphs) const
   {
-    unsigned int l = *(this+leftClassTable).get_value (left, num_glyphs);
-    unsigned int r = *(this+rightClassTable).get_value (right, num_glyphs);
+    unsigned int l = (this+leftClassTable).get_value_or_null (left, num_glyphs);
+    unsigned int r = (this+rightClassTable).get_value_or_null (right, num_glyphs);
     unsigned int offset = l + r;
     const FWORD *v = &StructAtOffset<FWORD> (&(this+array), offset);
     if (unlikely ((const char *) v < (const char *) &array ||
diff --git a/src/hb-ot-shape.cc b/src/hb-ot-shape.cc
index 21e06938..cf808c2a 100644
--- a/src/hb-ot-shape.cc
+++ b/src/hb-ot-shape.cc
@@ -826,6 +826,8 @@ hb_ot_position_complex (const hb_ot_shape_context_t *c)
 
   if (c->plan->apply_gpos)
     c->plan->position (c->font, c->buffer);
+  else if (c->plan->apply_kerx)
+    hb_aat_layout_position (c->plan, c->font, c->buffer);
 
   switch (c->plan->shaper->zero_width_marks)
   {
@@ -875,8 +877,6 @@ hb_ot_position (const hb_ot_shape_context_t *c)
     _hb_ot_shape_fallback_kern (c->plan, c->font, c->buffer);
 
   _hb_buffer_deallocate_gsubgpos_vars (c->buffer);
-
-  //hb_aat_layout_position (c->font, c->buffer);
 }
 
 static inline void


More information about the HarfBuzz mailing list