diff options
author | Behdad Esfahbod <behdad@behdad.org> | 2018-02-26 00:32:11 -0800 |
---|---|---|
committer | Behdad Esfahbod <behdad@behdad.org> | 2018-02-26 00:32:11 -0800 |
commit | fa3a69e2334ec4122d672670614a8e5a95611d75 (patch) | |
tree | ad02f2265cffd8f1d911e19f2455f717c7d32aa5 /src/hb-aat-layout-trak-table.hh | |
parent | f0bc6c0992c4302ae1a20f155ad256bfa331087c (diff) |
[aat/trak] Simplify sanitize()
Diffstat (limited to 'src/hb-aat-layout-trak-table.hh')
-rw-r--r-- | src/hb-aat-layout-trak-table.hh | 67 |
1 files changed, 16 insertions, 51 deletions
diff --git a/src/hb-aat-layout-trak-table.hh b/src/hb-aat-layout-trak-table.hh index 6c83760e..5767b116 100644 --- a/src/hb-aat-layout-trak-table.hh +++ b/src/hb-aat-layout-trak-table.hh @@ -42,15 +42,15 @@ struct TrackTableEntry inline bool sanitize (hb_sanitize_context_t *c, const void *base, unsigned int size) const { TRACE_SANITIZE (this); - return_trace (c->check_struct (this) && ((base+values).sanitize (c, size))); + return_trace (c->check_struct (this) && (values.sanitize (c, base, size))); } - inline Fixed get_track_value () const + inline float get_track_value () const { - return track; + return track.to_float (); } - inline float get_value (const void *base, unsigned int index) const + inline int get_value (const void *base, unsigned int index) const { return (base+values)[index]; } @@ -58,7 +58,7 @@ struct TrackTableEntry protected: Fixed track; /* Track value for this record. */ HBUINT16 trackNameID; /* The 'name' table index for this track */ - OffsetTo<UnsizedArrayOf<HBINT16> > + OffsetTo<UnsizedArrayOf<FWORD> > values; /* Offset from start of tracking table to * per-size tracking values for this track. */ @@ -71,26 +71,9 @@ struct TrackData inline bool sanitize (hb_sanitize_context_t *c, const void *base) const { TRACE_SANITIZE (this); - if (!(c->check_struct (this))) - return_trace (false); - - unsigned int tracks = nTracks; - unsigned int sizes = nSizes; - - // It should have at least one track - if (tracks < 1) return_trace (false); - - // We can not do interpolation with less than two - if (sizes < 2) return_trace (false); - - if (!((base+sizeTable).sanitize (c, sizes))) - return_trace (false); - - for (unsigned int i = 0; i < tracks; ++i) - if (!(trackTable[i].sanitize (c, base, sizes))) - return_trace (false); - - return_trace (true); + return_trace (c->check_struct (this) && + sizeTable.sanitize (c, base, nSizes) && + trackTable.sanitize (c, nTracks, base, nSizes)); } inline float get_tracking (const void *base, float ptem) const @@ -104,15 +87,14 @@ struct TrackData Fixed fixed_size; fixed_size.set_float (csspx); - /* TODO Clean this up. */ + /* XXX Clean this up. Make it work with nSizes==1 and 0. */ - unsigned int tracks = nTracks; unsigned int sizes = nSizes; const TrackTableEntry *trackTableEntry = nullptr; for (unsigned int i = 0; i < sizes; ++i) // For now we only seek for track entries with zero tracking value - if (trackTable[i].get_track_value () == 0) + if (trackTable[i].get_track_value () == 0.) trackTableEntry = &trackTable[0]; // We couldn't match any, exit @@ -142,9 +124,10 @@ struct TrackData protected: HBUINT16 nTracks; /* Number of separate tracks included in this table. */ HBUINT16 nSizes; /* Number of point sizes included in this table. */ - LOffsetTo<UnsizedArrayOf<Fixed> > + LOffsetTo<UnsizedArrayOf<Fixed> > /* Offset to array[nSizes] of size values. */ sizeTable; - UnsizedArrayOf<TrackTableEntry> trackTable;/* Array[nSizes] of size values. */ + UnsizedArrayOf<TrackTableEntry> + trackTable; /* Array[nTracks] of TrackTableEntry records. */ public: DEFINE_SIZE_ARRAY (8, trackTable); @@ -158,27 +141,9 @@ struct trak { TRACE_SANITIZE (this); - if (!(c->check_struct (this))) - return_trace (false); - - if ((format != 0) || (reserved != 0)) - return_trace (false); - - if (horizData) - { - const TrackData &trackData = this+horizData; - if (!trackData.sanitize (c, this)) - return_trace (false); - } - - if (vertData) - { - const TrackData &trackData = this+horizData; - if (!trackData.sanitize (c, this)) - return_trace (false); - } - - return_trace (true); + return_trace (c->check_struct (this) && + horizData.sanitize (c, this, this) && + vertData.sanitize (c, this, this)); } inline bool apply (hb_aat_apply_context_t *c) const |