From ac93f85125c1a4511507a8014bb3e7314be148bc Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Fri, 3 Jul 2026 22:52:44 -0600 Subject: [PATCH] [cff2] Accumulate deltas when a blend result feeds a later blend Chained blends (a blend result used as an operand of a later blend in the same charstring) are spec-legal and HB renders them correctly, but the symbolic (no-coords) interpretation overwrote the inner deltas via set_blends, silently corrupting desubroutinize and partial-instancing output. fontTools refuses such input; accumulating is exact. --- src/hb-cff2-interp-cs.hh | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/hb-cff2-interp-cs.hh b/src/hb-cff2-interp-cs.hh index 241524215..770a4ae36 100644 --- a/src/hb-cff2-interp-cs.hh +++ b/src/hb-cff2-interp-cs.hh @@ -264,6 +264,19 @@ struct cff2_cs_opset_t : cs_opset_t, PAR { if (env.have_coords ()) arg.set_int (round (arg.to_real () + env.blend_deltas (blends))); + else if (unlikely (arg.blending ())) + { + /* A blend result used as an operand of a later blend: the value is + * default + inner deltas + outer deltas, so accumulate the deltas. */ + hb_vector_t inner = std::move (arg.deltas); + arg.set_blends (n, i, blends); + if (likely (inner.length == arg.deltas.length)) + for (unsigned j = 0; j < inner.length; j++) + arg.deltas.arrayZ[j].set_real (arg.deltas.arrayZ[j].to_real () + + inner.arrayZ[j].to_real ()); + else + env.set_error (); + } else arg.set_blends (n, i, blends); }