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

Behdad Esfahbod behdad at kemper.freedesktop.org
Wed Jul 16 10:33:06 PDT 2014


 src/hb-ot-shape.cc                                                      |   24 +++-
 src/hb-unicode-private.hh                                               |    6 -
 test/shaping/Makefile.am                                                |    1 
 test/shaping/fonts/sha1sum/37033cc5cf37bb223d7355153016b6ccece93b28.ttf |binary
 test/shaping/fonts/sha1sum/MANIFEST                                     |    1 
 test/shaping/record-test.sh                                             |   49 ++++++++++
 test/shaping/tests/MANIFEST                                             |    1 
 test/shaping/tests/mongolian-variation-selector.tests                   |    1 
 8 files changed, 75 insertions(+), 8 deletions(-)

New commits:
commit 844f1a487d9c39724ebff20e89f6184c9a59be0b
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Wed Jul 16 13:32:51 2014 -0400

    [tests] Add record-test.sh

diff --git a/test/shaping/Makefile.am b/test/shaping/Makefile.am
index cefd480..33f75ab 100644
--- a/test/shaping/Makefile.am
+++ b/test/shaping/Makefile.am
@@ -20,6 +20,7 @@ EXTRA_DIST += \
 	hb-unicode-decode \
 	hb-unicode-encode \
 	hb-unicode-prettyname \
+	record-test.sh \
 	run-tests.sh \
 	texts/in-tree \
 	fonts/sha1sum \
