[subset] Add serialize_serialize to OffsetTo.

Similar to serialize_subset() this will serialize the new object and then link it to the offset.
This commit is contained in:
Garret Rieger 2021-06-11 13:14:51 -07:00
parent 2b0ced28b6
commit 35458b6b66
2 changed files with 18 additions and 1 deletions

View File

@ -355,6 +355,23 @@ struct OffsetTo : Offset<OffsetType, has_null>
return ret;
}
template <typename ...Ts>
bool serialize_serialize (hb_serialize_context_t *c, Ts&&... ds)
{
*this = 0;
Type* obj = c->push<Type> ();
bool ret = obj->serialize (c, hb_forward<Ts> (ds)...);
if (ret)
c->add_link (*this, c->pop_pack ());
else
c->pop_discard ();
return ret;
}
/* TODO: Somehow merge this with previous function into a serialize_dispatch(). */
/* Workaround clang bug: https://bugs.llvm.org/show_bug.cgi?id=23029
* Can't compile: whence = hb_serialize_context_t::Head followed by Ts&&...

View File

@ -101,7 +101,7 @@ struct SingleSubstFormat1
{
TRACE_SERIALIZE (this);
if (unlikely (!c->extend_min (*this))) return_trace (false);
if (unlikely (!coverage.serialize (c, this).serialize (c, glyphs))) return_trace (false);
if (unlikely (!coverage.serialize_serialize (c, glyphs))) return_trace (false);
c->check_assign (deltaGlyphID, delta, HB_SERIALIZE_ERROR_INT_OVERFLOW);
return_trace (true);
}