[serialize] Pass offset to serialize_subset()

This commit is contained in:
Behdad Esfahbod 2019-05-31 14:39:32 -07:00
parent 9260441624
commit 1834cf86d4
4 changed files with 21 additions and 16 deletions

View File

@ -298,20 +298,24 @@ struct OffsetTo : Offset<OffsetType, has_null>
}
template <typename ...Ts>
bool serialize_subset (hb_subset_context_t *c, const Type &src, const void *base, Ts&&... ds)
bool serialize_subset (hb_subset_context_t *c,
const OffsetTo& src,
const void *src_base,
const void *dst_base,
Ts&&... ds)
{
*this = 0;
if (has_null && &src == _hb_has_null<Type, has_null>::get_null ())
if (src.is_null ())
return false;
auto *s = c->serializer;
s->push ();
bool ret = c->dispatch (src, hb_forward<Ts> (ds)...);
bool ret = c->dispatch (src_base+src, hb_forward<Ts> (ds)...);
if (ret || !has_null)
s->add_link (*this, s->pop_pack (), base);
s->add_link (*this, s->pop_pack (), dst_base);
else
s->pop_discard ();
@ -683,7 +687,7 @@ struct OffsetListOf : OffsetArrayOf<Type>
if (unlikely (!out)) return_trace (false);
unsigned int count = this->len;
for (unsigned int i = 0; i < count; i++)
out->arrayZ[i].serialize_subset (c, (*this)[i], out);
out->arrayZ[i].serialize_subset (c, this->arrayZ[i], this, out);
return_trace (true);
}

View File

@ -142,7 +142,7 @@ struct RecordListOf : RecordArrayOf<Type>
if (unlikely (!out)) return_trace (false);
unsigned int count = this->len;
for (unsigned int i = 0; i < count; i++)
out->get_offset (i).serialize_subset (c, (*this)[i], out);
out->get_offset (i).serialize_subset (c, this->get_offset (i), this, out);
return_trace (true);
}
@ -732,7 +732,7 @@ struct Lookup
OffsetArrayOf<TSubTable>& out_subtables = out->get_subtables<TSubTable> ();
unsigned int count = subTable.len;
for (unsigned int i = 0; i < count; i++)
out_subtables[i].serialize_subset (c, this+subtables[i], out, get_type ());
out_subtables[i].serialize_subset (c, subtables[i], this, out, get_type ());
return_trace (true);
}

View File

@ -442,16 +442,16 @@ struct GDEF
auto *out = c->serializer->embed (*this);
if (unlikely (!out)) return_trace (false);
out->glyphClassDef.serialize_subset (c, this+glyphClassDef, out);
out->attachList = 0;//TODO(subset) serialize_subset (c, this+attachList, out);
out->ligCaretList = 0;//TODO(subset) serialize_subset (c, this+ligCaretList, out);
out->markAttachClassDef.serialize_subset (c, this+markAttachClassDef, out);
out->glyphClassDef.serialize_subset (c, glyphClassDef, this, out);
out->attachList = 0;//TODO(subset) serialize_subset (c, attachList, this, out);
out->ligCaretList = 0;//TODO(subset) serialize_subset (c, ligCaretList, this, out);
out->markAttachClassDef.serialize_subset (c, markAttachClassDef, this, out);
if (version.to_int () >= 0x00010002u)
out->markGlyphSetsDef = 0;// TODO(subset) serialize_subset (c, this+markGlyphSetsDef, out);
out->markGlyphSetsDef = 0;// TODO(subset) serialize_subset (c, markGlyphSetsDef, this, out);
if (version.to_int () >= 0x00010003u)
out->varStore = 0;// TODO(subset) serialize_subset (c, this+varStore, out);
out->varStore = 0;// TODO(subset) serialize_subset (c, varStore, this, out);
return_trace (true);
}

View File

@ -2684,14 +2684,15 @@ struct GSUBGPOS
auto *out = c->serializer->embed (*this);
if (unlikely (!out)) return_trace (false);
out->scriptList.serialize_subset (c, this+scriptList, out);
out->featureList.serialize_subset (c, this+featureList, out);
out->scriptList.serialize_subset (c, scriptList, this, out);
out->featureList.serialize_subset (c, featureList, this, out);
typedef OffsetListOf<TLookup> TLookupList;
/* TODO Use intersects() to count how many subtables survive? */
CastR<OffsetTo<TLookupList>> (out->lookupList)
.serialize_subset (c,
this+CastR<OffsetTo<TLookupList>> (lookupList),
CastR<OffsetTo<TLookupList>> (lookupList),
this,
out);
if (version.to_int () >= 0x00010001u)