typedef hb_pair_t<hb_codepoint_t, hb_codepoint_t> hb_codepoint_pair_t;
template<typename Iterator>
-static inline void SingleSubst_serialize (hb_serialize_context_t *c,
- Iterator it);
+static void SingleSubst_serialize (hb_serialize_context_t *c,
+ Iterator it);
struct SingleSubstFormat1
;
}
+ void closure_lookups (hb_closure_lookups_context_t *c) const {}
+
void collect_glyphs (hb_collect_glyphs_context_t *c) const
{
- if (unlikely (!(this+coverage).add_coverage (c->input))) return;
+ if (unlikely (!(this+coverage).collect_coverage (c->input))) return;
unsigned d = deltaGlyphID;
+ hb_iter (this+coverage)
| hb_map ([d] (hb_codepoint_t g) { return (g + d) & 0xFFFFu; })
;
}
+ void closure_lookups (hb_closure_lookups_context_t *c) const {}
+
void collect_glyphs (hb_collect_glyphs_context_t *c) const
{
- if (unlikely (!(this+coverage).add_coverage (c->input))) return;
+ if (unlikely (!(this+coverage).collect_coverage (c->input))) return;
+ hb_zip (this+coverage, substitute)
| hb_map (hb_second)
| hb_sink (c->output)
if (glyphs)
{
format = 1;
- auto get_delta = [=] (hb_codepoint_pair_t _) {
- return (unsigned) (_.second - _.first) & 0xFFFF;
- };
+ auto get_delta = [=] (hb_codepoint_pair_t _)
+ { return (unsigned) (_.second - _.first) & 0xFFFF; };
delta = get_delta (*glyphs);
if (!hb_all (++(+glyphs), delta, get_delta)) format = 2;
}
};
template<typename Iterator>
-static inline void
+static void
SingleSubst_serialize (hb_serialize_context_t *c,
Iterator it)
{ c->start_embed<SingleSubst> ()->serialize (c, it); }
if (!intersects (&glyphset)) return_trace (false);
auto it =
- + hb_iter (substitute)
- | hb_map (glyph_map)
- ;
+ + hb_iter (substitute)
+ | hb_map (glyph_map)
+ ;
auto *out = c->serializer->start_embed (*this);
return_trace (out->serialize (c->serializer, it));
;
}
+ void closure_lookups (hb_closure_lookups_context_t *c) const {}
+
void collect_glyphs (hb_collect_glyphs_context_t *c) const
{
- if (unlikely (!(this+coverage).add_coverage (c->input))) return;
+ if (unlikely (!(this+coverage).collect_coverage (c->input))) return;
+ hb_zip (this+coverage, sequence)
| hb_map (hb_second)
| hb_map (hb_add (this))
hb_sorted_vector_t<hb_codepoint_t> new_coverage;
+ hb_zip (this+coverage, sequence)
| hb_filter (glyphset, hb_first)
- | hb_filter (subset_offset_array (c, out->sequence, this, out), hb_second)
+ | hb_filter (subset_offset_array (c, out->sequence, this), hb_second)
| hb_map (hb_first)
| hb_map (glyph_map)
| hb_sink (new_coverage)
void closure (hb_closure_context_t *c) const
{
+ hb_zip (this+coverage, alternateSet)
+ | hb_filter (c->glyphs, hb_first)
| hb_map (hb_second)
| hb_map (hb_add (this))
| hb_apply ([c] (const AlternateSet &_) { _.closure (c); })
;
}
+ void closure_lookups (hb_closure_lookups_context_t *c) const {}
+
void collect_glyphs (hb_collect_glyphs_context_t *c) const
{
- if (unlikely (!(this+coverage).add_coverage (c->input))) return;
+ if (unlikely (!(this+coverage).collect_coverage (c->input))) return;
+ hb_zip (this+coverage, alternateSet)
| hb_map (hb_second)
| hb_map (hb_add (this))
hb_sorted_vector_t<hb_codepoint_t> new_coverage;
+ hb_zip (this+coverage, alternateSet)
| hb_filter (glyphset, hb_first)
- | hb_filter (subset_offset_array (c, out->alternateSet, this, out), hb_second)
+ | hb_filter (subset_offset_array (c, out->alternateSet, this), hb_second)
| hb_map (hb_first)
| hb_map (glyph_map)
| hb_sink (new_coverage)
if (unlikely (!c->serializer->extend_min (out))) return_trace (false);
+ hb_iter (ligature)
- | hb_filter (subset_offset_array (c, out->ligature, this, out))
+ | hb_filter (subset_offset_array (c, out->ligature, this))
| hb_drain
;
return_trace (bool (out->ligature));
;
}
+ void closure_lookups (hb_closure_lookups_context_t *c) const {}
+
void collect_glyphs (hb_collect_glyphs_context_t *c) const
{
- if (unlikely (!(this+coverage).add_coverage (c->input))) return;
+ if (unlikely (!(this+coverage).collect_coverage (c->input))) return;
+ hb_zip (this+coverage, ligatureSet)
| hb_map (hb_second)
{
TRACE_APPLY (this);
- unsigned int index = (this+coverage).get_coverage (c->buffer->cur().codepoint);
+ unsigned int index = (this+coverage).get_coverage (c->buffer->cur ().codepoint);
if (likely (index == NOT_COVERED)) return_trace (false);
const LigatureSet &lig_set = this+ligatureSet[index];
hb_sorted_vector_t<hb_codepoint_t> new_coverage;
+ hb_zip (this+coverage, ligatureSet)
| hb_filter (glyphset, hb_first)
- | hb_filter (subset_offset_array (c, out->ligatureSet, this, out), hb_second)
+ | hb_filter (subset_offset_array (c, out->ligatureSet, this), hb_second)
| hb_map (hb_first)
| hb_map (glyph_map)
| hb_sink (new_coverage)
struct ExtensionSubst : Extension<ExtensionSubst>
{
typedef struct SubstLookupSubTable SubTable;
-
bool is_reverse () const;
};
;
}
+ void closure_lookups (hb_closure_lookups_context_t *c) const {}
+
void collect_glyphs (hb_collect_glyphs_context_t *c) const
{
- if (unlikely (!(this+coverage).add_coverage (c->input))) return;
+ if (unlikely (!(this+coverage).collect_coverage (c->input))) return;
unsigned int count;
count = backtrack.len;
for (unsigned int i = 0; i < count; i++)
- if (unlikely (!(this+backtrack[i]).add_coverage (c->before))) return;
+ if (unlikely (!(this+backtrack[i]).collect_coverage (c->before))) return;
const OffsetArrayOf<Coverage> &lookahead = StructAfter<OffsetArrayOf<Coverage>> (backtrack);
count = lookahead.len;
for (unsigned int i = 0; i < count; i++)
- if (unlikely (!(this+lookahead[i]).add_coverage (c->after))) return;
+ if (unlikely (!(this+lookahead[i]).collect_coverage (c->after))) return;
const ArrayOf<HBGlyphID> &substitute = StructAfter<ArrayOf<HBGlyphID>> (lookahead);
count = substitute.len;
if (unlikely (c->nesting_level_left != HB_MAX_NESTING_LEVEL))
return_trace (false); /* No chaining to this type */
- unsigned int index = (this+coverage).get_coverage (c->buffer->cur().codepoint);
+ unsigned int index = (this+coverage).get_coverage (c->buffer->cur ().codepoint);
if (likely (index == NOT_COVERED)) return_trace (false);
const OffsetArrayOf<Coverage> &lookahead = StructAfter<OffsetArrayOf<Coverage>> (backtrack);
}
}
+ bool intersects (const hb_set_t *glyphs, unsigned int lookup_type) const
+ {
+ hb_intersects_context_t c (glyphs);
+ return dispatch (&c, lookup_type);
+ }
+
protected:
union {
SingleSubst single;
const SubTable& get_subtable (unsigned int i) const
{ return Lookup::get_subtable<SubTable> (i); }
- HB_INTERNAL static bool lookup_type_is_reverse (unsigned int lookup_type)
+ static inline bool lookup_type_is_reverse (unsigned int lookup_type)
{ return lookup_type == SubTable::ReverseChainSingle; }
bool is_reverse () const
{
unsigned int type = get_type ();
if (unlikely (type == SubTable::Extension))
- return CastR<ExtensionSubst> (get_subtable(0)).is_reverse ();
+ return reinterpret_cast<const ExtensionSubst &> (get_subtable (0)).is_reverse ();
return lookup_type_is_reverse (type);
}
return ret;
}
+ hb_closure_lookups_context_t::return_t closure_lookups (hb_closure_lookups_context_t *c, unsigned this_index) const
+ {
+ if (c->is_lookup_visited (this_index))
+ return hb_closure_lookups_context_t::default_return_value ();
+
+ c->set_lookup_visited (this_index);
+ if (!intersects (c->glyphs))
+ {
+ c->set_lookup_inactive (this_index);
+ return hb_closure_lookups_context_t::default_return_value ();
+ }
+
+ c->set_recurse_func (dispatch_closure_lookups_recurse_func);
+
+ hb_closure_lookups_context_t::return_t ret = dispatch (c);
+ return ret;
+ }
+
hb_collect_glyphs_context_t::return_t collect_glyphs (hb_collect_glyphs_context_t *c) const
{
c->set_recurse_func (dispatch_recurse_func<hb_collect_glyphs_context_t>);
}
template <typename set_t>
- void add_coverage (set_t *glyphs) const
+ void collect_coverage (set_t *glyphs) const
{
- hb_add_coverage_context_t<set_t> c (glyphs);
+ hb_collect_coverage_context_t<set_t> c (glyphs);
dispatch (&c);
}
return dispatch (c);
}
- HB_INTERNAL static bool apply_recurse_func (hb_ot_apply_context_t *c, unsigned int lookup_index);
+ static inline bool apply_recurse_func (hb_ot_apply_context_t *c, unsigned int lookup_index);
SubTable& serialize_subtable (hb_serialize_context_t *c,
unsigned int i)
}
template <typename context_t>
- HB_INTERNAL static typename context_t::return_t dispatch_recurse_func (context_t *c, unsigned int lookup_index);
+ static inline typename context_t::return_t dispatch_recurse_func (context_t *c, unsigned int lookup_index);
- HB_INTERNAL static hb_closure_context_t::return_t dispatch_closure_recurse_func (hb_closure_context_t *c, unsigned int lookup_index)
+ static inline hb_closure_context_t::return_t dispatch_closure_recurse_func (hb_closure_context_t *c, unsigned int lookup_index)
{
if (!c->should_visit_lookup (lookup_index))
return hb_empty_t ();
return ret;
}
+ HB_INTERNAL static hb_closure_lookups_context_t::return_t dispatch_closure_lookups_recurse_func (hb_closure_lookups_context_t *c, unsigned lookup_index);
+
template <typename context_t, typename ...Ts>
typename context_t::return_t dispatch (context_t *c, Ts&&... ds) const
{ return Lookup::dispatch<SubTable> (c, hb_forward<Ts> (ds)...); }
static constexpr hb_tag_t tableTag = HB_OT_TAG_GSUB;
const SubstLookup& get_lookup (unsigned int i) const
- { return CastR<SubstLookup> (GSUBGPOS::get_lookup (i)); }
+ { return static_cast<const SubstLookup &> (GSUBGPOS::get_lookup (i)); }
bool subset (hb_subset_context_t *c) const
- { return GSUBGPOS::subset<SubstLookup> (c); }
+ {
+ hb_subset_layout_context_t l (c, tableTag, c->plan->gsub_lookups, c->plan->gsub_features);
+ return GSUBGPOS::subset<SubstLookup> (&l);
+ }
bool sanitize (hb_sanitize_context_t *c) const
{ return GSUBGPOS::sanitize<SubstLookup> (c); }
#ifndef HB_NO_OT_LAYOUT
/*static*/ inline bool ExtensionSubst::is_reverse () const
{
- unsigned int type = get_type ();
- if (unlikely (type == SubTable::Extension))
- return CastR<ExtensionSubst> (get_subtable<SubTable>()).is_reverse ();
- return SubstLookup::lookup_type_is_reverse (type);
+ return SubstLookup::lookup_type_is_reverse (get_type ());
}
template <typename context_t>
-/*static*/ inline typename context_t::return_t SubstLookup::dispatch_recurse_func (context_t *c, unsigned int lookup_index)
+/*static*/ typename context_t::return_t SubstLookup::dispatch_recurse_func (context_t *c, unsigned int lookup_index)
{
const SubstLookup &l = c->face->table.GSUB.get_relaxed ()->table->get_lookup (lookup_index);
return l.dispatch (c);
}
-/*static*/ inline bool SubstLookup::apply_recurse_func (hb_ot_apply_context_t *c, unsigned int lookup_index)
+
+/*static*/ inline hb_closure_lookups_context_t::return_t SubstLookup::dispatch_closure_lookups_recurse_func (hb_closure_lookups_context_t *c, unsigned this_index)
+{
+ const SubstLookup &l = c->face->table.GSUB.get_relaxed ()->table->get_lookup (this_index);
+ return l.closure_lookups (c, this_index);
+}
+
+/*static*/ bool SubstLookup::apply_recurse_func (hb_ot_apply_context_t *c, unsigned int lookup_index)
{
const SubstLookup &l = c->face->table.GSUB.get_relaxed ()->table->get_lookup (lookup_index);
unsigned int saved_lookup_props = c->lookup_props;