From 14ff3cbe0f30dea24e1bb175b1e8e41039f6afdc Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Thu, 4 Oct 2018 11:34:21 +0200 Subject: [PATCH] Apply morx if there's no GSUB! --- src/hb-ot-shape.cc | 23 +++++++++---- src/hb-ot-shape.hh | 5 +++ .../data/text-rendering-tests/DISABLED | 32 ------------------- .../text-rendering-tests/Makefile.sources | 14 ++++---- 4 files changed, 29 insertions(+), 45 deletions(-) diff --git a/src/hb-ot-shape.cc b/src/hb-ot-shape.cc index 748af9693..9e87b300b 100644 --- a/src/hb-ot-shape.cc +++ b/src/hb-ot-shape.cc @@ -63,9 +63,14 @@ hb_ot_shape_planner_t::compile (hb_ot_shape_plan_t &plan, plan.kerning_requested = !!plan.kern_mask; plan.has_gpos_mark = !!plan.map.get_1_mask (HB_TAG ('m','a','r','k')); + plan.apply_morx = !hb_ot_layout_has_substitution (face) && + hb_aat_layout_has_substitution (face); + bool disable_gpos = plan.shaper->gpos_tag && plan.shaper->gpos_tag != plan.map.chosen_script[1]; - plan.fallback_positioning = disable_gpos || !hb_ot_layout_has_positioning (face); + plan.apply_gpos = !disable_gpos && hb_ot_layout_has_positioning (face); + + plan.fallback_positioning = !plan.apply_gpos; plan.fallback_glyph_classes = !hb_ot_layout_has_glyph_classes (face); } @@ -217,7 +222,13 @@ _hb_ot_shaper_shape_plan_data_create (hb_shape_plan_t *shape_plan, hb_ot_shape_planner_t planner (shape_plan); - planner.shaper = hb_ot_shape_complex_categorize (&planner); + /* 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)) + planner.shaper = &_hb_ot_complex_shaper_default; + else + planner.shaper = hb_ot_shape_complex_categorize (&planner); hb_ot_shape_collect_features (&planner, &shape_plan->props, user_features, num_user_features); @@ -661,10 +672,10 @@ hb_ot_substitute_complex (hb_ot_shape_context_t *c) if (c->plan->fallback_glyph_classes) hb_synthesize_glyph_classes (c); - c->plan->substitute (c->font, buffer); - - if (0) /* XXX Call morx instead. */ + if (unlikely (c->plan->apply_morx)) hb_aat_layout_substitute (c->font, c->buffer); + else + c->plan->substitute (c->font, buffer); } static inline void @@ -784,7 +795,7 @@ hb_ot_position_complex (hb_ot_shape_context_t *c) break; } - if (likely (!c->plan->fallback_positioning)) + if (c->plan->apply_gpos) c->plan->position (c->font, c->buffer); switch (c->plan->shaper->zero_width_marks) diff --git a/src/hb-ot-shape.hh b/src/hb-ot-shape.hh index 88c72dc15..23c385aa1 100644 --- a/src/hb-ot-shape.hh +++ b/src/hb-ot-shape.hh @@ -49,6 +49,11 @@ struct hb_ot_shape_plan_t bool fallback_positioning : 1; bool fallback_glyph_classes : 1; + bool apply_morx : 1; + + bool apply_gpos : 1; + + inline void collect_lookups (hb_tag_t table_tag, hb_set_t *lookups) const { unsigned int table_index; diff --git a/test/shaping/data/text-rendering-tests/DISABLED b/test/shaping/data/text-rendering-tests/DISABLED index 1ce62e072..8539c0ee1 100644 --- a/test/shaping/data/text-rendering-tests/DISABLED +++ b/test/shaping/data/text-rendering-tests/DISABLED @@ -1,38 +1,6 @@ # Non-Unicode cmap tests/CMAP-3.tests -# Not hooked up -tests/MORX-1.tests -tests/MORX-2.tests -tests/MORX-3.tests -tests/MORX-4.tests -tests/MORX-5.tests -tests/MORX-6.tests -tests/MORX-7.tests -tests/MORX-8.tests -tests/MORX-9.tests -tests/MORX-10.tests -tests/MORX-11.tests -tests/MORX-12.tests -tests/MORX-13.tests -tests/MORX-14.tests -tests/MORX-16.tests -tests/MORX-17.tests -tests/MORX-18.tests -tests/MORX-19.tests -tests/MORX-20.tests -tests/MORX-21.tests -tests/MORX-22.tests -tests/MORX-23.tests -tests/MORX-25.tests -tests/MORX-26.tests -tests/MORX-27.tests -tests/MORX-28.tests -tests/MORX-29.tests -tests/MORX-30.tests -tests/MORX-31.tests -tests/MORX-32.tests - # Rounding differences tests/SHARAN-1.tests tests/SHBALI-1.tests diff --git a/test/shaping/data/text-rendering-tests/Makefile.sources b/test/shaping/data/text-rendering-tests/Makefile.sources index 5c8cd03f9..6fe174e49 100644 --- a/test/shaping/data/text-rendering-tests/Makefile.sources +++ b/test/shaping/data/text-rendering-tests/Makefile.sources @@ -28,12 +28,6 @@ TESTS = \ tests/HVAR-2.tests \ tests/KERN-1.tests \ tests/KERN-2.tests \ - tests/SHBALI-3.tests \ - tests/SHKNDA-1.tests \ - $(NULL) - -DISBALED_TESTS = \ - tests/CMAP-3.tests \ tests/MORX-10.tests \ tests/MORX-11.tests \ tests/MORX-12.tests \ @@ -56,7 +50,6 @@ DISBALED_TESTS = \ tests/MORX-2.tests \ tests/MORX-30.tests \ tests/MORX-31.tests \ - tests/MORX-32.tests \ tests/MORX-3.tests \ tests/MORX-4.tests \ tests/MORX-5.tests \ @@ -64,9 +57,16 @@ DISBALED_TESTS = \ tests/MORX-7.tests \ tests/MORX-8.tests \ tests/MORX-9.tests \ + tests/SHBALI-3.tests \ + tests/SHKNDA-1.tests \ + $(NULL) + +DISBALED_TESTS = \ + tests/CMAP-3.tests \ tests/SHARAN-1.tests \ tests/SHBALI-1.tests \ tests/SHBALI-2.tests \ tests/SHKNDA-2.tests \ tests/SHKNDA-3.tests \ + tests/MORX-32.tests \ $(NULL)