From f030bd21868766c27fae7086221c837c4ba2eba7 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Thu, 29 Oct 2026 19:28:41 -0600 Subject: [PATCH] [ot-layout] Convert script tags for hanging baseline synthesis (#6467) The baseline fallback accepts an OpenType script tag but compared it with hb_script_t values. Convert the tag before choosing the glyph used to synthesize the hanging baseline. Exercise Bengali's old and new OpenType tags, Tibetan, and the script and language entry point. The updated test fails before the fix (622 versus 600); the full Meson suite passes (293 tests). Reported by Anthropic's OSS Scanner as ordinary bug ANT-2026-COIT72UF. Assisted-by: OpenAI Codex --- src/hb-ot-layout.cc | 2 +- test/api/test-baseline.c | 16 ++++++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/hb-ot-layout.cc b/src/hb-ot-layout.cc index bdc7e1d24..22e41e24a 100644 --- a/src/hb-ot-layout.cc +++ b/src/hb-ot-layout.cc @@ -2520,7 +2520,7 @@ hb_ot_layout_get_baseline_with_fallback (hb_font_t *font, hb_glyph_extents_t extents; /* Keep in sync with hb_ot_layout_get_horizontal_baseline_for_script */ - switch ((int) script_tag) + switch ((int) hb_ot_tag_to_script (script_tag)) { /* Unicode-1.1 additions */ case HB_SCRIPT_BENGALI: ch = 0x0995u; break; diff --git a/test/api/test-baseline.c b/test/api/test-baseline.c index 69412c20f..5db0616a3 100644 --- a/test/api/test-baseline.c +++ b/test/api/test-baseline.c @@ -105,13 +105,25 @@ test_ot_layout_base_with_fallback (void) font = hb_font_create (face); hb_ot_layout_get_baseline_with_fallback (font, HB_OT_LAYOUT_BASELINE_TAG_HANGING, HB_DIRECTION_LTR, - HB_SCRIPT_BENGALI, + HB_TAG ('b','e','n','g'), HB_TAG ('E','N','G',' '), &position); g_assert_cmpint (622, ==, position); hb_ot_layout_get_baseline_with_fallback (font, HB_OT_LAYOUT_BASELINE_TAG_HANGING, HB_DIRECTION_LTR, - HB_SCRIPT_TIBETAN, + HB_TAG ('b','n','g','2'), + HB_TAG ('E','N','G',' '), + &position); + g_assert_cmpint (622, ==, position); + + hb_ot_layout_get_baseline_with_fallback2 (font, HB_OT_LAYOUT_BASELINE_TAG_HANGING, HB_DIRECTION_LTR, + HB_SCRIPT_BENGALI, + hb_language_from_string ("bn", -1), + &position); + g_assert_cmpint (622, ==, position); + + hb_ot_layout_get_baseline_with_fallback (font, HB_OT_LAYOUT_BASELINE_TAG_HANGING, HB_DIRECTION_LTR, + HB_TAG ('t','i','b','t'), HB_TAG ('E','N','G',' '), &position); g_assert_cmpint (600, ==, position);