From bc06e2805ae55f5c152dfb70ee91c75830ad8f54 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Wed, 7 Nov 2018 16:02:40 -0500 Subject: [PATCH] [kerx/kern] Add has_cross_stream() --- src/hb-aat-layout-kerx-table.hh | 15 +++++++++++++++ src/hb-ot-kern-table.hh | 9 +++++++++ 2 files changed, 24 insertions(+) diff --git a/src/hb-aat-layout-kerx-table.hh b/src/hb-aat-layout-kerx-table.hh index 84fa6dcd7..422120949 100644 --- a/src/hb-aat-layout-kerx-table.hh +++ b/src/hb-aat-layout-kerx-table.hh @@ -848,6 +848,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_cross_stream (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->u.header.coverage & st->u.header.CrossStream) + return true; + st = &StructAfter (*st); + } + return false; + } + inline int get_h_kerning (hb_codepoint_t left, hb_codepoint_t right) const { typedef typename T::SubTable SubTable; diff --git a/src/hb-ot-kern-table.hh b/src/hb-ot-kern-table.hh index 95306ece3..690532e29 100644 --- a/src/hb-ot-kern-table.hh +++ b/src/hb-ot-kern-table.hh @@ -273,6 +273,15 @@ struct kern inline bool has_data (void) const { return u.version32; } + inline bool has_cross_stream (void) const + { + switch (u.major) { + case 0: return u.ot.has_cross_stream (); + case 1: return u.aat.has_cross_stream (); + default:return false; + } + } + inline int get_h_kerning (hb_codepoint_t left, hb_codepoint_t right) const { switch (u.major) {