From aa06574823e27c4dbb378d2467a3e6f6f36af9fe Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Fri, 16 Nov 2018 14:31:05 -0800 Subject: [PATCH 01/10] Minor --- src/hb-aat-layout-trak-table.hh | 2 +- src/hb-ot-layout-gdef-table.hh | 2 +- src/hb-ot-layout-gsubgpos.hh | 2 +- src/hb-ot-math-table.hh | 2 +- src/hb-ot-var-fvar-table.hh | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/hb-aat-layout-trak-table.hh b/src/hb-aat-layout-trak-table.hh index 3b55967c8..91c0f4562 100644 --- a/src/hb-aat-layout-trak-table.hh +++ b/src/hb-aat-layout-trak-table.hh @@ -169,7 +169,7 @@ struct trak { static const hb_tag_t tableTag = HB_AAT_TAG_trak; - inline bool has_data (void) const { return version.to_int () != 0; } + inline bool has_data (void) const { return version.to_int (); } inline bool apply (hb_aat_apply_context_t *c) const { diff --git a/src/hb-ot-layout-gdef-table.hh b/src/hb-ot-layout-gdef-table.hh index e6804e6b5..22e07f7a4 100644 --- a/src/hb-ot-layout-gdef-table.hh +++ b/src/hb-ot-layout-gdef-table.hh @@ -348,7 +348,7 @@ struct GDEF ComponentGlyph = 4 }; - inline bool has_data (void) const { return version.to_int () != 0; } + inline bool has_data (void) const { return version.to_int (); } inline bool has_glyph_classes (void) const { return glyphClassDef != 0; } inline unsigned int get_glyph_class (hb_codepoint_t glyph) const { return (this+glyphClassDef).get_class (glyph); } diff --git a/src/hb-ot-layout-gsubgpos.hh b/src/hb-ot-layout-gsubgpos.hh index 826486803..3d70c55c2 100644 --- a/src/hb-ot-layout-gsubgpos.hh +++ b/src/hb-ot-layout-gsubgpos.hh @@ -2657,7 +2657,7 @@ struct hb_ot_layout_lookup_accelerator_t struct GSUBGPOS { - inline bool has_data (void) const { return version.to_int () != 0; } + inline bool has_data (void) const { return version.to_int (); } inline unsigned int get_script_count (void) const { return (this+scriptList).len; } inline const Tag& get_script_tag (unsigned int i) const diff --git a/src/hb-ot-math-table.hh b/src/hb-ot-math-table.hh index a28acef79..b87304979 100644 --- a/src/hb-ot-math-table.hh +++ b/src/hb-ot-math-table.hh @@ -684,7 +684,7 @@ struct MATH { static const hb_tag_t tableTag = HB_OT_TAG_MATH; - inline bool has_data (void) const { return version.to_int () != 0; } + inline bool has_data (void) const { return version.to_int (); } inline bool sanitize (hb_sanitize_context_t *c) const { diff --git a/src/hb-ot-var-fvar-table.hh b/src/hb-ot-var-fvar-table.hh index 96c39c109..6d229c386 100644 --- a/src/hb-ot-var-fvar-table.hh +++ b/src/hb-ot-var-fvar-table.hh @@ -88,7 +88,7 @@ struct fvar { static const hb_tag_t tableTag = HB_OT_TAG_fvar; - inline bool has_data (void) const { return version.to_int () != 0; } + inline bool has_data (void) const { return version.to_int (); } inline bool sanitize (hb_sanitize_context_t *c) const { From eafd515639497098436ecf4c7b836e231bced323 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Fri, 16 Nov 2018 14:45:56 -0800 Subject: [PATCH 02/10] Prefer morx table if GSUB is empty (no scripts) Fixes https://github.com/harfbuzz/harfbuzz/issues/1348 --- src/hb-ot-shape.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/hb-ot-shape.cc b/src/hb-ot-shape.cc index 093511efa..00d4c0b67 100644 --- a/src/hb-ot-shape.cc +++ b/src/hb-ot-shape.cc @@ -62,7 +62,11 @@ _hb_apply_morx (hb_face_t *face) hb_aat_layout_has_substitution (face)) return true; - return !hb_ot_layout_has_substitution (face) && + /* Ignore empty GSUB tables. */ + return (!hb_ot_layout_has_substitution (face) || + !hb_ot_layout_table_get_script_tags (face, + HB_OT_TAG_GSUB, + 0, nullptr, nullptr)) && hb_aat_layout_has_substitution (face); } From 7a97f7074052a5d746af29f0743abd20682b09a2 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Fri, 16 Nov 2018 14:46:40 -0800 Subject: [PATCH 03/10] Don't apply GPOS if applying morx That's what Apple does, and it wouldn't degrade our OpenType performance. Part of https://github.com/harfbuzz/harfbuzz/issues/1348 --- src/hb-ot-shape.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hb-ot-shape.cc b/src/hb-ot-shape.cc index 00d4c0b67..ccee8d343 100644 --- a/src/hb-ot-shape.cc +++ b/src/hb-ot-shape.cc @@ -126,7 +126,7 @@ hb_ot_shape_planner_t::compile (hb_ot_shape_plan_t &plan, if (hb_options ().aat && hb_aat_layout_has_positioning (face)) plan.apply_kerx = true; - else if (!disable_gpos && hb_ot_layout_has_positioning (face)) + else if (!apply_morx && !disable_gpos && hb_ot_layout_has_positioning (face)) plan.apply_gpos = true; else if (hb_aat_layout_has_positioning (face)) plan.apply_kerx = true; From cff4c6087fdb667a40f54f20ca3c49251bf076de Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Fri, 16 Nov 2018 15:04:41 -0800 Subject: [PATCH 04/10] Fix vertical fallback space sign Ouch! Follow-up to cf203af8a33591c163b63dbdf0fd341bc4606190 Fixes https://github.com/harfbuzz/harfbuzz/issues/1343 --- src/hb-ot-shape-fallback.cc | 8 +++---- test/shaping/data/in-house/tests/spaces.tests | 22 +++++++++---------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/hb-ot-shape-fallback.cc b/src/hb-ot-shape-fallback.cc index bbc410ad6..d3afdffaf 100644 --- a/src/hb-ot-shape-fallback.cc +++ b/src/hb-ot-shape-fallback.cc @@ -509,16 +509,16 @@ _hb_ot_shape_fallback_spaces (const hb_ot_shape_plan_t *plan HB_UNUSED, case t::SPACE_EM_6: case t::SPACE_EM_16: if (horizontal) - pos[i].x_advance = (font->x_scale + ((int) space_type)/2) / (int) space_type; + pos[i].x_advance = +(font->x_scale + ((int) space_type)/2) / (int) space_type; else - pos[i].y_advance = (font->y_scale + ((int) space_type)/2) / (int) space_type; + pos[i].y_advance = -(font->y_scale + ((int) space_type)/2) / (int) space_type; break; case t::SPACE_4_EM_18: if (horizontal) - pos[i].x_advance = (int64_t) font->x_scale * 4 / 18; + pos[i].x_advance = (int64_t) +font->x_scale * 4 / 18; else - pos[i].y_advance = (int64_t) font->y_scale * 4 / 18; + pos[i].y_advance = (int64_t) -font->y_scale * 4 / 18; break; case t::SPACE_FIGURE: diff --git a/test/shaping/data/in-house/tests/spaces.tests b/test/shaping/data/in-house/tests/spaces.tests index 526d158b1..ea9099882 100644 --- a/test/shaping/data/in-house/tests/spaces.tests +++ b/test/shaping/data/in-house/tests/spaces.tests @@ -18,17 +18,17 @@ ../fonts/1c2c3fc37b2d4c3cb2ef726c6cdaaabd4b7f3eb9.ttf:--font-funcs=ot --direction=ttb:U+0020:[gid1=0@-280,0+0,-2048] ../fonts/1c2c3fc37b2d4c3cb2ef726c6cdaaabd4b7f3eb9.ttf:--font-funcs=ot --direction=ttb:U+00A0:[gid1=0@-280,0+0,-2048] ../fonts/1c2c3fc37b2d4c3cb2ef726c6cdaaabd4b7f3eb9.ttf:--font-funcs=ot --direction=ttb:U+1680:[gid0=0@-346,0+0,-2048] -../fonts/1c2c3fc37b2d4c3cb2ef726c6cdaaabd4b7f3eb9.ttf:--font-funcs=ot --direction=ttb:U+2000:[gid1=0@-280,0+0,1024] -../fonts/1c2c3fc37b2d4c3cb2ef726c6cdaaabd4b7f3eb9.ttf:--font-funcs=ot --direction=ttb:U+2001:[gid1=0@-280,0+0,2048] -../fonts/1c2c3fc37b2d4c3cb2ef726c6cdaaabd4b7f3eb9.ttf:--font-funcs=ot --direction=ttb:U+2002:[gid1=0@-280,0+0,1024] -../fonts/1c2c3fc37b2d4c3cb2ef726c6cdaaabd4b7f3eb9.ttf:--font-funcs=ot --direction=ttb:U+2003:[gid1=0@-280,0+0,2048] -../fonts/1c2c3fc37b2d4c3cb2ef726c6cdaaabd4b7f3eb9.ttf:--font-funcs=ot --direction=ttb:U+2004:[gid1=0@-280,0+0,683] -../fonts/1c2c3fc37b2d4c3cb2ef726c6cdaaabd4b7f3eb9.ttf:--font-funcs=ot --direction=ttb:U+2005:[gid1=0@-280,0+0,512] -../fonts/1c2c3fc37b2d4c3cb2ef726c6cdaaabd4b7f3eb9.ttf:--font-funcs=ot --direction=ttb:U+2006:[gid1=0@-280,0+0,341] +../fonts/1c2c3fc37b2d4c3cb2ef726c6cdaaabd4b7f3eb9.ttf:--font-funcs=ot --direction=ttb:U+2000:[gid1=0@-280,0+0,-1024] +../fonts/1c2c3fc37b2d4c3cb2ef726c6cdaaabd4b7f3eb9.ttf:--font-funcs=ot --direction=ttb:U+2001:[gid1=0@-280,0+0,-2048] +../fonts/1c2c3fc37b2d4c3cb2ef726c6cdaaabd4b7f3eb9.ttf:--font-funcs=ot --direction=ttb:U+2002:[gid1=0@-280,0+0,-1024] +../fonts/1c2c3fc37b2d4c3cb2ef726c6cdaaabd4b7f3eb9.ttf:--font-funcs=ot --direction=ttb:U+2003:[gid1=0@-280,0+0,-2048] +../fonts/1c2c3fc37b2d4c3cb2ef726c6cdaaabd4b7f3eb9.ttf:--font-funcs=ot --direction=ttb:U+2004:[gid1=0@-280,0+0,-683] +../fonts/1c2c3fc37b2d4c3cb2ef726c6cdaaabd4b7f3eb9.ttf:--font-funcs=ot --direction=ttb:U+2005:[gid1=0@-280,0+0,-512] +../fonts/1c2c3fc37b2d4c3cb2ef726c6cdaaabd4b7f3eb9.ttf:--font-funcs=ot --direction=ttb:U+2006:[gid1=0@-280,0+0,-341] ../fonts/1c2c3fc37b2d4c3cb2ef726c6cdaaabd4b7f3eb9.ttf:--font-funcs=ot --direction=ttb:U+2007:[gid1=0@-280,0+0,-2048] ../fonts/1c2c3fc37b2d4c3cb2ef726c6cdaaabd4b7f3eb9.ttf:--font-funcs=ot --direction=ttb:U+2008:[gid1=0@-280,0+0,-2048] -../fonts/1c2c3fc37b2d4c3cb2ef726c6cdaaabd4b7f3eb9.ttf:--font-funcs=ot --direction=ttb:U+2009:[gid1=0@-280,0+0,410] -../fonts/1c2c3fc37b2d4c3cb2ef726c6cdaaabd4b7f3eb9.ttf:--font-funcs=ot --direction=ttb:U+200A:[gid1=0@-280,0+0,128] +../fonts/1c2c3fc37b2d4c3cb2ef726c6cdaaabd4b7f3eb9.ttf:--font-funcs=ot --direction=ttb:U+2009:[gid1=0@-280,0+0,-410] +../fonts/1c2c3fc37b2d4c3cb2ef726c6cdaaabd4b7f3eb9.ttf:--font-funcs=ot --direction=ttb:U+200A:[gid1=0@-280,0+0,-128] ../fonts/1c2c3fc37b2d4c3cb2ef726c6cdaaabd4b7f3eb9.ttf:--font-funcs=ot --direction=ttb:U+202F:[gid1=0@-280,0+0,-1024] -../fonts/1c2c3fc37b2d4c3cb2ef726c6cdaaabd4b7f3eb9.ttf:--font-funcs=ot --direction=ttb:U+205F:[gid1=0@-280,0+0,455] -../fonts/1c2c3fc37b2d4c3cb2ef726c6cdaaabd4b7f3eb9.ttf:--font-funcs=ot --direction=ttb:U+3000:[gid1=0@-280,0+0,2048] +../fonts/1c2c3fc37b2d4c3cb2ef726c6cdaaabd4b7f3eb9.ttf:--font-funcs=ot --direction=ttb:U+205F:[gid1=0@-280,0+0,-455] +../fonts/1c2c3fc37b2d4c3cb2ef726c6cdaaabd4b7f3eb9.ttf:--font-funcs=ot --direction=ttb:U+3000:[gid1=0@-280,0+0,-2048] From fdb29ab2b0058c9813f9fc44c83dd9048db92d16 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Fri, 16 Nov 2018 15:38:11 -0800 Subject: [PATCH 05/10] 2.1.2 --- NEWS | 13 ++++++++++++- configure.ac | 2 +- src/hb-version.h | 4 ++-- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/NEWS b/NEWS index 04579d685..d72ea3db5 100644 --- a/NEWS +++ b/NEWS @@ -1,4 +1,15 @@ -Overview of changes leading to 2.1.1 +Overview of changes leading to 2.1.2 +Friday, November 16, 2018 +==================================== +- Various internal changes. +- AAT shaping improvements: + o Implement kern table Format 1 state-machine-based kerning. + o Implement cross-stream kerning (cursive positioning, etc). + o Ignore emptyish GSUB tables (zero scripts) if morx present. + o Don't apply GPOS if morx is being applied. Matches Apple. + + +-Overview of changes leading to 2.1.1 Monday, November 5, 2018 ==================================== - AAT improvements: diff --git a/configure.ac b/configure.ac index 48ee9ce94..0db1fd0d8 100644 --- a/configure.ac +++ b/configure.ac @@ -1,6 +1,6 @@ AC_PREREQ([2.64]) AC_INIT([HarfBuzz], - [2.1.1], + [2.1.2], [https://github.com/harfbuzz/harfbuzz/issues/new], [harfbuzz], [http://harfbuzz.org/]) diff --git a/src/hb-version.h b/src/hb-version.h index ec150d5dd..a18c897c9 100644 --- a/src/hb-version.h +++ b/src/hb-version.h @@ -38,9 +38,9 @@ HB_BEGIN_DECLS #define HB_VERSION_MAJOR 2 #define HB_VERSION_MINOR 1 -#define HB_VERSION_MICRO 1 +#define HB_VERSION_MICRO 2 -#define HB_VERSION_STRING "2.1.1" +#define HB_VERSION_STRING "2.1.2" #define HB_VERSION_ATLEAST(major,minor,micro) \ ((major)*10000+(minor)*100+(micro) <= \ From 6910ff03e66f5f4c9eb5592262d414ef7d91df04 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Fri, 16 Nov 2018 16:11:02 -0800 Subject: [PATCH 06/10] [aat] Fix mort shaping Ouch! --- src/hb-aat-layout.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hb-aat-layout.cc b/src/hb-aat-layout.cc index da6908a44..d9580c152 100644 --- a/src/hb-aat-layout.cc +++ b/src/hb-aat-layout.cc @@ -215,7 +215,7 @@ hb_aat_layout_substitute (const hb_ot_shape_plan_t *plan, return; } - hb_blob_t *mort_blob = font->face->table.morx.get_blob (); + hb_blob_t *mort_blob = font->face->table.mort.get_blob (); const AAT::mort& mort = *mort_blob->as (); if (mort.has_data ()) { From 52f61cdb87b67ef42a25288d8624170d0b6d3a25 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Fri, 16 Nov 2018 16:41:59 -0800 Subject: [PATCH 07/10] Detect over/under-flow in UnsizedArray::operator[] Was causing bad substitutions in mort table because of WordOffsetToIndex() producing negative numbers that were cast to unsigned int and returned as large numbers (which was desirable, so they would be rejected), but then they were cast to int when passed to this operator and acting as small negative integers, which was bad... Detect overflow. Ouch, however, now I see this still fails on 32-bit. Guess I'm going to revert an earlier change. --- src/hb-open-type.hh | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/src/hb-open-type.hh b/src/hb-open-type.hh index a14d0f021..bae73da4d 100644 --- a/src/hb-open-type.hh +++ b/src/hb-open-type.hh @@ -339,16 +339,27 @@ struct UnsizedArrayOf HB_NO_CREATE_COPY_ASSIGN_TEMPLATE (UnsizedArrayOf, Type); - /* Unlikely other places, use "int i" instead of "unsigned int i" for our - * indexing operator. For two reasons: + /* Unlikely other places, use "ssize_t i" instead of "unsigned int i" for our + * indexing operator. For three reasons: * 1. For UnsizedArrayOf, it's not totally unimaginable to want to look * at items before the start of current array. - * 2. Fixes MSVC 2008 "overloads have similar conversions" issue with the + * 2. Use the largest type, to help detect overflows. + * 3. Fixes MSVC 2008 "overloads have similar conversions" issue with the * built-in operator [] that takes int, in expressions like sizeof (array[0])). * I suppose I could fix that by replacing 0 with 0u, but like this fix * more now. */ - inline const Type& operator [] (int i) const { return arrayZ[i]; } - inline Type& operator [] (int i) { return arrayZ[i]; } + inline const Type& operator [] (ssize_t i) const + { + const Type *p = &arrayZ[i]; + if (unlikely ((0 <= i) != (arrayZ <= p))) return Null (Type); /* Over/under-flowed. */ + return *p; + } + inline Type& operator [] (ssize_t i) + { + const Type *p = &arrayZ[i]; + if (unlikely ((0 <= i) != (arrayZ <= p))) return Crap (Type); /* Over/under-flowed. */ + return *p; + } template inline operator T * (void) { return arrayZ; } template inline operator const T * (void) const { return arrayZ; } From 0328a1ce41611ed981d41384ae5727479699f3a0 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Fri, 16 Nov 2018 16:48:28 -0800 Subject: [PATCH 08/10] Revert b4c61130324455bfd42095b01fa14ac901e441f1 Was causing more trouble than it solved. We use unsigned for indexing, and it's not helpful to allow that wrapping to negative integers on 32bit machines. The only way we could work around it would have been by accepting int64_t arg, but that's overkill. Ignore the MSVC 2008 build issue. We don't support that compiler. --- src/hb-open-type.hh | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/src/hb-open-type.hh b/src/hb-open-type.hh index bae73da4d..c77c25fa0 100644 --- a/src/hb-open-type.hh +++ b/src/hb-open-type.hh @@ -339,25 +339,16 @@ struct UnsizedArrayOf HB_NO_CREATE_COPY_ASSIGN_TEMPLATE (UnsizedArrayOf, Type); - /* Unlikely other places, use "ssize_t i" instead of "unsigned int i" for our - * indexing operator. For three reasons: - * 1. For UnsizedArrayOf, it's not totally unimaginable to want to look - * at items before the start of current array. - * 2. Use the largest type, to help detect overflows. - * 3. Fixes MSVC 2008 "overloads have similar conversions" issue with the - * built-in operator [] that takes int, in expressions like sizeof (array[0])). - * I suppose I could fix that by replacing 0 with 0u, but like this fix - * more now. */ - inline const Type& operator [] (ssize_t i) const + inline const Type& operator [] (unsigned int i) const { const Type *p = &arrayZ[i]; - if (unlikely ((0 <= i) != (arrayZ <= p))) return Null (Type); /* Over/under-flowed. */ + if (unlikely (p < arrayZ)) return Null (Type); /* Overflowed. */ return *p; } - inline Type& operator [] (ssize_t i) + inline Type& operator [] (unsigned int i) { const Type *p = &arrayZ[i]; - if (unlikely ((0 <= i) != (arrayZ <= p))) return Crap (Type); /* Over/under-flowed. */ + if (unlikely (p < arrayZ)) return Crap (Type); /* Overflowed. */ return *p; } From 9714e114b88893bd962b1bcf36382bdacbc4866c Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Fri, 16 Nov 2018 16:52:42 -0800 Subject: [PATCH 09/10] Fix recent commits --- src/hb-open-type.hh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hb-open-type.hh b/src/hb-open-type.hh index c77c25fa0..b1fcd6877 100644 --- a/src/hb-open-type.hh +++ b/src/hb-open-type.hh @@ -347,7 +347,7 @@ struct UnsizedArrayOf } inline Type& operator [] (unsigned int i) { - const Type *p = &arrayZ[i]; + Type *p = &arrayZ[i]; if (unlikely (p < arrayZ)) return Crap (Type); /* Overflowed. */ return *p; } From e3a1a8350a6a7933b0a100194985f4425ab9de19 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Fri, 16 Nov 2018 16:53:25 -0800 Subject: [PATCH 10/10] 2.1.3 --- NEWS | 6 ++++++ configure.ac | 2 +- src/hb-version.h | 4 ++-- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/NEWS b/NEWS index d72ea3db5..9bfe99a2d 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,9 @@ +Overview of changes leading to 2.1.3 +Friday, November 16, 2018 +==================================== +- Fix AAT 'mort' shaping, which was broken in 2.1.2 + + Overview of changes leading to 2.1.2 Friday, November 16, 2018 ==================================== diff --git a/configure.ac b/configure.ac index 0db1fd0d8..95ab48f80 100644 --- a/configure.ac +++ b/configure.ac @@ -1,6 +1,6 @@ AC_PREREQ([2.64]) AC_INIT([HarfBuzz], - [2.1.2], + [2.1.3], [https://github.com/harfbuzz/harfbuzz/issues/new], [harfbuzz], [http://harfbuzz.org/]) diff --git a/src/hb-version.h b/src/hb-version.h index a18c897c9..fb9f8f306 100644 --- a/src/hb-version.h +++ b/src/hb-version.h @@ -38,9 +38,9 @@ HB_BEGIN_DECLS #define HB_VERSION_MAJOR 2 #define HB_VERSION_MINOR 1 -#define HB_VERSION_MICRO 2 +#define HB_VERSION_MICRO 3 -#define HB_VERSION_STRING "2.1.2" +#define HB_VERSION_STRING "2.1.3" #define HB_VERSION_ATLEAST(major,minor,micro) \ ((major)*10000+(minor)*100+(micro) <= \