diff --git a/test/shaping/record-test.sh b/test/shaping/record-test.sh
new file mode 100755
index 0000000..384d87f
--- /dev/null
+++ b/test/shaping/record-test.sh
@@ -0,0 +1,49 @@
+#!/bin/bash
+
+dir=`mktemp --directory`
+
+hb_shape=$1
+fontfile=$2
+unicodes=`./hb-unicode-decode`
+text=`./hb-unicode-encode "$unicodes"`
+glyphs=`echo "$text" | $hb_shape "$fontfile"`
+
+cp "$fontfile" "$dir/font.ttf"
+pyftsubset \
+	--glyph-names \
+	"$dir/font.ttf" \
+	--text="$text"
+if ! test -s "$dir/font.ttf.subset"; then
+	echo "Subsetter didn't produce nonempty subset font in $dir/font.ttf.subset" >&2
+	exit 2
+fi
+
+# Verify that subset font produces same glyphs!
+glyphs_subset=`echo "$text" | $hb_shape "$dir/font.ttf.subset"`
+
+if ! test "x$glyphs" = "x$glyphs_subset"; then
+	echo "Subset font produced different glyphs!" >&2
+	echo "Perhaps font doesn't have glyph names; checking visually..." >&2
+	hb_view=${hb_shape//shape/view}
+	echo "$text" | $hb_view "$dir/font.ttf" --output-format=png --output-file="$dir/orig.png"
+	echo "$text" | $hb_view "$dir/font.ttf.subset" --output-format=png --output-file="$dir/subset.png"
+	if ! cmp "$dir/orig.png" "$dir/subset.png"; then
+		echo "Images differ.  Please inspect $dir/*.png." >&2
+		echo "$glyphs"
+		echo "$glyphs_subset"
+		exit 2
+	fi
+	echo "Yep; all good." >&2
+	rm -f "$dir/orig.png"
+	rm -f "$dir/subset.png"
+	glyphs=$glyphs_subset
+fi
+
+sha1sum=`sha1sum "$dir/font.ttf.subset" | cut -d' ' -f1`
+subset="fonts/sha1sum/$sha1sum.ttf"
+mv "$dir/font.ttf.subset" "$subset"
+
+echo "$subset:$unicodes:$glyphs"
+
+rm -f "$dir/font.ttf"
+rmdir "$dir"
commit 3b861421a772f52eb232ff93bd74b5a8214801ec
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Wed Jul 16 13:22:05 2014 -0400

    Fix Mongolian Variation Selectors for fonts without GDEF
    
    Originally we fixed those in 79d1007a501fd63c0ba4d51038c513e6b8b94740.
    However, fonts like MongolianWhite don't have GDEF, but have IgnoreMarks
    in their LigatureSubstitute init/etc features.  We were synthesizing a
    GDEF class of mark for Mongolian Variation Selectors and as such the
    ligature lookups where not matching.  Uniscribe doesn't do that.
    
    I tried with more sophisticated fixes, like, if there is no GDEF and
    a lookup-flag mismatch happens, instead of rejecting a match, try
    skipping that glyph.  That surely produces some interesting behavior,
    but since we don't want to support fonts missing GDEF more than we have
    to, I went for this simpler fix which is to always mark
    default-ignorables as base when synthesizing GDEF.
    
    Micro-test added.
    
    Fixes rest of https://bugs.freedesktop.org/show_bug.cgi?id=65258

diff --git a/src/hb-ot-shape.cc b/src/hb-ot-shape.cc
index 5a1960c..736eefd 100644
--- a/src/hb-ot-shape.cc
+++ b/src/hb-ot-shape.cc
@@ -395,8 +395,17 @@ hb_synthesize_glyph_classes (hb_ot_shape_context_t *c)
   {
     hb_ot_layout_glyph_class_mask_t klass;
 
-    klass = _hb_glyph_info_get_general_category (&info[i]) !=
-	     HB_UNICODE_GENERAL_CATEGORY_NON_SPACING_MARK ?
+    /* Never mark default-ignorables as marks.
+     * They won't get in the way of lookups anyway,
+     * but having them as mark will cause them to be skipped
+     * over if the lookup-flag says so, but at least for the
+     * Mongolian variation selectors, looks like Uniscribe
+     * marks them as non-mark.  Some Mongolian fonts without
+     * GDEF rely on this.  Another notable character that
+     * this applies to is COMBINING GRAPHEME JOINER. */
+    klass = (_hb_glyph_info_get_general_category (&info[i]) !=
+	     HB_UNICODE_GENERAL_CATEGORY_NON_SPACING_MARK ||
+	     _hb_glyph_info_is_default_ignorable (&info[i])) ?
 	    HB_OT_LAYOUT_GLYPH_PROPS_BASE_GLYPH :
 	    HB_OT_LAYOUT_GLYPH_PROPS_MARK;
     _hb_glyph_info_set_glyph_props (&info[i], klass);
diff --git a/test/shaping/fonts/sha1sum/37033cc5cf37bb223d7355153016b6ccece93b28.ttf b/test/shaping/fonts/sha1sum/37033cc5cf37bb223d7355153016b6ccece93b28.ttf
new file mode 100644
index 0000000..14defeb
Binary files /dev/null and b/test/shaping/fonts/sha1sum/37033cc5cf37bb223d7355153016b6ccece93b28.ttf differ
diff --git a/test/shaping/fonts/sha1sum/MANIFEST b/test/shaping/fonts/sha1sum/MANIFEST
index c05a9ef..427f433 100644
--- a/test/shaping/fonts/sha1sum/MANIFEST
+++ b/test/shaping/fonts/sha1sum/MANIFEST
@@ -1,4 +1,5 @@
 226bc2deab3846f1a682085f70c67d0421014144.ttf
+37033cc5cf37bb223d7355153016b6ccece93b28.ttf
 4cce528e99f600ed9c25a2b69e32eb94a03b4ae8.ttf
 d629e7fedc0b350222d7987345fe61613fa3929a.ttf
 e207635780b42f898d58654b65098763e340f5c7.ttf
diff --git a/test/shaping/tests/MANIFEST b/test/shaping/tests/MANIFEST
index ac10e07..024169d 100644
--- a/test/shaping/tests/MANIFEST
+++ b/test/shaping/tests/MANIFEST
@@ -1,2 +1,3 @@
 context-matching.tests
 indic-pref-blocking.tests
+mongolian-variation-selector.tests
diff --git a/test/shaping/tests/mongolian-variation-selector.tests b/test/shaping/tests/mongolian-variation-selector.tests
new file mode 100644
index 0000000..043fa18
--- /dev/null
+++ b/test/shaping/tests/mongolian-variation-selector.tests
@@ -0,0 +1 @@
+fonts/sha1sum/37033cc5cf37bb223d7355153016b6ccece93b28.ttf:U+1826,U+180B,U+1826:[uni1826.E85E_ue.init1=0+599|uni1826.E856_ue.fina=2+750]
commit 878a25375b2fdf64cf0cc30c23fca9fcd58548e8
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Wed Jul 16 13:21:26 2014 -0400

    Minor

diff --git a/src/hb-ot-shape.cc b/src/hb-ot-shape.cc
index e122ef4..5a1960c 100644
--- a/src/hb-ot-shape.cc
+++ b/src/hb-ot-shape.cc
@@ -37,6 +37,7 @@
 #include "hb-ot-shape-normalize-private.hh"
 
 #include "hb-ot-layout-private.hh"
+#include "hb-unicode-private.hh"
 #include "hb-set-private.hh"
 
 
diff --git a/src/hb-unicode-private.hh b/src/hb-unicode-private.hh
index 31a7abb..6652015 100644
--- a/src/hb-unicode-private.hh
+++ b/src/hb-unicode-private.hh
@@ -102,7 +102,7 @@ HB_UNICODE_FUNCS_IMPLEMENT_CALLBACKS_SIMPLE
   }
 
 
-  unsigned int
+  inline unsigned int
   modified_combining_class (hb_codepoint_t unicode)
   {
     /* XXX This hack belongs to the Myanmar shaper. */
@@ -119,7 +119,7 @@ HB_UNICODE_FUNCS_IMPLEMENT_CALLBACKS_SIMPLE
     return _hb_modified_combining_class[combining_class (unicode)];
   }
 
-  inline hb_bool_t
+  static inline hb_bool_t
   is_variation_selector (hb_codepoint_t unicode)
   {
     return unlikely (hb_in_ranges (unicode,
@@ -164,7 +164,7 @@ HB_UNICODE_FUNCS_IMPLEMENT_CALLBACKS_SIMPLE
    * E0100..E01EF  # Mn [240] VARIATION SELECTOR-17..VARIATION SELECTOR-256
    * E01F0..E0FFF  # Cn [3600] <reserved-E01F0>..<reserved-E0FFF>
    */
-  inline hb_bool_t
+  static inline hb_bool_t
   is_default_ignorable (hb_codepoint_t ch)
   {
     hb_codepoint_t plane = ch >> 16;
commit ec181e50140fc65b32d6080e2f7f73bbe0269ba9
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Wed Jul 16 13:10:03 2014 -0400

    Minor moving around

diff --git a/src/hb-ot-shape.cc b/src/hb-ot-shape.cc
index bc9eaa5..e122ef4 100644
--- a/src/hb-ot-shape.cc
+++ b/src/hb-ot-shape.cc
@@ -391,11 +391,15 @@ hb_synthesize_glyph_classes (hb_ot_shape_context_t *c)
   unsigned int count = c->buffer->len;
   hb_glyph_info_t *info = c->buffer->info;
   for (unsigned int i = 0; i < count; i++)
-    _hb_glyph_info_set_glyph_props (&info[i],
-				    _hb_glyph_info_get_general_category (&info[i])
-				    == HB_UNICODE_GENERAL_CATEGORY_NON_SPACING_MARK ?
-				    HB_OT_LAYOUT_GLYPH_PROPS_MARK :
-				    HB_OT_LAYOUT_GLYPH_PROPS_BASE_GLYPH);
+  {
+    hb_ot_layout_glyph_class_mask_t klass;
+
+    klass = _hb_glyph_info_get_general_category (&info[i]) !=
+	     HB_UNICODE_GENERAL_CATEGORY_NON_SPACING_MARK ?
+	    HB_OT_LAYOUT_GLYPH_PROPS_BASE_GLYPH :
+	    HB_OT_LAYOUT_GLYPH_PROPS_MARK;
+    _hb_glyph_info_set_glyph_props (&info[i], klass);
+  }
 }
 
 static inline void


More information about the HarfBuzz mailing list