[kerx] Towards merging Format2

This commit is contained in:
Behdad Esfahbod 2018-11-07 12:16:38 -05:00
parent d5c0ca210f
commit 8faec4e334
1 changed files with 10 additions and 7 deletions

View File

@ -406,12 +406,15 @@ struct KerxSubTableFormat1
template <typename KernSubTableHeader> template <typename KernSubTableHeader>
struct KerxSubTableFormat2 struct KerxSubTableFormat2
{ {
typedef typename KernSubTableHeader::Types Types;
typedef typename Types::HBUINT HBUINT;
inline int get_kerning (hb_codepoint_t left, hb_codepoint_t right, inline int get_kerning (hb_codepoint_t left, hb_codepoint_t right,
hb_aat_apply_context_t *c) const hb_aat_apply_context_t *c) const
{ {
unsigned int num_glyphs = c->sanitizer.get_num_glyphs (); unsigned int num_glyphs = c->sanitizer.get_num_glyphs ();
unsigned int l = (this+leftClassTable).get_value_or_null (left, num_glyphs); unsigned int l = (this+leftClassTable).get_class (left, num_glyphs, 0);
unsigned int r = (this+rightClassTable).get_value_or_null (right, num_glyphs); unsigned int r = (this+rightClassTable).get_class (right, num_glyphs, 0);
unsigned int offset = l + r; unsigned int offset = l + r;
const FWORD *v = &StructAtOffset<FWORD> (&(this+array), offset); const FWORD *v = &StructAtOffset<FWORD> (&(this+array), offset);
if (unlikely (!v->sanitize (&c->sanitizer))) return 0; if (unlikely (!v->sanitize (&c->sanitizer))) return 0;
@ -459,18 +462,18 @@ struct KerxSubTableFormat2
protected: protected:
KernSubTableHeader header; KernSubTableHeader header;
HBUINT32 rowWidth; /* The width, in bytes, of a row in the table. */ HBUINT rowWidth; /* The width, in bytes, of a row in the table. */
LOffsetTo<Lookup<HBUINT16>, false> OffsetTo<typename Types::ClassType, HBUINT, false>
leftClassTable; /* Offset from beginning of this subtable to leftClassTable; /* Offset from beginning of this subtable to
* left-hand class table. */ * left-hand class table. */
LOffsetTo<Lookup<HBUINT16>, false> OffsetTo<typename Types::ClassType, HBUINT, false>
rightClassTable;/* Offset from beginning of this subtable to rightClassTable;/* Offset from beginning of this subtable to
* right-hand class table. */ * right-hand class table. */
LOffsetTo<UnsizedArrayOf<FWORD>, false> OffsetTo<UnsizedArrayOf<FWORD>, HBUINT, false>
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 (KernSubTableHeader::static_size + 16); DEFINE_SIZE_STATIC (KernSubTableHeader::static_size + 4 * sizeof (HBUINT));
}; };
template <typename KernSubTableHeader> template <typename KernSubTableHeader>