From 1d82b4761d0a2e2e0be002e8a6bfe060f7b6dec3 Mon Sep 17 00:00:00 2001 From: Ebrahim Byagowi Date: Sat, 10 Nov 2018 18:08:11 +0330 Subject: [PATCH] [colr/feat/trak] minor --- src/hb-aat-layout-feat-table.hh | 14 ++++++------- src/hb-aat-layout-trak-table.hh | 35 ++++++++++++++++++--------------- src/hb-ot-color-colr-table.hh | 18 ++++++----------- 3 files changed, 32 insertions(+), 35 deletions(-) diff --git a/src/hb-aat-layout-feat-table.hh b/src/hb-aat-layout-feat-table.hh index b670caab8..87ab4abd3 100644 --- a/src/hb-aat-layout-feat-table.hh +++ b/src/hb-aat-layout-feat-table.hh @@ -54,13 +54,6 @@ struct SettingName struct FeatureName { - inline bool sanitize (hb_sanitize_context_t *c, const void *base) const - { - TRACE_SANITIZE (this); - return_trace (likely (c->check_struct (this) && - (base+settingTable).sanitize (c, nSettings))); - } - enum { Exclusive = 0x8000, /* If set, the feature settings are mutually exclusive. */ NotDefault = 0x4000, /* If clear, then the setting with an index of 0 in @@ -75,6 +68,13 @@ struct FeatureName * as the default. */ }; + inline bool sanitize (hb_sanitize_context_t *c, const void *base) const + { + TRACE_SANITIZE (this); + return_trace (likely (c->check_struct (this) && + (base+settingTable).sanitize (c, nSettings))); + } + protected: HBUINT16 feature; /* Feature type. */ HBUINT16 nSettings; /* The number of records in the setting name array. */ diff --git a/src/hb-aat-layout-trak-table.hh b/src/hb-aat-layout-trak-table.hh index 68218ecb7..3b55967c8 100644 --- a/src/hb-aat-layout-trak-table.hh +++ b/src/hb-aat-layout-trak-table.hh @@ -171,15 +171,6 @@ struct trak inline bool has_data (void) const { return version.to_int () != 0; } - inline bool sanitize (hb_sanitize_context_t *c) const - { - TRACE_SANITIZE (this); - - return_trace (likely (c->check_struct (this) && - horizData.sanitize (c, this, this) && - vertData.sanitize (c, this, this))); - } - inline bool apply (hb_aat_apply_context_t *c) const { TRACE_APPLY (this); @@ -221,15 +212,27 @@ struct trak return_trace (true); } + inline bool sanitize (hb_sanitize_context_t *c) const + { + TRACE_SANITIZE (this); + + return_trace (likely (c->check_struct (this) && + version.major == 1 && + horizData.sanitize (c, this, this) && + vertData.sanitize (c, this, this))); + } + protected: - FixedVersion<> version; /* Version of the tracking table + FixedVersion<>version; /* Version of the tracking table * (0x00010000u for version 1.0). */ - HBUINT16 format; /* Format of the tracking table (set to 0). */ - OffsetTo horizData; /* Offset from start of tracking table to TrackData - * for horizontal text (or 0 if none). */ - OffsetTo vertData; /* Offset from start of tracking table to TrackData - * for vertical text (or 0 if none). */ - HBUINT16 reserved; /* Reserved. Set to 0. */ + HBUINT16 format; /* Format of the tracking table (set to 0). */ + OffsetTo + horizData; /* Offset from start of tracking table to TrackData + * for horizontal text (or 0 if none). */ + OffsetTo + vertData; /* Offset from start of tracking table to TrackData + * for vertical text (or 0 if none). */ + HBUINT16 reserved; /* Reserved. Set to 0. */ public: DEFINE_SIZE_STATIC (12); diff --git a/src/hb-ot-color-colr-table.hh b/src/hb-ot-color-colr-table.hh index b480af51d..fa40223b7 100644 --- a/src/hb-ot-color-colr-table.hh +++ b/src/hb-ot-color-colr-table.hh @@ -103,7 +103,12 @@ struct COLR unsigned int *count, /* IN/OUT. May be NULL. */ hb_ot_color_layer_t *layers /* OUT. May be NULL. */) const { - const BaseGlyphRecord &record = get_glyph_record (glyph); + const BaseGlyphRecord *rec = (BaseGlyphRecord *) bsearch (&glyph, + &(this+baseGlyphsZ), + numBaseGlyphs, + sizeof (BaseGlyphRecord), + BaseGlyphRecord::cmp); + const BaseGlyphRecord &record = rec ? *rec : Null (BaseGlyphRecord); hb_array_t all_layers ((this+layersZ).arrayZ, numLayers); hb_array_t glyph_layers = all_layers.sub_array (record.firstLayerIdx, @@ -129,17 +134,6 @@ struct COLR (this+layersZ).sanitize (c, numLayers))); } - private: - inline const BaseGlyphRecord &get_glyph_record (hb_codepoint_t glyph_id) const - { - const BaseGlyphRecord *rec = (BaseGlyphRecord *) bsearch (&glyph_id, - &(this+baseGlyphsZ), - numBaseGlyphs, - sizeof (BaseGlyphRecord), - BaseGlyphRecord::cmp); - return rec ? *rec : Null(BaseGlyphRecord); - } - protected: HBUINT16 version; /* Table version number (starts at 0). */ HBUINT16 numBaseGlyphs; /* Number of Base Glyph Records. */