Merge pull request #1376 from ebraminio/minor

[colr/feat/trak] minor
This commit is contained in:
Behdad Esfahbod 2018-11-10 15:35:12 -05:00 committed by GitHub
commit 5547bfa9f2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 32 additions and 35 deletions

View File

@ -54,13 +54,6 @@ struct SettingName
struct FeatureName 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 { enum {
Exclusive = 0x8000, /* If set, the feature settings are mutually exclusive. */ Exclusive = 0x8000, /* If set, the feature settings are mutually exclusive. */
NotDefault = 0x4000, /* If clear, then the setting with an index of 0 in NotDefault = 0x4000, /* If clear, then the setting with an index of 0 in
@ -75,6 +68,13 @@ struct FeatureName
* as the default. */ * 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: protected:
HBUINT16 feature; /* Feature type. */ HBUINT16 feature; /* Feature type. */
HBUINT16 nSettings; /* The number of records in the setting name array. */ HBUINT16 nSettings; /* The number of records in the setting name array. */

View File

@ -171,15 +171,6 @@ struct trak
inline bool has_data (void) const { return version.to_int () != 0; } 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 inline bool apply (hb_aat_apply_context_t *c) const
{ {
TRACE_APPLY (this); TRACE_APPLY (this);
@ -221,15 +212,27 @@ struct trak
return_trace (true); 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: protected:
FixedVersion<> version; /* Version of the tracking table FixedVersion<>version; /* Version of the tracking table
* (0x00010000u for version 1.0). */ * (0x00010000u for version 1.0). */
HBUINT16 format; /* Format of the tracking table (set to 0). */ HBUINT16 format; /* Format of the tracking table (set to 0). */
OffsetTo<TrackData> horizData; /* Offset from start of tracking table to TrackData OffsetTo<TrackData>
* for horizontal text (or 0 if none). */ horizData; /* Offset from start of tracking table to TrackData
OffsetTo<TrackData> vertData; /* Offset from start of tracking table to TrackData * for horizontal text (or 0 if none). */
* for vertical text (or 0 if none). */ OffsetTo<TrackData>
HBUINT16 reserved; /* Reserved. Set to 0. */ vertData; /* Offset from start of tracking table to TrackData
* for vertical text (or 0 if none). */
HBUINT16 reserved; /* Reserved. Set to 0. */
public: public:
DEFINE_SIZE_STATIC (12); DEFINE_SIZE_STATIC (12);

View File

@ -103,7 +103,12 @@ struct COLR
unsigned int *count, /* IN/OUT. May be NULL. */ unsigned int *count, /* IN/OUT. May be NULL. */
hb_ot_color_layer_t *layers /* OUT. May be NULL. */) const 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<const LayerRecord> all_layers ((this+layersZ).arrayZ, numLayers); hb_array_t<const LayerRecord> all_layers ((this+layersZ).arrayZ, numLayers);
hb_array_t<const LayerRecord> glyph_layers = all_layers.sub_array (record.firstLayerIdx, hb_array_t<const LayerRecord> glyph_layers = all_layers.sub_array (record.firstLayerIdx,
@ -129,17 +134,6 @@ struct COLR
(this+layersZ).sanitize (c, numLayers))); (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: protected:
HBUINT16 version; /* Table version number (starts at 0). */ HBUINT16 version; /* Table version number (starts at 0). */
HBUINT16 numBaseGlyphs; /* Number of Base Glyph Records. */ HBUINT16 numBaseGlyphs; /* Number of Base Glyph Records. */