[kern/kerx] Minor

This commit is contained in:
Behdad Esfahbod 2018-11-07 12:48:06 -05:00
parent f5e0a63a22
commit f8c3df7d4a
2 changed files with 13 additions and 11 deletions

View File

@ -852,6 +852,7 @@ public:
struct kerx
{
static const hb_tag_t tableTag = HB_AAT_TAG_kerx;
static const uint16_t minVersion = 2;
inline bool has_data (void) const { return version != 0; }
@ -898,8 +899,7 @@ struct kerx
inline bool sanitize (hb_sanitize_context_t *c) const
{
TRACE_SANITIZE (this);
if (!version.sanitize (c) || version < 2 ||
!tableCount.sanitize (c))
if (!version.sanitize (c) || version < minVersion || !tableCount.sanitize (c))
return_trace (false);
const KerxSubTable *st = &firstTable;
@ -921,6 +921,7 @@ struct kerx
HBUINT32 tableCount; /* The number of subtables included in the extended kerning
* table. */
KerxSubTable firstTable; /* Subtables. */
UnsizedArrayOf<HBUINT8> dataZ;
/*subtableGlyphCoverageArray*/ /* Only if version >= 3. We don't use. */
public:

View File

@ -170,7 +170,7 @@ struct KernTable
int v = 0;
const SubTable *st = CastP<SubTable> (&thiz()->dataZ);
unsigned int count = thiz()->nTables;
unsigned int count = thiz()->tableCount;
for (unsigned int i = 0; i < count; i++)
{
if ((st->u.header.coverage & (st->u.header.Variation | st->u.header.CrossStream)) ||
@ -188,7 +188,7 @@ struct KernTable
c->set_lookup_index (0);
const SubTable *st = CastP<SubTable> (&thiz()->dataZ);
unsigned int count = thiz()->nTables;
unsigned int count = thiz()->tableCount;
st = CastP<SubTable> (&thiz()->dataZ);
for (unsigned int i = 0; i < count; i++)
{
@ -216,14 +216,15 @@ struct KernTable
inline bool sanitize (hb_sanitize_context_t *c) const
{
TRACE_SANITIZE (this);
if (unlikely (!c->check_struct (thiz()) ||
thiz()->version != T::VERSION))
if (unlikely (!thiz()->version.sanitize (c) ||
thiz()->version < T::minVersion ||
!thiz()->tableCount.sanitize (c)))
return_trace (false);
typedef KernSubTable<typename T::SubTableHeader> SubTable;
const SubTable *st = CastP<SubTable> (&thiz()->dataZ);
unsigned int count = thiz()->nTables;
unsigned int count = thiz()->tableCount;
for (unsigned int i = 0; i < count; i++)
{
if (unlikely (!st->sanitize (c)))
@ -239,7 +240,7 @@ struct KernOT : KernTable<KernOT>
{
friend struct KernTable<KernOT>;
static const uint16_t VERSION = 0x0000u;
static const uint16_t minVersion = 0;
struct SubTableHeader
{
@ -275,7 +276,7 @@ struct KernOT : KernTable<KernOT>
protected:
HBUINT16 version; /* Version--0x0000u */
HBUINT16 nTables; /* Number of subtables in the kerning table. */
HBUINT16 tableCount; /* Number of subtables in the kerning table. */
UnsizedArrayOf<HBUINT8> dataZ;
public:
DEFINE_SIZE_ARRAY (4, dataZ);
@ -285,7 +286,7 @@ struct KernAAT : KernTable<KernAAT>
{
friend struct KernTable<KernAAT>;
static const uint32_t VERSION = 0x00010000u;
static const uint32_t minVersion = 0x00010000u;
struct SubTableHeader
{
@ -320,7 +321,7 @@ struct KernAAT : KernTable<KernAAT>
protected:
HBUINT32 version; /* Version--0x00010000u */
HBUINT32 nTables; /* Number of subtables in the kerning table. */
HBUINT32 tableCount; /* Number of subtables in the kerning table. */
UnsizedArrayOf<HBUINT8> dataZ;
public:
DEFINE_SIZE_ARRAY (8, dataZ);