From a48e65ba68fc7fcc55f85a04904dbba181010042 Mon Sep 17 00:00:00 2001 From: nrq6993-a11y Date: Mon, 19 Oct 2026 04:35:33 +0300 Subject: [PATCH] G9: map AI5_RulerUnits value 6 to pixels on .ai import Co-authored-by: Cursor --- crates/eps/src/import/ai/read.rs | 4 ++-- crates/eps/src/import/ai/tests.rs | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/crates/eps/src/import/ai/read.rs b/crates/eps/src/import/ai/read.rs index 45c89569b..c0d54d96b 100644 --- a/crates/eps/src/import/ai/read.rs +++ b/crates/eps/src/import/ai/read.rs @@ -81,7 +81,7 @@ const MAX_HEX: usize = (MAX_PIXELS as usize) * 10; /// Largest side of the document and its artboards (points). const MAX_SIDE: f64 = 1e6; -/// `%AI5_RulerUnits` → [`Unit`] (Illustrator 7 spec table 3; 4 and 5 are centimeters and pixels in later files). +/// `%AI5_RulerUnits` → [`Unit`] (Illustrator 7 spec table 3; centimeters is 4; pixels is 6 in later files). fn ruler_unit(v: u8) -> Option { Some(match v { 0 => Unit::Inches, @@ -89,7 +89,7 @@ fn ruler_unit(v: u8) -> Option { 2 => Unit::Points, 3 => Unit::Picas, 4 => Unit::Centimeters, - 5 => Unit::Pixels, + 5 | 6 => Unit::Pixels, _ => return None, }) } diff --git a/crates/eps/src/import/ai/tests.rs b/crates/eps/src/import/ai/tests.rs index b6c8c9e5c..28cf71fc1 100644 --- a/crates/eps/src/import/ai/tests.rs +++ b/crates/eps/src/import/ai/tests.rs @@ -43,6 +43,8 @@ fn ruler_units_from_the_header_set_the_documents_units() { assert_eq!(read_ok(&stream(&body)).doc.units, Unit::Points, "default when the comment is absent"); let with_in = with_mm.replace("AI5_RulerUnits: 1", "AI5_RulerUnits: 0"); assert_eq!(read(with_in.as_bytes()).unwrap().doc.units, Unit::Inches); + let with_px = with_mm.replace("AI5_RulerUnits: 1", "AI5_RulerUnits: 6"); + assert_eq!(read(with_px.as_bytes()).unwrap().doc.units, Unit::Pixels); } /// The children of the first layer.