G9: map AI5_RulerUnits value 6 to pixels on .ai import

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
nrq6993-a11y
2026-10-20 01:48:35 +07:00
committed by bflatastic
co-authored by Cursor
parent f557a1b6f3
commit a48e65ba68
2 changed files with 4 additions and 2 deletions
+2 -2
View File
@@ -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<Unit> {
Some(match v {
0 => Unit::Inches,
@@ -89,7 +89,7 @@ fn ruler_unit(v: u8) -> Option<Unit> {
2 => Unit::Points,
3 => Unit::Picas,
4 => Unit::Centimeters,
5 => Unit::Pixels,
5 | 6 => Unit::Pixels,
_ => return None,
})
}
+2
View File
@@ -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.