Type: the vertical ruby test passes with craft-fonts' Shippori Mincho

tests_ruby::vertical_ruby_is_upright_to_the_right_of_the_column
checked that no reading glyph is more than 1 pt wider than tall. With
craft-fonts in the build, the kana come from Shippori Mincho, whose か
is 8.24 pt wide and 7.22 pt tall at 10 pt. The test failed on that
glyph although it stands upright. FreeBSD CI, which builds with
craft-fonts at a71c20e3, fails it on every branch since 14f804cd. It
also fails on Windows with that ref or an older craft-fonts checkout.

The test now compares each reading glyph's ink with its own outline at
10 pt. The same width and height mean the glyph is upright; a swapped
width and height mean it lies on its side. It also requires one
reading glyph whose outline is not square.
This commit is contained in:
dotCooCoo
2026-10-22 04:34:32 +07:00
committed by bflatastic
parent a339433c4b
commit 95f503367f
+10 -4
View File
@@ -142,12 +142,18 @@ fn vertical_ruby_is_upright_to_the_right_of_the_column() {
let ruby = ruby_ink(&lay);
assert!(ruby.x0 > base.x0, "ruby right of the column: {ruby:?} vs {base:?}");
assert!(ruby.x0 >= base.x1 - 1.0, "ruby outside the column: {ruby:?} vs {base:?}");
// Upright kana are taller than wide (they would be lying on their side if not).
// Upright: each reading glyph's ink has the width and height of its outline at 10 pt (half the
// base size); a glyph on its side has them swapped.
let mut not_square = false;
for g in &lay.ruby {
if let Some(b) = ink(g) {
assert!(b.width() <= b.height() + 1.0, "upright ruby glyph {b:?}");
}
let Some(r) = ink(g) else { continue };
let face = db().face_by_id(g.font_id).expect("the ruby glyph's face");
let o = db().outline(&face, g.gid).bounding_box();
let (w, h) = (o.width() * 10.0 / face.units_per_em(), o.height() * 10.0 / face.units_per_em());
assert!((r.width() - w).abs() < 0.01 && (r.height() - h).abs() < 0.01, "upright ruby glyph {r:?}, its outline {w} x {h}");
not_square |= (w - h).abs() > 0.5;
}
assert!(not_square, "one reading glyph's outline is not square");
// Down the column: the reading's glyphs have distinct y positions.
let ys: Vec<f64> = lay.ruby.iter().filter_map(|g| ink(g).map(|b| b.center().y)).collect();
assert!(ys.windows(2).any(|w| w[0] != w[1]), "the reading runs down the column: {ys:?}");