From c6b0cd5e071f65698180987fe76a21c5e5013bfb Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Sat, 28 Feb 2026 03:32:56 -0300 Subject: [PATCH] [subset] Skip GPOS value format optimization for avar2 Don't compute effective value formats using layout_variation_idx_delta_map when has_avar2 is true. The delta map contains wrong deltas (computed from intermediate-space coords, not final coords) and could incorrectly strip device table format flags, breaking GPOS variation references. Co-Authored-By: Claude Opus 4.6 (1M context) --- src/OT/Layout/GPOS/PairPosFormat1.hh | 2 +- src/OT/Layout/GPOS/PairPosFormat2.hh | 2 +- src/OT/Layout/GPOS/SinglePosFormat1.hh | 2 +- src/OT/Layout/GPOS/SinglePosFormat2.hh | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/OT/Layout/GPOS/PairPosFormat1.hh b/src/OT/Layout/GPOS/PairPosFormat1.hh index a8ded1e75..6bb5bbdc3 100644 --- a/src/OT/Layout/GPOS/PairPosFormat1.hh +++ b/src/OT/Layout/GPOS/PairPosFormat1.hh @@ -156,7 +156,7 @@ struct PairPosFormat1_3 hb_pair_t newFormats = hb_pair (valueFormat[0], valueFormat[1]); - if (c->plan->normalized_coords) + if (c->plan->normalized_coords && !c->plan->has_avar2) { /* all device flags will be dropped when full instancing, no need to strip * hints, also do not strip emtpy cause we don't compute the new default diff --git a/src/OT/Layout/GPOS/PairPosFormat2.hh b/src/OT/Layout/GPOS/PairPosFormat2.hh index e7320b932..85bca2a0c 100644 --- a/src/OT/Layout/GPOS/PairPosFormat2.hh +++ b/src/OT/Layout/GPOS/PairPosFormat2.hh @@ -312,7 +312,7 @@ struct PairPosFormat2_4 : ValueBase hb_pair_t newFormats = hb_pair (valueFormat1, valueFormat2); - if (c->plan->normalized_coords) + if (c->plan->normalized_coords && !c->plan->has_avar2) { /* in case of full instancing, all var device flags will be dropped so no * need to strip hints here */ diff --git a/src/OT/Layout/GPOS/SinglePosFormat1.hh b/src/OT/Layout/GPOS/SinglePosFormat1.hh index 4792a4974..4238a17d5 100644 --- a/src/OT/Layout/GPOS/SinglePosFormat1.hh +++ b/src/OT/Layout/GPOS/SinglePosFormat1.hh @@ -149,7 +149,7 @@ struct SinglePosFormat1 : ValueBase unsigned new_format = valueFormat; - if (c->plan->normalized_coords) + if (c->plan->normalized_coords && !c->plan->has_avar2) { new_format = valueFormat.get_effective_format (values.arrayZ, false, false, this, &c->plan->layout_variation_idx_delta_map); } diff --git a/src/OT/Layout/GPOS/SinglePosFormat2.hh b/src/OT/Layout/GPOS/SinglePosFormat2.hh index dc92f6a52..97ecd286a 100644 --- a/src/OT/Layout/GPOS/SinglePosFormat2.hh +++ b/src/OT/Layout/GPOS/SinglePosFormat2.hh @@ -195,7 +195,7 @@ struct SinglePosFormat2 : ValueBase ; unsigned new_format = compute_effective_format (c->plan->source, it, - bool (c->plan->normalized_coords), + bool (c->plan->normalized_coords) && !c->plan->has_avar2, bool (c->plan->flags & HB_SUBSET_FLAGS_NO_HINTING), c->plan->has_gdef_varstore, &c->plan->layout_variation_idx_delta_map);