DesignCraft: An open-source page and layout design editor written by scratch in pure Rust
Merge clipping-paths: Images: clipping paths from IDML clip the image on screen and in PDF
aionggaf389f9a0b8a
diff --cc ROADMAP.mdindex 76d4bdbf3,6c17f443e..f55002d99--- a/ROADMAP.md+++ b/ROADMAP.md@@@ -128,48 -129,12 +128,49 @@@ list) · [roadmap.md](docs/roadmap.md)Newest first.+- **2026-10-12** · Text threads by hand: click a selected text frame's in or out port to load+ the text cursor, then click a frame to thread it, click empty space for a column-wide frame or+ drag one (it snaps like frame drawing); Shift-click autoflows, Alt-click stays loaded on the+ frame just added; click the linked frame or double-click a port to break the thread.+ `text.thread`, `text.unthread`, `text.removeFromThread` with undo; locked frames and layers+ refuse threads. The alpha gate now waits only on the Primary Text Frame page fixes (#165). No+ readiness percentage change.+- **2026-10-12** · Properties › Transform shows rotation, shear and X/Y scale, and Rotate 90° and Flip Horizontal/Vertical buttons, as InDesign's does. No readiness percentage change.+- **2026-10-12** · Underlines and strikethroughs are drawn as one bar per stretch of text on screen, as in PDF export: a bar per letter left faint seams between the letters. No readiness percentage change.+- **2026-10-12** · The section marker character shows its section's marker text on document pages (nothing when the section has none) instead of the word "Section", which stays on parent pages; editing the marker recomposes (#556). No readiness percentage change.+- **2026-10-12** · IDML import keeps a font family name exactly as written, trailing spaces included, and font lookup falls back to the name without surrounding spaces; `FontStyle="Nothing"` leaves the style to the paragraph (#558). No readiness percentage change.+ - **2026-10-12** · Clipping paths saved with images in IDML (Detect Edges, Alpha Channel, Photoshop Path, User-Modified Path, inverted or not) clip the image on screen and in PDF and survive IDML export; `object.clippingPathOptions` reports, inverts or removes one (#450). No readiness percentage change.- **2026-10-12** · Words in capitals hyphenate like capitalized words (FERRUM COM-MODI), as in InDesign; Hyphenate Capitalized Words off keeps them whole. No readiness percentage change.+- **2026-10-11 (printing):** `file.printers` and `file.print` use craft-libs/craft-print for CUPS and Windows. DesignCraft retains PDF export, page selection, spreads, marks and bleed; dry runs create no temporary PDF or print job. Windows selects matching or default driver paper and shrinks oversized sheets without enlarging smaller ones; queue duplex defaults are preserved. Headless tests exercise exported bytes, job settings, dry runs and refusals; shared native Windows CI passes, including paused-queue submission and cleanup. PostScript, production print controls and physical output validation remain open. No readiness percentage change.+- **2026-10-11** · The View menu follows InDesign's: proofing first, then zoom, Rotate Spread, Screen Mode, Display Performance, rulers, Extras, Grids & Guides and Structure; the view items that sat at the end of the Type menu moved there. No readiness percentage change.+- **2026-10-11** · Properties › Appearance's Fill and Stroke menus gain InDesign's Tint field and, for a text frame, Apply To: Frame / Text. No readiness percentage change.+- **2026-10-11** · `story.replaceRange`, `story.setText`, notes, footnotes, endnotes, type on a path and table cells read `\r` and `\r\n` as paragraph returns, as `frame.create` and `text.insert` already did. No readiness percentage change.+- **2026-10-11** · Corner Options keep curved sides curved and round every corner point, including where an arc meets a line (a Pathfinder quarter circle with rounded corners stayed a triangle). No readiness percentage change.+- **2026-10-11:** Type › Justification… (Cmd+Alt+Shift+J, also in the Paragraph panel menu) sets word and letter spacing, glyph scaling and the composer on the selected paragraphs, sharing the Paragraph Style Options section (#531). No readiness percentage change.+- **2026-10-11** · Properties gains InDesign's Pathfinder section (Add, Subtract, Intersect, Exclude Overlap, Minus Back) with several objects selected; section titles and icon buttons have accessible names. No readiness percentage change.- **2026-10-11** · `transform.move {copy}`, Edit › Duplicate and Step and Repeat return the copies' ids, so a script can go on with them. No readiness percentage change.- **2026-10-11** · `object.fill` and `object.stroke` refuse a swatch name the document doesn't have (it painted nothing) and suggest the name meant (`Paper` → `[Paper]`). No readiness percentage change.-- **2026-10-11 (printing):** `file.printers` and `file.print` use craft-libs/craft-print for CUPS and Windows. DesignCraft retains PDF export, page selection, spreads, marks and bleed; dry runs create no temporary PDF or print job. Windows selects matching or default driver paper and shrinks oversized sheets without enlarging smaller ones; queue duplex defaults are preserved. Headless tests exercise exported bytes, job settings, dry runs and refusals; shared native Windows CI passes, including paused-queue submission and cleanup. PostScript, production print controls and physical output validation remain open. No readiness percentage change.-+- **2026-10-11** · Japanese captions now cover print ranges, imported style handling and table+ row/column movement, including row-height distribution. Existing translation and RTL helpers+ handle the display; command IDs, stored option values and user-defined style names are unchanged.+- **2026-10-11** · Moving a sheared and rotated text frame no longer leaves trails of text behind: canvas repaints cover the frame's whole text box, not just its outline. No readiness percentage change.+- **2026-10-11** · Live corners: the yellow widget on a selected rectangle frame shows corner+ diamonds; dragging one rounds the corners, Alt-click steps the corner shape (#186).+- **2026-10-11** · Optical kerning (#181): pairs are spaced from their outlines (ink gap per band,+ pulled towards the font's stem gap, bounded) instead of silently using the font's kern pairs.+- **2026-10-11** · New Document laid out like InDesign's (#325): Recent, Saved, Print, Web and+ Mobile preset tabs beside the preset's details; saved document presets live in the engine+ (`file.savePreset`, `file.deletePreset`, `file.new {preset}`); `file.new` takes intent, units,+ start page and per-edge bleed and slug.+- **2026-10-11** · macOS: fonts that font services and managers activate (Adobe Fonts,+ RightFont) are listed, read from the files CoreText has available (#261, #327).+- **2026-10-11:** Document pages take their parent page's margins and columns (left or right parent page by side) and follow its changes unless they have their own; parent ruler guides draw and snap on the pages based on it. IDML import marks a page margin preference that differs from its parent as the page's own. No readiness percentage change.+- **2026-10-11** · Document Setup laid out like InDesign's: Page Size, Margins (new: every+ page's, `layout.documentSetup {margins}`), Bleed and Slug with links, Adjust Layout.+- **2026-10-11** · IDML reads and writes a spread's view rotation (Rotate Spread) as the+ rotation part of the spread transform (#484).+- **2026-10-11** · The document grid is drawn (View ▸ Grids & Guides ▸ Show/Hide Document Grid,+ ⌘'), on the lines Snap to Document Grid uses, behind or in front of page items (#530).- **2026-10-10 (UI.4–UI.5):** Panel tabs can move into other groups, split the dock, float, resize and return to their saved locations through shared docking transactions. Layouts persist in custom workspaces; UI and control commands share the same validated action path. Shared pane geometry and widget-state theme application retain all five palettes and local fonts. Split panes send keyboard input only to the focused canvas and scope contextual toolbar IDs per pane. No readiness percentage change.- **2026-10-10** · Version 0.6.0; releases add a Linux riscv64 tar.gz (cross-compiled, CLIsmoke-tested under QEMU).diff --cc crates/doc/src/item.rsindex b83c6bacc,b579280e9..56032291a--- a/crates/doc/src/item.rs+++ b/crates/doc/src/item.rs@@@ -696,13 -703,24 +785,31 @@@ fn is_zero_usize(v: &usize) -> bool}impl Graphic {+ /// The part of the graphic its frame shows, in the frame's inner space (bounding boxes);+ /// None when nothing shows.+ pub fn shown_bounds(&self, frame: Rect) -> Option<Rect> {+ let r = self.xf.transform_rect_bbox(Rect::new(0.0, 0.0, self.size.0, self.size.1)).intersect(frame);+ (r.width() > 0.0 && r.height() > 0.0).then_some(r)+ }++ /// The region the clipping path lets through, in frame inner space, and whether it is filled+ /// even-odd (an inverted clip: the graphic's rectangle minus the path). `None` when the graphic+ /// has no clipping path or the path is empty.+ pub fn clip_region(&self) -> Option<(designcraft_geom::BezPath, bool)> {+ use designcraft_geom::Shape;+ let c = self.clip.as_ref().filter(|c| !c.path.is_empty())?;+ let mut path = c.path.to_bezpath();+ if !c.invert {+ path.apply_affine(self.xf);+ return Some((path, false));+ }+ let outer = Rect::new(0.0, 0.0, self.size.0, self.size.1).union(path.bounding_box()).inflate(1.0, 1.0);+ let mut region = outer.to_path(0.1);+ region.extend(path.iter());+ region.apply_affine(self.xf);+ Some((region, true))+ }+/// The graphic transform that fits it into `frame` (the frame's inner rect) with `mode`,/// honouring the crop amounts and the reference point.pub fn fitted(&self, frame: Rect, mode: Fitting) -> Option<Affine> {diff --cc crates/engine/src/cmd/datamerge/fill.rsindex c76b5a2f0,643826173..bb5b15f06--- a/crates/engine/src/cmd/datamerge/fill.rs+++ b/crates/engine/src/cmd/datamerge/fill.rs@@@ -379,17 -379,10 +379,18 @@@ fn place_imagelink,data: Arc::new(bytes),pixels: Some((pw, ph)),- page: 0,+ ..Default::default()});- let mut g =- Graphic { asset: aid, size: (nw, nh), xf: Affine::translate((inner.x0, inner.y0)), auto_fit: mode, fit_align: 0, crop: [0.0; 4], clip: None };+ let mut g = Graphic {+ asset: aid,+ size: (nw, nh),+ xf: Affine::translate((inner.x0, inner.y0)),+ auto_fit: mode,+ fit_align: 0,+ crop: [0.0; 4],+ wrap: Default::default(),++ clip: None,+ };if let Some(xf) = g.fitted(inner, mode) {g.xf = xf;}diff --cc crates/engine/src/cmd/file.rsindex c07aa8b64,df85549f2..bf40799d5--- a/crates/engine/src/cmd/file.rs+++ b/crates/engine/src/cmd/file.rs@@@ -468,12 -352,13 +468,13 @@@ fn file_place(s: &mut Session, p: &Valulet it = d.item_mut(fid).ok_or(designcraft_doc::DocError::NoItem(fid))?;let r = it.inner_bounds();// Fill the frame proportionally once. Auto-Fit stays off, so resizing the frame crops.- let k = (r.width() / nw).max(r.height() / nh);- let (gw, gh) = (nw * k, nh * k);+ let k = (r.width() / bw).max(r.height() / bh);+ let (gw, gh) = (bw * k, bh * k);it.content = Content::Graphic(Graphic {asset: aid,- size: (nw, nh),+ size: (bw, bh),xf: Affine::translate((r.x0 + (r.width() - gw) / 2.0, r.y0 + (r.height() - gh) / 2.0)) * Affine::scale(k),+ clip: None,auto_fit: Default::default(),fit_align: 4,crop: [0.0; 4],@@@ -490,8 -375,9 +491,9 @@@it.object_style = d.styles.default_graphic_frame.clone();it.content = Content::Graphic(Graphic {asset: aid,- size: (nw, nh),- xf: Affine::translate((x - bx * k, y - by * k)) * Affine::scale(k),+ size: (bw, bh),+ xf: Affine::translate((x, y)) * Affine::scale(k),+ clip: None,auto_fit: Default::default(),fit_align: 4,crop: [0.0; 4],diff --cc crates/engine/src/cmd/mathexpr.rsindex dc1b6ed76,26f87fc86..ef840b217--- a/crates/engine/src/cmd/mathexpr.rs+++ b/crates/engine/src/cmd/mathexpr.rs@@@ -25,7 -33,7 +25,8 @@@ fn math_item(d: &mut designcraft_doc::Dauto_fit: Default::default(),fit_align: 4,crop: [0.0; 4],+ wrap: Default::default(),++ clip: None,});it.alt_text = latex.to_string();it.name = "Math".into();diff --cc crates/idml/src/export.rsindex 172415cf8,0512f0917..6e9658881--- a/crates/idml/src/export.rs+++ b/crates/idml/src/export.rs@@@ -1956,9 -1779,9 +1956,12 @@@ impl<'a> Ex<'a>}props.push(El::new("GraphicBounds").attr("Left", "0").attr("Top", "0").attr("Right", num(g.size.0)).attr("Bottom", num(g.size.1)));let mut el = with_props(el, props);+ if !g.wrap.is_default() {+ el.push(text_wrap_pref(&g.wrap));+ }+ if let Some(c) = &g.clip {+ el.push(clipping_settings(c));+ }let uri = match &asset.link {Some(l) => path_to_uri(l),None => format!("file:{}", asset.name),diff --cc crates/idml/src/import.rsindex f51cdfa9a,f7e65cb36..06acfc77d--- a/crates/idml/src/import.rs+++ b/crates/idml/src/import.rs@@@ -2648,14 -2268,9 +2648,15 @@@ impl<'r> Importer<'r>None => (0.0, 0.0, 0.0, 0.0),};let size = ((r - l).abs(), (b - t).abs());+ let wrap =+ if g.get("AppliedObjectStyle").is_some() { self.with_style(g, "TextWrapPreference") } else { g.find("TextWrapPreference").cloned() };+ let wrap = wrap.map(|w| text_wrap(&w)).unwrap_or_default();+ let clip = clipping_path(g, Affine::translate((-l, -t)));let link = g.find("Link");let uri = link.and_then(|k| k.get("LinkResourceURI")).map(uri_to_path);+ let page = pdf_page_in(g);+ // Where the box sits on the page needs the PDF parsed: the engine finds it after import.+ let pdf_crop = g.find("PDFAttribute").and_then(|a| a.get("PDFCrop")).map_or(designcraft_doc::PdfCrop::Crop, names::pdf_crop_in);let graphic = |asset| {Content::Graphic(designcraft_doc::Graphic {asset,diff --cc crates/idml/src/names.rsindex b0b2ce278,4ebe29baf..10bdc1b29--- a/crates/idml/src/names.rs+++ b/crates/idml/src/names.rs@@@ -2,7 -2,7 +2,7 @@@use designcraft_color::BlendMode;use designcraft_doc::{- Align, Arrowhead, AutoSize, Cap, Capitalization, ContourType, FirstBaseline, Join, Leading, NumberStyle, Position, StartParagraph, StrokeAlign,- Align, Arrowhead, AutoSize, Cap, Capitalization, ClippingKind, FirstBaseline, Join, Leading, NumberStyle, Position, StartParagraph, StrokeAlign,++ Align, Arrowhead, AutoSize, Cap, Capitalization, ClippingKind, ContourType, FirstBaseline, Join, Leading, NumberStyle, Position, StartParagraph, StrokeAlign,StrokeType, TabAlign, VerticalJustification, WrapMode, WrapSide,};use designcraft_geom::Unit;diff --cc crates/idml/src/tests.rsindex 1aefad330,3d18dbc80..be6dd6fdd--- a/crates/idml/src/tests.rs+++ b/crates/idml/src/tests.rs@@@ -8,12 -8,8 +8,13 @@@ use designcraft_geom::{Rect, shapes}use super::*;mod assets;+ mod clipping;mod decorations;+mod object_styles;+mod rtl_binding;+mod spread_rotation;+mod variables;+mod wrap;fn zip_files(files: &[(&str, &str)]) -> Vec<u8> {use zip::write::SimpleFileOptions;diff --cc crates/pdf/src/tests.rsindex 8607b9ff3,d16884a96..d27d03d31--- a/crates/pdf/src/tests.rs+++ b/crates/pdf/src/tests.rs@@@ -488,51 -448,38 +489,87 @@@ fn column_rules_are_drawn()assert!(rules(false).is_empty());}+#[test]+fn ruby_overprint_is_reported_as_not_exported() {+ use designcraft_doc::cjk_settings::AdornmentOverprint;+ let mut d = doc_with_text("漢字です");+ let sid = *d.stories.keys().next().unwrap();+ let clean = export_pdf_with_report(&d, &Cache::new(), &PdfOptions::default()).unwrap();+ assert!(!clean.warnings.iter().any(|w| w.contains("overprint")), "{:?}", clean.warnings);+ d.story_mut(sid).unwrap().format_chars(0.."漢字".len(), |f| {+ f.over.ruby = Some("かんじ".into());+ f.over.ruby_overprint_fill = Some(AdornmentOverprint::On);+ });+ let r = export_pdf_with_report(&d, &Cache::new(), &PdfOptions::default()).unwrap();+ assert!(r.warnings.iter().any(|w| w.contains("overprint is not exported yet")), "{:?}", r.warnings);+}++#[test]+fn small_caps_and_small_cap_figures_extract_as_typed() {+ // Source Sans 3 substitutes letters and figures under `smcp` / `c2sc` (`one` → `one.s`),+ // in typed text, in a page number and in a list label alike (each with its own figures, so+ // one's mapping can't stand in for another's).+ use designcraft_doc::{Capitalization, ListType, story::PAGE_NUMBER};+ for caps in [Capitalization::SmallCaps, Capitalization::OpenTypeAllSmallCaps] {+ let text = format!("Abc 234 x{PAGE_NUMBER}\nItem");+ let mut d = doc_with_text(&text);+ let sid = *d.stories.keys().next().unwrap();+ let st = d.story_mut(sid).unwrap();+ st.format_paras(0..text.len(), |f| {+ f.chars.font_family = Some("Source Sans 3".into());+ f.chars.capitalization = Some(caps);+ });+ st.format_paras(text.len() - 1..text.len(), |f| {+ f.para.list_type = Some(ListType::Numbers);+ f.para.start_at = Some(Some(5));+ });+ let got = extract_text(&export_pdf(&d, &Cache::new(), &PdfOptions::default()).unwrap()).concat();+ assert!(!got.contains('\u{FFFD}'), "{caps:?}: {got:?}");+ assert_eq!(got.split_whitespace().collect::<Vec<_>>(), ["Abc", "234", "x15.Item"], "{caps:?}: {got:?}");+ }+ // All small caps draws `A` and `a` with one glyph, which one ToUnicode entry can't cover: the+ // second spelling goes out as ActualText (which this extractor doesn't read).+ let mut d = doc_with_text("Aa");+ let sid = *d.stories.keys().next().unwrap();+ d.story_mut(sid).unwrap().format_chars(0..2, |f| {+ f.over.font_family = Some("Source Sans 3".into());+ f.over.capitalization = Some(Capitalization::OpenTypeAllSmallCaps);+ });+ assert!(uncompressed(&d, PdfOptions::default()).contains("/ActualText"));+}+++ /// A clipping path on a placed image becomes a clip in the page content, inside the frame's.+ #[test]+ fn clipping_path_clips_the_image() {+ let png = |d: &mut Document| {+ let mut b = Vec::new();+ image::RgbaImage::from_pixel(4, 4, image::Rgba([255, 0, 0, 255]))+ .write_to(&mut std::io::Cursor::new(&mut b), image::ImageFormat::Png)+ .unwrap();+ place(d, b, (4, 4));+ };+ let clips = |s: &str| s.lines().filter(|l| matches!(l.trim(), "W" | "W*")).count();+ let mut d = doc_with_text("x");+ png(&mut d);+ let plain = uncompressed(&d, PdfOptions::default());+ let id = d.spreads[0].items.iter().find(|i| i.graphic().is_some()).unwrap().id;+ let triangle = designcraft_geom::PathData::single(designcraft_geom::path::SubPath::polyline(+ &[designcraft_geom::Point::new(0.0, 4.0), designcraft_geom::Point::new(2.0, 0.0), designcraft_geom::Point::new(4.0, 4.0)],+ true,+ ));+ let mut clip = designcraft_doc::ClippingPath::new(designcraft_doc::ClippingKind::DetectEdges, triangle);+ let set = |d: &mut Document, c: &designcraft_doc::ClippingPath| {+ if let Some(designcraft_doc::Content::Graphic(g)) = d.item_mut(id).map(|it| &mut it.content) {+ g.clip = Some(std::sync::Arc::new(c.clone()));+ }+ };+ set(&mut d, &clip);+ let clipped = uncompressed(&d, PdfOptions::default());+ assert_eq!(clips(&clipped), clips(&plain) + 1, "{clipped}");+ // The triangle's apex: graphic (2, 0) → page (172, 72) → PDF y = page height − 72.+ let apex_y = d.spreads[0].pages[0].height - 72.0;+ assert!(clipped.contains(&format!("172 {apex_y} l")), "{clipped}");+ clip.invert = true;+ set(&mut d, &clip);+ assert!(uncompressed(&d, PdfOptions::default()).lines().any(|l| l.trim() == "W*"), "an inverted clip is even-odd");+ }diff --cc docs/gaps.mdindex 44a00d93e,3dae7ac84..c6c252213--- a/docs/gaps.md+++ b/docs/gaps.md@@@ -1,6 -1,6 +1,6 @@@# Where DesignCraft falls short of InDesign- > **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-12 · **Change:** minor (gap 0 shrunk: text threads by hand; threading gaps added; Optical kerning from outlines (#181); gap 6: macOS lists fonts that font services and managers activate; shared print spooler) · **Target:** Adobe InDesign 2026 (21.6)-> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-12 · **Change:** minor (image clipping paths from IDML) · **Target:** Adobe InDesign 2026 (21.6)++> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-12 · **Change:** minor (gap 0 shrunk: text threads by hand; threading gaps added; Optical kerning from outlines (#181); gap 6: macOS lists fonts that font services and managers activate; shared print spooler; image clipping paths from IDML) · **Target:** Adobe InDesign 2026 (21.6)Every known shortfall against InDesign 2026, one entry each, ranked by how much it stops anInDesign professional from doing real work. This is the work list: agents pick from the top.diff --cc docs/target-app-parity.mdindex af1cda170,b196a7349..8e10cca55--- a/docs/target-app-parity.md+++ b/docs/target-app-parity.md@@@ -1,6 -1,6 +1,6 @@@# DesignCraft parity with Adobe InDesign- > **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-12 · **Change:** minor (text threads by hand) · **Target:** Adobe InDesign 2026 (21.6.0.57, macOS)-> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-12 · **Change:** minor (image clipping paths from IDML) · **Target:** Adobe InDesign 2026 (21.6.0.57, macOS)++> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-12 · **Change:** minor (text threads by hand; image clipping paths from IDML) · **Target:** Adobe InDesign 2026 (21.6.0.57, macOS)The authoritative assessment of how close DesignCraft is to Adobe InDesign. [ROADMAP.md](../ROADMAP.md)summarizes it; [gaps.md](gaps.md) lists every known shortfall one at a time; the feature-by-feature