Skip to content

Instantly share code, notes, and snippets.

@behdad
Created May 16, 2019 21:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save behdad/a161586b18009dd2c69a2e44c3d311de to your computer and use it in GitHub Desktop.
Save behdad/a161586b18009dd2c69a2e44c3d311de to your computer and use it in GitHub Desktop.
diff --cc src/hb-ot-layout-gsub-table.hh
index 364ef189,364ef189..4de505aa
--- a/src/hb-ot-layout-gsub-table.hh
+++ b/src/hb-ot-layout-gsub-table.hh
@@@ -899,8 -899,8 +899,31 @@@ struct LigatureSubstFormat
bool subset (hb_subset_context_t *c) const
{
TRACE_SUBSET (this);
-- // TODO(subset)
-- return_trace (false);
++ const hb_set_t &glyphset = *c->plan->glyphset ();
++ const hb_map_t &glyph_map = *c->plan->glyph_map;
++
++ auto *out = c->serializer->start_embed (*this);
++ if (unlikely (!c->extend_min (out))) trace_return (false);
++ out->format = format;
++
++ hb_sorted_vector_t<hb_codepoint_t> new_coverage;
++ + hb_zip (this+coverage, ligatureSet)
++ | hb_filter (glyphset, hb_first)
++ | hb_filter ([&] (const OffsetTo<LigatureSet>& _)
++ {
++ if (unlikely (!out->ligatureSet.serialize_append (c->serializer))) return false;
++ bool ret = out.ligatureSet.tail ().serialize_subset (c, this+_, out);
++ if (!ret) out->ligatureSet.len--; umm.
++ 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment