}
}
- inline bool apply (hb_apply_context_t *c) const
- {
- TRACE_APPLY ();
- switch (u.format) {
- case 1: return TRACE_RETURN (u.format1.apply (c));
- case 2: return TRACE_RETURN (u.format2.apply (c));
- default:return TRACE_RETURN (false);
- }
- }
-
inline bool sanitize (hb_sanitize_context_t *c) {
TRACE_SANITIZE ();
if (!u.format.sanitize (c)) return TRACE_RETURN (false);
}
}
- inline bool apply (hb_apply_context_t *c) const
- {
- TRACE_APPLY ();
- switch (u.format) {
- case 1: return TRACE_RETURN (u.format1.apply (c));
- case 2: return TRACE_RETURN (u.format2.apply (c));
- default:return TRACE_RETURN (false);
- }
- }
-
inline bool sanitize (hb_sanitize_context_t *c) {
TRACE_SANITIZE ();
if (!u.format.sanitize (c)) return TRACE_RETURN (false);
}
}
- inline bool apply (hb_apply_context_t *c) const
- {
- TRACE_APPLY ();
- switch (u.format) {
- case 1: return TRACE_RETURN (u.format1.apply (c));
- default:return TRACE_RETURN (false);
- }
- }
-
inline bool sanitize (hb_sanitize_context_t *c) {
TRACE_SANITIZE ();
if (!u.format.sanitize (c)) return TRACE_RETURN (false);
}
}
- inline bool apply (hb_apply_context_t *c) const
- {
- TRACE_APPLY ();
- switch (u.format) {
- case 1: return TRACE_RETURN (u.format1.apply (c));
- default:return TRACE_RETURN (false);
- }
- }
-
inline bool sanitize (hb_sanitize_context_t *c) {
TRACE_SANITIZE ();
if (!u.format.sanitize (c)) return TRACE_RETURN (false);
}
}
- inline bool apply (hb_apply_context_t *c) const
- {
- TRACE_APPLY ();
- switch (u.format) {
- case 1: return TRACE_RETURN (u.format1.apply (c));
- default:return TRACE_RETURN (false);
- }
- }
-
inline bool sanitize (hb_sanitize_context_t *c) {
TRACE_SANITIZE ();
if (!u.format.sanitize (c)) return TRACE_RETURN (false);
}
}
- inline bool apply (hb_apply_context_t *c) const
- {
- TRACE_APPLY ();
- switch (u.format) {
- case 1: return TRACE_RETURN (u.format1.apply (c));
- default:return TRACE_RETURN (false);
- }
- }
-
inline bool sanitize (hb_sanitize_context_t *c) {
TRACE_SANITIZE ();
if (!u.format.sanitize (c)) return TRACE_RETURN (false);
};
-static inline bool position_lookup (hb_apply_context_t *c, unsigned int lookup_index);
-
struct ContextPos : Context
{
- inline bool apply (hb_apply_context_t *c) const
+ template <typename context_t>
+ inline typename context_t::return_t process (context_t *c) const
{
- TRACE_APPLY ();
- return TRACE_RETURN (Context::apply (c, position_lookup));
+ return Context::process (c);
}
};
struct ChainContextPos : ChainContext
{
- inline bool apply (hb_apply_context_t *c) const
+ template <typename context_t>
+ inline typename context_t::return_t process (context_t *c) const
{
- TRACE_APPLY ();
- return TRACE_RETURN (ChainContext::apply (c, position_lookup));
+ return ChainContext::process (c);
}
};
template <typename context_t>
inline typename context_t::return_t process (context_t *c) const;
- inline bool apply (hb_apply_context_t *c) const;
-
inline bool sanitize (hb_sanitize_context_t *c);
};
}
}
- inline bool apply (hb_apply_context_t *c, unsigned int lookup_type) const
- {
- TRACE_APPLY ();
- switch (lookup_type) {
- case Single: return TRACE_RETURN (u.single.apply (c));
- case Pair: return TRACE_RETURN (u.pair.apply (c));
- case Cursive: return TRACE_RETURN (u.cursive.apply (c));
- case MarkBase: return TRACE_RETURN (u.markBase.apply (c));
- case MarkLig: return TRACE_RETURN (u.markLig.apply (c));
- case MarkMark: return TRACE_RETURN (u.markMark.apply (c));
- case Context: return TRACE_RETURN (u.context.apply (c));
- case ChainContext: return TRACE_RETURN (u.chainContext.apply (c));
- case Extension: return TRACE_RETURN (u.extension.apply (c));
- default: return TRACE_RETURN (false);
- }
- }
-
inline bool sanitize (hb_sanitize_context_t *c, unsigned int lookup_type) {
TRACE_SANITIZE ();
if (!u.header.sub_format.sanitize (c))
if (!c->check_glyph_property (&c->buffer->cur(), c->lookup_props, &c->property))
return false;
- unsigned int count = get_subtable_count ();
- for (unsigned int i = 0; i < count; i++)
- if (get_subtable (i).apply (c, lookup_type))
- return true;
-
- return false;
+ return process (c);
}
+ static bool apply_recurse_func (hb_apply_context_t *c, unsigned int lookup_index);
+
inline bool apply_string (hb_apply_context_t *c, const hb_set_digest_t *digest) const
{
bool ret = false;
if (unlikely (!c->buffer->len || !c->lookup_mask))
return false;
+ c->set_recurse_func (apply_recurse_func);
c->set_lookup (*this);
c->buffer->idx = 0;
return get_subtable ().process (c, get_type ());
}
-inline bool ExtensionPos::apply (hb_apply_context_t *c) const
-{
- TRACE_APPLY ();
- return TRACE_RETURN (get_subtable ().apply (c, get_type ()));
-}
-
inline bool ExtensionPos::sanitize (hb_sanitize_context_t *c)
{
TRACE_SANITIZE ();
return TRACE_RETURN (StructAtOffset<PosLookupSubTable> (this, offset).sanitize (c, get_type ()));
}
-static inline bool position_lookup (hb_apply_context_t *c, unsigned int lookup_index)
+inline bool PosLookup::apply_recurse_func (hb_apply_context_t *c, unsigned int lookup_index)
{
const GPOS &gpos = *(hb_ot_layout_from_face (c->face)->gpos);
const PosLookup &l = gpos.get_lookup (lookup_index);
-
- if (unlikely (c->nesting_level_left == 0))
- return false;
-
- hb_apply_context_t new_c (*c);
- new_c.nesting_level_left--;
- new_c.set_lookup (l);
- return l.apply_once (&new_c);
+ c->set_lookup (l);
+ return l.apply_once (c);
}
}
}
- inline bool apply (hb_apply_context_t *c) const
- {
- TRACE_APPLY ();
- switch (u.format) {
- case 1: return TRACE_RETURN (u.format1.apply (c));
- case 2: return TRACE_RETURN (u.format2.apply (c));
- default:return TRACE_RETURN (false);
- }
- }
-
inline bool serialize (hb_serialize_context_t *c,
Supplier<GlyphID> &glyphs,
Supplier<GlyphID> &substitutes,
}
}
- inline bool apply (hb_apply_context_t *c) const
- {
- TRACE_APPLY ();
- switch (u.format) {
- case 1: return TRACE_RETURN (u.format1.apply (c));
- default:return TRACE_RETURN (false);
- }
- }
-
inline bool serialize (hb_serialize_context_t *c,
Supplier<GlyphID> &glyphs,
Supplier<unsigned int> &substitute_len_list,
}
}
- inline bool apply (hb_apply_context_t *c) const
- {
- TRACE_APPLY ();
- switch (u.format) {
- case 1: return TRACE_RETURN (u.format1.apply (c));
- default:return TRACE_RETURN (false);
- }
- }
-
inline bool serialize (hb_serialize_context_t *c,
Supplier<GlyphID> &glyphs,
Supplier<unsigned int> &alternate_len_list,
}
}
- inline bool apply (hb_apply_context_t *c) const
- {
- TRACE_APPLY ();
- switch (u.format) {
- case 1: return TRACE_RETURN (u.format1.apply (c));
- default:return TRACE_RETURN (false);
- }
- }
-
inline bool serialize (hb_serialize_context_t *c,
Supplier<GlyphID> &first_glyphs,
Supplier<unsigned int> &ligature_per_first_glyph_count_list,
};
-static inline bool substitute_lookup (hb_apply_context_t *c, unsigned int lookup_index);
-
struct ContextSubst : Context
{
template <typename context_t>
{
return Context::process (c);
}
-
- inline bool apply (hb_apply_context_t *c) const
- {
- TRACE_APPLY ();
- return TRACE_RETURN (Context::apply (c, substitute_lookup));
- }
};
struct ChainContextSubst : ChainContext
{
return ChainContext::process (c);
}
-
- inline bool apply (hb_apply_context_t *c) const
- {
- TRACE_APPLY ();
- return TRACE_RETURN (ChainContext::apply (c, substitute_lookup));
- }
};
template <typename context_t>
inline typename context_t::return_t process (context_t *c) const;
- inline bool apply (hb_apply_context_t *c) const;
-
inline bool sanitize (hb_sanitize_context_t *c);
inline bool is_reverse (void) const;
}
}
- inline bool apply (hb_apply_context_t *c) const
- {
- TRACE_APPLY ();
- switch (u.format) {
- case 1: return TRACE_RETURN (u.format1.apply (c));
- default:return TRACE_RETURN (false);
- }
- }
-
inline bool sanitize (hb_sanitize_context_t *c) {
TRACE_SANITIZE ();
if (!u.format.sanitize (c)) return TRACE_RETURN (false);
}
}
- inline bool apply (hb_apply_context_t *c, unsigned int lookup_type) const
- {
- TRACE_APPLY ();
- switch (lookup_type) {
- case Single: return TRACE_RETURN (u.single.apply (c));
- case Multiple: return TRACE_RETURN (u.multiple.apply (c));
- case Alternate: return TRACE_RETURN (u.alternate.apply (c));
- case Ligature: return TRACE_RETURN (u.ligature.apply (c));
- case Context: return TRACE_RETURN (u.context.apply (c));
- case ChainContext: return TRACE_RETURN (u.chainContext.apply (c));
- case Extension: return TRACE_RETURN (u.extension.apply (c));
- case ReverseChainSingle: return TRACE_RETURN (u.reverseChainContextSingle.apply (c));
- default: return TRACE_RETURN (false);
- }
- }
-
inline bool sanitize (hb_sanitize_context_t *c, unsigned int lookup_type) {
TRACE_SANITIZE ();
if (!u.header.sub_format.sanitize (c))
if (!c->check_glyph_property (&c->buffer->cur(), c->lookup_props, &c->property))
return false;
- unsigned int count = get_subtable_count ();
- for (unsigned int i = 0; i < count; i++)
- if (get_subtable (i).apply (c, lookup_type))
- return true;
-
- return false;
+ return process (c);
}
+ static bool apply_recurse_func (hb_apply_context_t *c, unsigned int lookup_index);
+
inline bool apply_string (hb_apply_context_t *c, const hb_set_digest_t *digest) const
{
bool ret = false;
if (unlikely (!c->buffer->len || !c->lookup_mask))
return false;
+ c->set_recurse_func (apply_recurse_func);
c->set_lookup (*this);
if (likely (!is_reverse ()))
static inline void substitute_start (hb_font_t *font, hb_buffer_t *buffer);
static inline void substitute_finish (hb_font_t *font, hb_buffer_t *buffer);
- static void_t closure_recurse_func (hb_closure_context_t *c, unsigned int lookup_index)
+ static inline void_t closure_recurse_func (hb_closure_context_t *c, unsigned int lookup_index)
{
const GSUB &gsub = *(hb_ot_layout_from_face (c->face)->gsub);
const SubstLookup &l = gsub.get_lookup (lookup_index);
return get_subtable ().process (c, get_type ());
}
-inline bool ExtensionSubst::apply (hb_apply_context_t *c) const
-{
- TRACE_APPLY ();
- return TRACE_RETURN (get_subtable ().apply (c, get_type ()));
-}
-
inline bool ExtensionSubst::sanitize (hb_sanitize_context_t *c)
{
TRACE_SANITIZE ();
return SubstLookup::lookup_type_is_reverse (type);
}
-static inline bool substitute_lookup (hb_apply_context_t *c, unsigned int lookup_index)
+inline bool SubstLookup::apply_recurse_func (hb_apply_context_t *c, unsigned int lookup_index)
{
const GSUB &gsub = *(hb_ot_layout_from_face (c->face)->gsub);
const SubstLookup &l = gsub.get_lookup (lookup_index);
-
- if (unlikely (c->nesting_level_left == 0))
- return false;
-
- hb_apply_context_t new_c (*c);
- new_c.nesting_level_left--;
- new_c.set_lookup (l);
- return l.apply_once (&new_c);
+ c->set_lookup (l);
+ return l.apply_once (c);
}
struct hb_apply_context_t
{
+ typedef bool return_t;
+ typedef return_t (*recurse_func_t) (hb_apply_context_t *c, unsigned int lookup_index);
+ template <typename T>
+ inline return_t process (const T &obj) { return obj.apply (this); }
+ static const return_t default_return_value (void) { return false; }
+ bool stop_sublookup_iteration (const return_t r) const { return r; }
+ return_t recurse (unsigned int lookup_index)
+ {
+ if (unlikely (nesting_level_left == 0 || !recurse_func))
+ return default_return_value ();
+
+ hb_apply_context_t new_c (*this);
+ new_c.nesting_level_left--;
+ return recurse_func (&new_c, lookup_index);
+ }
+
hb_font_t *font;
hb_face_t *face;
hb_buffer_t *buffer;
hb_direction_t direction;
hb_mask_t lookup_mask;
+ recurse_func_t recurse_func;
unsigned int nesting_level_left;
unsigned int lookup_props;
unsigned int property; /* propety of first glyph */
font (font_), face (font->face), buffer (buffer_),
direction (buffer_->props.direction),
lookup_mask (lookup_mask_),
+ recurse_func (NULL),
nesting_level_left (MAX_NESTING_LEVEL),
lookup_props (0), property (0), debug_depth (0),
gdef (*hb_ot_layout_from_face (face)->gdef),
has_glyph_classes (gdef.has_glyph_classes ()) {}
- void set_lookup_props (unsigned int lookup_props_) {
- lookup_props = lookup_props_;
- }
-
- void set_lookup (const Lookup &l) {
- lookup_props = l.get_props ();
- }
+ void set_recurse_func (recurse_func_t func) { recurse_func = func; }
+ void set_lookup_props (unsigned int lookup_props_) { lookup_props = lookup_props_; }
+ void set_lookup (const Lookup &l) { lookup_props = l.get_props (); }
struct mark_skipping_forward_iterator_t
{
typedef bool (*intersects_func_t) (hb_set_t *glyphs, const USHORT &value, const void *data);
typedef bool (*match_func_t) (hb_codepoint_t glyph_id, const USHORT &value, const void *data);
-typedef bool (*apply_lookup_func_t) (hb_apply_context_t *c, unsigned int lookup_index);
struct ContextClosureFuncs
{
struct ContextApplyFuncs
{
match_func_t match;
- apply_lookup_func_t apply;
};
static inline bool intersects_glyph (hb_set_t *glyphs, const USHORT &value, const void *data HB_UNUSED)
static inline bool apply_lookup (hb_apply_context_t *c,
unsigned int count, /* Including the first glyph */
unsigned int lookupCount,
- const LookupRecord lookupRecord[], /* Array of LookupRecords--in design order */
- apply_lookup_func_t apply_func)
+ const LookupRecord lookupRecord[] /* Array of LookupRecords--in design order */)
{
hb_auto_trace_t<HB_DEBUG_APPLY> trace (&c->debug_depth, "APPLY", NULL, HB_FUNC, "idx %d codepoint %u", c->buffer->idx, c->buffer->cur().codepoint);
unsigned int end = c->buffer->len;
unsigned int old_pos = c->buffer->idx;
/* Apply a lookup */
- bool done = apply_func (c, lookupRecord->lookupListIndex);
+ bool done = c->recurse (lookupRecord->lookupListIndex);
lookupRecord++;
lookupCount--;
lookup_context.funcs.match, lookup_context.match_data)
&& apply_lookup (c,
inputCount,
- lookupCount, lookupRecord,
- lookup_context.funcs.apply);
+ lookupCount, lookupRecord);
}
struct Rule
const RuleSet &rule_set = this+ruleSet[(this+coverage) (c->glyphs[0])];
struct ContextApplyLookupContext lookup_context = {
- {match_glyph, NULL},
+ {match_glyph},
NULL
};
return TRACE_RETURN (rule_set.would_apply (c, lookup_context));
return this+coverage;
}
- inline bool apply (hb_apply_context_t *c, apply_lookup_func_t apply_func) const
+ inline bool apply (hb_apply_context_t *c) const
{
TRACE_APPLY ();
unsigned int index = (this+coverage) (c->buffer->cur().codepoint);
const RuleSet &rule_set = this+ruleSet[index];
struct ContextApplyLookupContext lookup_context = {
- {match_glyph, apply_func},
+ {match_glyph},
NULL
};
return TRACE_RETURN (rule_set.apply (c, lookup_context));
unsigned int index = class_def (c->glyphs[0]);
const RuleSet &rule_set = this+ruleSet[index];
struct ContextApplyLookupContext lookup_context = {
- {match_class, NULL},
+ {match_class},
&class_def
};
return TRACE_RETURN (rule_set.would_apply (c, lookup_context));
return this+coverage;
}
- inline bool apply (hb_apply_context_t *c, apply_lookup_func_t apply_func) const
+ inline bool apply (hb_apply_context_t *c) const
{
TRACE_APPLY ();
unsigned int index = (this+coverage) (c->buffer->cur().codepoint);
index = class_def (c->buffer->cur().codepoint);
const RuleSet &rule_set = this+ruleSet[index];
struct ContextApplyLookupContext lookup_context = {
- {match_class, apply_func},
+ {match_class},
&class_def
};
return TRACE_RETURN (rule_set.apply (c, lookup_context));
const LookupRecord *lookupRecord = &StructAtOffset<LookupRecord> (coverage, coverage[0].static_size * glyphCount);
struct ContextApplyLookupContext lookup_context = {
- {match_coverage, NULL},
+ {match_coverage},
this
};
return TRACE_RETURN (context_would_apply_lookup (c, glyphCount, (const USHORT *) (coverage + 1), lookupCount, lookupRecord, lookup_context));
return this+coverage[0];
}
- inline bool apply (hb_apply_context_t *c, apply_lookup_func_t apply_func) const
+ inline bool apply (hb_apply_context_t *c) const
{
TRACE_APPLY ();
unsigned int index = (this+coverage[0]) (c->buffer->cur().codepoint);
const LookupRecord *lookupRecord = &StructAtOffset<LookupRecord> (coverage, coverage[0].static_size * glyphCount);
struct ContextApplyLookupContext lookup_context = {
- {match_coverage, apply_func},
+ {match_coverage},
this
};
return TRACE_RETURN (context_apply_lookup (c, glyphCount, (const USHORT *) (coverage + 1), lookupCount, lookupRecord, lookup_context));
}
}
- inline bool apply (hb_apply_context_t *c, apply_lookup_func_t apply_func) const
- {
- TRACE_APPLY ();
- switch (u.format) {
- case 1: return TRACE_RETURN (u.format1.apply (c, apply_func));
- case 2: return TRACE_RETURN (u.format2.apply (c, apply_func));
- case 3: return TRACE_RETURN (u.format3.apply (c, apply_func));
- default:return TRACE_RETURN (false);
- }
- }
-
inline bool sanitize (hb_sanitize_context_t *c) {
TRACE_SANITIZE ();
if (!u.format.sanitize (c)) return TRACE_RETURN (false);
lookahead_offset)
&& apply_lookup (c,
inputCount,
- lookupCount, lookupRecord,
- lookup_context.funcs.apply);
+ lookupCount, lookupRecord);
}
struct ChainRule
const ChainRuleSet &rule_set = this+ruleSet[(this+coverage) (c->glyphs[0])];
struct ChainContextApplyLookupContext lookup_context = {
- {match_glyph, NULL},
+ {match_glyph},
{NULL, NULL, NULL}
};
return TRACE_RETURN (rule_set.would_apply (c, lookup_context));
return this+coverage;
}
- inline bool apply (hb_apply_context_t *c, apply_lookup_func_t apply_func) const
+ inline bool apply (hb_apply_context_t *c) const
{
TRACE_APPLY ();
unsigned int index = (this+coverage) (c->buffer->cur().codepoint);
const ChainRuleSet &rule_set = this+ruleSet[index];
struct ChainContextApplyLookupContext lookup_context = {
- {match_glyph, apply_func},
+ {match_glyph},
{NULL, NULL, NULL}
};
return TRACE_RETURN (rule_set.apply (c, lookup_context));
unsigned int index = input_class_def (c->glyphs[0]);
const ChainRuleSet &rule_set = this+ruleSet[index];
struct ChainContextApplyLookupContext lookup_context = {
- {match_class, NULL},
+ {match_class},
{NULL, &input_class_def, NULL}
};
return TRACE_RETURN (rule_set.would_apply (c, lookup_context));
return this+coverage;
}
- inline bool apply (hb_apply_context_t *c, apply_lookup_func_t apply_func) const
+ inline bool apply (hb_apply_context_t *c) const
{
TRACE_APPLY ();
unsigned int index = (this+coverage) (c->buffer->cur().codepoint);
index = input_class_def (c->buffer->cur().codepoint);
const ChainRuleSet &rule_set = this+ruleSet[index];
struct ChainContextApplyLookupContext lookup_context = {
- {match_class, apply_func},
+ {match_class},
{&backtrack_class_def,
&input_class_def,
&lookahead_class_def}
const OffsetArrayOf<Coverage> &lookahead = StructAfter<OffsetArrayOf<Coverage> > (input);
const ArrayOf<LookupRecord> &lookup = StructAfter<ArrayOf<LookupRecord> > (lookahead);
struct ChainContextApplyLookupContext lookup_context = {
- {match_coverage, NULL},
+ {match_coverage},
{this, this, this}
};
return TRACE_RETURN (chain_context_would_apply_lookup (c,
return this+input[0];
}
- inline bool apply (hb_apply_context_t *c, apply_lookup_func_t apply_func) const
+ inline bool apply (hb_apply_context_t *c) const
{
TRACE_APPLY ();
const OffsetArrayOf<Coverage> &input = StructAfter<OffsetArrayOf<Coverage> > (backtrack);
const OffsetArrayOf<Coverage> &lookahead = StructAfter<OffsetArrayOf<Coverage> > (input);
const ArrayOf<LookupRecord> &lookup = StructAfter<ArrayOf<LookupRecord> > (lookahead);
struct ChainContextApplyLookupContext lookup_context = {
- {match_coverage, apply_func},
+ {match_coverage},
{this, this, this}
};
return TRACE_RETURN (chain_context_apply_lookup (c,
}
}
- inline bool apply (hb_apply_context_t *c, apply_lookup_func_t apply_func) const
- {
- TRACE_APPLY ();
- switch (u.format) {
- case 1: return TRACE_RETURN (u.format1.apply (c, apply_func));
- case 2: return TRACE_RETURN (u.format2.apply (c, apply_func));
- case 3: return TRACE_RETURN (u.format3.apply (c, apply_func));
- default:return TRACE_RETURN (false);
- }
- }
-
inline bool sanitize (hb_sanitize_context_t *c) {
TRACE_SANITIZE ();
if (!u.format.sanitize (c)) return TRACE_RETURN (false);
{
if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return;
- OT::hb_collect_glyphs_context_t c (face, glyphs_before, glyphs_input, glyphs_after, glyphs_output);
+// OT::hb_collect_glyphs_context_t c (face, glyphs_before, glyphs_input, glyphs_after, glyphs_output);
switch (table_tag) {
case HB_OT_TAG_GSUB: