DesignCraft: An open-source page and layout design editor written by scratch in pure Rust
Units: inches show four decimals, as InDesign's fields
moppeeera8388df9e8a5
diff --git a/ROADMAP.md b/ROADMAP.mdindex d60a6bf49..999153af4 100644--- a/ROADMAP.md+++ b/ROADMAP.md@@ -347,6 +347,7 @@ list) · [roadmap.md](docs/roadmap.md) (milestones, plan) · [parity-checklist.mNewest first.+- 2026-10-15: Measures in inches show four decimals, as InDesign's fields do (A4 is 8.2677 × 11.6929 in, a 1p0 gutter 0.1667 in); other units keep three.- **2026-10-14** · The Type tool draws a new text frame over a locked empty frame, as InDesign does, instead of turning the locked frame into a text frame. No readiness percentage change.- **2026-10-14** · 100% black shows as pure black on screen by default, as InDesign's Appearance of Black does out of the box (Display All Blacks as Rich Black); Preferences › Appearance of Black › Display All Blacks Accurately still shows it as the dark grey it prints, and a saved choice is kept. No readiness percentage change.- **2026-10-14** · Pathfinder keeps the frontmost object, as InDesign does: a photo placed over shapes and intersected with them shows through the shapes (it was dropped, and the shapes kept their black fill); Add, Exclude Overlap and Minus Back take the front object's fill too, Subtract still keeps the back one. No readiness percentage change.diff --git a/crates/geom/src/units.rs b/crates/geom/src/units.rsindex 9ad932930..da1676d4b 100644--- a/crates/geom/src/units.rs+++ b/crates/geom/src/units.rs@@ -258,7 +258,10 @@ 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 {- format_measure_prec(pt, unit, 3)+ // 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 };+ format_measure_prec(pt, unit, decimals)}pub fn format_measure_prec(pt: f64, unit: Unit, decimals: usize) -> String {@@ -301,6 +304,17 @@ mod tests {(a - b).abs() < 1e-6}+ /// Inches show four decimals, as InDesign's fields do; other units three.+ #[test]+ fn inches_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");+ assert_eq!(format_measure(10.0, Unit::Points), "10 pt");+ }+#[test]fn plain_and_units() {assert!(close(p("12"), 12.0));diff --git a/crates/ui-egui/src/widgets.rs b/crates/ui-egui/src/widgets.rsindex 44316fda4..dd95a1477 100644--- a/crates/ui-egui/src/widgets.rs+++ b/crates/ui-egui/src/widgets.rs@@ -5,7 +5,7 @@//! section headers and 1.5 pt section rules.use designcraft_geom::Unit;-use designcraft_geom::units::{format_measure_prec, parse_measure};+use designcraft_geom::units::{format_measure, parse_measure};use egui::{Color32, Rect, Response, Sense, Stroke, StrokeKind, Ui, pos2, vec2};use crate::theme::Tokens;@@ -35,7 +35,7 @@ pub enum NumKind<'a> {impl NumKind<'_> {pub fn format(&self, v: f64) -> String {match *self {- NumKind::Measure(u) => format_measure_prec(v, u, 3),+ NumKind::Measure(u) => format_measure(v, u),NumKind::Number { suffix, decimals } => {let s = format!("{v:.decimals$}");let s = if s.contains('.') { s.trim_end_matches('0').trim_end_matches('.').to_string() } else { s };