diff --git a/src/hb-aat-layout-kerx-table.hh b/src/hb-aat-layout-kerx-table.hh index bb88d9d15..74fecbb11 100644 --- a/src/hb-aat-layout-kerx-table.hh +++ b/src/hb-aat-layout-kerx-table.hh @@ -843,6 +843,21 @@ struct KerxTable /* https://en.wikipedia.org/wiki/Curiously_recurring_template_pattern */ inline const T* thiz (void) const { return static_cast (this); } + inline bool has_state_machine (void) const + { + typedef typename T::SubTable SubTable; + + const SubTable *st = &thiz()->firstSubTable; + unsigned int count = thiz()->tableCount; + for (unsigned int i = 0; i < count; i++) + { + if (st->get_type () == 1) + return true; + st = &StructAfter (*st); + } + return false; + } + inline bool has_cross_stream (void) const { typedef typename T::SubTable SubTable; diff --git a/src/hb-ot-kern-table.hh b/src/hb-ot-kern-table.hh index b2d571404..b57ebaea8 100644 --- a/src/hb-ot-kern-table.hh +++ b/src/hb-ot-kern-table.hh @@ -274,6 +274,15 @@ struct kern inline bool has_data (void) const { return u.version32; } inline unsigned int get_type (void) const { return u.major; } + inline bool has_state_machine (void) const + { + switch (get_type ()) { + case 0: return u.ot.has_state_machine (); + case 1: return u.aat.has_state_machine (); + default:return false; + } + } + inline bool has_cross_stream (void) const { switch (get_type ()) { diff --git a/src/hb-ot-layout.cc b/src/hb-ot-layout.cc index 092633c5d..9488fe82c 100644 --- a/src/hb-ot-layout.cc +++ b/src/hb-ot-layout.cc @@ -65,6 +65,12 @@ hb_ot_layout_has_kerning (hb_face_t *face) return face->table.kern->has_data (); } +bool +hb_ot_layout_has_machine_kerning (hb_face_t *face) +{ + return face->table.kern->has_state_machine (); +} + bool hb_ot_layout_has_cross_kerning (hb_face_t *face) { diff --git a/src/hb-ot-layout.hh b/src/hb-ot-layout.hh index db85508d2..a00b940b2 100644 --- a/src/hb-ot-layout.hh +++ b/src/hb-ot-layout.hh @@ -48,6 +48,9 @@ struct hb_ot_shape_plan_t; HB_INTERNAL bool hb_ot_layout_has_kerning (hb_face_t *face); +HB_INTERNAL bool +hb_ot_layout_has_machine_kerning (hb_face_t *face); + HB_INTERNAL bool hb_ot_layout_has_cross_kerning (hb_face_t *face); diff --git a/src/hb-ot-shape.cc b/src/hb-ot-shape.cc index 8d844807c..ef9743578 100644 --- a/src/hb-ot-shape.cc +++ b/src/hb-ot-shape.cc @@ -146,7 +146,9 @@ hb_ot_shape_planner_t::compile (hb_ot_shape_plan_t &plan, plan.apply_kern = true; } - plan.zero_marks = script_zero_marks && !plan.apply_kerx; + plan.zero_marks = script_zero_marks && + !plan.apply_kerx && + (!plan.apply_kern || !hb_ot_layout_has_machine_kerning (face)); plan.has_gpos_mark = !!plan.map.get_1_mask (HB_TAG ('m','a','r','k')); plan.adjust_mark_positioning_when_zeroing = !plan.apply_gpos &&