From 74c7a2c6c892446dcec574986e128967bd570e47 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Fri, 2 Nov 2018 14:26:04 -0400 Subject: [PATCH] [kern] Respect more flags --- src/hb-ot-kern-table.hh | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/hb-ot-kern-table.hh b/src/hb-ot-kern-table.hh index 303e1bb34..3845da8ea 100644 --- a/src/hb-ot-kern-table.hh +++ b/src/hb-ot-kern-table.hh @@ -395,8 +395,11 @@ struct KernSubTableWrapper /* https://en.wikipedia.org/wiki/Curiously_recurring_template_pattern */ inline const T* thiz (void) const { return static_cast (this); } + inline bool is_supported (void) const + { return !(thiz()->coverage & T::CheckFlags); } + inline bool is_horizontal (void) const - { return (thiz()->coverage & T::CheckFlags) == T::CheckHorizontal; } + { return (thiz()->coverage & T::Direction) == T::CheckHorizontal; } inline bool is_override (void) const { return bool (thiz()->coverage & T::Override); } @@ -405,7 +408,7 @@ struct KernSubTableWrapper { return thiz()->subtable.get_kerning (left, right, thiz()->format); } inline int get_h_kerning (hb_codepoint_t left, hb_codepoint_t right) const - { return is_horizontal () ? get_kerning (left, right) : 0; } + { return is_supported () && is_horizontal () ? get_kerning (left, right) : 0; } inline void apply (AAT::hb_aat_apply_context_t *c) const { thiz()->subtable.apply (c, thiz()->format); } @@ -435,7 +438,7 @@ struct KernTable unsigned int count = thiz()->nTables; for (unsigned int i = 0; i < count; i++) { - if (st->is_override ()) + if (st->is_supported () && st->is_override ()) v = 0; v += st->get_h_kerning (left, right); st = &StructAfter (*st); @@ -452,13 +455,19 @@ struct KernTable unsigned int last_override = 0; for (unsigned int i = 0; i < count; i++) { - if (st->is_override ()) + if (st->is_supported () && st->is_override ()) last_override = i; st = &StructAfter (*st); } st = CastP (&thiz()->dataZ); for (unsigned int i = 0; i < count; i++) { + if (!st->is_supported ()) + goto skip; + + if (HB_DIRECTION_IS_HORIZONTAL (c->buffer->props.direction) != st->is_horizontal ()) + goto skip; + if (i < last_override) goto skip; @@ -514,7 +523,7 @@ struct KernOT : KernTable Variation = 0x00u, /* Not supported. */ - CheckFlags = 0x07u, + CheckFlags = 0x06u, CheckHorizontal = 0x01u }; @@ -555,7 +564,7 @@ struct KernAAT : KernTable Override = 0x00u, /* Not supported. */ - CheckFlags = 0xE0u, + CheckFlags = 0x60u, CheckHorizontal = 0x00u };