Skip to content

DesignCraft: An open-source page and layout design editor written by scratch in pure Rust

Units: centimetres show four decimals, as InDesign's fields do

moppeeer39dfbdb36b00
diff --git a/ROADMAP.md b/ROADMAP.md
index 0128924c0..1692c590f 100644
--- a/ROADMAP.md
+++ b/ROADMAP.md
@@ -348,6 +348,7 @@ list) · [roadmap.md](docs/roadmap.md) (milestones, plan) · [parity-checklist.m
Newest first.
+- **2026-10-20** · Measures in centimetres show four decimals, as InDesign's fields do (a 1p gutter reads 0.4233 cm, not 0.423 cm). No readiness percentage change.
- **2026-10-16** · Type › Reload Fonts (`font.reload`): fonts installed, edited or removed while DesignCraft runs are read again without a restart, and the open documents recompose with them (#328, #547). An edited font file is noticed by its length and modification time; bundled, added and document fonts stay as they are. InDesign does this by itself, so noticing changes automatically is still open (gap 6). No readiness percentage change.
- **2026-10-16** · Parents can be deleted from their Pages-panel context menu or `layout.parents.delete {id}`. Applied-page and based-on references are cleared, local override copies survive, and Undo restores the parent. Addresses the deletion portion of #956; no readiness percentage change.
- **2026-10-17** · File › Package writes the document's and the IDML's links relative to the package (`Links/logo.png`, `file:Links/logo.png`), so a package holds no path from the machine that made it; opening a document resolves them to the files beside it. Links › Copy Link(s) To still links by full path. (#340). No readiness percentage change.
diff --git a/crates/geom/src/units.rs b/crates/geom/src/units.rs
index da1676d4b..f0457e75d 100644
--- a/crates/geom/src/units.rs
+++ b/crates/geom/src/units.rs
@@ -258,9 +258,9 @@ fn parse_single(tok: &str, default: Unit, percent_base: Option<f64>) -> Option<f
/// Format a value (points) in `unit` the way InDesign fields show it: up to 3 decimals, trailing
/// zeros trimmed; picas as `3p6`, ciceros as `2c4`.
pub fn format_measure(pt: f64, unit: Unit) -> String {
- // As InDesign shows them: inches to four decimals (a 1p gutter is 0.1667 in, A4 is
- // 8.2677 in wide), the other units to three.
- let decimals = if matches!(unit, Unit::Inches | Unit::InchesDecimal) { 4 } else { 3 };
+ // As InDesign shows them: inches and centimetres to four decimals (a 1p gutter is 0.1667 in
+ // or 0.4233 cm, A4 is 8.2677 in wide), the other units to three.
+ let decimals = if matches!(unit, Unit::Inches | Unit::InchesDecimal | Unit::Centimeters) { 4 } else { 3 };
format_measure_prec(pt, unit, decimals)
}
@@ -304,14 +304,18 @@ mod tests {
(a - b).abs() < 1e-6
}
- /// Inches show four decimals, as InDesign's fields do; other units three.
+ /// Inches and centimetres show four decimals, as InDesign's fields do; other units three.
#[test]
- fn inches_show_four_decimals() {
+ fn inches_and_centimeters_show_four_decimals() {
assert_eq!(format_measure(12.0, Unit::Inches), "0.1667 in");
assert_eq!(format_measure(210.0 * PT_PER_MM, Unit::Inches), "8.2677 in");
assert_eq!(format_measure(612.0, Unit::Inches), "8.5 in");
assert_eq!(format_measure(9.0, Unit::Inches), "0.125 in");
assert_eq!(format_measure(10.0, Unit::Millimeters), "3.528 mm");
+ // A 1p gutter and a frame's height, as InDesign's New Document and Transform fields show them.
+ assert_eq!(format_measure(12.0, Unit::Centimeters), "0.4233 cm");
+ assert_eq!(format_measure(17.1125 / 2.54 * 72.0, Unit::Centimeters), "17.1125 cm");
+ assert_eq!(format_measure(21.0 / 2.54 * 72.0, Unit::Centimeters), "21 cm");
assert_eq!(format_measure(10.0, Unit::Points), "10 pt");
}