From b949038a2b15efc0ef6d0e335af098fd30da595e Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sat, 31 Oct 2026 21:09:39 -0700 Subject: [PATCH] .ai save: the editing copy draws the artboards' background colors The PDF pages of a .ai draw each artboard's background color (Include Artboard Fill, on by default), but the editing copy of the art left it out, so the two differed and the file reopened from its PDF part. The editing copy now takes the same option. --- crates/engine/src/cmd/fileio/save.rs | 4 +++- crates/engine/src/cmd/fileio/tests_artboard_fill.rs | 12 ++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/crates/engine/src/cmd/fileio/save.rs b/crates/engine/src/cmd/fileio/save.rs index 35cef3e56..85fea0cbd 100644 --- a/crates/engine/src/cmd/fileio/save.rs +++ b/crates/engine/src/cmd/fileio/save.rs @@ -648,11 +648,13 @@ pub(super) fn encode_ai(cmd: &str, f: &Format, doc: &Document, p: &Value) -> Res resolved = d; (&resolved, w) }; + // With the artboards' background colors, as the pages draw them. + let art = super::export::with_artboard_fills(art, ¶ms, 0..art.artboards.len()).map_err(|e| bad(cmd, e))?; let o = vectorcraft_eps::AiEditingOptions { title: doc.title.clone(), created: doc.metadata.created.or_else(vectorcraft_doc::metadata::output_time), }; - let (data, lost) = vectorcraft_eps::ai_private_data(art, &o).map_err(|e| bad(cmd, e))?; + let (data, lost) = vectorcraft_eps::ai_private_data(&art, &o).map_err(|e| bad(cmd, e))?; // Placed files that weren't found are written as their previews here too. resolved_warnings.extend(lost); carries_editing.set(true); diff --git a/crates/engine/src/cmd/fileio/tests_artboard_fill.rs b/crates/engine/src/cmd/fileio/tests_artboard_fill.rs index 28e170e06..9a7684686 100644 --- a/crates/engine/src/cmd/fileio/tests_artboard_fill.rs +++ b/crates/engine/src/cmd/fileio/tests_artboard_fill.rs @@ -97,6 +97,18 @@ fn pdf_and_svg_show_the_color_and_their_editing_data_keeps_it_as_the_artboards() assert_eq!(back.layers.len(), doc.layers.len(), "no art made of it"); } +#[test] +fn the_ai_editing_copy_for_other_apps_draws_the_color_as_the_pages_do() { + let mut s = session(); + let opts = LoadOptions { native: false, ..Default::default() }; + for (more, fill) in [(json!({}), true), (json!({"includeArtboardFill": false}), false)] { + let l = load::load_with("a.ai", &file(&mut s, with(json!({"format": "ai"}), &more)), &opts).unwrap(); + assert!(l.editing_data && !l.restored, "{more}: {:?}", l.warnings); + let names: Vec = l.doc.layers.iter().filter_map(|l| l.name.clone()).collect(); + assert_eq!(names.iter().any(|n| n == "Artboard Fill"), fill, "{more}: {names:?}"); + } +} + #[test] fn eps_and_postscript_print_draw_the_color() { let mut s = session();