From bba03f1e2b308ad2a237ac53e35c84e73e50956c Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Thu, 19 Nov 2026 12:05:41 -0800 Subject: [PATCH] Retype: an explicit null for fonts or tolerance is an invalid parameter --- crates/engine/src/cmd/retype.rs | 4 ++-- crates/engine/src/cmd/retype_tests.rs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/crates/engine/src/cmd/retype.rs b/crates/engine/src/cmd/retype.rs index 7daa1d424c..d7381200f9 100644 --- a/crates/engine/src/cmd/retype.rs +++ b/crates/engine/src/cmd/retype.rs @@ -648,14 +648,14 @@ fn lookup_keys<'a>( fn retype(s: &mut Session, p: &Value) -> Result { const C: &str = "type.retype"; let fonts: Vec = match p.get("fonts") { - None | Some(Value::Null) => vec![], + None => vec![], Some(Value::Array(a)) => { a.iter().map(|v| v.as_str().map(str::to_owned).ok_or_else(|| bad(C, "fonts must be a list of family names"))).collect::>()? } Some(_) => return Err(bad(C, "fonts must be a list of family names")), }; let tolerance = match p.get("tolerance") { - None | Some(Value::Null) => 0.0, + None => 0.0, Some(v) => match v.as_f64() { Some(t) if (0.0..=vectorcraft_text::retype::MAX_TOLERANCE).contains(&t) => t, _ => return Err(bad(C, "tolerance must be a number from 0 to 0.05")), diff --git a/crates/engine/src/cmd/retype_tests.rs b/crates/engine/src/cmd/retype_tests.rs index 48bf680e75..0a99f20924 100644 --- a/crates/engine/src/cmd/retype_tests.rs +++ b/crates/engine/src/cmd/retype_tests.rs @@ -90,7 +90,7 @@ fn a_drawn_shape_is_reported_and_left_alone() { let g = outlined(&mut s, json!({"x": 40, "y": 200, "text": "AB", "size": 40})); s.execute("select.set", &json!({"ids": [g]})).unwrap(); let before = s.doc().unwrap().doc.clone(); - for bad in [json!("Source Sans 3"), json!([1]), json!({"family": "x"})] { + for bad in [json!("Source Sans 3"), json!([1]), json!({"family": "x"}), json!(null)] { let e = s.execute("type.retype", &json!({"fonts": bad})).unwrap_err().to_string(); assert!(e.contains("fonts must be a list of family names"), "{e}"); } @@ -596,7 +596,7 @@ fn simplified_outlines_retype_only_with_a_tolerance_and_report_their_score() { let before = s.doc().unwrap().doc.clone(); let e = s.execute("type.retype", &json!({})).unwrap_err().to_string(); assert!(e.contains("no selected shape matches"), "no exact match: {e}"); - for bad in [json!(-0.01), json!(0.06), json!("0.02"), json!(true)] { + for bad in [json!(-0.01), json!(0.06), json!("0.02"), json!(true), json!(null)] { let e = s.execute("type.retype", &json!({"tolerance": bad})).unwrap_err().to_string(); assert!(e.contains("tolerance must be a number from 0 to 0.05"), "{e}"); }