#include "hb-set-private.hh"
-#ifndef HB_MAX_NESTING_LEVEL
-#define HB_MAX_NESTING_LEVEL 6
-#endif
-#ifndef HB_MAX_CONTEXT_LENGTH
-#define HB_MAX_CONTEXT_LENGTH 64
-#endif
-
-
namespace OT {
#define NOT_COVERED ((unsigned int) -1)
+#define MAX_NESTING_LEVEL 8
+#define MAX_CONTEXT_LENGTH 64
{
TRACE_SANITIZE (this);
const sanitize_closure_t closure = {tag, base};
- return_trace (c->check_struct (this) && offset.sanitize (c, base, &closure));
+ return TRACE_RETURN (c->check_struct (this) && offset.sanitize (c, base, &closure));
}
Tag tag; /* 4-byte Tag identifier */
inline bool sanitize (hb_sanitize_context_t *c) const
{
TRACE_SANITIZE (this);
- return_trace (RecordArrayOf<Type>::sanitize (c, this));
+ return TRACE_RETURN (RecordArrayOf<Type>::sanitize (c, this));
}
};
inline bool sanitize (hb_sanitize_context_t *c) const
{
TRACE_SANITIZE (this);
- return_trace (c->check_struct (this));
+ return TRACE_RETURN (c->check_struct (this));
}
inline bool intersects (const hb_set_t *glyphs) const {
const Record<LangSys>::sanitize_closure_t * = NULL) const
{
TRACE_SANITIZE (this);
- return_trace (c->check_struct (this) && featureIndex.sanitize (c));
+ return TRACE_RETURN (c->check_struct (this) && featureIndex.sanitize (c));
}
Offset<> lookupOrderZ; /* = Null (reserved for an offset to a
const Record<Script>::sanitize_closure_t * = NULL) const
{
TRACE_SANITIZE (this);
- return_trace (defaultLangSys.sanitize (c, this) && langSys.sanitize (c, this));
+ return TRACE_RETURN (defaultLangSys.sanitize (c, this) && langSys.sanitize (c, this));
}
protected:
inline bool sanitize (hb_sanitize_context_t *c) const
{
TRACE_SANITIZE (this);
- if (unlikely (!c->check_struct (this))) return_trace (false);
+ if (unlikely (!c->check_struct (this))) return TRACE_RETURN (false);
/* This subtable has some "history", if you will. Some earlier versions of
* Adobe tools calculated the offset of the FeatureParams sutable from the
*/
if (!designSize)
- return_trace (false);
+ return TRACE_RETURN (false);
else if (subfamilyID == 0 &&
subfamilyNameID == 0 &&
rangeStart == 0 &&
rangeEnd == 0)
- return_trace (true);
+ return TRACE_RETURN (true);
else if (designSize < rangeStart ||
designSize > rangeEnd ||
subfamilyNameID < 256 ||
subfamilyNameID > 32767)
- return_trace (false);
+ return TRACE_RETURN (false);
else
- return_trace (true);
+ return TRACE_RETURN (true);
}
USHORT designSize; /* Represents the design size in 720/inch
TRACE_SANITIZE (this);
/* Right now minorVersion is at zero. Which means, any table supports
* the uiNameID field. */
- return_trace (c->check_struct (this));
+ return TRACE_RETURN (c->check_struct (this));
}
USHORT version; /* (set to 0): This corresponds to a “minor”
inline bool sanitize (hb_sanitize_context_t *c) const
{
TRACE_SANITIZE (this);
- return_trace (c->check_struct (this) &&
- characters.sanitize (c));
+ return TRACE_RETURN (c->check_struct (this) &&
+ characters.sanitize (c));
}
USHORT format; /* Format number is set to 0. */
{
TRACE_SANITIZE (this);
if (tag == HB_TAG ('s','i','z','e'))
- return_trace (u.size.sanitize (c));
+ return TRACE_RETURN (u.size.sanitize (c));
if ((tag & 0xFFFF0000u) == HB_TAG ('s','s','\0','\0')) /* ssXX */
- return_trace (u.stylisticSet.sanitize (c));
+ return TRACE_RETURN (u.stylisticSet.sanitize (c));
if ((tag & 0xFFFF0000u) == HB_TAG ('c','v','\0','\0')) /* cvXX */
- return_trace (u.characterVariants.sanitize (c));
- return_trace (true);
+ return TRACE_RETURN (u.characterVariants.sanitize (c));
+ return TRACE_RETURN (true);
}
inline const FeatureParamsSize& get_size_params (hb_tag_t tag) const
{
TRACE_SANITIZE (this);
if (unlikely (!(c->check_struct (this) && lookupIndex.sanitize (c))))
- return_trace (false);
+ return TRACE_RETURN (false);
/* Some earlier versions of Adobe tools calculated the offset of the
* FeatureParams subtable from the beginning of the FeatureList table!
OffsetTo<FeatureParams> orig_offset = featureParams;
if (unlikely (!featureParams.sanitize (c, this, closure ? closure->tag : HB_TAG_NONE)))
- return_trace (false);
+ return TRACE_RETURN (false);
if (likely (orig_offset.is_null ()))
- return_trace (true);
+ return TRACE_RETURN (true);
if (featureParams == 0 && closure &&
closure->tag == HB_TAG ('s','i','z','e') &&
if (new_offset == new_offset_int &&
c->try_set (&featureParams, new_offset) &&
!featureParams.sanitize (c, this, closure ? closure->tag : HB_TAG_NONE))
- return_trace (false);
-
- if (c->edit_count > 1)
- c->edit_count--; /* This was a "legitimate" edit; don't contribute to error count. */
+ return TRACE_RETURN (false);
}
- return_trace (true);
+ return TRACE_RETURN (true);
}
OffsetTo<FeatureParams>
DEFINE_SIZE_STATIC (2);
};
-} /* namespace OT */
-/* This has to be outside the namespace. */
-HB_MARK_AS_FLAG_T (OT::LookupFlag::Flags);
-namespace OT {
-
struct Lookup
{
inline unsigned int get_subtable_count (void) const { return subTable.len; }
for (unsigned int i = 0; i < count; i++) {
typename context_t::return_t r = get_subtable<SubTableType> (i).dispatch (c, lookup_type);
if (c->stop_sublookup_iteration (r))
- return_trace (r);
+ return TRACE_RETURN (r);
}
- return_trace (c->default_return_value ());
+ return TRACE_RETURN (c->default_return_value ());
}
inline bool serialize (hb_serialize_context_t *c,
unsigned int num_subtables)
{
TRACE_SERIALIZE (this);
- if (unlikely (!c->extend_min (*this))) return_trace (false);
+ if (unlikely (!c->extend_min (*this))) return TRACE_RETURN (false);
lookupType.set (lookup_type);
lookupFlag.set (lookup_props & 0xFFFFu);
- if (unlikely (!subTable.serialize (c, num_subtables))) return_trace (false);
+ if (unlikely (!subTable.serialize (c, num_subtables))) return TRACE_RETURN (false);
if (lookupFlag & LookupFlag::UseMarkFilteringSet)
{
USHORT &markFilteringSet = StructAfter<USHORT> (subTable);
markFilteringSet.set (lookup_props >> 16);
}
- return_trace (true);
+ return TRACE_RETURN (true);
}
inline bool sanitize (hb_sanitize_context_t *c) const
{
TRACE_SANITIZE (this);
/* Real sanitize of the subtables is done by GSUB/GPOS/... */
- if (!(c->check_struct (this) && subTable.sanitize (c))) return_trace (false);
+ if (!(c->check_struct (this) && subTable.sanitize (c))) return TRACE_RETURN (false);
if (lookupFlag & LookupFlag::UseMarkFilteringSet)
{
const USHORT &markFilteringSet = StructAfter<USHORT> (subTable);
- if (!markFilteringSet.sanitize (c)) return_trace (false);
+ if (!markFilteringSet.sanitize (c)) return TRACE_RETURN (false);
}
- return_trace (true);
+ return TRACE_RETURN (true);
}
private:
unsigned int num_glyphs)
{
TRACE_SERIALIZE (this);
- if (unlikely (!c->extend_min (*this))) return_trace (false);
+ if (unlikely (!c->extend_min (*this))) return TRACE_RETURN (false);
glyphArray.len.set (num_glyphs);
- if (unlikely (!c->extend (glyphArray))) return_trace (false);
+ if (unlikely (!c->extend (glyphArray))) return TRACE_RETURN (false);
for (unsigned int i = 0; i < num_glyphs; i++)
glyphArray[i] = glyphs[i];
glyphs.advance (num_glyphs);
- return_trace (true);
+ return TRACE_RETURN (true);
}
inline bool sanitize (hb_sanitize_context_t *c) const
{
TRACE_SANITIZE (this);
- return_trace (glyphArray.sanitize (c));
+ return TRACE_RETURN (glyphArray.sanitize (c));
}
inline bool intersects_coverage (const hb_set_t *glyphs, unsigned int index) const {
unsigned int num_glyphs)
{
TRACE_SERIALIZE (this);
- if (unlikely (!c->extend_min (*this))) return_trace (false);
+ if (unlikely (!c->extend_min (*this))) return TRACE_RETURN (false);
- if (unlikely (!num_glyphs))
- {
- rangeRecord.len.set (0);
- return_trace (true);
- }
+ if (unlikely (!num_glyphs)) return TRACE_RETURN (true);
unsigned int num_ranges = 1;
for (unsigned int i = 1; i < num_glyphs; i++)
if (glyphs[i - 1] + 1 != glyphs[i])
num_ranges++;
rangeRecord.len.set (num_ranges);
- if (unlikely (!c->extend (rangeRecord))) return_trace (false);
+ if (unlikely (!c->extend (rangeRecord))) return TRACE_RETURN (false);
unsigned int range = 0;
rangeRecord[range].start = glyphs[0];
rangeRecord[range].end = glyphs[i];
}
glyphs.advance (num_glyphs);
- return_trace (true);
+ return TRACE_RETURN (true);
}
inline bool sanitize (hb_sanitize_context_t *c) const
{
TRACE_SANITIZE (this);
- return_trace (rangeRecord.sanitize (c));
+ return TRACE_RETURN (rangeRecord.sanitize (c));
}
inline bool intersects_coverage (const hb_set_t *glyphs, unsigned int index) const {
unsigned int num_glyphs)
{
TRACE_SERIALIZE (this);
- if (unlikely (!c->extend_min (*this))) return_trace (false);
+ if (unlikely (!c->extend_min (*this))) return TRACE_RETURN (false);
unsigned int num_ranges = 1;
for (unsigned int i = 1; i < num_glyphs; i++)
if (glyphs[i - 1] + 1 != glyphs[i])
num_ranges++;
u.format.set (num_glyphs * 2 < num_ranges * 3 ? 1 : 2);
switch (u.format) {
- case 1: return_trace (u.format1.serialize (c, glyphs, num_glyphs));
- case 2: return_trace (u.format2.serialize (c, glyphs, num_glyphs));
- default:return_trace (false);
+ case 1: return TRACE_RETURN (u.format1.serialize (c, glyphs, num_glyphs));
+ case 2: return TRACE_RETURN (u.format2.serialize (c, glyphs, num_glyphs));
+ default:return TRACE_RETURN (false);
}
}
inline bool sanitize (hb_sanitize_context_t *c) const
{
TRACE_SANITIZE (this);
- if (!u.format.sanitize (c)) return_trace (false);
+ if (!u.format.sanitize (c)) return TRACE_RETURN (false);
switch (u.format) {
- case 1: return_trace (u.format1.sanitize (c));
- case 2: return_trace (u.format2.sanitize (c));
- default:return_trace (true);
+ case 1: return TRACE_RETURN (u.format1.sanitize (c));
+ case 2: return TRACE_RETURN (u.format2.sanitize (c));
+ default:return TRACE_RETURN (true);
}
}
inline bool sanitize (hb_sanitize_context_t *c) const
{
TRACE_SANITIZE (this);
- return_trace (c->check_struct (this) && classValue.sanitize (c));
+ return TRACE_RETURN (c->check_struct (this) && classValue.sanitize (c));
}
template <typename set_t>
inline bool sanitize (hb_sanitize_context_t *c) const
{
TRACE_SANITIZE (this);
- return_trace (rangeRecord.sanitize (c));
+ return TRACE_RETURN (rangeRecord.sanitize (c));
}
template <typename set_t>
inline bool sanitize (hb_sanitize_context_t *c) const
{
TRACE_SANITIZE (this);
- if (!u.format.sanitize (c)) return_trace (false);
+ if (!u.format.sanitize (c)) return TRACE_RETURN (false);
switch (u.format) {
- case 1: return_trace (u.format1.sanitize (c));
- case 2: return_trace (u.format2.sanitize (c));
- default:return_trace (true);
+ case 1: return TRACE_RETURN (u.format1.sanitize (c));
+ case 2: return TRACE_RETURN (u.format2.sanitize (c));
+ default:return TRACE_RETURN (true);
}
}
inline hb_position_t get_y_delta (hb_font_t *font) const
{ return get_delta (font->y_ppem, font->y_scale); }
- inline unsigned int get_size (void) const
- {
- unsigned int f = deltaFormat;
- if (unlikely (f < 1 || f > 3 || startSize > endSize)) return 3 * USHORT::static_size;
- return USHORT::static_size * (4 + ((endSize - startSize) >> (4 - f)));
- }
-
- inline bool sanitize (hb_sanitize_context_t *c) const
- {
- TRACE_SANITIZE (this);
- return_trace (c->check_struct (this) && c->check_range (this, this->get_size ()));
- }
-
- private:
-
inline int get_delta (unsigned int ppem, int scale) const
{
if (!ppem) return 0;
return (int) (pixels * (int64_t) scale / ppem);
}
+
+
inline int get_delta_pixels (unsigned int ppem_size) const
{
unsigned int f = deltaFormat;
return delta;
}
+ inline unsigned int get_size (void) const
+ {
+ unsigned int f = deltaFormat;
+ if (unlikely (f < 1 || f > 3 || startSize > endSize)) return 3 * USHORT::static_size;
+ return USHORT::static_size * (4 + ((endSize - startSize) >> (4 - f)));
+ }
+
+ inline bool sanitize (hb_sanitize_context_t *c) const
+ {
+ TRACE_SANITIZE (this);
+ return TRACE_RETURN (c->check_struct (this) && c->check_range (this, this->get_size ()));
+ }
+
protected:
USHORT startSize; /* Smallest size to correct--in ppem */
USHORT endSize; /* Largest size to correct--in ppem */