From 79e8b306090ebadafa0fd53242ffcfbc74c94ab6 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Fri, 16 Jul 2021 15:06:10 -0600 Subject: [PATCH] [ot-shape] Fix application of kern table if GPOS kern is missing Was broken sometime after we implemented kerx and tweaking it. Fixes https://github.com/harfbuzz/harfbuzz/issues/3043 --- src/hb-ot-shape.cc | 9 ++++++--- src/hb-ot-shape.hh | 1 + test/shaping/data/in-house/Makefile.sources | 1 + .../b121d4306b2e3add5abbaad21d95fcf04aacbd64.ttf | Bin 0 -> 1308 bytes test/shaping/data/in-house/meson.build | 1 + .../data/in-house/tests/tt-kern-gpos.tests | 1 + 6 files changed, 10 insertions(+), 3 deletions(-) create mode 100644 test/shaping/data/in-house/fonts/b121d4306b2e3add5abbaad21d95fcf04aacbd64.ttf create mode 100644 test/shaping/data/in-house/tests/tt-kern-gpos.tests diff --git a/src/hb-ot-shape.cc b/src/hb-ot-shape.cc index 246936db3..01286d03f 100644 --- a/src/hb-ot-shape.cc +++ b/src/hb-ot-shape.cc @@ -151,7 +151,7 @@ hb_ot_shape_planner_t::compile (hb_ot_shape_plan_t &plan, bool has_gsub = hb_ot_layout_has_substitution (face); bool has_gpos = !disable_gpos && hb_ot_layout_has_positioning (face); - if (0) + if (false) ; #ifndef HB_NO_AAT_SHAPE else if (hb_aat_layout_has_positioning (face) && !(has_gsub && has_gpos)) @@ -174,6 +174,8 @@ hb_ot_shape_planner_t::compile (hb_ot_shape_plan_t &plan, #endif } + plan.apply_fallback_kern = !(plan.apply_gpos || plan.apply_kerx || plan.apply_kern); + plan.zero_marks = script_zero_marks && !plan.apply_kerx && (!plan.apply_kern @@ -274,11 +276,12 @@ hb_ot_shape_plan_t::position (hb_font_t *font, else if (this->apply_kerx) hb_aat_layout_position (this, font, buffer); #endif + #ifndef HB_NO_OT_KERN - else if (this->apply_kern) + if (this->apply_kern) hb_ot_layout_kern (this, font, buffer); #endif - else + else if (this->apply_fallback_kern) _hb_ot_shape_fallback_kern (this, font, buffer); #ifndef HB_NO_AAT_SHAPE diff --git a/src/hb-ot-shape.hh b/src/hb-ot-shape.hh index acc98772a..e8c81015c 100644 --- a/src/hb-ot-shape.hh +++ b/src/hb-ot-shape.hh @@ -112,6 +112,7 @@ struct hb_ot_shape_plan_t #else static constexpr bool apply_kern = false; #endif + bool apply_fallback_kern : 1; #ifndef HB_NO_AAT_SHAPE bool apply_kerx : 1; bool apply_morx : 1; diff --git a/test/shaping/data/in-house/Makefile.sources b/test/shaping/data/in-house/Makefile.sources index 39cc8d658..ae48a776a 100644 --- a/test/shaping/data/in-house/Makefile.sources +++ b/test/shaping/data/in-house/Makefile.sources @@ -53,6 +53,7 @@ TESTS = \ tests/tibetan-contractions-1.tests \ tests/tibetan-contractions-2.tests \ tests/tibetan-vowels.tests \ + tests/tt-kern-gpos.tests \ tests/use-indic3.tests \ tests/use-marchen.tests \ tests/use-syllable.tests \ diff --git a/test/shaping/data/in-house/fonts/b121d4306b2e3add5abbaad21d95fcf04aacbd64.ttf b/test/shaping/data/in-house/fonts/b121d4306b2e3add5abbaad21d95fcf04aacbd64.ttf new file mode 100644 index 0000000000000000000000000000000000000000..707559247802568040064be9d4e83fb46c8a3deb GIT binary patch literal 1308 zcmZWpYiyHM7=F%o>1A%NgxrQemE^yX2fAXG-zcrsD(-UFUSLf$;|^Fj9qOY=DzSH;#U8y(YYhkZ>4N` zf`Y0``nTj`Aw#RJ@px;s zV2x&m=7%E7mo05J&0w&M3gUn;g|>IMc-p@8tF0Up4JY3_aqhMVfAsMur}X^s*&Wl3 z6)Wu@&R&!~JOf*i79{lpers~yy!0&T)3(LZ+D^U2QyZg>m@jL%v-;1RF zQjO{UD}1I0SnU=R^h%6NKfXQ1qg0u>Gi7h}AO2rlnUSjH#oNrtr%&lohF(zms+Tb! zZu%7E0gp%3HO1}rf3gm@#X9f=+R))yVAo*6w?}!-fOubKsI6tE0E2y#rzxGUlF#@fGhbTr`WvfRTLc@3Qy!XRgka|`0=XD0oy$StBi3?qZhj3KoWlp2`kjGz@^ z&c$UE#v)3)s69-*B>foZAReK$T&2GuqBNGEhq5@4ff(g!WU-!n5Ujp)8lz!|^*YkB{Wue=Eh(af*x qiw_m3f|tFkCWrjzatC|FZ>iG~Rd9#z-5n)f$BK)jl}ppdz415J$@TyM literal 0 HcmV?d00001 diff --git a/test/shaping/data/in-house/meson.build b/test/shaping/data/in-house/meson.build index 474a789f4..c98a90de6 100644 --- a/test/shaping/data/in-house/meson.build +++ b/test/shaping/data/in-house/meson.build @@ -53,6 +53,7 @@ in_house_tests = [ 'tibetan-contractions-1.tests', 'tibetan-contractions-2.tests', 'tibetan-vowels.tests', + 'tt-kern-gpos.tests', 'use-indic3.tests', 'use-marchen.tests', 'use-syllable.tests', diff --git a/test/shaping/data/in-house/tests/tt-kern-gpos.tests b/test/shaping/data/in-house/tests/tt-kern-gpos.tests new file mode 100644 index 000000000..78296aee2 --- /dev/null +++ b/test/shaping/data/in-house/tests/tt-kern-gpos.tests @@ -0,0 +1 @@ +../fonts/b121d4306b2e3add5abbaad21d95fcf04aacbd64.ttf::U+0041,U+0043,U+0041,U+0042:[A=0+1275|C=1@-20,0+1272|A=2+1296|B=3+1327]