From dc50493a8da05d6561242136d63cae836486c150 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Mon, 3 Sep 2018 18:23:23 -0700 Subject: [PATCH] [subset] Towards subsetting SingleSubstFormat1 Why does subset plan not have a hb_set_t of glyphs? --- src/hb-machinery.hh | 10 +++++++++- src/hb-ot-layout-gsub-table.hh | 12 +++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/hb-machinery.hh b/src/hb-machinery.hh index 6e3e70c75..280a5a69a 100644 --- a/src/hb-machinery.hh +++ b/src/hb-machinery.hh @@ -33,6 +33,7 @@ #include "hb-blob.hh" #include "hb-iter.hh" +#include "hb-vector.hh" /* @@ -579,12 +580,19 @@ struct hb_serialize_context_t template struct Supplier { - inline Supplier (const Type *array, unsigned int len_, unsigned int stride_=sizeof(Type)) + inline Supplier (const Type *array, unsigned int len_, unsigned int stride_=sizeof (Type)) { head = array; len = len_; stride = stride_; } + inline Supplier (const hb_vector_t *v) + { + head = v->arrayZ; + len = v->len; + stride = sizeof (Type); + } + inline const Type operator [] (unsigned int i) const { if (unlikely (i >= len)) return Type (); diff --git a/src/hb-ot-layout-gsub-table.hh b/src/hb-ot-layout-gsub-table.hh index b5ac08baf..c0f708158 100644 --- a/src/hb-ot-layout-gsub-table.hh +++ b/src/hb-ot-layout-gsub-table.hh @@ -104,8 +104,18 @@ struct SingleSubstFormat1 inline bool subset (hb_subset_context_t *c) const { + return false; TRACE_SUBSET (this); - // TODO(subset) + hb_auto_t> from; + hb_auto_t> to; + hb_codepoint_t delta = deltaGlyphID; + for (hb_auto_t iter (this+coverage); iter.more (); iter.next ()) + { + //if (!c->plan->glyphs->has (iter.get_glyph ())) + // continue; + from.push (iter.get_glyph ()); + to.push ((iter.get_glyph () + delta) & 0xFFFF); + } return_trace (false); }