Tests: the paragraph indent test loads system fonts and skips only without glyphs (#1227)

This commit is contained in:
aiongg
2026-10-23 13:50:42 -04:00
committed by GitHub
parent c48102350b
commit 6ba0223636
+5 -6
View File
@@ -177,20 +177,19 @@ fn vertical_trim_through_node_set() {
#[test]
fn paragraph_indent_only_moves_left_aligned_text() {
figcraft_text::scan_system_fonts();
let mut s = Session::new();
let t = text(&mut s, "Indented paragraph", json!({"fontSize": 20, "paragraphIndent": 30}));
let first_x = |s: &Session| {
let (l, _) = figcraft_text::layout_node(s.doc().unwrap().node(t).unwrap()).unwrap();
(l.glyphs.first().map_or(0.0, |g| g.x), l.width)
(l.glyphs.first().map(|g| g.x), l.width)
};
let (x, w) = first_x(&s);
if w <= 0.0 {
return;
}
// Without any font there are no glyphs, but the indent alone still gives the box a width.
let (Some(x), w) = first_x(&s) else { return };
assert!((x - 30.0).abs() < 1e-6, "left: indented");
s.execute("node.set", &json!({"id": t, "props": {"textAlign": "center"}})).unwrap();
let (x, w2) = first_x(&s);
assert!((w2 - (w - 30.0)).abs() < 1e-6 && x.abs() < 1e-6, "centered auto-width text: no indent, the box shrinks by it");
assert!((w2 - (w - 30.0)).abs() < 1e-6 && x.is_some_and(|x| x.abs() < 1e-6), "centered auto-width text: no indent, the box shrinks by it");
}
/// A new text made with the Text tool by a press at `from`, a drag to `to` and a release, holding