DesignCraft: An open-source page and layout design editor written by scratch in pure Rust
Merge #825: Gradient swatches on text, laid across the text frame
aiongg1847b8cef5a2
diff --cc ROADMAP.mdindex b68b61e3f,9689ce7f2..2a5d8a75a--- a/ROADMAP.md+++ b/ROADMAP.md@@@ -128,81 -129,9 +128,82 @@@ list) · [roadmap.md](docs/roadmap.md)Newest first.+ - **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-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** · The Gradient panel follows InDesign's layout (thumbnail, Type, Location, Angle, Reverse, ramp with midpoint diamonds) and takes swatches dragged from the Swatches panel: dropped on a stop they colour it, elsewhere they add a stop. Stops keep their CMYK through panel edits; `object.gradient` stops accept a `swatch`. No readiness percentage change.+- **2026-10-13** · New Swatch works as InDesign's: a gradient made in the Gradient panel becomes "New Gradient Swatch" (still applied), an unnamed colour a listed swatch, a named swatch a "copy" (`swatch.new`); `swatch.create {gradient}` makes a gradient swatch from colour swatches. 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** · `.indd` and `.indt` documents open through File › Open, drop, the web inbox, `file.open`, `file.openBytes`, `file.openIdml` and the CLI: [storytold/indd-utils](https://github.com/storytold/indd-utils) converts them to IDML in memory and the IDML importer reads the result, on desktop and web. Converter warnings come first in the open result; an unreadable file is an open error (#21, #114). No readiness percentage change until a real-file corpus measures it.+- **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** · 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** · PDF export leaves out form fields, buttons and video or sound that don't print: inside a hidden group, on a hidden or non-printing layer, or marked non-printing. Page content and interactive elements follow one inclusion rule. 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** · 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-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** · 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** · The Story Editor stays with the document its story belongs to: it hides while another document is active and closes with its document, so its edits never reach another document's story with the same id (#729). Undo restores the selection from before the command and Redo the one after it (#716). No readiness percentage change.+- **2026-10-13** · Saving never reports success without a file: a document that can't be written is an error from Save, Save As, Save a Copy, Package, snippet export and the web serializer, leaving the existing file, the unsaved state and the recovery checkpoint as they were. Placed files over 4 GiB are written with zip64 sizes. A web Save whose browser download can't start reports the error and keeps the document unsaved (#741, #708). No readiness percentage change.+- **2026-10-13** · Colour management runs on craft-libs' `craft-cms`. The default CMYK working space is its Coated FOGRA39 profile (Generic CMYK and Device CMYK stay selectable); CMYK swatches show relative colorimetric with the settings' black point compensation, and PDF/X-4 output intents embed the working CMYK profile (FOGRA39 by default). Profile names the built-in stands in for resolve to it; other unknown names are an error, and saved settings naming one start with the default. 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** · 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-12** · Placed Excel tables and Excel data-merge records keep numeric precision, including small values, and preserve numeric-looking cached formula strings as text. 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** · HTML and reflowable EPUB order grouped stories and graphics by their transformed spread position, including nested groups and rotated frames. Explicit Article order is unchanged. No readiness percentage change.+- **2026-10-13** · A selected placed graphic shows its own brown bounding box with handles: dragging one resizes the graphic inside its frame (Shift keeps proportions, Alt from the centre) and leaves the frame as it is; `transform.set` takes the graphic's new spread `bounds`. Builds on #415 and #550. 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** · Ungroup only takes groups apart: a frame with pasted-in content stays whole (and selected), is named by its shape in the Layers and Properties panels, and offers Convert Shape rather than Ungroup. Non-groups stay selected. 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** · 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-12** · The engine's atomic writer, used by saves and exports (documents, snippets, books, libraries, swatches, XML, interchange, MCP, desktop and CLI writes), delegates to craft-libs/craft-atomic. Failed writes retain the original; new files follow the umask and replaced files keep their permissions. Recovery checkpoints and package output keep their own no-follow writers. No readiness percentage change.+- **2026-10-13** · New Document has Preview (off by default, kept for the session): a document with the window's settings shows in the workspace and follows them once typing pauses. Create keeps it with a clean undo history and refuses invalid fields; Close removes it and shows the previous document again. The preview takes no Untitled number and writes no recovery data; one edited by a menu or script stays open as a document. No readiness percentage change.+- **2026-10-13** · Object styles carry effects (drop shadow, feather, inner and outer shadows and glows, bevel, satin, gradient and directional feather). New styles from a selection keep its effects, `style.object.edit` changes a style's effects and every item that follows them, `style.object.clearOverrides` returns items to their style, and new frames take their default style's effects. IDML carries only the drop shadow and feather, for ObjectStyles (with their effects category and BasedOn chain) as for items (#653). No readiness percentage change.+- **2026-10-13** · A parent can be based on another parent (`layout.parents.options`). Pages draw the base parent's items, then the parent's, then their own, on screen and in PDF and image export; chains work, cycles are refused, overrides reach base items, `document.inspect` reports `basedOn`, and IDML round-trips it. No readiness percentage change.+- **2026-10-12** · The Effects dialog, as in InDesign: Object › Effects (Transparency…, Drop Shadow… and the rest, and their shortcuts) and the Effects panel's fx button open it on the chosen effect, turned on. Transparency and every effect in one window, in the document's units, with X/Y offsets, Preview on the page, Cancel putting things back, and OK as one undo step (`object.effects`). Shadows default to InDesign's 120° light angle. 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 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** · 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** · 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-12** · Text in oval, polygon and other non-rectangular text frames follows the frame's outline: each line is set in the part of its band inside the shape, one inset away from the outline, in every column and in vertical frames; text wrap still applies on top (#646). No readiness percentage change.+- **2026-10-12** · Colour entry: the Color Picker's hex, R/G/B and C/M/Y/K fields and the Color panel's number fields keep typed text until it is complete; panel and picker values are applied on a fixed scale (`{model, …}` colours in 0..1), so M 1 is 1 %. Picking keeps a CMYK colour CMYK; dialogs leave the page behind them undimmed; colours that round to the same swatch name share one swatch (#323). No readiness percentage change.+- **2026-10-12** · Placed photos show in their own colours: embedded ICC profiles (Adobe RGB, ProPhoto, P3, grey) are converted to sRGB on screen, and CMYK JPEGs (including YCCK), CMYK TIFFs and CMYK PSDs go through their embedded CMYK profile or the working CMYK space with the colour settings' intent and black-point compensation, instead of the profile-free formula. Unreadable profiles are ignored. 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** · 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** · Type tool: Option/Alt+Left/Right kerns the pair at the caret (manual kerning) or tracks a selection by the Kerning/Tracking increment (Preferences › Units & Increments, 20/1000 em), five times with Cmd/Ctrl; moving by words is Cmd+Left/Right on macOS and Ctrl+Left/Right elsewhere, and Option/Alt+Shift+Left/Right still selects by words (#621). No readiness percentage change.+- **2026-10-12** · Autoflow on Place threads one frame per page column (right to left in a right-to-left story), so text no longer runs across the gutter; pages Smart Text Reflow adds get a primary frame with the page's columns (#625). No readiness percentage change.+- **2026-10-12** · Vector art copied in Illustrator, VectorCraft, Figma or Inkscape pastes as editable paths, as InDesign pastes Illustrator art: the SVG those apps put on the clipboard becomes paths with their fills, strokes (weight, caps, joins, dashes) and opacity, groups stay groups and text comes in as outlines, centred in the view (`edit.pasteSvg`, `ui.paste`). Edit › Paste reads the system clipboard when nothing was copied in DesignCraft. No readiness percentage change.+- **2026-10-12** · Pages panel: double-clicking a parent shows that parent and selects only its row; parent rows show rendered thumbnails. Commands name parents by id, full name, or a prefix only one parent has; an unknown or ambiguous name is an error instead of clearing the page's parent (#624). No readiness percentage change.+- **2026-10-12** · With the Type tool, dragging a table's column or row border resizes it (the double-arrow cursor shows over a border): later columns and rows move along, Shift keeps the table size, and Shift on the right or bottom edge scales every column or row. A dragged row becomes At Least; one undo step per drag, Esc cancels; works in rotated frames and turned spreads. Scripts use `table.resizeBorder`. 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-12** · With a placed graphic selected (Direct Selection), the Transform values act on the graphic inside its frame, as in InDesign: a tilted frame's image can be straightened to 0°. No readiness percentage change.+- **2026-10-11** · Font menu laid out like InDesign's: filters (classification, favourites,+ recently added), families opening to their styles, the selected text as the sample in three+ sizes, Recently Used fonts, Show Similar Fonts and each font's format.+- **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-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** · Load Styles: the Paragraph Styles and Character Styles panels load styles from another DesignCraft document or an IDML file, with the styles, swatches and lists they name; a dialog picks the styles and what happens to one the document defines differently (`style.load`). 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** · 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** · Anchored objects with text wrap push text aside: other stories' text under them and the lines of their own story after the anchor's line (#557). 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** · Text frame auto-size: Height Only, Width Only, Height and Width (also keeping proportions) frames grow and shrink to fit their text after edits, around their reference point, with minimum sizes and No Line Breaks, in the same undo step (#180). No readiness percentage change.+- **2026-10-12** · Text Frame Options › Balance Columns (`object.textFrameOptions {balanceColumns}`, IDML `VerticalBalanceColumns`) evens out the columns of the frame a story ends in, from its last column break on; frames the text runs on from fill normally (#609). 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** · 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** · Windows: dragging the window across monitors with different display scales keeps its size instead of growing until it crashes (winit pinned to its 0.30.x backport of the fix). The GPU surface may be as large as the adapter's largest texture (16384 px on DirectX 12, Vulkan and Metal hardware) instead of 8192, and a wgpu error is logged instead of closing the app. 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.diff --cc crates/engine/src/cmd/text.rsindex cc17fe325,3441b451c..c415586e2--- a/crates/engine/src/cmd/text.rs+++ b/crates/engine/src/cmd/text.rs@@@ -2843,102 -2006,100 +2843,157 @@@ mod story_query_contract_testss.execute("text.select", &json!({"story":f["story"],"anchor":0})).unwrap();assert_eq!(s.execute("story.get", &json!({})).unwrap()["text"], "");}-}--#[cfg(test)]-mod multi_click_tests {- use super::{para_bounds, sentence_bounds};-- fn sentence(s: &str, at: &str) -> String {- let i = s.find(at).unwrap();- let (a, b) = sentence_bounds(s, i);- s[a..b].to_string()- }#[test]- fn sentences_end_at_a_stop_before_a_space_or_the_paragraph_end() {- let s = "It costs 3.5 euros. \u{201C}Really?\u{201D} (Twice!) Yes\u{2026} fine.\nNext one. Last";- assert_eq!(sentence(s, "costs"), "It costs 3.5 euros. ");- assert_eq!(sentence(s, "Really"), "\u{201C}Really?\u{201D} ");- assert_eq!(sentence(s, "Twice"), "(Twice!) ");- assert_eq!(sentence(s, "Yes"), "Yes\u{2026} ");- assert_eq!(sentence(s, "fine"), "fine.");- assert_eq!(sentence(s, "one"), "Next one. ");- assert_eq!(sentence(s, "Last"), "Last");- // The caret at the very end of a paragraph is in its last sentence.- let end = s.find('\n').unwrap();- assert_eq!(sentence_bounds(s, end), (s.find("fine").unwrap(), end));+ fn kenten_shatai_auto_tcy_and_grid_settings_take_checked_values() {+ use designcraft_doc::cjk::CharacterAlignment;+ use designcraft_doc::cjk_settings::{KentenKind, KentenPosition};+ let mut s = crate::Session::new();+ s.execute("file.new", &json!({})).unwrap();+ let r = s.execute("frame.create", &json!({"rect": [72, 72, 200, 400], "content": "text", "text": "縦書き12年", "vertical": true})).unwrap();+ let sid = designcraft_doc::StoryId(r["story"].as_u64().unwrap());+ s.execute("text.select", &json!({"story": sid.0, "anchor": 0, "focus": "縦書き".len()})).unwrap();+ let chars = |s: &crate::Session| s.doc().unwrap().doc.stories[&sid].char_format_at(1).over.clone();+ let para = |s: &crate::Session| s.doc().unwrap().doc.stories[&sid].paras[0].para.clone();+ // Any setting turns kenten on; values are clamped and text is capped.+ let long = "★".repeat(10_000);+ s.execute(+ "type.kenten",+ &json!({"kind": "custom", "character": long, "size": 1e300, "distance": -1e300, "xScale": 0, "fillTint": 250, "position": "belowLeft"}),+ )+ .unwrap();+ let a = chars(&s);+ assert_eq!((a.kenten, a.kenten_kind, a.kenten_position), (Some(true), Some(KentenKind::Custom), Some(KentenPosition::BelowLeft)));+ assert_eq!(a.kenten_character.as_ref().map(|c| c.chars().count()), Some(designcraft_doc::cjk_settings::KENTEN_MARK_MAX_CHARS));+ assert_eq!(+ (a.kenten_size, a.kenten_distance, a.kenten_x_scale, a.kenten_fill_tint),+ (Some(Some(1296.0)), Some(-1296.0), Some(0.01), Some(Some(1.0)))+ );+ // Bad values change nothing.+ for bad in [json!({"kind": "sparkle"}), json!({"size": "big"}), json!({"character": 5}), json!({"on": "yes"}), json!({"overprintFill": 1})] {+ assert!(s.execute("type.kenten", &bad).is_err(), "{bad}");+ }+ assert_eq!(chars(&s), a);+ s.execute("type.kenten", &json!({"on": false})).unwrap();+ assert_eq!((chars(&s).kenten, chars(&s).kenten_kind), (Some(false), Some(KentenKind::Custom)), "off keeps the settings");+ // Shatai.+ s.execute("type.shatai", &json!({"magnification": 1e9, "angle": -30, "adjustRotation": true})).unwrap();+ let a = chars(&s);+ assert_eq!((a.shatai_magnification, a.shatai_angle, a.shatai_adjust_rotation), (Some(90.0), Some(150.0), Some(true)));+ assert!(s.execute("type.shatai", &json!({})).is_err());+ assert!(s.execute("type.shatai", &json!({"angle": [45]})).is_err());+ // Paragraph settings.+ s.execute("type.autoTateChuYoko", &json!({"digits": 1e12, "includeRoman": true})).unwrap();+ assert_eq!((para(&s).auto_tcy, para(&s).auto_tcy_include_roman), (Some(designcraft_compose::shape::AUTO_TCY_MAX), Some(true)));+ s.execute("type.gridSettings", &json!({"alignment": "emCenter", "firstLineOnly": true, "gyoudori": 1e12, "paragraphGyoudori": true}))+ .unwrap();+ let p = para(&s);+ assert_eq!((p.grid_align, p.grid_reference), (Some(designcraft_doc::GridAlign::FirstLineOnly), Some(CharacterAlignment::EmCenter)));+ assert_eq!((p.grid_gyoudori, p.paragraph_gyoudori), (Some(100), Some(true)));+ assert!(s.execute("type.gridSettings", &json!({"alignment": "middle"})).is_err());+ s.execute("type.gridSettings", &json!({"alignment": "none"})).unwrap();+ assert_eq!(para(&s).grid_align, Some(designcraft_doc::GridAlign::None));+ s.execute("type.rotateRoman", &json!({})).unwrap();+ assert_eq!(para(&s).rotate_roman, Some(true));+ s.execute("type.rotateRoman", &json!({})).unwrap();+ assert_eq!(para(&s).rotate_roman, Some(false));+ s.execute("type.romanWordBreak", &json!({"on": true})).unwrap();+ assert_eq!(para(&s).roman_word_break, Some(true));+ // The story still composes with every setting at its limit.+ let cs = designcraft_compose::compose_story(&s.doc().unwrap().doc, sid, &Default::default());+ assert!(!cs.frames.is_empty());}+}- #[test]- fn cjk_full_stops_end_sentences_without_a_space() {- let s = "これは文です。次の文!最後";- assert_eq!(sentence(s, "次"), "次の文!");- assert_eq!(sentence(s, "最後"), "最後");- }+#[cfg(test)]+mod reserve_tests {+ use super::*;#[test]- fn paragraphs_stop_at_returns() {- let s = "One.\nTwo two.\n";- assert_eq!(para_bounds(s, 6), (5, 13));- assert_eq!(para_bounds(s, 0), (0, 4));- assert_eq!(para_bounds(s, s.len()), (s.len(), s.len()));+ fn failed_reservation_rolls_back_the_edit_even_after_local_text_was_removed() {+ let mut s = Session::new();+ s.execute("file.new", &json!({})).unwrap();+ let result = s.execute("frame.create", &json!({"rect":[36,36,300,300],"content":"text","text":"Keep this text."})).unwrap();+ let sid = StoryId(result["story"].as_u64().unwrap());+ s.execute("text.select", &json!({"story":sid.0,"anchor":1,"focus":4})).unwrap();+ let before = s.doc().unwrap().clone();+ assert!(before.selection.text.is_some_and(|t| !t.range().is_empty()));+ let journal = s.journal.clone();+ let error = s+ .edit(|d, sel| {+ let st = d.story_mut(sid).unwrap();+ st.format_chars(5..9, |f| f.over.change = Some(designcraft_doc::ChangeMark::Inserted));+ let at = super::super::changes::mark_deleted(st, 0..9);+ assert_eq!(at, 5);+ assert_eq!(st.text, "Keep text.");+ assert_eq!(st.format_after(0).over.change, Some(designcraft_doc::ChangeMark::Deleted));+ sel.text = None;+ reserve_command_text(st, usize::MAX)?;+ ok()+ })+ .unwrap_err();+ assert!(error.to_string().contains("could not reserve text insertion"));+ let after = s.doc().unwrap();+ assert!(std::sync::Arc::ptr_eq(&after.doc, &before.doc));+ assert_eq!(after.selection, before.selection);+ assert_eq!(after.revision, before.revision);+ assert_eq!(after.history.undo.len(), before.history.undo.len());+ assert_eq!(after.history.redo.len(), before.history.redo.len());+ assert_eq!(s.journal, journal);}}++ #[cfg(test)]+ mod gradient_text_tests {+ use serde_json::json;++ /// Mean red and blue of the ink (pixels whose green is low: red → blue has none) in columns+ /// `x0..x1`.+ fn ink(img: &designcraft_render::Rendered, x0: u32, x1: u32) -> (f64, f64) {+ let (mut r, mut b, mut n) = (0.0, 0.0, 0.0);+ for x in x0..x1 {+ for y in 0..img.height {+ let p = img.pixel(x, y);+ if p[1] < 100 {+ (r, b, n) = (r + p[0] as f64, b + p[2] as f64, n + 1.0);+ }+ }+ }+ assert!(n > 50.0, "no ink in {x0}..{x1}");+ (r / n, b / n)+ }++ /// Red ink at the frame's left, blue at its right.+ fn check(img: &designcraft_render::Rendered, what: &str) {+ let (lr, lb) = ink(img, 0, 60);+ let (rr, rb) = ink(img, 200, 300);+ assert!(lr > lb + 80.0, "{what}: the left ink is red ({lr:.0}, {lb:.0})");+ assert!(rb > rr + 80.0, "{what}: the right ink is blue ({rr:.0}, {rb:.0})");+ }++ #[test]+ fn a_gradient_on_text_spans_its_frame_on_screen_and_in_pdf() {+ let mut s = crate::Session::new();+ s.execute("file.new", &json!({"width": 300, "height": 120, "facingPages": false, "margins": 0})).unwrap();+ // A gradient swatch (an off-page object's unnamed one), red → blue.+ let shape = s.execute("frame.create", &json!({"rect": [-60, 0, -50, 10], "content": "unassigned"})).unwrap()["id"].clone();+ s.execute("object.gradient", &json!({"ids": [shape], "stops": [{"location": 0, "color": "#ff0000"}, {"location": 100, "color": "#0000ff"}]}))+ .unwrap();+ let id = designcraft_doc::ItemId(shape.as_u64().unwrap());+ let swatch = s.doc().unwrap().doc.item(id).unwrap().fill.swatch.clone();+ let r = s.execute("frame.create", &json!({"rect": [0, 0, 300, 120], "content": "text", "text": "IIIIIIIIIIIIIIIIIIIIIIIIIIIIII"})).unwrap();+ s.execute("text.select", &json!({"story": r["story"], "anchor": 0, "focus": 30})).unwrap();+ s.execute("type.char", &json!({"size": 60, "tracking": 0, "fill": swatch})).unwrap();+ let d = s.doc().unwrap().doc.clone();+ let mut rr = designcraft_render::Renderer::new();+ check(&rr.render_page(&d, &s.cache, 0, 1.0, false, &Default::default()).unwrap(), "screen");+ // The PDF, placed back and drawn: the same gradient.+ let pdf = designcraft_pdf::export_pdf(&d, &s.cache, &Default::default()).unwrap();+ let mut p = crate::Session::new();+ p.execute("file.new", &json!({"width": 300, "height": 120, "facingPages": false})).unwrap();+ p.execute("file.place", &json!({"base64": super::super::file::base64_encode(&pdf), "name": "text.pdf", "x": 0, "y": 0, "width": 300}))+ .unwrap();+ let d = p.doc().unwrap().doc.clone();+ check(&rr.render_page(&d, &p.cache, 0, 1.0, false, &Default::default()).unwrap(), "pdf");+ }+ }diff --cc crates/pdf/src/export.rsindex f773d678f,45eb331ff..5a097c185--- a/crates/pdf/src/export.rs+++ b/crates/pdf/src/export.rs@@@ -1079,8 -1042,8 +1094,8 @@@ impl Exporter<'_>fr: 0.0,cx,cy,- cr: r,- transform: tf(xf),+ cr: rx as f32,- transform: tf(stretch),++ transform: tf(xf * stretch),spread_method: SpreadMethod::Pad,stops,anti_alias: false,diff --cc crates/pdf/src/text.rsindex aaf00e995,b7921f326..03e29f536--- a/crates/pdf/src/text.rs+++ b/crates/pdf/src/text.rs@@@ -431,107 -310,76 +449,113 @@@ impl Exporter<'_>let face = g0.face;let size = g0.sy * face.upem;let hs = g0.sx / g0.sy;- let skew = if st.skew != 0.0 { Affine::new([1.0, 0.0, -st.skew.to_radians().tan(), 1.0, 0.0, 0.0]) } else { Affine::IDENTITY };+ let tan = if st.skew != 0.0 { st.skew.to_radians().tan() } else { 0.0 };+ let skew = if st.skew != 0.0 { Affine::new([1.0, 0.0, -tan, 1.0, 0.0, 0.0]) } else { Affine::IDENTITY };let origin = Affine::translate((g0.x, baseline + g0.y)) * skew * Affine::scale_non_uniform(hs, 1.0);+ // Outside a frame (no text area), a gradient spans the run.+ let end = glyphs.last().map_or(g0.x, |g| g.x + g.adv);+ let run_area = Rect::new(g0.x, baseline - size, end.max(g0.x + 1.0), baseline + size * 0.25);+ let fill = self.text_paint(&st.fill, st.fill_tint, origin, run_area);+ let stroke = if st.stroke != designcraft_color::swatch::NONE && st.stroke_weight > 0.0 {+ self.text_paint(&st.stroke, st.stroke_tint, origin, run_area)+ } else {+ None+ };+ if fill.is_none() && stroke.is_none() {+ return;+ }++ if st.overprint_fill || st.overprint_stroke {++ self.warn("overprint is not exported yet");++ }+ // Stroke behind fill: a double-width stroke first, as outlines so the text is not+ // duplicated, then the fill over its inner half. With no fill, the stroke is clipped+ // to the outside of the glyphs instead.+ let behind = st.stroke_behind_fill && stroke.is_some();+ let weight = if behind { st.stroke_weight * 2.0 } else { st.stroke_weight };+ let mut clipped = false;+ let stroke = if behind {+ let outlines = glyph_outlines(glyphs, size, tan);+ if fill.is_some() {+ self.paint_outlines(s, &outlines, origin, None, stroke, weight);+ None+ } else {+ clipped = self.push_outside_clip(s, &outlines, origin, weight);+ stroke+ }+ } else {+ stroke+ };// A missing glyph is drawn as its box: PDF/A and PDF/UA forbid showing .notdef as text.if g0.gid == 0 {- self.outline_run(s, glyphs, origin, size, fill, stroke, st.stroke_weight);- return;- }- let Some(font) = self.font(&face) else {+ self.paint_outlines(s, &glyph_outlines(glyphs, size, tan), origin, fill, stroke, weight);+ } else if let Some(font) = self.font(&face) {+ self.text_run(s, glyphs, story, font, origin, size, hs, tan, fill, stroke, weight);+ } else {self.warn(format!("font `{} {}` could not be embedded; its text was drawn as outlines", face.family, face.style));- self.outline_run(s, glyphs, origin, size, fill, stroke, st.stroke_weight);- return;- };- let (text, ranges) = self.run_text(glyphs, story);+ self.paint_outlines(s, &glyph_outlines(glyphs, size, tan), origin, fill, stroke, weight);+ }+ if clipped {+ s.pop();+ }+ }++ /// A run as real text.+ #[allow(clippy::too_many_arguments)]+ fn text_run(+ &mut self,+ s: &mut Surface,+ glyphs: &[PlacedGlyph],+ story: &str,+ font: Font,+ origin: Affine,+ size: f64,+ hs: f64,+ tan: f64,- fill: Option<krilla::color::Color>,- stroke: Option<krilla::color::Color>,++ fill: Option<Paint>,++ stroke: Option<Paint>,+ stroke_weight: f64,+ ) {+ let Some(g0) = glyphs.first() else { return };+ let (text, mut ranges) = self.run_text(glyphs, story);+ let order = split_clusters(glyphs, &text, &mut ranges);let k = 1.0 / (hs * size);- let kg: Vec<KrillaGlyph> = glyphs+ // Glyphs are placed absolutely: each advance reaches the next glyph drawn, a vertical offset+ // (a mark above or below its base) is undone by the skew so it lands where it was composed.+ let kg: Vec<KrillaGlyph> = order.iter()- .zip(ranges).enumerate()- .map(|(i, (g, r))| {- let next = glyphs.get(i + 1).map_or(g.x + g.adv, |n| n.x);- KrillaGlyph::new(GlyphId::new(g.gid), ((next - g.x) * k) as f32, 0.0, 0.0, 0.0, r, None)+ .filter_map(|(n, &i)| {+ let g = glyphs.get(i)?;+ let next = order.get(n + 1).and_then(|&m| glyphs.get(m)).map_or(g.x + g.adv, |m| m.x);+ let dy = g.y - g0.y;+ let r = ranges.get(i)?.clone();+ Some(KrillaGlyph::new(GlyphId::new(g.gid), ((next - g.x) * k) as f32, (tan * dy * k) as f32, (-dy / size) as f32, 0.0, r, None))}).collect();+ let start = order.first().and_then(|&i| glyphs.get(i)).map_or(0.0, |g| (g.x - g0.x) / hs);s.push_transform(&tf(origin));- s.set_fill(fill.map(|c| solid_fill(c, 1.0)));- s.set_stroke(stroke.map(|c| Stroke { paint: c.into(), width: stroke_weight as f32, ..Default::default() }));+ s.set_fill(fill.map(paint_fill));- s.set_stroke(stroke.map(|paint| Stroke { paint, width: st.stroke_weight as f32, ..Default::default() }));- s.draw_glyphs(Point::from_xy(0.0, 0.0), &kg, font, &text, size as f32, false);++ s.set_stroke(stroke.map(|paint| Stroke { paint, width: stroke_weight as f32, ..Default::default() }));+ s.draw_glyphs(Point::from_xy(start as f32, 0.0), &kg, font, &text, size as f32, false);s.set_fill(None);s.set_stroke(None);s.pop();}- /// Fallback for faces krilla can't embed: glyph outlines as paths.- #[allow(clippy::too_many_arguments)]- fn outline_run(+ /// Glyph outlines as paths (faces krilla can't embed, missing glyphs, strokes behind fill).+ fn paint_outlines(&mut self,s: &mut Surface,- glyphs: &[PlacedGlyph],+ outlines: &BezPath,origin: Affine,- fill: Option<krilla::color::Color>,- stroke: Option<krilla::color::Color>,- size: f64,+ fill: Option<Paint>,+ stroke: Option<Paint>,stroke_weight: f64,) {- let db = FontDb::global();- let g0 = &glyphs[0];- let k = size / g0.face.upem;- let mut bp = BezPath::new();- for g in glyphs {- let a = Affine::translate(((g.x - g0.x) / (g0.sx / g0.sy), 0.0)) * Affine::scale(k);- let mut o = (*db.outline(&g.face, g.gid)).clone();- o.apply_affine(a);- bp.extend(o.iter());- }- let Some(p) = to_path(&bp) else { return };+ let Some(p) = to_path(outlines) else { return };s.push_transform(&tf(origin));- s.set_fill(fill.map(|c| solid_fill(c, 1.0)));- s.set_stroke(stroke.map(|c| Stroke { paint: c.into(), width: stroke_weight as f32, ..Default::default() }));+ s.set_fill(fill.map(paint_fill));+ s.set_stroke(stroke.map(|paint| Stroke { paint, width: stroke_weight as f32, ..Default::default() }));s.draw_path(&p);s.set_fill(None);s.set_stroke(None);diff --cc crates/render/src/text.rsindex 7abee870e,f10c0d348..1a44b28fc--- a/crates/render/src/text.rs+++ b/crates/render/src/text.rs@@@ -382,10 -414,34 +424,10 @@@ impl Rendererlet lg = &fg.lines[i];self.stats.glyphs += lg.glyphs;for (si, bp) in &lg.runs {- if let Some(c) = fill_of(*si) {- let st = &cs.styles[*si as usize];- let op = crate::overprints(f, &st.fill, st.fill_tint, false);- if op {- ctx.push_layer(- None,- Some(vello_cpu::peniko::BlendMode::new(vello_cpu::peniko::Mix::Multiply, vello_cpu::peniko::Compose::SrcOver)),- None,- None,- None,- );- }- c.set(ctx, doc, area);- ctx.fill_path(bp);- ctx.reset_paint_transform();- if op {- ctx.pop_layer();- }- }let st = &cs.styles[*si as usize];- if st.stroke != designcraft_color::swatch::NONE- && let Some(c) = TextPaint::of(doc, &st.stroke, st.stroke_tint)- {- c.set(ctx, doc, area);- ctx.set_stroke(kurbo::Stroke::new(st.stroke_weight));- ctx.stroke_path(bp);- ctx.reset_paint_transform();- }+ let fill = fill_of(*si).map(|c| (c, crate::overprints(f, &st.fill, st.fill_tint, st.overprint_fill)));+ let stroke = stroke_of(doc, st).map(|c| (c, crate::overprints(f, &st.stroke, st.stroke_tint, st.overprint_stroke)));- paint_glyphs(ctx, bp, fill, stroke, st.stroke_weight, st.stroke_behind_fill);++ paint_glyphs(ctx, doc, area, bp, fill, stroke, st.stroke_weight, st.stroke_behind_fill);}}for &i in &shown {@@@ -469,89 -513,14 +511,97 @@@ impl Renderer}}-/// Kurbo stroke for a table edge.-fn cell_stroke(s: &designcraft_doc::CellStroke) -> kurbo::Stroke {- let st = kurbo::Stroke::new(s.weight).with_caps(kurbo::Cap::Square);- match &s.kind {- designcraft_doc::StrokeType::Dashed { pattern } if !pattern.is_empty() => {+/// A run's stroke colour, if it has one.- fn stroke_of(doc: &designcraft_doc::Document, st: &designcraft_compose::RunStyle) -> Option<peniko::Color> {++fn stroke_of(doc: &designcraft_doc::Document, st: &designcraft_compose::RunStyle) -> Option<TextPaint> {+ if st.stroke == designcraft_color::swatch::NONE {+ return None;+ }- doc.resolve_color(&st.stroke, st.stroke_tint).map(|c| color_of(&c, 1.0))++ TextPaint::of(doc, &st.stroke, st.stroke_tint)+}++/// Run `paint` in a Multiply layer when `overprint` is set.+fn overprinting(ctx: &mut RenderContext, overprint: bool, paint: impl FnOnce(&mut RenderContext)) {+ if overprint {+ ctx.push_layer(None, Some(peniko::BlendMode::new(peniko::Mix::Multiply, peniko::Compose::SrcOver)), None, None, None);+ }+ paint(ctx);+ if overprint {+ ctx.pop_layer();+ }+}++/// Paint glyph outlines: the fill, then the stroke over it, each multiplied when it overprints+/// (`(colour, overprint)`). With stroke behind fill a double-width stroke goes first and the fill+/// covers its inner half; with no fill to cover it, the glyph shapes are cut out of the stroke+/// instead.++#[allow(clippy::too_many_arguments)]+fn paint_glyphs(+ ctx: &mut RenderContext,++ doc: &designcraft_doc::Document,++ area: Rect,+ bp: &BezPath,- fill: Option<(peniko::Color, bool)>,- stroke: Option<(peniko::Color, bool)>,++ fill: Option<(TextPaint, bool)>,++ stroke: Option<(TextPaint, bool)>,+ weight: f64,+ behind: bool,+) {++ let has_fill = fill.is_some();+ let paint_fill = |ctx: &mut RenderContext| {- let Some((c, overprint)) = fill else { return };- overprinting(ctx, overprint, |ctx| {- ctx.set_paint(c);++ let Some((c, overprint)) = &fill else { return };++ overprinting(ctx, *overprint, |ctx| {++ c.set(ctx, doc, area);+ ctx.fill_path(bp);++ ctx.reset_paint_transform();+ });+ };+ let Some((sc, stroke_overprint)) = stroke else {+ paint_fill(ctx);+ return;+ };+ if !behind {+ paint_fill(ctx);+ overprinting(ctx, stroke_overprint, |ctx| {- ctx.set_paint(sc);++ sc.set(ctx, doc, area);+ ctx.set_stroke(kurbo::Stroke::new(weight));+ ctx.stroke_path(bp);++ ctx.reset_paint_transform();+ });+ return;+ }- if fill.is_some() {++ if has_fill {+ overprinting(ctx, stroke_overprint, |ctx| {- ctx.set_paint(sc);++ sc.set(ctx, doc, area);+ ctx.set_stroke(kurbo::Stroke::new(weight * 2.0));+ ctx.stroke_path(bp);++ ctx.reset_paint_transform();+ });+ paint_fill(ctx);+ } else {+ overprinting(ctx, stroke_overprint, |ctx| {+ ctx.push_layer(None, None, None, None, None);- ctx.set_paint(sc);++ sc.set(ctx, doc, area);+ ctx.set_stroke(kurbo::Stroke::new(weight * 2.0));+ ctx.stroke_path(bp);+ ctx.push_layer(None, Some(peniko::BlendMode::new(peniko::Mix::Normal, peniko::Compose::DestOut)), None, None, None);+ ctx.fill_path(bp);+ ctx.pop_layer();+ ctx.pop_layer();++ ctx.reset_paint_transform();+ });+ }+}++/// Kurbo stroke for a table edge `length` points long of a resolved stroke type.+pub(crate) fn cell_stroke(kind: &designcraft_doc::StrokeType, weight: f64, length: f64) -> kurbo::Stroke {+ use designcraft_doc::StrokeType;+ let st = kurbo::Stroke::new(weight).with_caps(kurbo::Cap::Square);+ match kind {+ StrokeType::Dashed { pattern } if StrokeType::expandable_dashes(pattern, length) => {st.with_caps(kurbo::Cap::Butt).with_dashes(0.0, pattern.iter().copied())}- designcraft_doc::StrokeType::Dotted => st.with_dashes(0.0, [0.0, s.weight * 2.0]).with_caps(kurbo::Cap::Round),+ StrokeType::Dotted if StrokeType::expandable_dashes(&[0.0, weight * 2.0], length) => {+ st.with_dashes(0.0, [0.0, weight * 2.0]).with_caps(kurbo::Cap::Round)+ }_ => st,}}@@@ -571,10 -540,23 +621,12 @@@ impl Renderer) {let doc = f.doc;ctx.set_transform(f.view * xf);+ // A gradient on type on a path spans the path's box.+ let area = path.bounding_box();for (si, bp) in designcraft_compose::path_glyphs(cs, ft, path, pt) {let st = &cs.styles[si as usize];- let fill = doc.resolve_color(&st.fill, st.fill_tint).map(|c| (color_of(&c, 1.0), false));- paint_glyphs(ctx, &bp, fill, stroke_of(doc, st).map(|c| (c, false)), st.stroke_weight, st.stroke_behind_fill);- if let Some(c) = TextPaint::of(doc, &st.fill, st.fill_tint) {- c.set(ctx, doc, area);- ctx.fill_path(&bp);- ctx.reset_paint_transform();- }- if st.stroke != designcraft_color::swatch::NONE- && let Some(c) = TextPaint::of(doc, &st.stroke, st.stroke_tint)- {- c.set(ctx, doc, area);- ctx.set_stroke(kurbo::Stroke::new(st.stroke_weight));- ctx.stroke_path(&bp);- ctx.reset_paint_transform();- }++ let fill = TextPaint::of(doc, &st.fill, st.fill_tint).map(|c| (c, false));++ paint_glyphs(ctx, doc, area, &bp, fill, stroke_of(doc, st).map(|c| (c, false)), st.stroke_weight, st.stroke_behind_fill);self.stats.glyphs += 1;}}diff --cc docs/target-app-parity.mdindex 1f3a5fd05,eae72856a..d40ffee08--- a/docs/target-app-parity.md+++ b/docs/target-app-parity.md@@@ -433,9 -421,8 +433,9 @@@ It is evidence of breadth: each item ex- View › Display Performance: Fast (grey boxes, no effects, ⌥⇧⌘Z), Typical (72 ppi proxies, ⌥⌘Z), High Quality (⌥⌘H, our default — the renderer is fast enough).- OpenType menu (Character panel): discretionary ligatures, fractions, ordinal, swash, titling, contextual alternates, slashed zero, the four figure styles and stylistic sets 1–20; `type.openType`; mapped to IDML's OTF attributes.- Add Anchor Point (=), Delete Anchor Point (-) and Convert Direction Point (⇧C) tools (click toggles smooth/corner, drag pulls out handles), with `path.addAnchor`, `path.deleteAnchor`, `path.convertAnchor`.- - Gradients: the Gradient Swatch tool (G) drags a gradient's start and end across objects (Shift: 45°); the Gradient panel (InDesign's layout: thumbnail, Type, Location, Angle, Reverse) sets type, angle, reverse and edits stops and midpoints on a ramp (drag, add, drag off to remove, location; drop a swatch from the Swatches panel on a stop or the ramp; stops keep their CMYK), and follows the Fill/Stroke proxy. Edited gradients are unnamed swatches until the Swatches panel's New Swatch names one "New Gradient Swatch" (`swatch.new`, which also duplicates a named swatch); `swatch.create {gradient}` builds one from colour swatches; `object.gradient` (`target: stroke` for a stroke's gradient, drawn across the path's box on screen and in PDF); the vector round-trips through IDML (`GradientFill…`/`GradientStroke…`). A radial gradient stretches with the object's box as InDesign's does (an ellipse reaching the sides of a non-square frame, on screen and in PDF).-- Gradients: the Gradient Swatch tool (G) drags a gradient's start and end across objects (Shift: 45°); the Gradient panel sets type, angle, reverse and edits stops on a ramp (drag, add, drag off to remove, location, colour). Edited gradients are unnamed swatches; `object.gradient`; the vector round-trips through IDML. Text takes a gradient swatch as its fill or stroke, laid across its frame's box as in InDesign (screen and PDF).-- Document Setup (⌥⌘P): intent, number of pages, start page # (an even start begins with a left page), facing pages, size presets and orientation, bleed and slug per edge; `layout.documentSetup {}` reports the setup.++- Gradients: the Gradient Swatch tool (G) drags a gradient's start and end across objects (Shift: 45°); the Gradient panel (InDesign's layout: thumbnail, Type, Location, Angle, Reverse) sets type, angle, reverse and edits stops and midpoints on a ramp (drag, add, drag off to remove, location; drop a swatch from the Swatches panel on a stop or the ramp; stops keep their CMYK), and follows the Fill/Stroke proxy. Edited gradients are unnamed swatches until the Swatches panel's New Swatch names one "New Gradient Swatch" (`swatch.new`, which also duplicates a named swatch); `swatch.create {gradient}` builds one from colour swatches; `object.gradient` (`target: stroke` for a stroke's gradient, drawn across the path's box on screen and in PDF); the vector round-trips through IDML (`GradientFill…`/`GradientStroke…`). A radial gradient stretches with the object's box as InDesign's does (an ellipse reaching the sides of a non-square frame, on screen and in PDF). Text takes a gradient swatch as its fill or stroke, laid across its frame's box as in InDesign (screen and PDF).+- New Document (⌘N) as in InDesign: Recent, Saved, Print, Web and Mobile tabs of page cards (double-click creates) beside the preset's details: document name, size with arrows, units, orientation, pages, start page #, facing pages, primary text frame, columns, margins, bleed and slug per edge (linked or not); Save Document Preset (`file.savePreset`, `file.deletePreset`; saved presets are kept with the preferences, listed by `file.presets` and made by `file.new {preset: name}`); `file.new` takes `intent`, `units`, `startPage` and per-edge `bleed`/`slug`. Preview shows a document with the window's settings in the workspace while it is open; Create keeps it, Close removes it.+- Document Setup (⌥⌘P), laid out like InDesign's: intent, number of pages, start page # (an even start begins with a left page), facing pages, binding, Page Size (presets keeping the orientation, width and height with arrows, orientation), margins for every page and parent page, bleed and slug per edge (each group linked or not), and Adjust Layout (objects follow the new page size and margins), all in one undo step; measures are read in the document's units, and a value that can't be read keeps the dialog open; `layout.documentSetup {}` reports the setup, margins included.- Stroke panel: cap, join, miter limit, alignment, type, Start/End arrowheads (12 kinds, drawn on screen and in PDF; the path is shortened under pointed heads) and gap colour under dashes and dots.- Preferences (⌘K: General, Type, Units & Increments, Grids, Guides & Pasteboard, Display Performance) backed by `prefs.set` (application) and `document.preferences` (units, increments, grids — undoable, saved with the document; right-click a ruler to pick its units, the horizontal and vertical rulers each have their own); scaling applies to content and scales stroke weights (Include Stroke Weight), and X/Y/W/H measure the stroke's outer edge (Dimensions Include Stroke Weight). Quick Apply (⌘Return) finds paragraph, character and object styles as well as commands.- Parent item overrides: Cmd+Shift-click a parent item on a page (or Override All Parent Page Items, ⌥⇧⌘L) makes an editable local copy that hides the parent's; Remove All Local Overrides and Detach All Objects from Parent in the Pages panel menu.