DesignCraft: An open-source page and layout design editor written by scratch in pure Rust
Merge remote-tracking branch 'origin/main' into anchored-wrap-as-placed
moppeeerc0d2156ea657
diff --cc ROADMAP.mdindex 74fba305c,5d91d43f9..a26538bed--- a/ROADMAP.md+++ b/ROADMAP.md@@@ -348,8 -348,7 +348,8 @@@ list) · [roadmap.md](docs/roadmap.md)Newest 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-15** · Anchored objects wrap their own story as their anchor lines are set, as in InDesign: the layout no longer depends on where an earlier composition put them (a long story whose pictures moved between frames from pass to pass never settled). 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 --cc crates/compose/src/tests.rsindex 1502b74dc,15c412ada..859352a99--- a/crates/compose/src/tests.rs+++ b/crates/compose/src/tests.rs@@@ -7291,39 -7291,22 +7291,59 @@@ fn greek_text_gets_greek_hyphenation()assert_eq!(hyphen::hyphen_points_in("ανθρωπος", &hyphen::Limits::default(), el), vec![2, 5]);}+/// An object's wrap pushes the text so that a later object's anchor goes on into the next frame+/// (Learn Skills Daily's long-document exercise: pictures anchored in headings through a 79-page+/// story). Each object is placed when its anchor line is set and wraps only the lines after it,+/// in the frame its anchor lands in: the layout doesn't depend on where an earlier composition put+/// the objects, and composing again gives the same lines.+#[test]+fn an_object_wraps_the_frame_its_anchor_lands_in_after_an_earlier_object_pushed_it_on() {+ let text = [LOREM; 6].join(" ");+ let mut d = Document::new(&NewDocument::default());+ let lid = d.default_layer();+ let (a, sid) = d.add_text_frame(SpreadRef::Doc(0), Rect::new(0.0, 0.0, 300.0, 300.0), lid, &text, ParaFormat::default()).unwrap();+ let (b, _) = d.add_text_frame(SpreadRef::Doc(0), Rect::new(320.0, 0.0, 620.0, 300.0), lid, "", ParaFormat::default()).unwrap();+ d.thread(a, b).unwrap();+ let plain = compose_story(&d, sid, &ComposeOptions::default());+ // The second object's anchor sits near the end of the first frame without wrap.+ let late = plain.frames[0].lines.iter().rev().nth(2).unwrap().range.start + 2;+ anchor_box(&mut d, sid, late, 0.0, 0.0, true, WrapMode::BoundingBox);+ // The first, early in the first frame: 60 pt over its whole width pushes the later anchor on.+ let early = plain.frames[0].lines[1].range.start + 2;+ anchor_box(&mut d, sid, early, 0.0, 0.0, true, WrapMode::JumpObject);+ let cs = compose_story(&d, sid, &ComposeOptions::default());+ let late = late + OBJECT_LEN;+ let anchor_frame = cs.frames.iter().position(|f| f.range.contains(&late) || f.range.end == late).unwrap();+ assert_eq!(anchor_frame, 1, "the later anchor went on into the second frame");+ // The first frame's lines under the first object's band keep the full measure (the second+ // object is in the other frame); in the second frame, the lines under its object move right.+ let left = cs.frames[0].lines[0].x0;+ assert!(cs.frames[0].lines.iter().all(|l| (l.x0 - left).abs() < 1e-6));+ let f1 = &cs.frames[1];+ let (li, line) = f1.lines.iter().enumerate().find(|(_, l)| l.range.contains(&late)).unwrap();+ let under: Vec<_> = f1.lines[li + 1..].iter().filter(|l| l.baseline - l.ascent < line.baseline + 60.0).collect();+ assert!(!under.is_empty() && under.iter().all(|l| l.x0 >= f1.lines[0].x0 + 100.0 - 1e-6));+ assert_eq!(f1.objects.len(), 1);+ // Deterministic: the same lines again.+ assert_eq!(line_layout(&compose_story(&d, sid, &ComposeOptions::default())), line_layout(&cs));+}+++ /// 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);+ }