diff --git a/crates/engine/tests/import_fuzz.rs b/crates/engine/tests/import_fuzz.rs index 9ff294a878..c6f02b9240 100644 --- a/crates/engine/tests/import_fuzz.rs +++ b/crates/engine/tests/import_fuzz.rs @@ -929,7 +929,20 @@ fn mutate_text(src: &str, cut: usize, edits: &[(usize, char)]) -> String { fn svg_type_shifted_two_billion_points_exports_to_pdf() { let svg = r#"f"#; let d = vectorcraft_svg::import(svg).unwrap(); - assert!(vectorcraft_engine::export_pdf(&d, &vectorcraft_pdf::PdfOptions::default()).is_ok()); + // The type opens with its shift, so the export below meets a glyph that far out. + let mut shifts = Vec::new(); + d.walk(|n| { + if let vectorcraft_doc::NodeKind::Text(t) = &n.kind { + shifts.extend(t.runs.iter().map(|r| r.style.baseline_shift)); + } + }); + assert!(shifts.iter().any(|&s| s.abs() > 2e9), "baseline shifts read: {shifts:?}"); + let pdf = vectorcraft_engine::export_pdf(&d, &vectorcraft_pdf::PdfOptions::default()).unwrap(); + // The PDF leaves the type out: reading it back finds no type. + let back = vectorcraft_pdf::import(&pdf).unwrap(); + let mut text = 0; + back.walk(|n| text += usize::from(matches!(n.kind, vectorcraft_doc::NodeKind::Text(_)))); + assert_eq!(text, 0, "type left out of the page"); } proptest! { @@ -8630,6 +8643,16 @@ fn a_long_thin_shape_with_a_shadow_renders_and_exports() { let stream = canvas_stream(vec![with_effects(rectangle(10, (0.0, 0.0), (3_276_800.0, 50.0)), vec![shadow()])]); let bytes = affinity_sample_file(&stream, None); let doc = vectorcraft_engine::cmd::fileio::load("long.af", &bytes).unwrap().doc; + // The shape opens whole, with its shadow, so the exports below draw the shadow that far out. + let mut shadowed = Vec::new(); + doc.walk(|n| { + if n.appearance.effects.iter().any(|e| e.id == "stylize.dropShadow") { + shadowed.push(n.id); + } + }); + assert_eq!(shadowed.len(), 1, "one shape with a drop shadow"); + let width = doc.bounds_of(&shadowed, false).map(|r| r.width()); + assert!(width.is_some_and(|w| w > 3_000_000.0), "the shape is {width:?} pt wide"); survive("long shape", || Some(doc)).unwrap(); }