mirror of
https://github.com/storytold/harfbuzz.git
synced 2026-11-20 14:31:10 +01:00
[ot-metrics] Use the vertical descender in the fallback (#6466)
Fonts without vhea returned the ascender for the vertical descender metric. Read the descender from the synthesized vertical font extents, as the horizontal fallback already does. Add a regression comparing all three fallback vertical metrics with the font extents. It fails before this change (1024 versus -1024). The full Meson suite passes (293 tests). Reported by Anthropic's OSS Scanner as ordinary bug ANT-2026-4UNO2SK8. Assisted-by: OpenAI Codex
This commit is contained in:
1 parent
1e6a7f38ee
commit
879be16fdf
2 files changed
+28
-1
No files matched your search
@@ -301,7 +301,7 @@ hb_ot_metrics_get_position_with_fallback (hb_font_t *font,
|
||||
|
||||
case HB_OT_METRICS_TAG_VERTICAL_DESCENDER:
|
||||
hb_font_get_extents_for_direction (font, HB_DIRECTION_TTB, &font_extents);
|
||||
*position = font_extents.ascender;
|
||||
*position = font_extents.descender;
|
||||
break;
|
||||
|
||||
case HB_OT_METRICS_TAG_HORIZONTAL_LINE_GAP:
|
||||
|
||||
@@ -68,11 +68,38 @@ test_ot_metrics_get_var (void)
|
||||
hb_face_destroy (face);
|
||||
}
|
||||
|
||||
static void
|
||||
test_ot_metrics_get_with_fallback (void)
|
||||
{
|
||||
/* No vhea table: vertical metrics are synthesized. */
|
||||
hb_face_t *face = hb_test_open_font_file ("fonts/Roboto-Regular.abc.ttf");
|
||||
hb_font_t *font = hb_font_create (face);
|
||||
hb_font_extents_t extents;
|
||||
hb_position_t value;
|
||||
|
||||
g_assert_false (hb_ot_metrics_get_position (font, HB_OT_METRICS_TAG_VERTICAL_ASCENDER, &value));
|
||||
g_assert_false (hb_ot_metrics_get_position (font, HB_OT_METRICS_TAG_VERTICAL_DESCENDER, &value));
|
||||
|
||||
hb_font_get_extents_for_direction (font, HB_DIRECTION_TTB, &extents);
|
||||
g_assert_cmpint (extents.ascender, !=, extents.descender);
|
||||
|
||||
hb_ot_metrics_get_position_with_fallback (font, HB_OT_METRICS_TAG_VERTICAL_ASCENDER, &value);
|
||||
g_assert_cmpint (value, ==, extents.ascender);
|
||||
hb_ot_metrics_get_position_with_fallback (font, HB_OT_METRICS_TAG_VERTICAL_DESCENDER, &value);
|
||||
g_assert_cmpint (value, ==, extents.descender);
|
||||
hb_ot_metrics_get_position_with_fallback (font, HB_OT_METRICS_TAG_VERTICAL_LINE_GAP, &value);
|
||||
g_assert_cmpint (value, ==, extents.line_gap);
|
||||
|
||||
hb_font_destroy (font);
|
||||
hb_face_destroy (face);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
hb_test_init (&argc, &argv);
|
||||
hb_test_add (test_ot_metrics_get_no_var);
|
||||
hb_test_add (test_ot_metrics_get_var);
|
||||
hb_test_add (test_ot_metrics_get_with_fallback);
|
||||
return hb_test_run ();
|
||||
}
|
||||
Reference in new issue
Block a user