From f47cbade18acc4f9c935ba2c6c863beb6087d781 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Mon, 9 Dec 2019 18:10:34 -0600 Subject: [PATCH] [aat] Adjust fallback positioning logic MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes https://github.com/harfbuzz/harfbuzz/issues/1528 Wish could add a test... $ ./hb-view --font-file Thonburi.ttc --unicodes U+0E17,U+0E35,U+0E48,U+0E4A --shaper ot ▃ ▂▃▃▄▃▂▁▊ ▃ ▃ ▎ ▗ ▅▆▆▅ ▌ ▆▆▅▆▙ ▌▗ ▗ ▙ ▂ ▎▗ ▟ ▅▆▆▆▇▇▇▇▇▇▇▆▆▅▄ ▇▅▅▅ ▙▆▇ ▁▁▂▁ ▁▁ ▖ ▖ ▂▂ ▉ ▁ ▆▆ ▌ ▆ ▙▄ ▁▁ ▙ ▉ ▃▖ ▟ ▊ ▉ ▅▟ ▗▄ ▊ ▉ ▗ ▏ ▇▆ ▊ ▟ ▉ ▆ ▖ ▊ ▉ ▌ ▂ ▊ ▏ ▉ ▌ ▗ ▄▟ ▊ ▆ --- src/hb-ot-shape-complex-default.cc | 20 ++++++++++++++++++++ src/hb-ot-shape-complex.hh | 5 +++-- src/hb-ot-shape.cc | 5 +++-- 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/src/hb-ot-shape-complex-default.cc b/src/hb-ot-shape-complex-default.cc index a921f16fa..a755aea09 100644 --- a/src/hb-ot-shape-complex-default.cc +++ b/src/hb-ot-shape-complex-default.cc @@ -49,5 +49,25 @@ const hb_ot_complex_shaper_t _hb_ot_complex_shaper_default = true, /* fallback_position */ }; +/* Same as default but no mark advance zeroing / fallback positioning. + * Dumbest shaper ever, basically. */ +const hb_ot_complex_shaper_t _hb_ot_complex_shaper_dumber = +{ + nullptr, /* collect_features */ + nullptr, /* override_features */ + nullptr, /* data_create */ + nullptr, /* data_destroy */ + nullptr, /* preprocess_text */ + nullptr, /* postprocess_glyphs */ + HB_OT_SHAPE_NORMALIZATION_MODE_DEFAULT, + nullptr, /* decompose */ + nullptr, /* compose */ + nullptr, /* setup_masks */ + HB_TAG_NONE, /* gpos_tag */ + nullptr, /* reorder_marks */ + HB_OT_SHAPE_ZERO_WIDTH_MARKS_NONE, + false, /* fallback_position */ +}; + #endif diff --git a/src/hb-ot-shape-complex.hh b/src/hb-ot-shape-complex.hh index 269162213..a9f583442 100644 --- a/src/hb-ot-shape-complex.hh +++ b/src/hb-ot-shape-complex.hh @@ -50,8 +50,9 @@ enum hb_ot_shape_zero_width_marks_type_t { /* Master OT shaper list */ #define HB_COMPLEX_SHAPERS_IMPLEMENT_SHAPERS \ - HB_COMPLEX_SHAPER_IMPLEMENT (default) /* should be first */ \ HB_COMPLEX_SHAPER_IMPLEMENT (arabic) \ + HB_COMPLEX_SHAPER_IMPLEMENT (default) \ + HB_COMPLEX_SHAPER_IMPLEMENT (dumber) \ HB_COMPLEX_SHAPER_IMPLEMENT (hangul) \ HB_COMPLEX_SHAPER_IMPLEMENT (hebrew) \ HB_COMPLEX_SHAPER_IMPLEMENT (indic) \ @@ -60,7 +61,7 @@ enum hb_ot_shape_zero_width_marks_type_t { HB_COMPLEX_SHAPER_IMPLEMENT (myanmar_zawgyi) \ HB_COMPLEX_SHAPER_IMPLEMENT (thai) \ HB_COMPLEX_SHAPER_IMPLEMENT (use) \ - /* ^--- Add new shapers here */ + /* ^--- Add new shapers here; keep sorted. */ struct hb_ot_complex_shaper_t diff --git a/src/hb-ot-shape.cc b/src/hb-ot-shape.cc index 45f8e9912..4506b55e6 100644 --- a/src/hb-ot-shape.cc +++ b/src/hb-ot-shape.cc @@ -78,8 +78,9 @@ hb_ot_shape_planner_t::hb_ot_shape_planner_t (hb_face_t *fac script_zero_marks = shaper->zero_width_marks != HB_OT_SHAPE_ZERO_WIDTH_MARKS_NONE; script_fallback_mark_positioning = shaper->fallback_position; - if (apply_morx) - shaper = &_hb_ot_complex_shaper_default; + /* https://github.com/harfbuzz/harfbuzz/issues/1528 */ + if (apply_morx && shaper != &_hb_ot_complex_shaper_default) + shaper = &_hb_ot_complex_shaper_dumber; } void