提交 f8c3df7d 编写于 作者: B Behdad Esfahbod

[kern/kerx] Minor

上级 f5e0a63a
...@@ -852,6 +852,7 @@ public: ...@@ -852,6 +852,7 @@ public:
struct kerx struct kerx
{ {
static const hb_tag_t tableTag = HB_AAT_TAG_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; } inline bool has_data (void) const { return version != 0; }
...@@ -898,8 +899,7 @@ struct kerx ...@@ -898,8 +899,7 @@ struct kerx
inline bool sanitize (hb_sanitize_context_t *c) const inline bool sanitize (hb_sanitize_context_t *c) const
{ {
TRACE_SANITIZE (this); TRACE_SANITIZE (this);
if (!version.sanitize (c) || version < 2 || if (!version.sanitize (c) || version < minVersion || !tableCount.sanitize (c))
!tableCount.sanitize (c))
return_trace (false); return_trace (false);
const KerxSubTable *st = &firstTable; const KerxSubTable *st = &firstTable;
...@@ -921,6 +921,7 @@ struct kerx ...@@ -921,6 +921,7 @@ struct kerx
HBUINT32 tableCount; /* The number of subtables included in the extended kerning HBUINT32 tableCount; /* The number of subtables included in the extended kerning
* table. */ * table. */
KerxSubTable firstTable; /* Subtables. */ KerxSubTable firstTable; /* Subtables. */
UnsizedArrayOf<HBUINT8> dataZ;
/*subtableGlyphCoverageArray*/ /* Only if version >= 3. We don't use. */ /*subtableGlyphCoverageArray*/ /* Only if version >= 3. We don't use. */
public: public:
......
...@@ -170,7 +170,7 @@ struct KernTable ...@@ -170,7 +170,7 @@ struct KernTable
int v = 0; int v = 0;
const SubTable *st = CastP<SubTable> (&thiz()->dataZ); 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++) for (unsigned int i = 0; i < count; i++)
{ {
if ((st->u.header.coverage & (st->u.header.Variation | st->u.header.CrossStream)) || if ((st->u.header.coverage & (st->u.header.Variation | st->u.header.CrossStream)) ||
...@@ -188,7 +188,7 @@ struct KernTable ...@@ -188,7 +188,7 @@ struct KernTable
c->set_lookup_index (0); c->set_lookup_index (0);
const SubTable *st = CastP<SubTable> (&thiz()->dataZ); const SubTable *st = CastP<SubTable> (&thiz()->dataZ);
unsigned int count = thiz()->nTables; unsigned int count = thiz()->tableCount;
st = CastP<SubTable> (&thiz()->dataZ); st = CastP<SubTable> (&thiz()->dataZ);
for (unsigned int i = 0; i < count; i++) for (unsigned int i = 0; i < count; i++)
{ {
...@@ -216,14 +216,15 @@ struct KernTable ...@@ -216,14 +216,15 @@ struct KernTable
inline bool sanitize (hb_sanitize_context_t *c) const inline bool sanitize (hb_sanitize_context_t *c) const
{ {
TRACE_SANITIZE (this); TRACE_SANITIZE (this);
if (unlikely (!c->check_struct (thiz()) || if (unlikely (!thiz()->version.sanitize (c) ||
thiz()->version != T::VERSION)) thiz()->version < T::minVersion ||
!thiz()->tableCount.sanitize (c)))
return_trace (false); return_trace (false);
typedef KernSubTable<typename T::SubTableHeader> SubTable; typedef KernSubTable<typename T::SubTableHeader> SubTable;
const SubTable *st = CastP<SubTable> (&thiz()->dataZ); 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++) for (unsigned int i = 0; i < count; i++)
{ {
if (unlikely (!st->sanitize (c))) if (unlikely (!st->sanitize (c)))
...@@ -239,7 +240,7 @@ struct KernOT : KernTable<KernOT> ...@@ -239,7 +240,7 @@ struct KernOT : KernTable<KernOT>
{ {
friend struct KernTable<KernOT>; friend struct KernTable<KernOT>;
static const uint16_t VERSION = 0x0000u; static const uint16_t minVersion = 0;
struct SubTableHeader struct SubTableHeader
{ {
...@@ -275,7 +276,7 @@ struct KernOT : KernTable<KernOT> ...@@ -275,7 +276,7 @@ struct KernOT : KernTable<KernOT>
protected: protected:
HBUINT16 version; /* Version--0x0000u */ 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; UnsizedArrayOf<HBUINT8> dataZ;
public: public:
DEFINE_SIZE_ARRAY (4, dataZ); DEFINE_SIZE_ARRAY (4, dataZ);
...@@ -285,7 +286,7 @@ struct KernAAT : KernTable<KernAAT> ...@@ -285,7 +286,7 @@ struct KernAAT : KernTable<KernAAT>
{ {
friend struct KernTable<KernAAT>; friend struct KernTable<KernAAT>;
static const uint32_t VERSION = 0x00010000u; static const uint32_t minVersion = 0x00010000u;
struct SubTableHeader struct SubTableHeader
{ {
...@@ -320,7 +321,7 @@ struct KernAAT : KernTable<KernAAT> ...@@ -320,7 +321,7 @@ struct KernAAT : KernTable<KernAAT>
protected: protected:
HBUINT32 version; /* Version--0x00010000u */ 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; UnsizedArrayOf<HBUINT8> dataZ;
public: public:
DEFINE_SIZE_ARRAY (8, dataZ); DEFINE_SIZE_ARRAY (8, dataZ);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册