mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-10-24 09:46:59 -06:00
Merge pull request #3477 from dotCooCoo/fix/ruby-tests-with-ci-fonts
Type: the vertical ruby test passes with craft-fonts' Shippori Mincho
This commit is contained in:
@@ -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:?}");
|
||||
|
||||
Reference in New Issue
Block a user