DesignCraft: An open-source page and layout design editor written by scratch in pure Rust
Paragraph rules: Rule Above's offset is measured from the baseline (#1535)
aiongg2aa5da595058
diff --git a/ROADMAP.md b/ROADMAP.mdindex a7b5105d3..5d91d43f9 100644--- a/ROADMAP.md+++ b/ROADMAP.md@@ -348,6 +348,7 @@ list) · [roadmap.md](docs/roadmap.md) (milestones, plan) · [parity-checklist.mNewest first.+- **2026-10-22** · Paragraph rules: Rule Above's offset is measured from the first line's baseline to the rule's bottom edge, as in InDesign. Rules sat one ascent too high and crossed the previous paragraph's text (reported from an imported INDD document). 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/compose/src/lib.rs b/crates/compose/src/lib.rsindex 4a2c66397..89ea89bd3 100644--- a/crates/compose/src/lib.rs+++ b/crates/compose/src/lib.rs@@ -1860,11 +1860,12 @@ fn compose_with_db(doc: &Document, story: &Story, frames: &[FrameSpec], opts: &Ccur.band = Band { para: pi + 1, line0: ft.lines.len(), above: Some(above), tail: None };}// Rules and shading for the paragraph.- if let Some((fi, bl, asc, _)) = first_line_rect {+ if let Some((fi, bl, _, _)) = first_line_rect {let ft = &mut out.frames[fi];if pp.rule_above.on {let r = &pp.rule_above;- let y = bl - asc - r.offset;+ // The offset runs from the first line's baseline up to the rule's bottom edge.+ let y = bl - r.offset;let col = ft.lines.iter()diff --git a/crates/compose/src/tests.rs b/crates/compose/src/tests.rsindex ed4c7c476..15c412ada 100644--- a/crates/compose/src/tests.rs+++ b/crates/compose/src/tests.rs@@ -7290,3 +7290,23 @@ fn greek_text_gets_greek_hyphenation() {let el = hyphen::Lang::for_language("Greek").unwrap();assert_eq!(hyphen::hyphen_points_in("ανθρωπος", &hyphen::Limits::default(), el), vec![2, 5]);}++/// Rule Above's offset runs from the first line's baseline up to the rule's bottom edge, as in+/// InDesign: a rule set clear of the cap height sits between the rows, not across the row above+/// (an INDD project list whose rules crossed the previous paragraph's text).+#[test]+fn rule_above_offset_is_measured_from_the_baseline() {+ use designcraft_doc::Rule;+ let rule = Rule { on: true, weight: 1.5, offset: 10.0, ..Default::default() };+ let para = ParaAttrs { rule_above: Some(rule), ..Default::default() };+ let (d, sid, fid) = doc_with("Row one\nRow two", Rect::new(0.0, 0.0, 300.0, 200.0), para);+ let cs = compose_story(&d, sid, &ComposeOptions::default());+ let lines = all_lines(&cs);+ let (first, second) = (lines[0], lines[1]);+ let mut decos: Vec<Rect> = cs.frame(fid).unwrap().decos.iter().map(|dc| dc.rect).collect();+ decos.sort_by(|a, b| a.y0.total_cmp(&b.y0));+ let rule = decos[1];+ assert!((rule.y1 - (second.baseline - 10.0)).abs() < 1e-6, "{rule:?}, baseline {}", second.baseline);+ assert!((rule.height() - 1.5).abs() < 1e-6);+ assert!(rule.y0 > first.baseline, "the rule stays below the row above: {rule:?}, its baseline {}", first.baseline);+}