From 95f503367fe121e4a7a8b45534b95669f9da5db8 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Wed, 21 Oct 2026 13:24:36 -0700 Subject: [PATCH] Type: the vertical ruby test passes with craft-fonts' Shippori Mincho MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- crates/text/src/tests_ruby.rs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/crates/text/src/tests_ruby.rs b/crates/text/src/tests_ruby.rs index 2435fa434..fa49bf13a 100644 --- a/crates/text/src/tests_ruby.rs +++ b/crates/text/src/tests_ruby.rs @@ -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 = 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:?}");