};
ASSERT_SIZE (LookupFlag, 2);
-struct LookupSubTable
-{
- inline bool sanitize (SANITIZE_ARG_DEF) {
- TRACE_SANITIZE ();
- return SANITIZE_SELF ();
- }
-
- private:
- USHORT format; /* Subtable format. Different for GSUB and GPOS */
-};
-ASSERT_SIZE (LookupSubTable, 2);
-
struct Lookup
{
- inline const LookupSubTable& get_subtable (unsigned int i) const { return this+subTable[i]; }
inline unsigned int get_subtable_count (void) const { return subTable.len; }
inline unsigned int get_type (void) const { return lookupType; }
inline bool sanitize (SANITIZE_ARG_DEF) {
TRACE_SANITIZE ();
- /* We sanitize subtables shallow here since we don't have their actual
- * type. Real sanitize of the referenced data is done by GSUB/GPOS/... */
- if (!(SANITIZE_SELF () && HB_LIKELY (subTable.sanitize_shallow (SANITIZE_ARG)))) return false;
+ /* Real sanitize of the subtables is done by GSUB/GPOS/... */
+ if (!(SANITIZE_SELF () && HB_LIKELY (subTable.sanitize (SANITIZE_ARG)))) return false;
if (HB_UNLIKELY (lookupFlag & LookupFlag::UseMarkFilteringSet))
{
USHORT &markFilteringSet = StructAfter<USHORT> (subTable);
USHORT lookupType; /* Different enumerations for GSUB and GPOS */
USHORT lookupFlag; /* Lookup qualifiers */
- OffsetArrayOf<LookupSubTable>
+ ArrayOf<Offset>
subTable; /* Array of SubTables */
USHORT markFilteringSetX[VAR]; /* Index (base 0) into GDEF mark glyph sets
* structure. This field is only present if bit
private:
inline const struct PosLookupSubTable& get_subtable (void) const
- { return CONST_CAST (PosLookupSubTable, Extension::get_subtable (), 0); }
+ {
+ unsigned int offset = get_offset ();
+ if (HB_UNLIKELY (!offset)) return Null(PosLookupSubTable);
+ return CONST_CAST (PosLookupSubTable, *this, offset);
+ }
inline bool apply (APPLY_ARG_DEF) const;
inline bool sanitize (SANITIZE_ARG_DEF) {
TRACE_SANITIZE ();
- if (!Lookup::sanitize (SANITIZE_ARG)) return false;
+ if (HB_UNLIKELY (!Lookup::sanitize (SANITIZE_ARG))) return false;
OffsetArrayOf<PosLookupSubTable> &list = CAST (OffsetArrayOf<PosLookupSubTable>, subTable, 0);
return SANITIZE_THIS (list);
}
inline bool sanitize (SANITIZE_ARG_DEF) {
TRACE_SANITIZE ();
- if (!GSUBGPOS::sanitize (SANITIZE_ARG)) return false;
+ if (HB_UNLIKELY (!GSUBGPOS::sanitize (SANITIZE_ARG))) return false;
OffsetTo<PosLookupList> &list = CAST(OffsetTo<PosLookupList>, lookupList, 0);
return SANITIZE_THIS (list);
}
inline bool ExtensionPos::sanitize (SANITIZE_ARG_DEF)
{
TRACE_SANITIZE ();
- return Extension::sanitize (SANITIZE_ARG) &&
- (&(Extension::get_subtable ()) == &Null(LookupSubTable) ||
- get_type () == PosLookupSubTable::Extension ||
- DECONST_CAST (PosLookupSubTable, get_subtable (), 0).sanitize (SANITIZE_ARG));
+ if (HB_UNLIKELY (!Extension::sanitize (SANITIZE_ARG))) return false;
+ if (HB_UNLIKELY (get_type () == PosLookupSubTable::Extension)) return false;
+
+ unsigned int offset = get_offset ();
+ if (HB_UNLIKELY (!offset)) return true;
+ return SANITIZE (CAST (PosLookupSubTable, *this, offset));
}
static inline bool position_lookup (APPLY_ARG_DEF, unsigned int lookup_index)
private:
inline const struct SubstLookupSubTable& get_subtable (void) const
- { return CONST_CAST (SubstLookupSubTable, Extension::get_subtable (), 0); }
+ {
+ unsigned int offset = get_offset ();
+ if (HB_UNLIKELY (!offset)) return Null(SubstLookupSubTable);
+ return CONST_CAST (SubstLookupSubTable, *this, offset);
+ }
inline bool apply (APPLY_ARG_DEF) const;
inline bool sanitize (SANITIZE_ARG_DEF) {
TRACE_SANITIZE ();
- if (!Lookup::sanitize (SANITIZE_ARG)) return false;
+ if (HB_UNLIKELY (!Lookup::sanitize (SANITIZE_ARG))) return false;
OffsetArrayOf<SubstLookupSubTable> &list = CAST (OffsetArrayOf<SubstLookupSubTable>, subTable, 0);
return SANITIZE_THIS (list);
}
inline bool sanitize (SANITIZE_ARG_DEF) {
TRACE_SANITIZE ();
- if (!GSUBGPOS::sanitize (SANITIZE_ARG)) return false;
+ if (HB_UNLIKELY (!GSUBGPOS::sanitize (SANITIZE_ARG))) return false;
OffsetTo<SubstLookupList> &list = CAST(OffsetTo<SubstLookupList>, lookupList, 0);
return SANITIZE_THIS (list);
}
inline bool ExtensionSubst::sanitize (SANITIZE_ARG_DEF)
{
TRACE_SANITIZE ();
- return Extension::sanitize (SANITIZE_ARG) &&
- (&(Extension::get_subtable ()) == &Null(LookupSubTable) ||
- get_type () == SubstLookupSubTable::Extension ||
- DECONST_CAST (SubstLookupSubTable, get_subtable (), 0).sanitize (SANITIZE_ARG));
+ if (HB_UNLIKELY (!Extension::sanitize (SANITIZE_ARG))) return false;
+ if (HB_UNLIKELY (get_type () == SubstLookupSubTable::Extension)) return false;
+
+ unsigned int offset = get_offset ();
+ if (HB_UNLIKELY (!offset)) return true;
+ return SANITIZE (CAST (SubstLookupSubTable, *this, offset));
}
static inline bool substitute_lookup (APPLY_ARG_DEF, unsigned int lookup_index)
protected:
inline unsigned int get_type (void) const { return extensionLookupType; }
- inline const LookupSubTable& get_subtable (void) const
- {
- unsigned int offset = extensionOffset;
- if (HB_UNLIKELY (!offset)) return Null(LookupSubTable);
- return CONST_CAST (LookupSubTable, *this, offset);
- }
+ inline unsigned int get_offset (void) const { return extensionOffset; }
inline bool sanitize (SANITIZE_ARG_DEF) {
TRACE_SANITIZE ();
default:return 0;
}
}
- inline const LookupSubTable& get_subtable (void) const
+ inline unsigned int get_offset (void) const
{
switch (u.format) {
- case 1: return u.format1->get_subtable ();
- default:return Null(LookupSubTable);
+ case 1: return u.format1->get_offset ();
+ default:return 0;
}
}