From 22955b23cdeb48e46cdffd0eb906a855a420c4d1 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Wed, 10 Oct 2018 19:58:20 -0400 Subject: [PATCH] [kerx] Start fleshing out Format6 --- src/hb-aat-layout-kerx-table.hh | 42 ++++++++++++++++++++++++++------- src/hb-open-type.hh | 3 +++ 2 files changed, 36 insertions(+), 9 deletions(-) diff --git a/src/hb-aat-layout-kerx-table.hh b/src/hb-aat-layout-kerx-table.hh index cd8dc458c..05b28f3cf 100644 --- a/src/hb-aat-layout-kerx-table.hh +++ b/src/hb-aat-layout-kerx-table.hh @@ -225,6 +225,13 @@ struct KerxSubTableFormat4 struct KerxSubTableFormat6 { + enum Flags + { + ValuesAreLong = 0x00000001, + }; + + inline bool is_long (void) const { return flags & ValuesAreLong; } + inline bool apply (hb_aat_apply_context_t *c) const { TRACE_APPLY (this); @@ -241,10 +248,16 @@ struct KerxSubTableFormat6 { TRACE_SANITIZE (this); return_trace (likely (c->check_struct (this) && - rowIndexTable.sanitize (c, this) && - columnIndexTable.sanitize (c, this) && - kerningArray.sanitize (c, this) && - kerningVector.sanitize (c, this))); + is_long () ? + ( + u.l.rowIndexTable.sanitize (c, this) && + u.l.columnIndexTable.sanitize (c, this) && + u.l.kerningArray.sanitize (c, this) + ) : ( + u.s.rowIndexTable.sanitize (c, this) && + u.s.columnIndexTable.sanitize (c, this) && + u.s.kerningArray.sanitize (c, this) + ))); } protected: @@ -252,12 +265,23 @@ struct KerxSubTableFormat6 HBUINT32 flags; HBUINT16 rowCount; HBUINT16 columnCount; - LOffsetTo > rowIndexTable; - LOffsetTo > columnIndexTable; - LOffsetTo > kerningArray; - LOffsetTo > kerningVector; + union + { + struct + { + LOffsetTo > rowIndexTable; + LOffsetTo > columnIndexTable; + LOffsetTo kerningArray; + } s; + struct + { + LOffsetTo > rowIndexTable; + LOffsetTo > columnIndexTable; + LOffsetTo kerningArray; + } l; + } u; public: - DEFINE_SIZE_STATIC (36); + DEFINE_SIZE_STATIC (32); }; struct KerxTable diff --git a/src/hb-open-type.hh b/src/hb-open-type.hh index 9a0873369..2eae09d5c 100644 --- a/src/hb-open-type.hh +++ b/src/hb-open-type.hh @@ -92,6 +92,9 @@ typedef IntType HBUINT24; /* 24-bit unsigned integer. */ /* 16-bit signed integer (HBINT16) that describes a quantity in FUnits. */ typedef HBINT16 FWORD; +/* 32-bit signed integer (HBINT32) that describes a quantity in FUnits. */ +typedef HBINT32 FWORD32; + /* 16-bit unsigned integer (HBUINT16) that describes a quantity in FUnits. */ typedef HBUINT16 UFWORD;