[kern/kerx] More towards sharing

This commit is contained in:
Behdad Esfahbod 2018-11-07 10:33:46 -05:00
parent d0f8f4c200
commit 540ccc38b0
2 changed files with 11 additions and 6 deletions

View File

@ -59,6 +59,8 @@ kerxTupleKern (int value,
struct KerxSubTableHeader struct KerxSubTableHeader
{ {
typedef MorxTypes Types;
enum Coverage enum Coverage
{ {
Vertical = 0x80000000, /* Set if table has vertical kerning values. */ Vertical = 0x80000000, /* Set if table has vertical kerning values. */
@ -134,13 +136,12 @@ struct KerxSubTableFormat0
inline bool sanitize (hb_sanitize_context_t *c) const inline bool sanitize (hb_sanitize_context_t *c) const
{ {
TRACE_SANITIZE (this); TRACE_SANITIZE (this);
return_trace (likely (c->check_struct (this) && return_trace (likely (pairs.sanitize (c)));
pairs.sanitize (c)));
} }
protected: protected:
KernSubTableHeader header; KernSubTableHeader header;
BinSearchArrayOf<KernPair, HBUINT32> BinSearchArrayOf<KernPair, typename KernSubTableHeader::Types::HBUINT>
pairs; /* Sorted kern records. */ pairs; /* Sorted kern records. */
public: public:
DEFINE_SIZE_ARRAY (KernSubTableHeader::static_size + 16, pairs); DEFINE_SIZE_ARRAY (KernSubTableHeader::static_size + 16, pairs);

View File

@ -49,8 +49,7 @@ struct KernSubTableFormat0
{ {
hb_glyph_pair_t pair = {left, right}; hb_glyph_pair_t pair = {left, right};
int i = pairs.bsearch (pair); int i = pairs.bsearch (pair);
if (i == -1) if (i == -1) return 0;
return 0;
return pairs[i].get_kerning (); return pairs[i].get_kerning ();
} }
@ -78,7 +77,8 @@ struct KernSubTableFormat0
protected: protected:
KernSubTableHeader header; KernSubTableHeader header;
BinSearchArrayOf<KernPair> pairs; /* Array of kerning pairs. */ BinSearchArrayOf<KernPair, typename KernSubTableHeader::Types::HBUINT>
pairs; /* Array of kerning pairs. */
public: public:
DEFINE_SIZE_ARRAY (KernSubTableHeader::static_size + 8, pairs); DEFINE_SIZE_ARRAY (KernSubTableHeader::static_size + 8, pairs);
}; };
@ -543,6 +543,8 @@ struct KernOT : KernTable<KernOT>
struct SubTableHeader struct SubTableHeader
{ {
typedef AAT::MortTypes Types;
enum Coverage enum Coverage
{ {
Direction = 0x01u, Direction = 0x01u,
@ -586,6 +588,8 @@ struct KernAAT : KernTable<KernAAT>
struct SubTableHeader struct SubTableHeader
{ {
typedef AAT::MortTypes Types;
enum Coverage enum Coverage
{ {
Direction = 0x80u, Direction = 0x80u,