[kern/kerx] Towards sharing KernTable

This commit is contained in:
Behdad Esfahbod 2018-11-07 12:32:39 -05:00
parent 330508497d
commit f5e0a63a22
2 changed files with 9 additions and 14 deletions

View File

@ -769,6 +769,7 @@ struct KerxSubTableHeader
typedef ExtendedTypes Types; typedef ExtendedTypes Types;
inline unsigned int tuple_count (void) const { return tupleCount; } inline unsigned int tuple_count (void) const { return tupleCount; }
inline bool is_horizontal (void) const { return !(coverage & Vertical); }
enum Coverage enum Coverage
{ {
@ -863,8 +864,7 @@ struct kerx
{ {
bool reverse; bool reverse;
if (HB_DIRECTION_IS_VERTICAL (c->buffer->props.direction) != if (HB_DIRECTION_IS_HORIZONTAL (c->buffer->props.direction) != st->u.header.is_horizontal ())
bool (st->u.header.coverage & st->u.header.Vertical))
goto skip; goto skip;
reverse = bool (st->u.header.coverage & st->u.header.Backwards) != reverse = bool (st->u.header.coverage & st->u.header.Backwards) !=

View File

@ -173,9 +173,8 @@ struct KernTable
unsigned int count = thiz()->nTables; unsigned int count = thiz()->nTables;
for (unsigned int i = 0; i < count; i++) for (unsigned int i = 0; i < count; i++)
{ {
if ((st->u.header.coverage & if ((st->u.header.coverage & (st->u.header.Variation | st->u.header.CrossStream)) ||
(st->u.header.Variation | st->u.header.CrossStream | st->u.header.Direction)) != !st->u.header.is_horizontal ())
st->u.header.DirectionHorizontal)
continue; continue;
v += st->get_kerning (left, right); v += st->get_kerning (left, right);
st = &StructAfter<SubTable> (*st); st = &StructAfter<SubTable> (*st);
@ -196,8 +195,7 @@ struct KernTable
if (st->u.header.coverage & st->u.header.Variation) if (st->u.header.coverage & st->u.header.Variation)
goto skip; goto skip;
if (HB_DIRECTION_IS_HORIZONTAL (c->buffer->props.direction) != if (HB_DIRECTION_IS_HORIZONTAL (c->buffer->props.direction) != st->u.header.is_horizontal ())
((st->u.header.coverage & st->u.header.Direction) == st->u.header.DirectionHorizontal))
goto skip; goto skip;
if (!c->buffer->message (c->font, "start kern subtable %d", c->lookup_index)) if (!c->buffer->message (c->font, "start kern subtable %d", c->lookup_index))
@ -248,18 +246,16 @@ struct KernOT : KernTable<KernOT>
typedef AAT::ObsoleteTypes Types; typedef AAT::ObsoleteTypes Types;
inline unsigned int tuple_count (void) const { return 0; } inline unsigned int tuple_count (void) const { return 0; }
inline bool is_horizontal (void) const { return (coverage & Horizontal); }
enum Coverage enum Coverage
{ {
Direction = 0x01u, Horizontal = 0x01u,
Minimum = 0x02u, Minimum = 0x02u,
CrossStream = 0x04u, CrossStream = 0x04u,
Override = 0x08u, Override = 0x08u,
Variation = 0x00u, /* Not supported. */ Variation = 0x00u, /* Not supported. */
DirectionHorizontal= 0x01u
}; };
inline bool sanitize (hb_sanitize_context_t *c) const inline bool sanitize (hb_sanitize_context_t *c) const
@ -296,14 +292,13 @@ struct KernAAT : KernTable<KernAAT>
typedef AAT::ObsoleteTypes Types; typedef AAT::ObsoleteTypes Types;
inline unsigned int tuple_count (void) const { return 0; } inline unsigned int tuple_count (void) const { return 0; }
inline bool is_horizontal (void) const { return !(coverage & Vertical); }
enum Coverage enum Coverage
{ {
Direction = 0x80u, Vertical = 0x80u,
CrossStream = 0x40u, CrossStream = 0x40u,
Variation = 0x20u, Variation = 0x20u,
DirectionHorizontal= 0x00u
}; };
inline bool sanitize (hb_sanitize_context_t *c) const inline bool sanitize (hb_sanitize_context_t *c) const