[kerx] Towards sharing subtables with kern

This commit is contained in:
Behdad Esfahbod 2018-11-07 10:19:46 -05:00
parent befac337ca
commit a6acff252c
1 changed files with 23 additions and 18 deletions

View File

@ -90,6 +90,7 @@ struct KerxSubTableHeader
DEFINE_SIZE_STATIC (12); DEFINE_SIZE_STATIC (12);
}; };
template <typename KernSubTableHeader>
struct KerxSubTableFormat0 struct KerxSubTableFormat0
{ {
inline int get_kerning (hb_codepoint_t left, hb_codepoint_t right, inline int get_kerning (hb_codepoint_t left, hb_codepoint_t right,
@ -141,13 +142,14 @@ struct KerxSubTableFormat0
} }
protected: protected:
KerxSubTableHeader header; KernSubTableHeader header;
BinSearchArrayOf<KernPair, HBUINT32> BinSearchArrayOf<KernPair, HBUINT32>
pairs; /* Sorted kern records. */ pairs; /* Sorted kern records. */
public: public:
DEFINE_SIZE_ARRAY (28, pairs); DEFINE_SIZE_ARRAY (KernSubTableHeader::static_size + 16, pairs);
}; };
template <typename KernSubTableHeader>
struct KerxSubTableFormat1 struct KerxSubTableFormat1
{ {
struct EntryData struct EntryData
@ -329,13 +331,14 @@ struct KerxSubTableFormat1
} }
protected: protected:
KerxSubTableHeader header; KernSubTableHeader header;
StateTable<MorxTypes, EntryData> machine; StateTable<MorxTypes, EntryData> machine;
LOffsetTo<UnsizedArrayOf<FWORD>, false> kernAction; LOffsetTo<UnsizedArrayOf<FWORD>, false> kernAction;
public: public:
DEFINE_SIZE_STATIC (32); DEFINE_SIZE_STATIC (KernSubTableHeader::static_size + 20);
}; };
template <typename KernSubTableHeader>
struct KerxSubTableFormat2 struct KerxSubTableFormat2
{ {
inline int get_kerning (hb_codepoint_t left, hb_codepoint_t right, inline int get_kerning (hb_codepoint_t left, hb_codepoint_t right,
@ -390,7 +393,7 @@ struct KerxSubTableFormat2
} }
protected: protected:
KerxSubTableHeader header; KernSubTableHeader header;
HBUINT32 rowWidth; /* The width, in bytes, of a row in the table. */ HBUINT32 rowWidth; /* The width, in bytes, of a row in the table. */
LOffsetTo<Lookup<HBUINT16>, false> LOffsetTo<Lookup<HBUINT16>, false>
leftClassTable; /* Offset from beginning of this subtable to leftClassTable; /* Offset from beginning of this subtable to
@ -402,9 +405,10 @@ struct KerxSubTableFormat2
array; /* Offset from beginning of this subtable to array; /* Offset from beginning of this subtable to
* the start of the kerning array. */ * the start of the kerning array. */
public: public:
DEFINE_SIZE_STATIC (28); DEFINE_SIZE_STATIC (KernSubTableHeader::static_size + 16);
}; };
template <typename KernSubTableHeader>
struct KerxSubTableFormat4 struct KerxSubTableFormat4
{ {
struct EntryData struct EntryData
@ -566,14 +570,15 @@ struct KerxSubTableFormat4
} }
protected: protected:
KerxSubTableHeader header; KernSubTableHeader header;
StateTable<MorxTypes, EntryData> StateTable<MorxTypes, EntryData>
machine; machine;
HBUINT32 flags; HBUINT32 flags;
public: public:
DEFINE_SIZE_STATIC (32); DEFINE_SIZE_STATIC (KernSubTableHeader::static_size + 20);
}; };
template <typename KernSubTableHeader>
struct KerxSubTableFormat6 struct KerxSubTableFormat6
{ {
enum Flags enum Flags
@ -589,7 +594,7 @@ struct KerxSubTableFormat6
unsigned int num_glyphs = c->sanitizer.get_num_glyphs (); unsigned int num_glyphs = c->sanitizer.get_num_glyphs ();
if (is_long ()) if (is_long ())
{ {
const U::Long &t = u.l; const typename U::Long &t = u.l;
unsigned int l = (this+t.rowIndexTable).get_value_or_null (left, num_glyphs); unsigned int l = (this+t.rowIndexTable).get_value_or_null (left, num_glyphs);
unsigned int r = (this+t.columnIndexTable).get_value_or_null (right, num_glyphs); unsigned int r = (this+t.columnIndexTable).get_value_or_null (right, num_glyphs);
unsigned int offset = l + r; unsigned int offset = l + r;
@ -601,7 +606,7 @@ struct KerxSubTableFormat6
} }
else else
{ {
const U::Short &t = u.s; const typename U::Short &t = u.s;
unsigned int l = (this+t.rowIndexTable).get_value_or_null (left, num_glyphs); unsigned int l = (this+t.rowIndexTable).get_value_or_null (left, num_glyphs);
unsigned int r = (this+t.columnIndexTable).get_value_or_null (right, num_glyphs); unsigned int r = (this+t.columnIndexTable).get_value_or_null (right, num_glyphs);
unsigned int offset = l + r; unsigned int offset = l + r;
@ -660,7 +665,7 @@ struct KerxSubTableFormat6
}; };
protected: protected:
KerxSubTableHeader header; KernSubTableHeader header;
HBUINT32 flags; HBUINT32 flags;
HBUINT16 rowCount; HBUINT16 rowCount;
HBUINT16 columnCount; HBUINT16 columnCount;
@ -681,7 +686,7 @@ struct KerxSubTableFormat6
} u; } u;
LOffsetTo<UnsizedArrayOf<FWORD>, false> vector; LOffsetTo<UnsizedArrayOf<FWORD>, false> vector;
public: public:
DEFINE_SIZE_STATIC (36); DEFINE_SIZE_STATIC (KernSubTableHeader::static_size + 24);
}; };
struct KerxTable struct KerxTable
@ -719,11 +724,11 @@ struct KerxTable
protected: protected:
union { union {
KerxSubTableHeader header; KerxSubTableHeader header;
KerxSubTableFormat0 format0; KerxSubTableFormat0<KerxSubTableHeader> format0;
KerxSubTableFormat1 format1; KerxSubTableFormat1<KerxSubTableHeader> format1;
KerxSubTableFormat2 format2; KerxSubTableFormat2<KerxSubTableHeader> format2;
KerxSubTableFormat4 format4; KerxSubTableFormat4<KerxSubTableHeader> format4;
KerxSubTableFormat6 format6; KerxSubTableFormat6<KerxSubTableHeader> format6;
} u; } u;
public: public:
DEFINE_SIZE_MIN (12); DEFINE_SIZE_MIN (12);