From b28e8490c23a358bbefafe772544698498c4e7e0 Mon Sep 17 00:00:00 2001 From: vangel76 Date: Fri, 16 Oct 2026 19:56:05 +0200 Subject: [PATCH] Effects: skip type tests when built without craft-fonts (#2476) Co-Authored-By: Claude Opus 5.5 --- crates/effects/src/bake.rs | 36 ++++++++++++++++++++++++++++++++++++ crates/effects/src/group.rs | 21 +++++++++++++++++++++ 2 files changed, 57 insertions(+) diff --git a/crates/effects/src/bake.rs b/crates/effects/src/bake.rs index 6697f5b65..e0165c2ef 100644 --- a/crates/effects/src/bake.rs +++ b/crates/effects/src/bake.rs @@ -572,6 +572,15 @@ mod tests { use vectorcraft_doc::{CharStyle, Effect, NodeId, TextObject}; use vectorcraft_geom::{Point, Rect, shapes}; + /// Type tests need glyph outlines, which only the optional craft-fonts build input provides. + fn skip_without_craft_fonts() -> bool { + let skip = vectorcraft_text::CRAFT_FONTS.is_empty(); + if skip { + eprintln!("skipped: built without craft-fonts (set CRAFT_FONTS_DIR to a craft-fonts checkout to run it)"); + } + skip + } + fn fx(id: &str, params: serde_json::Value) -> Effect { Effect { id: id.into(), params, visible: true } } @@ -647,6 +656,9 @@ mod tests { #[test] fn type_moved_or_copied_by_a_groups_transform_effect_stays_type() { + if skip_without_craft_fonts() { + return; + } for (params, origins, square) in [ (json!({"moveH": 30}), vec![(50.0, 60.0)], Rect::new(30.0, 0.0, 40.0, 10.0)), (json!({"moveH": 200, "copies": 1}), vec![(20.0, 60.0), (220.0, 60.0)], Rect::new(0.0, 0.0, 210.0, 10.0)), @@ -678,6 +690,9 @@ mod tests { #[test] fn hidden_type_in_a_group_that_keeps_its_type_stays_hidden() { + if skip_without_craft_fonts() { + return; + } let mut g = type_group(vec![fx("distort.transform", json!({"moveH": 200, "copies": 1}))]); let mut hidden = type_node(55); hidden.visible = false; @@ -689,6 +704,9 @@ mod tests { #[test] fn type_outlined_next_to_type_that_stays_type_keeps_its_look() { + if skip_without_craft_fonts() { + return; + } let mut g = type_group(vec![fx("distort.transform", json!({"moveH": 200, "copies": 1}))]); let mut shadowed = type_node(55); shadowed.opacity = 0.5; @@ -711,6 +729,9 @@ mod tests { #[test] fn type_in_a_clipping_group_with_a_fill_of_its_own_is_outlined_plain() { + if skip_without_craft_fonts() { + return; + } let mut g = type_group(vec![fx("distort.transform", json!({"moveH": 200, "copies": 1}))]); // The clipping path is a group with a fill of its own, holding type with an effect of its own. let mut moved = type_node(60); @@ -729,6 +750,9 @@ mod tests { #[test] fn type_with_its_own_transform_effect_copies_stays_type() { + if skip_without_craft_fonts() { + return; + } let mut n = type_node(50); n.opacity = 0.5; n.appearance.effects = vec![fx("distort.transform", json!({"moveV": 50, "copies": 2})), fx("stylize.dropShadow", json!({}))]; @@ -775,6 +799,9 @@ mod tests { #[test] fn type_whose_copies_paint_over_each_other_is_still_outlined() { + if skip_without_craft_fonts() { + return; + } let moves = vec![fx("distort.transform", json!({"moveV": 40, "copies": 1}))]; assert_eq!(type_origins(&bake_document(&doc_with(type_group(moves.clone()))).unwrap()).len(), 2); // A 20 pt stroke on the characters reaches the copy below. @@ -790,6 +817,9 @@ mod tests { #[test] fn type_with_a_look_of_its_own_in_a_moved_group_is_still_outlined() { + if skip_without_craft_fonts() { + return; + } let moves = vec![fx("distort.transform", json!({"moveV": 40, "copies": 1}))]; let mut translucent = type_node(50); translucent.opacity = 0.5; @@ -862,6 +892,9 @@ mod tests { #[test] fn type_whose_copies_hold_too_much_is_still_outlined() { + if skip_without_craft_fonts() { + return; + } let spaced = |spaces: usize| { let mut n = type_node(50); if let NodeKind::Text(t) = &mut n.kind { @@ -899,6 +932,9 @@ mod tests { #[test] fn type_in_a_pathfinder_group_inside_a_moved_group_is_still_outlined() { + if skip_without_craft_fonts() { + return; + } let mut inner = type_group(vec![fx("pathfinder.add", json!({}))]); inner.id = NodeId(53); let mut outer = Node::group(NodeId(54), vec![Arc::new(inner)]); diff --git a/crates/effects/src/group.rs b/crates/effects/src/group.rs index 78d51dca8..69425b907 100644 --- a/crates/effects/src/group.rs +++ b/crates/effects/src/group.rs @@ -293,6 +293,15 @@ mod tests { use vectorcraft_doc::{CharStyle, Effect, NodeId, TextObject}; use vectorcraft_geom::{Point, Rect, shapes}; + /// Type tests need glyph outlines, which only the optional craft-fonts build input provides. + fn skip_without_craft_fonts() -> bool { + let skip = vectorcraft_text::CRAFT_FONTS.is_empty(); + if skip { + eprintln!("skipped: built without craft-fonts (set CRAFT_FONTS_DIR to a craft-fonts checkout to run it)"); + } + skip + } + fn sq(id: u64, x: f64, color: Color) -> Arc { Arc::new(Node::path( NodeId(id), @@ -350,6 +359,9 @@ mod tests { #[test] fn type_changes_the_result_of_every_pathfinder_effect() { + if skip_without_craft_fonts() { + return; + } let glyphs = crate::outline_text(&type_h()).unwrap(); let b = glyphs.geometric_bounds().unwrap(); assert!(b.x0 < 100.0 && b.x1 > 100.0 && b.y0 > 0.0 && b.y1 < 100.0, "{b:?}"); @@ -377,6 +389,9 @@ mod tests { #[test] fn pieces_of_type_keep_its_paint_opacity_and_blend_mode() { + if skip_without_craft_fonts() { + return; + } let mut t = type_h(); (t.opacity, t.blend) = (0.5, BlendMode::Multiply); let look = |p: &Arc| (p.appearance.fill_paint(), p.opacity, p.blend); @@ -418,6 +433,9 @@ mod tests { #[test] fn type_in_a_group_keeps_its_look_when_the_groups_geometry_effects_outline_it() { + if skip_without_craft_fonts() { + return; + } use vectorcraft_color::BlendMode; let art = type_in_group(|t| (t.opacity, t.blend) = (0.5, BlendMode::Multiply)); assert!(art.id == NodeId(3) && !matches!(art.kind, NodeKind::Text(_)), "{art:?}"); @@ -447,6 +465,9 @@ mod tests { #[test] fn a_transform_on_a_group_moves_the_gradients_of_its_type_and_not_those_placed_on_its_paths() { + if skip_without_craft_fonts() { + return; + } use vectorcraft_color::{Gradient, GradientGeom, GradientKind, GradientPaint, GradientStop}; let stops = vec![GradientStop::new(0.0, Color::rgb(1.0, 0.0, 0.0)), GradientStop::new(1.0, Color::rgb(0.0, 0.0, 1.0))]; let ramp = GradientPaint::new(Gradient { kind: GradientKind::Linear, stops });