From bf4b34e87e5d7428b7b206a38ce6d7948657a9cb Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Sun, 19 Feb 2023 11:16:51 -0700 Subject: [PATCH] [subset-cff2] Don't encode vsindex in Private dict --- src/hb-subset-cff-common.hh | 14 +++++++++----- src/hb-subset-cff2.cc | 2 +- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/hb-subset-cff-common.hh b/src/hb-subset-cff-common.hh index 2b7870c4e..ea67dba1b 100644 --- a/src/hb-subset-cff-common.hh +++ b/src/hb-subset-cff-common.hh @@ -192,8 +192,8 @@ struct cff_font_dict_op_serializer_t : op_serializer_t struct cff_private_dict_op_serializer_t : op_serializer_t { - cff_private_dict_op_serializer_t (bool desubroutinize_, bool drop_hints_) - : desubroutinize (desubroutinize_), drop_hints (drop_hints_) {} + cff_private_dict_op_serializer_t (bool desubroutinize_, bool drop_hints_, bool pinned_ = false) + : desubroutinize (desubroutinize_), drop_hints (drop_hints_), pinned (pinned_) {} bool serialize (hb_serialize_context_t *c, const op_str_t &opstr, @@ -202,7 +202,10 @@ struct cff_private_dict_op_serializer_t : op_serializer_t TRACE_SERIALIZE (this); if (drop_hints && dict_opset_t::is_hint_op (opstr.op)) - return true; + return_trace (true); + if (pinned && opstr.op == OpCode_vsindexdict) + return_trace (true); + if (opstr.op == OpCode_Subrs) { if (desubroutinize || !subrs_link) @@ -215,8 +218,9 @@ struct cff_private_dict_op_serializer_t : op_serializer_t } protected: - const bool desubroutinize; - const bool drop_hints; + const bool desubroutinize; + const bool drop_hints; + const bool pinned; }; struct flatten_param_t diff --git a/src/hb-subset-cff2.cc b/src/hb-subset-cff2.cc index 9bf28e87b..23bab9d8b 100644 --- a/src/hb-subset-cff2.cc +++ b/src/hb-subset-cff2.cc @@ -361,7 +361,7 @@ static bool _serialize_cff2 (hb_serialize_context_t *c, PrivateDict *pd = c->start_embed (); if (unlikely (!pd)) return false; c->push (); - cff_private_dict_op_serializer_t privSzr (plan.desubroutinize, plan.drop_hints); + cff_private_dict_op_serializer_t privSzr (plan.desubroutinize, plan.drop_hints, plan.pinned); if (likely (pd->serialize (c, acc.privateDicts[i], privSzr, subrs_link))) { unsigned fd = plan.fdmap[i];