Skip to content

VectorCraft: An open-source, vector art tool written by scratch in pure Rust

EPS import: the printer's crop marks after the layers aren't art outside them

Don Omondi2d4e9dc9c952
diff --git a/crates/eps/src/import/ai/read/types.rs b/crates/eps/src/import/ai/read/types.rs
index 95423c94e..fccbc6c48 100644
--- a/crates/eps/src/import/ai/read/types.rs
+++ b/crates/eps/src/import/ai/read/types.rs
@@ -246,6 +246,9 @@ pub(super) const SKIPPED: &[(&str, &str)] = &[
("BeginSymbolList", "EndSymbolList"),
("BeginTextDocument", "EndTextDocument"),
("BeginEncoding", "EndEncoding"),
+ // The printer's crop marks, drawn after the layers (`userdict /AI3_noCropMarks known not {
+ // … } if`); the crop area they mark is `%AI3_Cropmarks`.
+ ("BeginCrops", "EndCrops"),
];
/// The note for versioned content whose `%AI17_End_Versioned_Content` is missing: every
diff --git a/crates/eps/src/import/ai/tests.rs b/crates/eps/src/import/ai/tests.rs
index 1c3ff8acc..813113d5b 100644
--- a/crates/eps/src/import/ai/tests.rs
+++ b/crates/eps/src/import/ai/tests.rs
@@ -1929,3 +1929,15 @@ fn a_blend_record_is_read_to_its_length() {
let (blend, warnings) = read_blend(&blend_file("%_10 50 m\n%_110 50 L\n", [Some("A"), Some("B")], &longer));
assert!(matches!(blend.kind, NodeKind::Blend { .. }), "{warnings:?}");
}
+
+/// The printer's crop marks Illustrator draws after the last layer (`%AI3_BeginCrops`, inside
+/// `userdict /AI3_noCropMarks known not { … } if`) aren't art outside the layers: the file reads
+/// from its layers, without them (the crop area is `%AI3_Cropmarks`).
+#[test]
+fn crop_marks_after_the_layers_are_not_art() {
+ let crops = "%AI3_BeginCrops\nuserdict /AI3_noCropMarks known not {\n0 A\nu\n0 R\n1 1 1 1 ([Registration]) 0 XS\n\
+ 0 J 0 j 0.5 w 4 M []0 d\n0 XR\n-9 -400 m\n-36 -400 L\nS\nU\n} if\n%AI3_EndCrops\n";
+ let r = read_ok(&format!("{}{crops}", layer(&(rect_path(0.0, 0.0, 1.0, 1.0) + "f\n"))));
+ assert_eq!(art(&r.doc).len(), 1);
+ assert_eq!(r.doc.layers.len(), 1);
+}