[subset] Implement AlternateSubst subsetting
This commit is contained in:
parent
23681b6da4
commit
dc9222b1dd
|
@ -360,7 +360,7 @@ struct Sequence
|
||||||
;
|
;
|
||||||
|
|
||||||
auto *out = c->serializer->start_embed (*this);
|
auto *out = c->serializer->start_embed (*this);
|
||||||
return out->serialize (c->serializer, it);
|
return_trace (out->serialize (c->serializer, it));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool sanitize (hb_sanitize_context_t *c) const
|
bool sanitize (hb_sanitize_context_t *c) const
|
||||||
|
@ -526,6 +526,9 @@ struct MultipleSubst
|
||||||
|
|
||||||
struct AlternateSet
|
struct AlternateSet
|
||||||
{
|
{
|
||||||
|
bool intersects (const hb_set_t *glyphs) const
|
||||||
|
{ return hb_any (alternates, glyphs); }
|
||||||
|
|
||||||
void closure (hb_closure_context_t *c) const
|
void closure (hb_closure_context_t *c) const
|
||||||
{ c->output->add_array (alternates.arrayZ, alternates.len); }
|
{ c->output->add_array (alternates.arrayZ, alternates.len); }
|
||||||
|
|
||||||
|
@ -566,6 +569,23 @@ struct AlternateSet
|
||||||
return_trace (alternates.serialize (c, alts));
|
return_trace (alternates.serialize (c, alts));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool subset (hb_subset_context_t *c) const
|
||||||
|
{
|
||||||
|
TRACE_SUBSET (this);
|
||||||
|
const hb_set_t &glyphset = *c->plan->glyphset ();
|
||||||
|
const hb_map_t &glyph_map = *c->plan->glyph_map;
|
||||||
|
|
||||||
|
auto it =
|
||||||
|
+ hb_iter (alternates)
|
||||||
|
| hb_filter (glyphset)
|
||||||
|
| hb_map (glyph_map)
|
||||||
|
;
|
||||||
|
|
||||||
|
auto *out = c->serializer->start_embed (*this);
|
||||||
|
return_trace (out->serialize (c->serializer, it) &&
|
||||||
|
out->alternates);
|
||||||
|
}
|
||||||
|
|
||||||
bool sanitize (hb_sanitize_context_t *c) const
|
bool sanitize (hb_sanitize_context_t *c) const
|
||||||
{
|
{
|
||||||
TRACE_SANITIZE (this);
|
TRACE_SANITIZE (this);
|
||||||
|
@ -641,8 +661,37 @@ struct AlternateSubstFormat1
|
||||||
bool subset (hb_subset_context_t *c) const
|
bool subset (hb_subset_context_t *c) const
|
||||||
{
|
{
|
||||||
TRACE_SUBSET (this);
|
TRACE_SUBSET (this);
|
||||||
// TODO(subset)
|
const hb_set_t &glyphset = *c->plan->glyphset ();
|
||||||
return_trace (false);
|
const hb_map_t &glyph_map = *c->plan->glyph_map;
|
||||||
|
|
||||||
|
auto *out = c->serializer->start_embed (*this);
|
||||||
|
if (unlikely (!c->serializer->extend_min (out))) return_trace (false);
|
||||||
|
out->format = format;
|
||||||
|
|
||||||
|
hb_sorted_vector_t<hb_codepoint_t> new_coverage;
|
||||||
|
+ hb_zip (this+coverage, alternateSet)
|
||||||
|
| hb_filter (glyphset, hb_first)
|
||||||
|
| hb_filter ([this, c, out] (const OffsetTo<AlternateSet>& _)
|
||||||
|
{
|
||||||
|
auto *o = out->alternateSet.serialize_append (c->serializer);
|
||||||
|
if (unlikely (!o)) return false;
|
||||||
|
auto snap = c->serializer->snapshot ();
|
||||||
|
bool ret = o->serialize_subset (c, _, this, out);
|
||||||
|
if (!ret)
|
||||||
|
{
|
||||||
|
out->alternateSet.pop ();
|
||||||
|
c->serializer->revert (snap);
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
},
|
||||||
|
hb_second)
|
||||||
|
| hb_map (hb_first)
|
||||||
|
| hb_map (glyph_map)
|
||||||
|
| hb_sink (new_coverage);
|
||||||
|
;
|
||||||
|
out->coverage.serialize (c->serializer, out)
|
||||||
|
.serialize (c->serializer, new_coverage.iter ());
|
||||||
|
return_trace (bool (new_coverage));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool sanitize (hb_sanitize_context_t *c) const
|
bool sanitize (hb_sanitize_context_t *c) const
|
||||||
|
@ -794,9 +843,9 @@ struct Ligature
|
||||||
;
|
;
|
||||||
|
|
||||||
auto *out = c->serializer->start_embed (*this);
|
auto *out = c->serializer->start_embed (*this);
|
||||||
return out->serialize (c->serializer,
|
return_trace (out->serialize (c->serializer,
|
||||||
glyph_map[ligGlyph],
|
glyph_map[ligGlyph],
|
||||||
it);
|
it));
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
Loading…
Reference in New Issue