Skip to content

DesignCraft: An open-source page and layout design editor written by scratch in pure Rust

Merge upstream main a930276 into gpu-startup: the indirect-call validation fix is kept once

aiongg4186f95aedc1
diff --cc ROADMAP.md
index c587b4d2d,d60a6bf49..2b1b6b1ac
--- a/ROADMAP.md
+++ b/ROADMAP.md
@@@ -127,8 -343,116 +343,117 @@@ list) · [roadmap.md](docs/roadmap.md)
## Progress log
+ - **2026-10-13** · Switching between document and parent pages refreshes the canvas immediately, preventing black parent pages and stale document objects when the zoom stays the same. Ordinary edits retain partial repainting. No readiness percentage change.
+
Newest first.
++- **2026-10-15** · Start-up picks the GPU that drives the display (or the kind `WGPU_POWER_PREF` or the adapter `WGPU_ADAPTER_NAME` names), and when a start-up fails or hangs it restarts on the next adapter, then the next backend, then a software renderer, keeping recovered documents; start-up errors are logged to standard error and the log file (#273, #334). No readiness percentage change.
+ - **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.
+ - **2026-10-14** · The Color panel's Tint field keeps what is typed while it has focus and applies it on Enter or when it loses focus, clamped to 0–100 %. Typing 60 over 100 % no longer snaps back to 100 after the first digit (10060), and a typed tint is no longer ignored. No readiness percentage change.
+ - **2026-10-15** · IDML: ruler guides import and export (they were dropped). Each page's guides come in measured from the document's ruler origin (spread, page or spine), with Fit to Page, Locked and their layer, parent pages' included, and go out again under their pages. No readiness percentage change.
+ - **2026-10-15** · Find Font no longer reports a style missing when it differs from the installed one only in spacing or case (InDesign files can name `Regular ` with a trailing space); the text was already drawn in the right face. No readiness percentage change.
+ - **2026-10-15** · A line of text is set when its baseline fits in the frame, as in InDesign: descenders may hang below the frame's bottom. A frame sized to the cap height of a big heading (103 pt in a 2.77 cm frame, as Zero2Graphic's magazine tutorial draws them) no longer oversets. No readiness percentage change.
+ - **2026-10-15** · A story that ends with a return is no longer overset when only its empty last paragraph doesn't fit, as in InDesign (Preflight said "Overset text: 0 characters" for a caption InDesign shows with no errors). No readiness percentage change.
+ - **2026-10-15** · Flex Layout (InDesign 2026): Object › Flex Layout (Add to, Convert to, Remove) and a Flex Layout panel laid out as InDesign's, also in Properties. A container lays out its objects by direction, wrap, justification, the alignment grid, Fixed/Auto width and height, padding and spacing, after every edit; Add detects aligned objects (direction, Auto size, Space Between at their spacing); resizing a container reflows its objects instead of scaling them; dragging an object in one reorders it. Montilla Design's tutorial replays step for step. No readiness percentage change.
+ - **2026-10-14** · Layout › Margins and Columns and Layout › Create Guides are laid out as InDesign's: Margins in Top/Bottom and Inside/Outside pairs with a link button that makes all four the same, Rows and Columns side by side, Fit Guides to Margins or Page, and a Preview checkbox that shows the change on the canvas before OK. A measurement field works out arithmetic when you leave it (`0.4375 in*2` becomes `0.875 in`). No readiness percentage change.
+ - **2026-10-14** · The Pathfinder panel is laid out as InDesign's: Paths (Join, Open, Close, Reverse), Pathfinder, Convert Shape and Convert Point, each a row of icon buttons. Join Path closes an open path or joins two at their nearest ends (`path.join`), and Convert Point makes the selected points plain, corner, smooth or symmetrical (`path.convertPoints`). No readiness percentage change.
+ - **2026-10-12** · Linked text files (#597): placed Word, RTF and text files can stay linked; the Links panel shows them OK / Modified / Missing, and Update imports the file again into the same frames with the saved style map (the Links panel asks before replacing edits made in the layout). No readiness percentage change.
+ - **2026-10-15** · IDML: the CJK leading model InDesign writes on [No paragraph style] of every document (Aki Below) only applies when the document uses a Japanese composer, as in InDesign; a Western document's paragraphs after a size change no longer sit lower than in InDesign (Montilla Design's Flex Layout file: its captions came out overset). No readiness percentage change.
+ - **2026-10-14** · Type › Fill with Placeholder Text fills a frame with paragraphs of a few sentences, as InDesign does, so one paragraph can be styled on its own (it was one long paragraph, and the filler ran sentences together, "interit.Ovid"). No readiness percentage change.
+ - **2026-10-13** · Object › Fitting has InDesign's shortcuts: Fill Frame Proportionally ⌘⌥⇧C, Fit Content Proportionally ⌘⌥⇧E, Fit Frame to Content ⌘⌥C, Fit Content to Frame ⌘⌥E, Center Content ⌘⇧E. No readiness percentage change.
+ - **2026-10-13** · Gradients between process colours blend as inks, as InDesign shows them: magenta to cyan passes through C 50 M 50 (a light lilac) on screen instead of the darker RGB mix, and a midpoint between CMYK or grey stops no longer turns the PDF shading RGB. No readiness percentage change.
+ - **2026-10-14** · The Swatches panel has InDesign's header: a Fill/Stroke proxy, Formatting Affects Container/Text and the Tint of the colour in front (a tint alone keeps each object's own swatch). Clicking a swatch applies it to the fill or stroke in front (of the text, when formatting affects text), and the bottom row has New Color Group, New Swatch and Delete Swatch. No readiness percentage change.
+ - **2026-10-14** · With the Page tool, the Control panel shows the page as InDesign's does: W/H from a reference point, page-size preset (US Business Card added), orientation, Liquid Page Rule (now with Controlled by Parent) and Show Parent Page Overlay, which draws the parent page's size over a resized page. No readiness percentage change.
+ - **2026-10-14** · On an object-based page the Page tool shows a selected object's liquid pins and resize locks as InDesign does: a click pins a side to the page edge or locks the width or height, with InDesign's tooltips. No readiness percentage change.
+ - **2026-10-14** · The Liquid Layout panel follows InDesign's: Liquid Page Rule with the page number, Content › Auto-Fit, and Object Constraints › Resize with Page and Pin for the selected object on an object-based page; Create Alternate Layout moved to the Layout menu. No readiness percentage change.
+ - **2026-10-14** · With the Page tool, the Control panel shows the page as InDesign's does: W/H from a reference point, page-size preset (US Business Card added), orientation, Liquid Page Rule (now with Controlled by Parent) and Show Parent Page Overlay, which draws the parent page's size over a resized page. No readiness percentage change.
+ - **2026-10-14** · With the Page tool, the Control panel shows the page as InDesign's does: W/H from a reference point, page-size preset (US Business Card added), orientation, Liquid Page Rule and Show Parent Page Overlay, which draws the parent page's size over a resized page. No readiness percentage change.
+ - **2026-10-14** · The Page tool works as InDesign's: a click selects a page and shows its handles and liquid page rule; dragging a handle previews the rule and springs back, Alt-drag resizes the page from the opposite edge, Shift keeps proportions, with a W/H readout. No readiness percentage change.
+ - **2026-10-14** · With the Page tool, a guide dragged from a ruler is a liquid guide (dashed), as in InDesign; guide-based pages stretch the objects it crosses. No readiness percentage change.
+ - **2026-10-14** · The Pages panel menu follows InDesign's order: Insert Pages…, Move Pages…, Duplicate Spread (and at End of Document), Delete Page/Spread, New Parent…, Apply Parent to Pages, Override All Parent Page Items, Parent Pages, Create Alternate Layout…, Numbering & Section Options…, Allow Selected Spread to Shuffle. No readiness percentage change.
+ - **2026-10-14** · Pages panel: Alt-drag copies a page, a page dropped on Create new page is duplicated at the end, Edit page size offers the presets and Custom Page Size…; duplicated pages keep their own size, rule and guides; thumbnails of pages of their own size stay in their rows. No readiness percentage change.
+ - **2026-10-12 (PDFW)** · PDF, booklet and book composition share guarded writing, metadata and font preparation through craft-pdf. Layout, shaping, placed graphics, colour policy, tagging and PDF/X postprocessing remain in DesignCraft. Failed native drawing returns an export error; failed writer cleanup cannot serialize an incomplete document. No readiness percentage change.
+
+ - **2026-10-13** · Copy with a placed graphic selected (Direct Selection) copies just the graphic, uncropped, where it sits on the page and without the frame's stroke, so Paste Into puts the whole image in place; Cut and Delete then remove only the graphic and leave its frame empty. Nested selections copy in their spread coordinates. No readiness percentage change.
+ - **2026-10-13** · Object effects (Basic Feather, Inner Glow, shadows, glows, bevel, satin, directional and gradient feathers) apply to frames with pasted-in content, on screen and in image exports: the frame, its clipped content and its stroke are one object to the effect. PDF export still has no soft effects for any object. No readiness percentage change.
+ - **2026-10-13** · Links rows show their source paths; selecting a link shows its full path wrapped inside the panel, so same-named files from different folders can be distinguished. No readiness percentage change.
+ - **2026-10-13** · The Text Wrap panel is laid out as InDesign's: the wrap buttons with Invert, and the four offsets (Top, Left, Bottom, Right) showing the object's values, with the link button that sets them all the same. It used to show a single offset, always 0. No readiness percentage change.
+ - **2026-10-13** · Radial gradients stretch with the object's box, as InDesign draws them: by default an ellipse reaching the frame's sides (it was a circle reaching only the longer side), and a Gradient Swatch tool drag keeps the box's proportions; on screen and in PDF. No readiness percentage change.
+ - **2026-10-13** · The Window menu follows InDesign's order (Arrange, Workspace, then the panels alphabetically with Color, Editorial, Object & Layout, Styles… submenus), and Window › Workspace lists the workspaces as InDesign does, now with Essentials Classic: the Control panel and an icon column of named panel groups. No readiness percentage change.
+ - **2026-10-14** · In a facing document, pages take their side from their section's page numbers, as InDesign shuffles them: a section that starts at 1 on a left page moves it to the right and the pages after it follow, with their objects. No readiness percentage change.
+ - **2026-10-14** · The Type menu follows InDesign's order (Size, Character ⌘T, Paragraph ⌥⌘T, Glyphs, the style panels, Notes, footnotes and endnotes, then the insert submenus and Show Hidden Characters); Current Page Number has ⌥⇧⌘N. No readiness percentage change.
+ - **2026-10-14** · Colour parameters: a bare `{c,m,y,k}` is always read as 0..100, so C 1 is a 1 % tint and no longer
+ solid cyan; fractions take the colour's own `{model: "cmyk", …}` form (#910). No readiness percentage change.
+ - **2026-10-14** · The Tools panel follows InDesign's: Gradient Swatch and Gradient Feather are tools of their own; in two columns Content Collector and Placer, Apply Color / Gradient / None and Normal / Preview each get a button; View Options holds Frame Edges, Rulers, Guides, Smart Guides, Baseline Grid and Hidden Characters; Apply Color (,) and Apply Gradient (.) reuse the last colour and gradient. No readiness percentage change.
+ - **2026-10-13** · Create Outlines makes one compound path per line (and per text colour within a line), grouped, as InDesign does: Ungroup then leaves each line on its own to be spaced and made into one compound path again. A single line in one colour stays a single compound path. No readiness percentage change.
+ - **2026-10-13** · Gradient swatches work on strokes: drawn across the path's box on screen and in PDF (they drew nothing), set with `object.gradient {target: stroke}` and in the Gradient panel when the Stroke box is in front; the stroke's gradient vector moves with the shape and round-trips through IDML. No readiness percentage change.
+ - **2026-10-13** · Text takes gradient swatches: a gradient fill or stroke on characters spans the text frame's box (on a path: the path's), on screen and in PDF. No readiness percentage change.
+ - **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-14** · Georgian interface (`ka`, Edit ▸ Interface Language ▸ ქართული): every catalog key
+ translated, count captions as `noun: n`.
+ - **2026-10-13** · Layout ▸ Table of Contents opens a real dialog: title and title style, Include Paragraph Styles and Other Styles lists with Add and Remove, and per style its entry style, page number position (after, before, none), separator and level. Replace Existing regenerates the current table of contents in place; otherwise OK makes a new frame on the page in view. IDML export writes the definition as a TOC style that import reads back, so Update works after a round trip. No readiness percentage change.
+ - **2026-10-13** · Control-channel clicks and drags validate positive counts and the complete pending-event budget before queuing input (#732). Oversized requests leave pending gestures intact, preventing unbounded click-count allocation. No readiness percentage change.
+ - **2026-10-13** · Backspace between two consecutive tables, pasting a table next to a table anchor, and pasting several paragraphs right before one keep every table on its own anchor paragraph. Previously a table was dropped or left without its anchor, and the saved file failed to reopen. No readiness percentage change.
+ - **2026-10-13** · Dialogs and the About window move when you drag their title row, so the page behind them can be seen. A dragged dialog may go partly off-screen, but its title row stays reachable; each dialog opens centred, and again after the window is resized. No readiness percentage change.
+ - **2026-10-13** · Command scripts look up only a well-formed `$N.path` / `$last.path` reference; other strings starting with `$`, such as a GREP replacement of `$1` and a nonbreaking space, stay as written, and `$$` writes a literal `$` (#749). No readiness percentage change.
+ - **2026-10-13** · An explicit recovery folder (`file.recovery.save` with `dir`) never overwrites or deletes another running app's checkpoints. Document uids start at 1 in every process, so two apps saving recovery to one chosen folder replaced or removed each other's `<uid>.designcraft`. A run replaces or removes only the entries it wrote or recovered there, refuses an occupied uid, and refuses a folder whose run lock another app holds. No readiness percentage change.
+ - **2026-10-13** · Path edits (`path.setAnchor`, `path.moveAnchors`, `path.appendAnchor`, `path.reverse`, `path.close`, anchor add/delete/convert, Erase, Smooth and Scissors) refuse a path that is locked, sits in a locked group or on a locked layer (#735). Properties links to the Stroke, Character, Paragraph, Effects, Text Wrap and Info panels open them in a customized panel layout too (#736). No readiness percentage change.
+ - **2026-10-13** · IDML export keeps parent item overrides: each page lists its overridden parent items and the local copy keeps its link to the parent item, so a reopened IDML file shows only the local copy (#725). No readiness percentage change.
+ - **2026-10-13** · macOS: a command chosen with the mouse in the menu bar runs at once. It used to wait for the next mouse move or key press over the window, so File › Open, Place and Save As seemed to take 10–20 seconds to open their dialogs. No readiness percentage change.
+ - **2026-10-13** · Text recomposes when the document baseline grid changes, when a layer holding a text-wrap object is shown or hidden, or when a section's start number, numbering style, prefix or marker changes; the composition cache keyed only on the section count and item identities and kept the old layout. No readiness percentage change.
+ - **2026-10-13** · Reflowable EPUB and HTML export include tables (header and footer rows, merged cells), footnotes (a linked note after the paragraph that refers to it) and endnotes (a linked section at the end of the book). No readiness percentage change.
+ - **2026-10-13** · Word import: table cells read text by the same rules as body text, so deleted text, moved-away text and field codes stay out (#721). Word's Normal comes in as its own paragraph style "Normal" over the document defaults, so text formatted only by Normal keeps its look; it conflicts only with a document's own Normal, and the style map can send it to [Basic Paragraph] (#722). No readiness percentage change.
+ - **2026-10-12** · macOS Dock Quit uses the same unsaved-document prompts as window and menu Quit. Repeated requests keep the current answers; Cancel retains every tab and unsaved recovery checkpoint, and completed Save/Don't Save answers exit through the ordinary event loop. No readiness percentage change.
+ - **2026-10-12** · Text strokes can sit behind the fill: the stroke lies wholly outside the letters at its full weight on screen, in PNG and in PDF, set from the Properties panel or Character Style Options. IDML `StrokeAlignment` on text imports and exports as this setting, so imported text with outside-aligned strokes keeps its letter shapes (#619). No readiness percentage change.
+ - **2026-10-12** · Placed Word documents keep their bullets and numbering (#626): `numbering.xml` levels become bullet or numbered paragraphs with Word's number formats, label text, start numbers, restarts and list indents, also when a paragraph style carries the list. No readiness percentage change.
+ - **2026-10-12** · Orderly native exit writes the latest recovery state after finalizing current quit approvals; incomplete or stale plans keep their documents, and Undo to the saved state clears stale recovery. Unavailable or failed recovery is reported. Cancelable macOS Dock Quit remains open (#544). No readiness percentage change.
+ - **2026-10-12** · Recovered documents keep a checkpoint until saved, closed or reverted, including a second crash before autosave. Restarted document IDs and explicit recovery folders preserve other snapshots; failed republishing retains the original. No readiness percentage change.
+ - **2026-10-12** · Book numbering and style updates prepare every chapter before saving. Only closed native chapters are changed; imported IDML remains a read-only style/PDF source. If a later disk write fails, the error names the completed chapters; the batch is not a whole-book transaction. No readiness percentage change.
+ - **2026-10-12** · Desktop write callbacks and CLI raster exports use the atomic writer too; open readers retain the original bytes, while private Unix modes and symlink targets survive replacement. Permanent tests cover both actual callers. No readiness percentage change.
+ - **2026-10-12** · Save As, library edits and book collection edits persist prospective values before changing live state; failed writes preserve the document and existing collections. Save a Copy rebases data-source paths for its destination without changing the open document. No readiness percentage change.
+ - **2026-10-12** · The Pen tool continues an open path from either end point, as in InDesign: the cursor shows it over an end point, a click there carries on drawing that path, a drag first reshapes the end point's direction lines, and the other end closes it. Object › Paths › Reverse Path (`path.reverse`); `path.setAnchor`; `path.appendAnchor` and `path.close` take a subpath. No readiness percentage change.
+ - **2026-10-12** · Editing type on a path: the Type tool clicks, drags and double-clicks along the curve (the character under the pointer, not one on the straightened line), a click on the letters themselves hits the frame, and the caret and highlight bend with the path. No readiness percentage change.
+ - **2026-10-12** · Type on a path has start and end brackets, as in InDesign: selected path type shows them across the path, and dragging either with the Selection or Direct Selection tool moves where the text starts or ends (text past the end bracket is overset). `type.pathOptions {end}`; IDML reads and writes EndBracket. No readiness percentage change.
+ - **2026-10-12** · The Eyedropper puts a colour sampled from an image on the stroke when the toolbox's Stroke box is in front, as in InDesign (a line takes it on its stroke). No readiness percentage change.
+ - **2026-10-12** · Window close and application/menu Quit ask about unsaved documents; later Cancel keeps every tab open, including earlier Don't Save choices. Approvals are rechecked after edits. Cancelable macOS Dock Quit remains open (#544). No readiness percentage change.
+ - **2026-10-12** · Each running app keeps recovery data in its own locked folder; current folder and lock ownership are checked before writes and cleanup. Failed isolation disables recovery with a warning instead of sharing document IDs. No readiness percentage change.
+ - **2026-10-12** · Native engine saves and exports replace files atomically; failed writes retain the original, private staging preserves Unix permissions, and valid long filenames work. Desktop Services and CLI raster exports remain separate follow-ups. No readiness percentage change.
+ - **2026-10-12** · Hyphenation Zone applies to the Single-line Composer only, as in InDesign. With the default Paragraph Composer, ragged text hyphenates where InDesign does (aper-natem), giving the same line breaks. No readiness percentage change.
+ - **2026-10-12** · The Tools panel's Fill/Stroke keys work: D (default fill and stroke), X (fill or stroke in front), Shift+X (swap per object, tints included) and / (Apply None), as `color.*` commands; swap and default are one undo step (`object.swapFillStroke`, `object.defaultFillStroke`); the Color panel follows the proxy's fill/stroke choice. 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** · `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** · 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-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-13** · Placed PDFs are drawn through pdfcraft's patched hayro crates: calculator functions whose `idiv` divides by zero or overflows, chains of stitching functions a hundred thousand deep, and mesh shadings with points far off the page, ten thousand overlapping triangles or forty thousand patches no longer panic, overflow the stack, run for over a minute or use more than 2 GiB of memory. A page with a `/UserUnit`, and its trim, bleed and art boxes, are sized in points. 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** · Edit › Step and Repeat has its InDesign dialog: Repeat (Count, or Rows and Columns with Create as a grid), Offset (Vertical, Horizontal, in ruler units) and Preview, which shows the copies while the dialog is open; Cancel takes them away and OK makes them as one undo step. No readiness percentage change.
+ - **2026-10-12** · Double-clicking the Fill or Stroke box in the Tools panel opens the Color Picker with the selection's colour, as in InDesign (it opened the Swatches panel). No readiness percentage change.
+ - **2026-10-12** · The Effects panel shows the level its settings apply to ("Group: Color Dodge 100%") and, as in InDesign, Isolate Blending and Knockout Group for a selected group. 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-12** · The Eyedropper samples a placed image: clicking the photo with text (or objects) selected fills them with the image's colour under the pointer, as an unnamed colour (`color.sample`), as in InDesign. Images on locked layers can be sampled. 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** · On screen, blend modes blend with the objects below and not with the paper, as in InDesign and in PDF export: a Color Dodge or Screen object over blank paper shows as it is. No readiness percentage change.
+ - **2026-10-12** · A gradient feather on a group fades the group as one, on screen and in PDF. Before, the screen ignored it, and PDF masked the group with a box of zero size because a group has no path of its own. No readiness percentage change.
+ - **2026-10-12** · In a CMYK transparency blend space (print documents), blend modes blend in CMYK on screen as in InDesign. Color Dodge with 100% K text turns coloured areas under it white and leaves the paper alone, where RGB blending changed almost nothing. PDF export already did this. No readiness percentage change.
+ - **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-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-12** · Load Swatches refuses an `.ase` file with more than 100,000 colors, and `swatch.load` merges a file of 100,000 colors in under 0.1 s (it took 9.6 s of CPU in a test build). 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-13** · Dropping an `.ase` file on the window loads its swatches, as Load Swatches does (the drop failed with "Can't Place the File"). 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-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, CLI
+ smoke-tested under QEMU).
- **2026-10-10** · Readiness per audience: full ~47% (method aligned with the standard, was
42%), mainstream practitioner ~42%, essentials user ~54%, each with hours to ~95%.
- **2026-10-10** · Stage re-normalized to **pre-alpha** under craftrules' core-workflow gate: text
diff --cc apps/designcraft/Cargo.toml
index a18c28a8a,0f08ae8ed..6cb30b94e
--- a/apps/designcraft/Cargo.toml
+++ b/apps/designcraft/Cargo.toml
@@@ -29,11 -31,7 +31,13 @@@ arboard = { workspace = true
# The same winit eframe uses: to pick the X11 backend (file drag-and-drop) in main.rs.
winit = { version = "0.30", default-features = false, features = ["x11"] }
+[target.'cfg(windows)'.dependencies]
+# EnumDisplayDevices (src/gpu.rs): which GPU drives the display, so the window draws on the GPU
+# that shows it; drawing on a GPU without a monitor reset the display driver. Safe wrappers over
+# Win32 (MIT); the `user` feature is User32.dll only.
+winsafe = { version = "0.0.29", default-features = false, features = ["user"] }
+
[target.'cfg(target_os = "macos")'.dependencies]
+ # The same winit as eframe; only the native termination opt-in is used.
+ winit = { version = "0.30", default-features = false }
muda = { version = "0.21", default-features = false }
diff --cc apps/designcraft/src/gpu/backend.rs
index 3cfd672df,000000000..7a944b35c
mode 100644,000000..100644
--- a/apps/designcraft/src/gpu/backend.rs
+++ b/apps/designcraft/src/gpu/backend.rs
@@@ -1,518 -1,0 +1,520 @@@
+//! Which wgpu backend draws the window, and the fallback when one of them takes the process down
+//! at start-up.
+//!
+//! A fault inside a graphics driver can't be caught: on an AMD hybrid-graphics laptop (a Radeon
+//! RX 6800M beside an integrated Radeon, two versions of `amdvlk64.dll` loaded into the process)
+//! AMD's Vulkan driver faulted with an access violation at the first swapchain present; creating
+//! an OpenGL instance crashed inside AMD's `atio6axx.dll` (#167); and creating a Vulkan instance
+//! loads every installed Vulkan driver into the process, of which a faulty one (Intel's
+//! `igvk64.dll`, VectorCraft #806) crashed before the window appeared. So each start creates the
+//! instance with one backend, chosen before the window exists: on Windows DirectX 12 first, then
+//! OpenGL, then Vulkan, each on its own; on Linux Vulkan, with OpenGL beside it as the in-process
+//! fallback, then OpenGL alone; on macOS Metal. `WGPU_BACKEND` — wgpu's own variable: `dx12`,
+//! `vulkan`, `gl`, `metal`, or a comma-separated list — overrides the choice and turns the
+//! fallback off.
+//!
+//! The fallback: before the window is created, `gpu.json` in the settings directory records the
+//! backend being tried; once a frame has been presented, or the graphics failed with an error the
+//! app caught (see `gpu::finish`), that entry is cleared. An entry still there at the next start
+//! means the previous start never got that far — the driver crashed, or the app was killed
+//! meanwhile — so that backend joins `failed`, the next candidate is tried and the status bar says
+//! so. Backends a restart left out (`--gpu-skip=`, see `gpu`) aren't chosen for that start but
+//! aren't recorded: the restart caught their failure, and a later launch may try them again. When
+//! every candidate has failed the list starts over, and so does a new DesignCraft version (drivers
+//! and wgpu move on). `DESIGNCRAFT_NO_PREFS` records nothing.
+
+use std::path::{Path, PathBuf};
+
+use eframe::wgpu;
+use serde::{Deserialize, Serialize};
+
+/// The record's file name inside the settings directory.
+pub const FILE: &str = "gpu.json";
+
+/// A graphics backend wgpu can draw the window with.
+#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
+#[serde(rename_all = "lowercase")]
+pub enum Backend {
+ Dx12,
+ Vulkan,
+ Metal,
+ Gl,
+}
+
+impl Backend {
+ /// The name the status bar and the log use.
+ pub fn name(self) -> &'static str {
+ match self {
+ Backend::Dx12 => "DirectX 12",
+ Backend::Vulkan => "Vulkan",
+ Backend::Metal => "Metal",
+ Backend::Gl => "OpenGL",
+ }
+ }
+
+ /// wgpu's bit for this backend.
+ pub fn bit(self) -> wgpu::Backends {
+ match self {
+ Backend::Dx12 => wgpu::Backends::DX12,
+ Backend::Vulkan => wgpu::Backends::VULKAN,
+ Backend::Metal => wgpu::Backends::METAL,
+ Backend::Gl => wgpu::Backends::GL,
+ }
+ }
+
+ /// How a restart's skip list ([`super::skip_arg`]) names the whole backend: wgpu's name for it, which also
+ /// starts each of its adapters' keys (`Dx12:10de:2204`).
+ pub fn key(self) -> &'static str {
+ match self {
+ Backend::Dx12 => "Dx12",
+ Backend::Vulkan => "Vulkan",
+ Backend::Metal => "Metal",
+ Backend::Gl => "Gl",
+ }
+ }
+
+ /// The backend [`Backend::key`] names; `None` for anything else, such as an adapter's key.
+ pub fn from_key(key: &str) -> Option<Backend> {
+ [Backend::Dx12, Backend::Vulkan, Backend::Metal, Backend::Gl].into_iter().find(|b| b.key() == key)
+ }
+
+ /// The backend of the adapter wgpu picked; `None` for the web and no-op backends.
+ pub fn of(backend: wgpu::Backend) -> Option<Backend> {
+ match backend {
+ wgpu::Backend::Dx12 => Some(Backend::Dx12),
+ wgpu::Backend::Vulkan => Some(Backend::Vulkan),
+ wgpu::Backend::Metal => Some(Backend::Metal),
+ wgpu::Backend::Gl => Some(Backend::Gl),
+ _ => None,
+ }
+ }
+}
+
+/// The backends to try on this platform, best first. Windows reaches Vulkan last: creating its
+/// instance loads every installed Vulkan driver (VectorCraft #806).
+pub fn candidates() -> &'static [Backend] {
+ if cfg!(windows) {
+ &[Backend::Dx12, Backend::Gl, Backend::Vulkan]
+ } else if cfg!(target_os = "macos") {
+ &[Backend::Metal]
+ } else {
+ &[Backend::Vulkan, Backend::Gl]
+ }
+}
+
+/// What `gpu.json` holds.
+#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
+pub struct Record {
+ /// The DesignCraft version that wrote the record; another version starts afresh.
+ #[serde(default)]
+ pub version: String,
+ /// The backend of a start that has not presented a frame yet.
+ #[serde(default)]
+ pub trying: Option<Backend>,
+ /// Backends whose start never presented a frame.
+ #[serde(default)]
+ pub failed: Vec<Backend>,
+}
+
+/// The backend for a start, from [`choose`].
+#[derive(Clone, Debug, PartialEq, Eq)]
+pub struct Choice {
+ pub backend: Backend,
+ /// The record to write before the window is created.
+ pub record: Record,
+ /// The backend the previous start never finished with, when this start moves away from it.
+ pub switched_from: Option<Backend>,
+}
+
+/// The backends a restart's skip list leaves out ([`super::skip_arg`]): a restart found no adapter
+/// of them that could show the window.
+pub fn skipped_backends(skip: &[String]) -> Vec<Backend> {
+ skip.iter().filter_map(|k| Backend::from_key(k)).collect()
+}
+
+/// Pick the backend for this start from the candidates (best first), the previous start's record
+/// and the backends a restart left out (`skipped`, not recorded); `None` without candidates.
+pub fn choose(candidates: &[Backend], previous: &Record, version: &str, skipped: &[Backend]) -> Option<Choice> {
+ let first = *candidates.first()?;
+ let same_version = previous.version == version;
+ let mut failed: Vec<Backend> = if same_version { previous.failed.clone() } else { Vec::new() };
+ let unfinished = previous.trying.filter(|_| same_version);
+ if let Some(b) = unfinished
+ && !failed.contains(&b)
+ {
+ failed.push(b);
+ }
+ failed.retain(|b| candidates.contains(b));
+ let pick = |failed: &[Backend]| candidates.iter().copied().find(|b| !failed.contains(b) && !skipped.contains(b));
+ let backend = match pick(&failed) {
+ Some(b) => b,
+ // Every candidate has failed: start over rather than never starting.
+ None => {
+ failed.clear();
+ pick(&failed).unwrap_or(first)
+ }
+ };
+ let switched_from = unfinished.filter(|b| *b != backend);
+ Some(Choice { backend, record: Record { version: version.to_owned(), trying: Some(backend), failed }, switched_from })
+}
+
+/// The record in `path`; a missing or unreadable file is an empty record.
+pub fn read(path: &Path) -> Record {
+ std::fs::read(path).ok().and_then(|bytes| serde_json::from_slice(&bytes).ok()).unwrap_or_default()
+}
+
+/// Write `record` to `path` (creating the directory).
+pub fn write(path: &Path, record: &Record) -> std::io::Result<()> {
+ if let Some(dir) = path.parent() {
+ std::fs::create_dir_all(dir)?;
+ }
+ let bytes = serde_json::to_vec_pretty(record).map_err(std::io::Error::other)?;
+ std::fs::write(path, bytes)
+}
+
+/// See [`Fallback::backends`].
+fn instance_backends(backend: Backend, failed: &[Backend]) -> wgpu::Backends {
+ let mut backends = backend.bit();
+ if !cfg!(windows) && !failed.contains(&Backend::Gl) {
+ backends |= wgpu::Backends::GL;
+ }
+ backends
+}
+
+/// The first of `candidates` whose bit isn't in `tried` and that hasn't `failed`.
+fn next_candidate(candidates: &[Backend], tried: wgpu::Backends, failed: &[Backend]) -> Option<Backend> {
+ candidates.iter().copied().find(|b| !tried.contains(b.bit()) && !failed.contains(b))
+}
+
+/// A start in progress: the backend chosen for it and the record that says so until a frame has
+/// been presented.
+#[derive(Debug)]
+pub struct Fallback {
+ pub backend: Backend,
+ pub switched_from: Option<Backend>,
+ /// The backends the instance is created with ([`Fallback::backends`]).
+ instance: wgpu::Backends,
+ /// `gpu.json`, when the record is persisted.
+ path: Option<PathBuf>,
+ record: Record,
+}
+
+impl Fallback {
+ /// Choose the backend for this start and record it in `path` (nothing is recorded without
+ /// one), leaving out the backends a restart `skipped`. `None` when `WGPU_BACKEND` is set —
+ /// wgpu follows it and the fallback is off — or the platform has no candidates.
+ pub fn begin(path: Option<PathBuf>, version: &str, skipped: &[Backend]) -> Option<Fallback> {
+ if wgpu::Backends::from_env().is_some_and(|b| !b.is_empty()) {
+ log::info!("graphics: WGPU_BACKEND is set, wgpu picks the backend and the start-up fallback is off");
+ return None;
+ }
+ Self::begin_unforced(path, version, skipped)
+ }
+
+ fn begin_unforced(path: Option<PathBuf>, version: &str, skipped: &[Backend]) -> Option<Fallback> {
+ let previous = path.as_deref().map(read).unwrap_or_default();
+ let choice = choose(candidates(), &previous, version, skipped)?;
+ if let Some(p) = &path
+ && let Err(e) = write(p, &choice.record)
+ {
+ log::warn!("graphics: {}: {e}", p.display());
+ }
+ match choice.switched_from {
+ Some(from) => log::warn!(
+ "graphics: the last start with {} never showed a frame; trying {} (failed so far: {:?})",
+ from.name(),
+ choice.backend.name(),
+ choice.record.failed
+ ),
+ None => log::info!("graphics: {} (WGPU_BACKEND overrides)", choice.backend.name()),
+ }
+ let instance = instance_backends(choice.backend, &choice.record.failed);
+ Some(Fallback { backend: choice.backend, switched_from: choice.switched_from, instance, path, record: choice.record })
+ }
+
+ /// The backends wgpu may use: the chosen one, with OpenGL as the in-process fallback when it
+ /// has no adapter (unless OpenGL itself has failed). Not on Windows: some OpenGL drivers
+ /// (AMD's) crash while the instance is created (#167), before any fallback could help, so
+ /// there OpenGL is only ever tried as its own candidate.
+ pub fn backends(&self) -> wgpu::Backends {
+ self.instance
+ }
+
+ /// wgpu picked an adapter of `backend`: record that one, so a crash is blamed on the backend
+ /// that is actually drawing.
+ pub fn started_with(&mut self, backend: Backend) {
+ if self.record.trying == Some(backend) {
+ return;
+ }
+ self.backend = backend;
+ self.record.trying = Some(backend);
+ self.save();
+ }
+
+ /// The backend to start again with when no adapter of this start's backends could show the
+ /// window: the next candidate not among them, not failed and not left out by a restart
+ /// (`skipped`). `None` when there is none, so the restarts end.
+ pub fn next_after(&self, skipped: &[Backend]) -> Option<Backend> {
+ let tried = skipped.iter().fold(self.backends(), |set, b| set | b.bit());
+ next_candidate(candidates(), tried, &self.record.failed)
+ }
+
+ /// The start got past the point where a driver fault could take the process down: a frame was
+ /// presented, the app exited normally, or the graphics failed with an error the app caught.
+ /// Returns the backend that was being tried, for [`Fallback::retry`].
+ pub fn finished(&mut self) -> Option<Backend> {
+ let trying = self.record.trying.take();
+ if trying.is_some() {
+ self.save();
+ }
+ trying
+ }
+
+ /// Undo [`Fallback::finished`]: the start isn't over after all (starting again failed).
+ pub fn retry(&mut self, trying: Option<Backend>) {
+ if self.record.trying != trying {
+ self.record.trying = trying;
+ self.save();
+ }
+ }
+
+ /// The status-bar line for a start that moved away from a backend that crashed.
+ pub fn status_line(&self) -> Option<String> {
+ let from = self.switched_from?;
+ Some(format!(
+ "Graphics: switched from {} to {} — the last start with {} never showed a frame (set WGPU_BACKEND to choose).",
+ from.name(),
+ self.backend.name(),
+ from.name()
+ ))
+ }
+
+ fn save(&self) {
+ if let Some(p) = &self.path
+ && let Err(e) = write(p, &self.record)
+ {
+ log::warn!("graphics: {}: {e}", p.display());
+ }
+ }
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+ use std::sync::atomic::{AtomicUsize, Ordering};
+
+ const V: &str = "0.5.0";
+ const WIN: &[Backend] = &[Backend::Dx12, Backend::Gl, Backend::Vulkan];
+
+ fn temp_path(tag: &str) -> PathBuf {
+ static N: AtomicUsize = AtomicUsize::new(0);
+ let d = std::env::temp_dir().join(format!("designcraft-gpu-{tag}-{}-{}", std::process::id(), N.fetch_add(1, Ordering::Relaxed)));
+ let _ = std::fs::remove_dir_all(&d);
+ d.join(FILE)
+ }
+
+ fn record(trying: Option<Backend>, failed: &[Backend]) -> Record {
+ Record { version: V.into(), trying, failed: failed.to_vec() }
+ }
+
+ #[test]
+ fn every_platform_has_candidates_without_duplicates() {
+ let c = candidates();
+ assert!(!c.is_empty());
+ for (i, b) in c.iter().enumerate() {
+ assert!(!c[..i].contains(b), "{b:?} twice in {c:?}");
+ }
+ if cfg!(windows) {
+ assert_eq!(c, WIN, "DirectX 12 first (AMD's Vulkan driver faulted at the first present), Vulkan last (#806)");
+ }
+ if cfg!(target_os = "macos") {
+ assert_eq!(c, &[Backend::Metal]);
+ }
+ }
+
+ #[test]
+ fn a_fresh_start_takes_the_first_candidate() {
+ let c = choose(WIN, &Record::default(), V, &[]).unwrap();
+ assert_eq!(c.backend, Backend::Dx12);
+ assert_eq!(c.record, record(Some(Backend::Dx12), &[]));
+ assert_eq!(c.switched_from, None);
+ assert!(choose(&[], &Record::default(), V, &[]).is_none());
+ }
+
+ #[test]
+ fn a_start_that_never_presented_moves_to_the_next_candidate() {
+ let c = choose(WIN, &record(Some(Backend::Dx12), &[]), V, &[]).unwrap();
+ assert_eq!(c.backend, Backend::Gl);
+ assert_eq!(c.record, record(Some(Backend::Gl), &[Backend::Dx12]));
+ assert_eq!(c.switched_from, Some(Backend::Dx12));
+
+ let c = choose(WIN, &record(Some(Backend::Gl), &[Backend::Dx12]), V, &[]).unwrap();
+ assert_eq!(c.backend, Backend::Vulkan);
+ assert_eq!(c.record.failed, &[Backend::Dx12, Backend::Gl]);
+ assert_eq!(c.switched_from, Some(Backend::Gl));
+ }
+
+ #[test]
+ fn a_finished_start_keeps_the_failed_list_and_switches_silently() {
+ // `trying` was cleared by a presented frame; the next start still avoids what failed.
+ let c = choose(WIN, &record(None, &[Backend::Dx12]), V, &[]).unwrap();
+ assert_eq!(c.backend, Backend::Gl);
+ assert_eq!(c.record.failed, &[Backend::Dx12]);
+ assert_eq!(c.switched_from, None);
+ // The same backend failing again is listed once.
+ let c = choose(WIN, &record(Some(Backend::Dx12), &[Backend::Dx12]), V, &[]).unwrap();
+ assert_eq!(c.record.failed, &[Backend::Dx12]);
+ }
+
+ #[test]
+ fn when_every_candidate_failed_the_list_starts_over() {
+ let c = choose(WIN, &record(Some(Backend::Vulkan), &[Backend::Dx12, Backend::Gl]), V, &[]).unwrap();
+ assert_eq!(c.backend, Backend::Dx12);
+ assert_eq!(c.record.failed, &[]);
+ assert_eq!(c.switched_from, Some(Backend::Vulkan));
+ }
+
+ #[test]
+ fn another_version_or_platform_forgets_what_failed() {
+ let old = Record { version: "0.4.0".into(), trying: Some(Backend::Dx12), failed: vec![Backend::Vulkan] };
+ let c = choose(WIN, &old, V, &[]).unwrap();
+ assert_eq!(c.backend, Backend::Dx12);
+ assert_eq!(c.record, record(Some(Backend::Dx12), &[]));
+ assert_eq!(c.switched_from, None);
+ // A backend that is no candidate here (a record copied from another machine) is dropped.
+ let c = choose(&[Backend::Vulkan, Backend::Gl], &record(None, &[Backend::Metal, Backend::Vulkan]), V, &[]).unwrap();
+ assert_eq!(c.backend, Backend::Gl);
+ assert_eq!(c.record.failed, &[Backend::Vulkan]);
+ }
+
+ /// A restart that found no adapter of DirectX 12 names the backend in its skip list: that start
+ /// takes the next candidate, with or without a record, and the record doesn't keep it as failed
+ /// (a later launch tries it again).
+ #[test]
+ fn backends_a_restart_left_out_are_not_chosen_or_recorded() {
+ let skip: Vec<String> = ["Dx12:10de:2204", "Dx12", "Metal:Intel Iris Pro Graphics", "dx12", ""].map(String::from).to_vec();
+ assert_eq!(skipped_backends(&skip), [Backend::Dx12]);
+ // A backend's key is wgpu's name for it, the prefix of its adapters' keys.
+ for w in [wgpu::Backend::Dx12, wgpu::Backend::Vulkan, wgpu::Backend::Metal, wgpu::Backend::Gl] {
+ let b = Backend::of(w).expect("native backend");
+ assert_eq!(b.key(), format!("{w:?}"));
+ assert_eq!(Backend::from_key(b.key()), Some(b));
+ }
+ let c = choose(WIN, &Record::default(), V, &[Backend::Dx12]).unwrap();
+ assert_eq!(c.backend, Backend::Gl);
+ assert_eq!(c.record, record(Some(Backend::Gl), &[]));
+ let c = choose(WIN, &record(None, &[Backend::Gl]), V, &[Backend::Dx12]).unwrap();
+ assert_eq!(c.record, record(Some(Backend::Vulkan), &[Backend::Gl]));
+ // Every candidate failed or left out: the record starts over, still without the left-out one.
+ let c = choose(WIN, &record(Some(Backend::Vulkan), &[Backend::Gl]), V, &[Backend::Dx12]).unwrap();
+ assert_eq!(c.record, record(Some(Backend::Gl), &[]));
+ // A backend that is no candidate here is ignored.
+ let c = choose(WIN, &Record::default(), V, &[Backend::Metal]).unwrap();
+ assert_eq!(c.backend, Backend::Dx12);
+ }
+
+ /// When no adapter of a start's backends could show the window, the restart moves on to a
+ /// backend not yet tried in this start (an in-process OpenGL fallback counts as tried), and
+ /// the restarts end once none is left.
+ #[test]
+ fn the_next_backend_after_one_without_a_working_adapter() {
+ let none = wgpu::Backends::empty();
+ assert_eq!(next_candidate(WIN, wgpu::Backends::DX12, &[]), Some(Backend::Gl));
+ assert_eq!(next_candidate(WIN, wgpu::Backends::DX12 | wgpu::Backends::GL, &[]), Some(Backend::Vulkan));
+ assert_eq!(next_candidate(WIN, wgpu::Backends::DX12, &[Backend::Gl]), Some(Backend::Vulkan));
+ assert_eq!(next_candidate(WIN, wgpu::Backends::all(), &[]), None);
+ assert_eq!(next_candidate(WIN, none, &[Backend::Dx12, Backend::Gl, Backend::Vulkan]), None);
+ // Linux: Vulkan with OpenGL beside it has tried both.
+ assert_eq!(next_candidate(&[Backend::Vulkan, Backend::Gl], wgpu::Backends::VULKAN | wgpu::Backends::GL, &[]), None);
+ assert_eq!(next_candidate(&[Backend::Metal], wgpu::Backends::METAL | wgpu::Backends::GL, &[]), None);
+
+ let s = Fallback::begin_unforced(None, V, &[]).expect("candidates");
+ let next = s.next_after(&[]);
+ if cfg!(windows) {
+ assert_eq!(next, Some(Backend::Gl));
+ assert_eq!(s.next_after(&[Backend::Gl]), Some(Backend::Vulkan));
+ assert_eq!(s.next_after(&[Backend::Gl, Backend::Vulkan]), None);
+ } else {
+ assert_eq!(next, None, "the first start already has OpenGL beside its backend");
+ }
+ }
+
+ #[test]
+ fn the_record_round_trips_and_garbage_reads_as_empty() {
+ let path = temp_path("roundtrip");
+ assert_eq!(read(&path), Record::default());
+ let r = record(Some(Backend::Vulkan), &[Backend::Dx12]);
+ write(&path, &r).expect("write");
+ assert_eq!(read(&path), r);
+ let text = std::fs::read_to_string(&path).expect("read");
+ assert!(text.contains("\"trying\": \"vulkan\"") && text.contains("\"dx12\""), "{text}");
+ std::fs::write(&path, b"{not json").expect("garbage");
+ assert_eq!(read(&path), Record::default());
+ // Unknown fields and missing ones are tolerated.
+ std::fs::write(&path, br#"{"failed":["gl"],"later":1}"#).expect("partial");
+ assert_eq!(read(&path), Record { version: String::new(), trying: None, failed: vec![Backend::Gl] });
+ let _ = std::fs::remove_dir_all(path.parent().expect("dir"));
+ }
+
+ #[test]
+ fn a_start_records_its_backend_until_a_frame_is_presented() {
+ let path = temp_path("startup");
+ let mut s = Fallback::begin_unforced(Some(path.clone()), V, &[]).expect("candidates");
+ let first = candidates()[0];
+ assert_eq!(s.backend, first);
+ assert_eq!(read(&path).trying, Some(first));
+ assert!(s.backends().contains(first.bit()));
+ // OpenGL is the in-process fallback, except on Windows where it is only its own candidate
+ // (#167), and Windows never loads Vulkan drivers on its first try (#806).
+ assert_eq!(s.backends().contains(wgpu::Backends::GL), !cfg!(windows) || first == Backend::Gl);
+ if cfg!(windows) {
+ assert_eq!(s.backends(), wgpu::Backends::DX12);
+ }
+ assert_eq!(s.status_line(), None);
+
+ // wgpu actually picked OpenGL (the chosen backend had no adapter): blame that one.
+ s.started_with(Backend::Gl);
+ assert_eq!(read(&path).trying, Some(Backend::Gl));
+ // A restart takes the entry and puts it back when starting again failed.
+ let trying = s.finished();
+ assert_eq!((trying, read(&path)), (Some(Backend::Gl), record(None, &[])));
+ s.retry(trying);
+ assert_eq!(read(&path).trying, Some(Backend::Gl));
+ s.finished();
+ assert_eq!(read(&path), record(None, &[]));
+ assert_eq!(s.finished(), None);
+ assert_eq!(read(&path), record(None, &[]));
+
+ // The next start after one that never presented: switches, says so, and leaves OpenGL
+ // out of the set once it failed.
+ write(&path, &record(Some(Backend::Gl), &[])).expect("write");
+ let s = Fallback::begin_unforced(Some(path.clone()), V, &[]).expect("candidates");
- if candidates().len() > 1 {
++ // This synthetic prior start records OpenGL even on Metal-only macOS.
++ // Switching depends on the chosen backend, not the candidate count.
++ if s.backend != Backend::Gl {
+ assert_eq!(s.switched_from, Some(Backend::Gl));
+ let line = s.status_line().expect("status");
+ assert!(line.contains("OpenGL") && line.contains(s.backend.name()) && line.contains("WGPU_BACKEND"), "{line}");
+ assert!(!s.backends().contains(wgpu::Backends::GL));
+ } else {
+ assert_eq!(s.switched_from, None);
+ }
+ let _ = std::fs::remove_dir_all(path.parent().expect("dir"));
+ }
+
+ #[test]
+ fn without_a_path_nothing_is_written_and_a_bad_path_is_not_fatal() {
+ let mut s = Fallback::begin_unforced(None, V, &[]).expect("candidates");
+ s.started_with(Backend::Gl);
+ s.finished();
+ // A file where the directory should be: every write fails, nothing panics.
+ let blocked = temp_path("blocked");
+ let dir = blocked.parent().expect("dir");
+ std::fs::create_dir_all(dir.parent().expect("tmp")).expect("tmp");
+ std::fs::write(dir, "a file where the directory should be").expect("block");
+ let mut s = Fallback::begin_unforced(Some(blocked.clone()), V, &[]).expect("candidates");
+ s.started_with(Backend::Gl);
+ s.finished();
+ let _ = std::fs::remove_file(dir);
+ }
+}
diff --cc apps/designcraft/src/main.rs
index 196cc32ff,2f90f6484..ff26776f9
--- a/apps/designcraft/src/main.rs
+++ b/apps/designcraft/src/main.rs
@@@ -66,7 -61,13 +67,11 @@@ impl eframe::App for App
}
fn on_exit(&mut self) {
// A normal exit before the third frame is not a crash.
- if let Some(s) = self.startup.as_mut() {
- s.presented();
- }
+ self.startup.presented();
+ if let Err(e) = preserve_documents_on_exit(&mut self.app) {
+ log::error!("Couldn't preserve documents on exit: {e}");
+ eprintln!("designcraft: couldn't preserve documents on exit: {e}");
+ }
save_prefs(&self.app);
}
}
@@@ -280,37 -283,21 +291,37 @@@ fn main() -> std::process::ExitCode
options.viewport = options.viewport.with_icon(icon);
}
// The graphics backend, decided before the window exists: a driver that faults takes the
- // process down before any Rust code can catch it (see `gpu`).
- let gpu = gpu::Startup::begin(if no_prefs() { None } else { profile::config_dir().map(|d| d.join(gpu::FILE)) }, env!("CARGO_PKG_VERSION"));
- if let Some(s) = &gpu
- && let eframe::egui_wgpu::WgpuSetup::CreateNew(create) = &mut options.wgpu_options.wgpu_setup
- {
- create.instance_descriptor.backends = s.backends();
+ // process down before any Rust code can catch it (see `gpu::backend`).
+ let fallback = gpu::backend::Fallback::begin(
- if no_prefs() { None } else { config_dir().map(|d| d.join(gpu::backend::FILE)) },
++ if no_prefs() { None } else { profile::config_dir().map(|d| d.join(gpu::backend::FILE)) },
+ env!("CARGO_PKG_VERSION"),
+ &gpu::backend::skipped_backends(&skip),
+ );
+ let instance_backends = fallback.as_ref().map(gpu::backend::Fallback::backends);
+ let startup = std::sync::Arc::new(gpu::Startup::new(fallback, skip.clone()));
+ // The adapter: the GPU that drives the (primary) display unless `WGPU_POWER_PREF` chooses a
+ // kind; a GPU without a monitor reset its driver and took every monitor down. Logged first:
+ // the first question in every black-window report.
+ let power_env = eframe::wgpu::PowerPreference::from_env();
+ let power = gpu::power_preference(power_env);
+ let displays = gpu::preferred_displays(power_env);
+ let chosen_gpu = !gpu::automatic(power_env);
+ if chosen_gpu {
+ log::info!("graphics processor chosen by WGPU_POWER_PREF ({power:?}): which GPU drives the display isn't considered");
+ } else {
+ let listed: Vec<String> = displays.iter().map(ToString::to_string).collect();
+ log::info!("display GPUs (PCI vendor:device): {}", if listed.is_empty() { "unknown".to_string() } else { listed.join(", ") });
}
- // Nothing draws or dispatches indirectly, so wgpu's check of indirect arguments only costs a
- // compute shader when the device is created, one that Metal can't compile on an Intel Iris
- // Pro: the device is lost and the window never opens. `WGPU_VALIDATION_INDIRECT_CALL=1` turns
- // the check back on.
if let eframe::egui_wgpu::WgpuSetup::CreateNew(create) = &mut options.wgpu_options.wgpu_setup {
- create.instance_descriptor.flags =
- create.instance_descriptor.flags.difference(eframe::wgpu::InstanceFlags::VALIDATION_INDIRECT_CALL).with_env();
+ if let Some(backends) = instance_backends {
+ create.instance_descriptor.backends = backends;
+ }
+ create.instance_descriptor.flags = gpu::instance_flags();
+ // Only adapters that can show the window, in the order `gpu` gives.
+ create.native_adapter_selector = Some(gpu::selector(power, displays, startup.clone()));
}
+ gpu::watch_panics();
+ gpu::watch_first_frame(startup.clone());
// winit has no file drag-and-drop on Wayland (only on X11), so dropping images from the file
// manager showed a "no" cursor. Run through XWayland when it's there; DESIGNCRAFT_WAYLAND=1
// keeps the native Wayland backend.
@@@ -321,86 -308,63 +332,95 @@@
b.with_x11();
}));
}
+ // AppKit Dock Quit otherwise terminates before egui can cancel the close. Route it through
+ // ordinary CloseRequested events, preserving the same transactional Save/Don't Save flow.
+ #[cfg(target_os = "macos")]
+ {
+ options.event_loop_builder = Some(Box::new(|builder| {
+ use winit::platform::macos::EventLoopBuilderExtMacOS;
+ builder.with_close_requested_on_terminate(true);
+ }));
+ }
- eframe::run_native(
- "DesignCraft",
- options,
- Box::new(move |cc| {
- let mut gpu = gpu;
- if let Some(rs) = &cc.wgpu_render_state {
- // What a bug report needs to know about the graphics driver.
- let info = rs.adapter.get_info();
- log::info!("graphics: {} on {:?} ({:?}; driver {} {})", info.name, info.backend, info.device_type, info.driver, info.driver_info);
- if let (Some(s), Some(backend)) = (gpu.as_mut(), gpu::Backend::of(info.backend)) {
- s.started_with(backend);
+ let created = startup.clone();
+ // A panic that ends the window (egui-wgpu's own) is caught here: never a crash.
+ let run = std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| {
+ eframe::run_native(
+ "DesignCraft",
+ options,
+ Box::new(move |cc| {
+ let mut restarted = None;
+ if let Some(rs) = &cc.wgpu_render_state {
+ // What a bug report needs to know about the graphics driver.
+ let info = rs.adapter.get_info();
+ log::info!(
+ "graphics: {} on {:?} ({:?}; driver {} {}; power preference {power:?})",
+ info.name,
+ info.backend,
+ info.device_type,
+ info.driver,
+ info.driver_info
+ );
+ created.started_with(info.backend);
+ created.created(&cc.egui_ctx);
+ if !skip.is_empty() {
+ // A processor chosen by `WGPU_POWER_PREF` can be the one that can't show the window.
+ let hint = if chosen_gpu { " (without WGPU_POWER_PREF it uses the one that drives your display)" } else { "" };
+ restarted = Some(format!(
+ "The graphics processor tried first couldn't show the window, so DesignCraft started again on {} ({:?}, {:?}){hint}.",
+ info.name.trim(),
+ info.backend,
+ info.device_type
+ ));
+ }
}
- }
- let mut session = Session::new();
- // Crash recovery: reopen what a previous run left unsaved, then keep it current.
- session.recovery_dir = profile::recovery_dir();
- let recovered = session.execute("file.recovery.open", &serde_json::json!({})).ok();
- let mut app = DesignApp::new(session, services());
- if let Some(line) = gpu.as_ref().and_then(gpu::Startup::status_line) {
- app.status(line);
- }
- // Recovered documents matter more than the graphics note; both are in the log.
- if let Some(n) = recovered.as_ref().and_then(|r| r["opened"].as_array()).map(Vec::len).filter(|n| *n > 0) {
- app.status(format!("Recovered {n} unsaved document{} from the last session.", if n == 1 { "" } else { "s" }));
- }
- load_prefs(&mut app);
- app.integrated_titlebar = cfg!(target_os = "macos");
- if let Some(port) = control_port {
- let rx = control_server::start(port, cc.egui_ctx.clone());
- app = app.with_control(rx);
- }
- if sample {
- let _ = app.run("file.newSample", serde_json::json!({}));
- }
- for f in files {
- if let Err(e) = app.open_file("file.open", serde_json::json!({"path": f})) {
- eprintln!("designcraft: {f}: {e}");
+ let mut session = Session::new();
+ // Crash recovery: reopen what a previous run left unsaved, then keep it current.
- session.recovery_dir = designcraft_engine::recovery::default_dir();
++ session.recovery_dir = profile::recovery_dir();
+ let recovered = session.execute("file.recovery.open", &serde_json::json!({})).ok();
+ let mut app = DesignApp::new(session, services());
+ if let Some(line) = restarted.or_else(|| created.status_line()) {
+ app.status(line);
}
- }
- Ok(Box::new(App {
- app,
- #[cfg(target_os = "macos")]
- menu: None,
- startup: gpu,
- frames: 0,
- }))
- }),
- )
+ // Recovered documents matter more than the graphics note; both are in the log.
+ if let Some(n) = recovered.as_ref().and_then(|r| r["opened"].as_array()).map(Vec::len).filter(|n| *n > 0) {
+ app.status(format!("Recovered {n} unsaved document{} from the last session.", if n == 1 { "" } else { "s" }));
+ }
+ load_prefs(&mut app);
+ app.integrated_titlebar = cfg!(target_os = "macos");
+ if let Some(port) = control_port {
+ let rx = control_server::start(port, cc.egui_ctx.clone());
+ app = app.with_control(rx);
+ }
+ if sample {
+ let _ = app.run("file.newSample", serde_json::json!({}));
+ }
+ for f in files {
+ if let Err(e) = app.open_file("file.open", serde_json::json!({"path": f})) {
+ log::warn!("{f}: {e}");
+ }
+ }
+ // The first frame is due from now (`gpu::watch_first_frame`).
+ created.ready();
+ Ok(Box::new(App {
+ app,
+ #[cfg(target_os = "macos")]
+ menu: None,
+ startup: created,
+ frames: 0,
+ }))
+ }),
+ )
+ }))
+ .map_err(|payload| designcraft_engine::guard::panic_message(payload.as_ref()));
+ // The window's end, or a graphics failure that starts the app again. A failure is logged:
+ // standard error and the log file, since a Windows start has no console to show it.
+ match gpu::finish(run, &startup) {
+ Ok(()) => std::process::ExitCode::SUCCESS,
+ Err(e) => {
+ log::error!("DesignCraft stopped: {e}");
+ std::process::ExitCode::FAILURE
+ }
+ }
}
#[cfg(test)]
diff --cc docs/target-app-parity.md
index 3731ee23a,62ba7f08a..2a42d105c
--- a/docs/target-app-parity.md
+++ b/docs/target-app-parity.md
@@@ -288,11 -289,14 +289,15 @@@ It is evidence of breadth: each item ex
- Missing fonts: highlighted pink on screen (never in output), listed by Preflight; Type › Find/Replace Font (fonts in the document, missing first; replace in text, cells, footnotes and styles); `font.list` / `font.replace`.
- Missing glyphs, as in InDesign: a character the applied font lacks is drawn as that font's missing-glyph box (its .notdef; a drawn box when the font's is empty), on screen and in PDF (as a path, so PDF/A and PDF/UA exports take it), and Preflight lists the characters by font. Preferences › Composition › Draw Missing Glyphs from Fallback Fonts (`document.preferences {glyphFallback}`, stored with the document) draws them from other fonts instead; it is off in new documents and IDML imports, on in documents saved before it existed. A missing font's substitute always uses fallback fonts.
- Damage-region repaint: after an edit the canvas re-renders only the frames whose composed text (or the items that) changed and patches its texture — pixel-identical to a full render; typing in a frame repaints in under a millisecond instead of a full-viewport render (22 ms measured on the sample).
- - Crash recovery: unsaved documents are written to the recovery folder every 30 s and reopened (unsaved, remembering their files) after a crash; File › Revert and Save a Copy…; `file.recovery.*`, `file.revert`, `file.saveACopy`.
+ - Native engine saves, Save a Copy, snippets, books, libraries, swatches and engine/MCP exports use same-folder atomic replacement, as do desktop Services writes and CLI raster exports. Failed writes before replacement retain the original; existing Unix permissions apply before staging document bytes, and already-open readers retain the old bytes. Parent-folder flushing is best effort, so this is not a power-loss durability guarantee.
+ - Save As prepares destination-relative data-source paths before writing and installs them only after a successful save. Failed Save As retains the document, saved state and history; Save a Copy rebases only the saved copy. Library and book collection edits likewise update live values only after persistence succeeds.
+ - Crash recovery: unsaved documents are written every 30 s into a locked folder owned by that running app and reopened (unsaved, remembering their files) after a crash. Startup takes entries from ended runs and leaves live runs alone; writes and cleanup validate current folder and lock ownership. Failed isolation disables recovery with a warning. Recovered checkpoints remain available through another crash before autosave; restarting IDs and explicit recovery from another folder preserve unopened snapshots. Successful Save, Close or Revert clears the document's checkpoints, including manual recovery while autosave is disabled; failed republishing keeps the original. A folder given to `file.recovery.save` keeps other runs' entries: a run replaces or removes only the entries it wrote or recovered there, and refuses a folder whose run lock another app holds. Concurrent older versions still use unlocked root entries; mixed-version isolation remains open. File › Revert and Save a Copy…; `file.recovery.*`, `file.revert`, `file.saveACopy`.
+ - Window close, application/menu Quit and macOS Dock Quit ask about every unsaved document. Cancel or a cancelled/failed save keeps all tabs open; Don't Save approvals discard nothing until the complete plan is current. Later edits and new documents are checked before closing. Repeated native requests preserve an active dialog and partial approvals. Control-channel quit remains immediate.
- Graphics backend chosen before the window exists (DirectX 12 on Windows, Vulkan on Linux, Metal on macOS, OpenGL as the fallback; `WGPU_BACKEND` overrides) with a start-up fallback: a backend whose start never showed a frame is skipped at the next start and the status bar says so (`gpu.json`). Found on an AMD hybrid-graphics laptop whose Vulkan driver faulted at the first present.
+- Graphics adapter chosen by the app: the GPU that drives the primary display (Windows `EnumDisplayDevices`, Linux sysfs), then the power preference (`WGPU_POWER_PREF`, `WGPU_ADAPTER_NAME` override). An adapter that fails or hangs while the window starts is left out and the app starts again on the next one, then on the next backend, with software renderers last; wgpu's indirect-call check is off (it lost the Metal device on an Intel Mac, #334); why the app stopped is logged, also when the window never opened (#273). Ported from VectorCraft.
- Edit › Paste Into (copied objects become a frame's content, clipped by it; rendered, PDF and IDML both ways — verified in InDesign 2026); Polygon Settings (sides, star inset; double-click the Polygon tool).
- Color panel (fill/stroke proxy, CMYK/RGB/Lab sliders with channel ramps, tint slider for swatches, spectrum ramp, Add to Swatches) and Color Picker (double-click the proxy); mixed colours are unnamed (not listed in Swatches until added); `object.color`, `swatch.addToSwatches`, `swatch.addUnnamed`.
+ - Threading: click a selected text frame's in or out port (overset or not) to load the text cursor, then click a frame to thread it (stories merge), click empty space for a column-wide frame down to the bottom margin, or drag a frame; Shift-click autoflows, Alt-click stays loaded; click the linked frame or double-click a port to break the thread; Esc unloads. Link and unthread cursors show where a click threads or unthreads. `text.thread`, `text.unthread`, `text.removeFromThread`.
- Place text files: Word (.docx: styles by name with their attributes, bold/italic/underline/size/font, footnotes, tables, tabs, breaks), RTF and plain text, into the insertion point, the selected frame or a new frame; autoflow adds pages and threaded frames until the text fits; Remove Styles option (`designcraft-textimport`).
- Gradient Feather (⇧G tool, `object.gradientFeather`): objects fade along a linear or radial opacity gradient, on screen and as a soft mask in PDF.
- Script Label (`object.label`, `object.findByLabel`), alt text (`object.altText`), Isolate Blending / Knockout Group (`object.transparencyGroup`; on screen, PDF isolates), Table ▸ Sort (`table.sortRows`, numeric-aware, header/footer fixed).