From a6a8d7149cb2a70b2bec86c0b5544b77a8b70785 Mon Sep 17 00:00:00 2001 From: NetterSilver <133535268+Silvertree2010@users.noreply.github.com> Date: Sun, 25 Oct 2026 03:52:14 +0000 Subject: [PATCH] Scale the path of text on a path in transform.scale Found while testing crates/engine/src/cmd/arrange.rs:~495 (scale_node, the Text branch). Compare crates/layout/src/lib.rs:136, which calls TextPath::scale on resize. Co-Authored-By: Claude Haiku 5.5 Co-Authored-By: Claude Sonnet 5.5 --- crates/engine/src/cmd/arrange.rs | 3 +++ crates/engine/src/draw_tools_tests.rs | 12 ++++++++++++ 2 files changed, 15 insertions(+) diff --git a/crates/engine/src/cmd/arrange.rs b/crates/engine/src/cmd/arrange.rs index 10ad13e5..72f2118a 100644 --- a/crates/engine/src/cmd/arrange.rs +++ b/crates/engine/src/cmd/arrange.rs @@ -494,6 +494,9 @@ pub fn scale_node(doc: &mut Document, id: NodeId, k: f64) -> Result<()> { t.paragraph_spacing *= k; t.paragraph_indent *= k; t.list_spacing *= k; + if let Some(tp) = &mut t.path { + tp.scale(k, k); + } } if let NodeKind::Vector { network } = &mut n.kind { network.scale(k, k); diff --git a/crates/engine/src/draw_tools_tests.rs b/crates/engine/src/draw_tools_tests.rs index d67b0af4..adfbb32d 100644 --- a/crates/engine/src/draw_tools_tests.rs +++ b/crates/engine/src/draw_tools_tests.rs @@ -60,6 +60,18 @@ fn text_goes_onto_a_path_and_off_again() { assert!(s.doc().unwrap().node(v).is_some() && text_path(&s, t).is_none(), "undo brings the path back"); } +#[test] +fn scaling_text_scales_its_path() { + let mut s = Session::new(); + let t = id(s.execute("text.create", &json!({"text": "Around", "x": 0, "y": 0})).unwrap()); + let v = id(s.execute("vector.create", &json!({"path": "M0 0 C50 -50 150 -50 200 0", "x": 40, "y": 100})).unwrap()); + s.execute("text.onPath", &json!({"ids": [t, v]})).unwrap(); + let w0 = figcraft_geom::Shape::bounding_box(&text_path(&s, t).unwrap().path()).width(); + s.execute("transform.scale", &json!({"ids": [t], "factor": 2.0})).unwrap(); + let w1 = figcraft_geom::Shape::bounding_box(&text_path(&s, t).unwrap().path()).width(); + assert!((w1 - w0 * 2.0).abs() < 1.0, "path width {w0} -> {w1}"); +} + #[test] fn svg_text_paths_import_as_text_on_a_path() { // SVG text is parsed with Inter standing in for every family (CI has no fonts).