};
-struct ExtensionPos : Extension
+struct ExtensionPos : Extension<struct GPOS>
{
friend struct PosLookupSubTable;
struct PosLookup : Lookup
{
- inline const PosLookupSubTable& get_subtable (unsigned int i) const
- { return this+CastR<OffsetArrayOf<PosLookupSubTable> > (subTable)[i]; }
+ typedef struct PosLookupSubTable SubTable;
+
+ inline const SubTable& get_subtable (unsigned int i) const
+ { return this+CastR<OffsetArrayOf<SubTable> > (subTable)[i]; }
inline bool apply_once (hb_apply_context_t *c) const
{
inline bool sanitize (hb_sanitize_context_t *c) {
TRACE_SANITIZE ();
if (unlikely (!Lookup::sanitize (c))) return TRACE_RETURN (false);
- OffsetArrayOf<PosLookupSubTable> &list = CastR<OffsetArrayOf<PosLookupSubTable> > (subTable);
+ OffsetArrayOf<SubTable> &list = CastR<OffsetArrayOf<SubTable> > (subTable);
return TRACE_RETURN (list.sanitize (c, this, get_type ()));
}
};
struct GPOS : GSUBGPOS
{
+ typedef struct PosLookup Lookup;
+
static const hb_tag_t Tag = HB_OT_TAG_GPOS;
inline const PosLookup& get_lookup (unsigned int i) const
inline bool ExtensionPos::sanitize (hb_sanitize_context_t *c)
{
TRACE_SANITIZE ();
- if (unlikely (!Extension::sanitize (c))) return TRACE_RETURN (false);
+ if (unlikely (!Extension<GPOS>::sanitize (c))) return TRACE_RETURN (false);
unsigned int offset = get_offset ();
if (unlikely (!offset)) return TRACE_RETURN (true);
- return TRACE_RETURN (StructAtOffset<PosLookupSubTable> (this, offset).sanitize (c, get_type ()));
+ return TRACE_RETURN (StructAtOffset<PosLookup::SubTable> (this, offset).sanitize (c, get_type ()));
}
static inline bool position_lookup (hb_apply_context_t *c, unsigned int lookup_index)
};
-struct ExtensionSubst : Extension
+struct ExtensionSubst : Extension<struct GSUB>
{
friend struct SubstLookupSubTable;
friend struct SubstLookup;
struct SubstLookup : Lookup
{
- inline const SubstLookupSubTable& get_subtable (unsigned int i) const
- { return this+CastR<OffsetArrayOf<SubstLookupSubTable> > (subTable)[i]; }
+ typedef struct SubstLookupSubTable SubTable;
+
+ inline const SubTable& get_subtable (unsigned int i) const
+ { return this+CastR<OffsetArrayOf<SubTable> > (subTable)[i]; }
inline static bool lookup_type_is_reverse (unsigned int lookup_type)
- { return lookup_type == SubstLookupSubTable::ReverseChainSingle; }
+ { return lookup_type == SubTable::ReverseChainSingle; }
inline bool is_reverse (void) const
{
unsigned int type = get_type ();
- if (unlikely (type == SubstLookupSubTable::Extension))
+ if (unlikely (type == SubTable::Extension))
return CastR<ExtensionSubst> (get_subtable(0)).is_reverse ();
return lookup_type_is_reverse (type);
}
/* TODO: For the most common case this can move out of the main
* loop, but it's not a big deal for now. */
- if (unlikely (lookup_type == SubstLookupSubTable::Extension))
+ if (unlikely (lookup_type == SubTable::Extension))
{
/* The spec says all subtables should have the same type.
* This is specially important if one has a reverse type!
inline bool sanitize (hb_sanitize_context_t *c) {
TRACE_SANITIZE ();
if (unlikely (!Lookup::sanitize (c))) return TRACE_RETURN (false);
- OffsetArrayOf<SubstLookupSubTable> &list = CastR<OffsetArrayOf<SubstLookupSubTable> > (subTable);
+ OffsetArrayOf<SubTable> &list = CastR<OffsetArrayOf<SubTable> > (subTable);
return TRACE_RETURN (list.sanitize (c, this, get_type ()));
}
};
struct GSUB : GSUBGPOS
{
+ typedef struct SubstLookup Lookup;
+
static const hb_tag_t Tag = HB_OT_TAG_GSUB;
inline const SubstLookup& get_lookup (unsigned int i) const
inline bool ExtensionSubst::sanitize (hb_sanitize_context_t *c)
{
TRACE_SANITIZE ();
- if (unlikely (!Extension::sanitize (c))) return TRACE_RETURN (false);
+ if (unlikely (!Extension<GSUB>::sanitize (c))) return TRACE_RETURN (false);
unsigned int offset = get_offset ();
if (unlikely (!offset)) return TRACE_RETURN (true);
- return TRACE_RETURN (StructAtOffset<SubstLookupSubTable> (this, offset).sanitize (c, get_type ()));
+ return TRACE_RETURN (StructAtOffset<GSUB::Lookup::SubTable> (this, offset).sanitize (c, get_type ()));
}
inline bool ExtensionSubst::is_reverse (void) const
{
unsigned int type = get_type ();
- if (unlikely (type == SubstLookupSubTable::Extension))
+ if (unlikely (type == SubstLookup::SubTable::Extension))
return CastR<ExtensionSubst> (get_subtable()).is_reverse ();
return SubstLookup::lookup_type_is_reverse (type);
}
}
+struct match_glyph_t {
+ inline bool operator() (hb_codepoint_t glyph_id, const USHORT &value, const void *data)
+ {
+ return glyph_id == value;
+ }
+};
+struct match_class_t {
+ inline bool operator() (hb_codepoint_t glyph_id, const USHORT &value, const void *data)
+ {
+ const ClassDef &class_def = *reinterpret_cast<const ClassDef *>(data);
+ return class_def.get_class (glyph_id) == value;
+ }
+};
+struct match_coverage_t {
+ inline bool operator() (hb_codepoint_t glyph_id, const USHORT &value, const void *data)
+ {
+ const OffsetTo<Coverage> &coverage = (const OffsetTo<Coverage>&)value;
+ return (data+coverage).get_coverage (glyph_id) != NOT_COVERED;
+ }
+};
+
static inline bool match_glyph (hb_codepoint_t glyph_id, const USHORT &value, const void *data HB_UNUSED)
{
return glyph_id == value;
}
+template <typename match_func_t>
static inline bool match_input (hb_apply_context_t *c,
unsigned int count, /* Including the first glyph (not matched) */
const USHORT input[], /* Array of input values--start with second glyph */
return true;
}
+template <typename match_func_t>
static inline bool match_backtrack (hb_apply_context_t *c,
unsigned int count,
const USHORT backtrack[],
return true;
}
+template <typename match_func_t>
static inline bool match_lookahead (hb_apply_context_t *c,
unsigned int count,
const USHORT lookahead[],
};
+template <typename Table> struct Extension;
+
+template <typename Table>
struct ExtensionFormat1
{
- friend struct Extension;
+ friend struct Extension<Table>;
protected:
inline unsigned int get_type (void) const { return extensionLookupType; }
DEFINE_SIZE_STATIC (8);
};
+template <typename Table>
struct Extension
{
inline unsigned int get_type (void) const
private:
union {
USHORT format; /* Format identifier */
- ExtensionFormat1 format1;
+ ExtensionFormat1<Table>
+ format1;
} u;
};