[fvar] Use hb_array_t for axes

This commit is contained in:
Behdad Esfahbod 2018-11-19 13:04:43 -05:00
parent e009739601
commit 4a6a692e3e
2 changed files with 10 additions and 10 deletions

View File

@ -573,6 +573,10 @@ struct hb_array_t
inline unsigned int get_size (void) const { return len * sizeof (Type); } inline unsigned int get_size (void) const { return len * sizeof (Type); }
template <typename hb_sanitize_context_t>
inline bool sanitize (hb_sanitize_context_t *c) const
{ return c->check_array (arrayZ, len); }
template <typename T> inline operator T * (void) const { return arrayZ; } template <typename T> inline operator T * (void) const { return arrayZ; }
inline Type * operator & (void) const { return arrayZ; } inline Type * operator & (void) const { return arrayZ; }
@ -598,6 +602,8 @@ struct hb_array_t
Type *arrayZ; Type *arrayZ;
unsigned int len; unsigned int len;
}; };
template <typename T>
hb_array_t<T> hb_array (T *array, unsigned int len) { return hb_array_t<T> (array, len); }
struct HbOpOr struct HbOpOr

View File

@ -114,9 +114,6 @@ struct fvar
inline bool get_axis (unsigned int index, hb_ot_var_axis_t *info) const inline bool get_axis (unsigned int index, hb_ot_var_axis_t *info) const
{ {
if (unlikely (index >= axisCount))
return false;
if (info) if (info)
{ {
const AxisRecord &axis = get_axes ()[index]; const AxisRecord &axis = get_axes ()[index];
@ -133,9 +130,6 @@ struct fvar
inline hb_ot_var_axis_flags_t get_axis_flags (unsigned int index) const inline hb_ot_var_axis_flags_t get_axis_flags (unsigned int index) const
{ {
if (unlikely (index >= axisCount))
return (hb_ot_var_axis_flags_t) 0;
const AxisRecord &axis = get_axes ()[index]; const AxisRecord &axis = get_axes ()[index];
return (hb_ot_var_axis_flags_t) (unsigned int) axis.flags; return (hb_ot_var_axis_flags_t) (unsigned int) axis.flags;
} }
@ -195,11 +189,11 @@ struct fvar
} }
protected: protected:
inline const AxisRecord * get_axes (void) const inline hb_array_t<const AxisRecord> get_axes (void) const
{ return &(this+firstAxis); } { return hb_array (&(this+firstAxis), axisCount); }
inline const InstanceRecord * get_instances (void) const inline const InstanceRecord * get_first_instance (void) const
{ return &StructAtOffset<InstanceRecord> (get_axes () + axisCount, 0); } { return &StructAfter<InstanceRecord> (get_axes ()); }
protected: protected:
FixedVersion<>version; /* Version of the fvar table FixedVersion<>version; /* Version of the fvar table