From c97dde5d55929df394fbe57c1ba1a725592c6732 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Wed, 7 Nov 2018 10:39:39 -0500 Subject: [PATCH] [kern/kerx] Towards merge more --- src/hb-aat-layout-kerx-table.hh | 75 ++++++++++++++++++++++++++++++----------- src/hb-kern.hh | 33 ------------------ src/hb-ot-kern-table.hh | 7 ++-- 3 files changed, 58 insertions(+), 57 deletions(-) diff --git a/src/hb-aat-layout-kerx-table.hh b/src/hb-aat-layout-kerx-table.hh index a2f0c64..dcab790 100644 --- a/src/hb-aat-layout-kerx-table.hh +++ b/src/hb-aat-layout-kerx-table.hh @@ -29,6 +29,7 @@ #define HB_AAT_LAYOUT_KERX_TABLE_HH #include "hb-kern.hh" +#include "hb-aat-layout-ankr-table.hh" /* * kerx -- Extended Kerning @@ -57,36 +58,36 @@ kerxTupleKern (int value, } -struct KerxSubTableHeader +struct hb_glyph_pair_t { - typedef MorxTypes Types; + hb_codepoint_t left; + hb_codepoint_t right; +}; - enum Coverage +struct KernPair +{ + inline int get_kerning (void) const + { return value; } + + inline int cmp (const hb_glyph_pair_t &o) const { - Vertical = 0x80000000, /* Set if table has vertical kerning values. */ - CrossStream = 0x40000000, /* Set if table has cross-stream kerning values. */ - Variation = 0x20000000, /* Set if table has variation kerning values. */ - Backwards = 0x10000000, /* If clear, process the glyphs forwards, that - * is, from first to last in the glyph stream. - * If we, process them from last to first. - * This flag only applies to state-table based - * 'kerx' subtables (types 1 and 4). */ - Reserved = 0x0FFFFF00, /* Reserved, set to zero. */ - SubtableType = 0x000000FF, /* Subtable type. */ - }; + int ret = left.cmp (o.left); + if (ret) return ret; + return right.cmp (o.right); + } inline bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); - return_trace (likely (c->check_struct (this))); + return_trace (c->check_struct (this)); } + protected: + GlyphID left; + GlyphID right; + FWORD value; public: - HBUINT32 length; - HBUINT32 coverage; - HBUINT32 tupleCount; - public: - DEFINE_SIZE_STATIC (12); + DEFINE_SIZE_STATIC (6); }; template @@ -687,6 +688,39 @@ struct KerxSubTableFormat6 DEFINE_SIZE_STATIC (KernSubTableHeader::static_size + 24); }; + +struct KerxSubTableHeader +{ + typedef MorxTypes Types; + + enum Coverage + { + Vertical = 0x80000000, /* Set if table has vertical kerning values. */ + CrossStream = 0x40000000, /* Set if table has cross-stream kerning values. */ + Variation = 0x20000000, /* Set if table has variation kerning values. */ + Backwards = 0x10000000, /* If clear, process the glyphs forwards, that + * is, from first to last in the glyph stream. + * If we, process them from last to first. + * This flag only applies to state-table based + * 'kerx' subtables (types 1 and 4). */ + Reserved = 0x0FFFFF00, /* Reserved, set to zero. */ + SubtableType = 0x000000FF, /* Subtable type. */ + }; + + inline bool sanitize (hb_sanitize_context_t *c) const + { + TRACE_SANITIZE (this); + return_trace (likely (c->check_struct (this))); + } + + public: + HBUINT32 length; + HBUINT32 coverage; + HBUINT32 tupleCount; + public: + DEFINE_SIZE_STATIC (12); +}; + struct KerxTable { friend struct kerx; @@ -816,6 +850,7 @@ struct kerx DEFINE_SIZE_MIN (8); }; + } /* namespace AAT */ diff --git a/src/hb-kern.hh b/src/hb-kern.hh index de72696..60e625c 100644 --- a/src/hb-kern.hh +++ b/src/hb-kern.hh @@ -114,39 +114,6 @@ struct hb_kern_machine_t }; -struct hb_glyph_pair_t -{ - hb_codepoint_t left; - hb_codepoint_t right; -}; - -struct KernPair -{ - inline int get_kerning (void) const - { return value; } - - inline int cmp (const hb_glyph_pair_t &o) const - { - int ret = left.cmp (o.left); - if (ret) return ret; - return right.cmp (o.right); - } - - inline bool sanitize (hb_sanitize_context_t *c) const - { - TRACE_SANITIZE (this); - return_trace (c->check_struct (this)); - } - - protected: - GlyphID left; - GlyphID right; - FWORD value; - public: - DEFINE_SIZE_STATIC (6); -}; - - } /* namespace OT */ diff --git a/src/hb-ot-kern-table.hh b/src/hb-ot-kern-table.hh index 9f75466..c7c15e8 100644 --- a/src/hb-ot-kern-table.hh +++ b/src/hb-ot-kern-table.hh @@ -27,8 +27,7 @@ #ifndef HB_OT_KERN_TABLE_HH #define HB_OT_KERN_TABLE_HH -#include "hb-kern.hh" -#include "hb-ot-shape.hh" +#include "hb-aat-layout-kerx-table.hh" /* @@ -47,7 +46,7 @@ struct KernSubTableFormat0 { inline int get_kerning (hb_codepoint_t left, hb_codepoint_t right) const { - hb_glyph_pair_t pair = {left, right}; + AAT::hb_glyph_pair_t pair = {left, right}; int i = pairs.bsearch (pair); if (i == -1) return 0; return pairs[i].get_kerning (); @@ -77,7 +76,7 @@ struct KernSubTableFormat0 protected: KernSubTableHeader header; - BinSearchArrayOf + BinSearchArrayOf pairs; /* Array of kerning pairs. */ public: DEFINE_SIZE_ARRAY (KernSubTableHeader::static_size + 8, pairs); -- 2.7.4