}
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 ()))
- {
- /* in/out forward substitution */
- c->buffer->clear_output ();
- c->buffer->idx = 0;
-
- while (c->buffer->idx < c->buffer->len)
- {
- if (digest->may_have (c->buffer->cur().codepoint) &&
- (c->buffer->cur().mask & c->lookup_mask) &&
- apply_once (c))
- ret = true;
- else
- c->buffer->next_glyph ();
- }
- if (ret)
- c->buffer->swap_buffers ();
- }
- else
- {
- /* in-place backward substitution */
- c->buffer->remove_output ();
- c->buffer->idx = c->buffer->len - 1;
- do
- {
- if (digest->may_have (c->buffer->cur().codepoint) &&
- (c->buffer->cur().mask & c->lookup_mask) &&
- apply_once (c))
- ret = true;
- else
- c->buffer->idx--;
-
- }
- while ((int) c->buffer->idx >= 0);
- }
-
- return ret;
- }
inline SubstLookupSubTable& serialize_subtable (hb_serialize_context_t *c,
unsigned int i)
* Copyright © 1998-2004 David Turner and Werner Lemberg
* Copyright © 2006 Behdad Esfahbod
* Copyright © 2007,2008,2009 Red Hat, Inc.
- * Copyright © 2012 Google, Inc.
+ * Copyright © 2012,2013 Google, Inc.
*
* This is part of HarfBuzz, a text shaping library.
*
};
+template <typename Lookup>
+static inline bool apply_once (OT::hb_apply_context_t *c,
+ const Lookup &lookup)
+{
+ if (!c->check_glyph_property (&c->buffer->cur(), c->lookup_props))
+ return false;
+ return lookup.dispatch (c);
+}
+
+template <typename Proxy>
+static inline bool
+apply_string (OT::hb_apply_context_t *c,
+ const typename Proxy::Lookup &lookup,
+ const hb_ot_layout_lookup_accelerator_t &accel)
+{
+ bool ret = false;
+
+ if (unlikely (!c->buffer->len || !c->lookup_mask))
+ return false;
+
+ c->set_lookup (lookup);
+
+ if (likely (!lookup.is_reverse ()))
+ {
+ /* in/out forward substitution/positioning */
+ if (Proxy::table_index == 0)
+ c->buffer->clear_output ();
+ c->buffer->idx = 0;
+
+ while (c->buffer->idx < c->buffer->len)
+ {
+ if (accel.digest.may_have (c->buffer->cur().codepoint) &&
+ (c->buffer->cur().mask & c->lookup_mask) &&
+ apply_once (c, lookup))
+ ret = true;
+ else
+ c->buffer->next_glyph ();
+ }
+ if (ret && Proxy::table_index == 0)
+ c->buffer->swap_buffers ();
+ }
+ else
+ {
+ /* in-place backward substitution/positioning */
+ if (Proxy::table_index == 0)
+ c->buffer->remove_output ();
+ c->buffer->idx = c->buffer->len - 1;
+ do
+ {
+ if (accel.digest.may_have (c->buffer->cur().codepoint) &&
+ (c->buffer->cur().mask & c->lookup_mask) &&
+ apply_once (c, lookup))
+ ret = true;
+ else
+ c->buffer->idx--;
+
+ }
+ while ((int) c->buffer->idx >= 0);
+ }
+
+ return ret;
+}
+
template <typename Proxy>
inline void hb_ot_map_t::apply (const Proxy &proxy,
const hb_ot_shape_plan_t *plan,
const unsigned int table_index = proxy.table_index;
unsigned int i = 0;
OT::hb_apply_context_t c (table_index, font, buffer);
+ c.set_recurse_func (Proxy::Lookup::apply_recurse_func);
for (unsigned int stage_index = 0; stage_index < stages[table_index].len; stage_index++) {
const stage_map_t *stage = &stages[table_index][stage_index];
unsigned int lookup_index = lookups[table_index][i].index;
c.set_lookup_mask (lookups[table_index][i].mask);
c.set_auto_zwj (lookups[table_index][i].auto_zwj);
- proxy.table.get_lookup (lookup_index).apply_string (&c, &proxy.accels[lookup_index].digest);
+ apply_string<Proxy> (&c,
+ proxy.table.get_lookup (lookup_index),
+ proxy.accels[lookup_index]);
}
if (stage->pause_func)
const OT::SubstLookup &lookup,
const hb_ot_layout_lookup_accelerator_t &accel)
{
- lookup.apply_string (c, &accel.digest);
+ apply_string<GSUBProxy> (c, lookup, accel);
}