From be6b6ab2b50d9bf99203e904cd1137cb60aeaa23 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Thu, 29 Oct 2026 19:07:27 -0600 Subject: [PATCH] [subset] Use outline bounds for instanced CFF2 metrics (#6469) The bounds vectors used to rebuild hhea and vhea expect non-negative widths and heights, with a sentinel for glyphs without outlines. CFF2 instancing stored negative extents.height values and replaced the sentinel for empty glyphs. Store yMax - yMin and preserve empty bounds. Regenerate the three affected expected fonts through the subset test generator. Only header metrics and checksums change. The new vhea values agree with FontTools recalculation from the glyph outlines. Both affected test cases fail without the source fix; the full Meson suite passes with it (293 tests). Reported by Anthropic's OSS Scanner as ordinary bug ANT-2026-3LQ6CVVN. Assisted-by: OpenAI Codex --- src/hb-subset-plan-var.cc | 6 ++++-- ...,6F,20,57,6F,72,6C,64.wght=400,opsz=20.otf | Bin 2968 -> 2968 bytes ...,6F,20,57,6F,72,6C,64.wght=650,opsz=48.otf | Bin 2912 -> 2912 bytes ...t.default.5005,5006,5009,500D.wght=300.otf | Bin 2124 -> 2124 bytes 4 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/hb-subset-plan-var.cc b/src/hb-subset-plan-var.cc index a1b13dd2a..1a8082cc6 100644 --- a/src/hb-subset-plan-var.cc +++ b/src/hb-subset-plan-var.cc @@ -755,7 +755,8 @@ update_instance_metrics_map_from_cff2 (hb_subset_plan_t *plan) _hmtx.get_leading_bearing_without_var_unscaled (old_gid, &lsb); } plan->hmtx_map.set (new_gid, hb_pair ((unsigned) hori_aw, lsb)); - plan->bounds_width_vec[new_gid] = extents.width; + if (has_bounds_info) + plan->bounds_width_vec[new_gid] = extents.width; } if (_vmtx.has_data ()) @@ -777,7 +778,8 @@ update_instance_metrics_map_from_cff2 (hb_subset_plan_t *plan) } plan->vmtx_map.set (new_gid, hb_pair ((unsigned) vert_aw, tsb)); - plan->bounds_height_vec[new_gid] = extents.height; + if (has_bounds_info) + plan->bounds_height_vec[new_gid] = hb_saturate_neg (extents.height); } } /* No glyph contributed bounds: do not serialize the accumulator's diff --git a/test/subset/data/expected/downgrade_cff2/SourceSerif4Variable-Roman-HelloWorld.downgrade-cff2.48,65,6C,6C,6F,20,57,6F,72,6C,64.wght=400,opsz=20.otf b/test/subset/data/expected/downgrade_cff2/SourceSerif4Variable-Roman-HelloWorld.downgrade-cff2.48,65,6C,6C,6F,20,57,6F,72,6C,64.wght=400,opsz=20.otf index e08da9e97c158a3bbbca939708a93078624582bb..d2a70513bb740698b39c9a74ff634078b9de4765 100644 GIT binary patch delta 24 gcmbOsK0|!MM8<0qCrxMMpRC1L&KSLU5#u*b0CXk^2LJ#7 delta 24 gcmbOsK0|!MM8@M2CrxK$n5@NE&RDs55#u*b0COh^2LJ#7 diff --git a/test/subset/data/expected/downgrade_cff2/SourceSerif4Variable-Roman-HelloWorld.downgrade-cff2.48,65,6C,6C,6F,20,57,6F,72,6C,64.wght=650,opsz=48.otf b/test/subset/data/expected/downgrade_cff2/SourceSerif4Variable-Roman-HelloWorld.downgrade-cff2.48,65,6C,6C,6F,20,57,6F,72,6C,64.wght=650,opsz=48.otf index f623441a95dd6682b7ceba6d27e28f910c829c5b..999d9e9e25de43e606c6d4bb7c9bcabd647e7180 100644 GIT binary patch delta 25 hcmaDL_CRdHM8@S4CrxMMo~*@K#&quO=0%MAI02063W@*# delta 25 hcmaDL_CRdHM8-K2CrxK$n5@NE#&n)}^CHH5oB)O(35x&# diff --git a/test/subset/data/expected/instantiate_cff2_tsb/NotoSansJP-VF.subset.default.5005,5006,5009,500D.wght=300.otf b/test/subset/data/expected/instantiate_cff2_tsb/NotoSansJP-VF.subset.default.5005,5006,5009,500D.wght=300.otf index 2e62a8a0d3df2cb67d890822894cb18c639c79af..0eae3260a71e306adfbcfcb4a435ab9127ae158a 100644 GIT binary patch delta 34 qcmX>ja7JLl0~Xc?LW&cgY-H7C&|%&)c^0D|%gwF?tIcm16W9Rj*$oQ- delta 34 scmV+-0Nwx05X=ye-~<8p72T2Ku>}AF=l}qdngLD(;aph4v+Mz22LGiF3IG5A