[subset-cff2] Don't encode vsindex in Private dict

This commit is contained in:
Behdad Esfahbod 2023-02-19 11:16:51 -07:00
parent 220caa7e09
commit bf4b34e87e
2 changed files with 10 additions and 6 deletions

View File

@ -192,8 +192,8 @@ struct cff_font_dict_op_serializer_t : op_serializer_t
struct cff_private_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_) cff_private_dict_op_serializer_t (bool desubroutinize_, bool drop_hints_, bool pinned_ = false)
: desubroutinize (desubroutinize_), drop_hints (drop_hints_) {} : desubroutinize (desubroutinize_), drop_hints (drop_hints_), pinned (pinned_) {}
bool serialize (hb_serialize_context_t *c, bool serialize (hb_serialize_context_t *c,
const op_str_t &opstr, const op_str_t &opstr,
@ -202,7 +202,10 @@ struct cff_private_dict_op_serializer_t : op_serializer_t
TRACE_SERIALIZE (this); TRACE_SERIALIZE (this);
if (drop_hints && dict_opset_t::is_hint_op (opstr.op)) 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 (opstr.op == OpCode_Subrs)
{ {
if (desubroutinize || !subrs_link) if (desubroutinize || !subrs_link)
@ -215,8 +218,9 @@ struct cff_private_dict_op_serializer_t : op_serializer_t
} }
protected: protected:
const bool desubroutinize; const bool desubroutinize;
const bool drop_hints; const bool drop_hints;
const bool pinned;
}; };
struct flatten_param_t struct flatten_param_t

View File

@ -361,7 +361,7 @@ static bool _serialize_cff2 (hb_serialize_context_t *c,
PrivateDict *pd = c->start_embed<PrivateDict> (); PrivateDict *pd = c->start_embed<PrivateDict> ();
if (unlikely (!pd)) return false; if (unlikely (!pd)) return false;
c->push (); 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))) if (likely (pd->serialize (c, acc.privateDicts[i], privSzr, subrs_link)))
{ {
unsigned fd = plan.fdmap[i]; unsigned fd = plan.fdmap[i];