From 35458b6b66f801194a1dad957308be9a71280425 Mon Sep 17 00:00:00 2001 From: Garret Rieger Date: Fri, 11 Jun 2021 13:14:51 -0700 Subject: [PATCH] [subset] Add serialize_serialize to OffsetTo. Similar to serialize_subset() this will serialize the new object and then link it to the offset. --- src/hb-open-type.hh | 17 +++++++++++++++++ src/hb-ot-layout-gsub-table.hh | 2 +- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/hb-open-type.hh b/src/hb-open-type.hh index 42eb8af05..a1ff423ca 100644 --- a/src/hb-open-type.hh +++ b/src/hb-open-type.hh @@ -355,6 +355,23 @@ struct OffsetTo : Offset return ret; } + + template + bool serialize_serialize (hb_serialize_context_t *c, Ts&&... ds) + { + *this = 0; + + Type* obj = c->push (); + bool ret = obj->serialize (c, hb_forward (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&&... diff --git a/src/hb-ot-layout-gsub-table.hh b/src/hb-ot-layout-gsub-table.hh index 25538d52f..ae57cbb10 100644 --- a/src/hb-ot-layout-gsub-table.hh +++ b/src/hb-ot-layout-gsub-table.hh @@ -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); }