mirror of
https://github.com/storytold/designcraft.git
synced 2026-10-31 15:49:42 +00:00
Units: centimetres show four decimals, as InDesign's fields do
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
8dff7ecdb0
commit
39dfbdb36b
2 files changed
+10
-5
No files matched your search
@@ -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.
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user