[aat] Disable mark advance zeroing if kern table has state-machines

Geeza Pro for example, relies on that for fancy mark positioning.

Fixes https://github.com/harfbuzz/harfbuzz/issues/1405
This commit is contained in:
Behdad Esfahbod 2018-11-23 11:10:17 -05:00
parent 3d2b98ef14
commit 748962264a
5 changed files with 36 additions and 1 deletions

View File

@ -843,6 +843,21 @@ struct KerxTable
/* https://en.wikipedia.org/wiki/Curiously_recurring_template_pattern */
inline const T* thiz (void) const { return static_cast<const T *> (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<SubTable> (*st);
}
return false;
}
inline bool has_cross_stream (void) const
{
typedef typename T::SubTable SubTable;

View File

@ -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 ()) {

View File

@ -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)
{

View File

@ -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);

View File

@ -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 &&