Skip to content

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

Merge PR #823 (with main's radial ellipse: linear gradients go through #823's linear_axis)

Brandon Thomas528264a4a9bd
diff --cc ROADMAP.md
index 14a4c9351,4493ac1ad..e4c0bb889
--- a/ROADMAP.md
+++ b/ROADMAP.md
@@@ -131,44 -126,9 +131,45 @@@ 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-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** · 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-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** · 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-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
diff --cc crates/doc/src/item.rs
index cccb4972c,593edd170..25c4c7270
--- a/crates/doc/src/item.rs
+++ b/crates/doc/src/item.rs
@@@ -32,28 -32,21 +32,43 @@@ impl Default for Fill
}
impl Fill {
+ /// A radial gradient's ellipse on an object whose bounds (in its own space) are `b`: centre and
+ /// horizontal and vertical radii. As in InDesign, a radial gradient stretches with the object's
+ /// box: by default it's centred and reaches the box's sides (an ellipse in a non-square box);
+ /// with a Gradient Swatch tool vector it's centred at the vector's start, and the vector's
+ /// length, measured with the box made square, sets its size.
+ pub fn radial_ellipse(&self, b: designcraft_geom::Rect) -> (designcraft_geom::Point, f64, f64) {
+ let k = if b.width() > 1e-9 && b.height() > 1e-9 { b.height() / b.width() } else { 1.0 };
+ match self.gradient_vector {
+ Some([x0, y0, x1, y1]) => {
+ let r = designcraft_geom::Vec2::new(x1 - x0, (y1 - y0) / k).hypot();
+ (designcraft_geom::Point::new(x0, y0), r, r * k)
+ }
+ // A box with no width or height (a straight line's) has no ellipse: a circle across
+ // its length.
+ None if b.width() <= 1e-9 || b.height() <= 1e-9 => {
+ let r = b.width().max(b.height()).max(1e-3) / 2.0;
+ (b.center(), r, r)
+ }
+ None => (b.center(), b.width() / 2.0, b.height() / 2.0),
+ }
+ }
+
+ /// A linear gradient's axis on an object whose bounds (in its own space) are `b`: the
+ /// Gradient Swatch tool's vector, or the box's extent along the gradient's angle through its
+ /// centre. A box with no extent along that angle (a straight line, across it) takes its longer
+ /// side.
+ pub fn linear_axis(&self, b: Rect) -> (Point, Point) {
+ if let Some([x0, y0, x1, y1]) = self.gradient_vector {
+ return (Point::new(x0, y0), Point::new(x1, y1));
+ }
+ let a = self.gradient_angle.unwrap_or(0.0).to_radians();
+ let half = (b.width() * a.cos().abs() + b.height() * a.sin().abs()) / 2.0;
+ let half = if half > 1e-9 { half } else { b.width().max(b.height()).max(1e-3) / 2.0 };
+ let d = designcraft_geom::Vec2::new(a.cos(), -a.sin()) * half;
+ (b.center() - d, b.center() + d)
+ }
+
pub fn none() -> Self {
Fill { swatch: designcraft_color::swatch::NONE.into(), tint: 1.0, gradient_angle: None, gradient_vector: None, overprint: false }
}
diff --cc crates/engine/src/cmd/style.rs
index 2609af641,fdc11e805..7916ccb9f
--- a/crates/engine/src/cmd/style.rs
+++ b/crates/engine/src/cmd/style.rs
@@@ -144,7 -144,7 +144,7 @@@ pub fn specs() -> Vec<CommandSpec>
"Gradient",
[],
None,
- "{kind?: linear|radial, stops?: [{location: 0–100, color: \"#rrggbb\"|{c,m,y,k}(0..100)|[r,g,b]|{model, …}(0..1), opacity?: 0–100, midpoint?: 13–87}], reverse?: bool, angle?: degrees, from?: [x,y], to?: [x,y] (spread coords: the Gradient Swatch tool's drag), ids?} → {swatch, kind, stops} — edits the fill's gradient (an unnamed gradient unless it equals a gradient swatch)",
- "{kind?: linear|radial, stops?: [{location: 0–100, color: \"#rrggbb\"|{c,m,y,k}|[r,g,b], opacity?: 0–100, midpoint?: 13–87}], reverse?: bool, angle?: degrees, from?: [x,y], to?: [x,y] (spread coords: the Gradient Swatch tool's drag), target?: fill|stroke, ids?} → {swatch, kind, stops} — edits the fill's (or the stroke's) gradient (an unnamed gradient unless it equals a gradient swatch)",
++ "{kind?: linear|radial, stops?: [{location: 0–100, color: \"#rrggbb\"|{c,m,y,k}(0..100)|[r,g,b]|{model, …}(0..1), opacity?: 0–100, midpoint?: 13–87}], reverse?: bool, angle?: degrees, from?: [x,y], to?: [x,y] (spread coords: the Gradient Swatch tool's drag), target?: fill|stroke, ids?} → {swatch, kind, stops} — edits the fill's (or the stroke's) gradient (an unnamed gradient unless it equals a gradient swatch)",
super::has_selection,
apply_gradient
),
@@@ -1931,72 -1854,99 +1942,163 @@@ mod sample_color_tests
assert_eq!(text.format_after(0).over.stroke.as_deref(), r["swatch"].as_str(), "selected text stroke: {command}");
}
}
+
+ #[test]
+ fn sampling_with_the_stroke_in_front_colours_a_lines_stroke() {
+ let (mut s, _) = session_with_image();
+ let line = s.execute("line.create", &json!({"a": [300, 300], "b": [500, 300]})).unwrap()["id"].as_u64().unwrap();
+ s.execute("selection.set", &json!({"ids": [line]})).unwrap();
+ let r = s.execute("color.sample", &json!({"at": [100, 100], "target": "stroke"})).unwrap();
+ let it = s.doc().unwrap().doc.item(ItemId(line)).unwrap().clone();
+ assert_eq!(it.stroke.swatch, r["swatch"].as_str().unwrap(), "{r}");
+ assert!(it.fill.is_none(), "the fill stays empty");
+ }
+}
+
+#[cfg(test)]
+mod radial_gradient_tests {
+ use serde_json::json;
+
+ /// White at the side and the top of a 100×200 radial (black → white) rectangle at (50, 20) on
+ /// a 200×240 page, rendered at 1 px/pt.
+ fn sides(img: &designcraft_render::Rendered) -> (u8, u8, u8) {
+ (img.pixel(100, 120)[0], img.pixel(52, 120)[0], img.pixel(100, 22)[0])
+ }
+
+ #[test]
+ fn a_radial_gradient_is_the_objects_ellipse_on_screen_and_in_pdf() {
+ let mut s = crate::Session::new();
+ s.execute("file.new", &json!({"width": 200, "height": 240, "facingPages": false})).unwrap();
+ let id = s.execute("frame.create", &json!({"rect": [50, 20, 150, 220], "content": "unassigned"})).unwrap()["id"].as_u64().unwrap();
+ s.execute("object.stroke", &json!({"ids": [id], "swatch": "[None]"})).unwrap();
+ s.execute(
+ "object.gradient",
+ &json!({"ids": [id], "kind": "radial", "stops": [{"location": 0, "color": "#000000"}, {"location": 100, "color": "#ffffff"}]}),
+ )
+ .unwrap();
+ let d = s.doc().unwrap().doc.clone();
+ let mut r = designcraft_render::Renderer::new();
+ let (c, side, top) = sides(&r.render_page(&d, &s.cache, 0, 1.0, false, &Default::default()).unwrap());
+ assert!(c < 30 && side > 220 && top > 220, "screen: centre {c}, side {side}, top {top}");
+ // The PDF, placed back and drawn: the same ellipse.
+ let pdf = designcraft_pdf::export_pdf(&d, &s.cache, &Default::default()).unwrap();
+ let mut p = crate::Session::new();
+ p.execute("file.new", &json!({"width": 200, "height": 240, "facingPages": false})).unwrap();
+ p.execute("file.place", &json!({"base64": crate::cmd::file::base64_encode(&pdf), "name": "radial.pdf", "x": 0, "y": 0, "width": 200}))
+ .unwrap();
+ let d = p.doc().unwrap().doc.clone();
+ let (c, side, top) = sides(&r.render_page(&d, &p.cache, 0, 1.0, false, &Default::default()).unwrap());
+ assert!(c < 30 && side > 220 && top > 220, "pdf: centre {c}, side {side}, top {top}");
+ }
+
+ #[test]
+ fn a_box_with_no_height_or_width_has_a_circle_across_its_length() {
+ let f = designcraft_doc::Fill::swatch("g");
+ let line = designcraft_geom::Rect::new(20.0, 60.0, 180.0, 60.0);
+ let (c, rx, ry) = f.radial_ellipse(line);
+ assert_eq!((c.x, c.y, rx, ry), (100.0, 60.0, 80.0, 80.0));
+ let (_, rx, ry) = f.radial_ellipse(designcraft_geom::Rect::new(10.0, 0.0, 10.0, 50.0));
+ assert_eq!((rx, ry), (25.0, 25.0));
+ // A point: a tiny circle, never a zero radius.
+ let (_, rx, ry) = f.radial_ellipse(designcraft_geom::Rect::new(5.0, 5.0, 5.0, 5.0));
+ assert!(rx > 0.0 && rx == ry);
+ // A box keeps its ellipse.
+ let (_, rx, ry) = f.radial_ellipse(designcraft_geom::Rect::new(0.0, 0.0, 100.0, 200.0));
+ assert_eq!((rx, ry), (50.0, 100.0));
+ }
}
+ #[cfg(test)]
+ mod gradient_stroke_tests {
+ use serde_json::json;
+
+ /// Grey along a 20 pt line from (20, 60) to (180, 60): near its start, middle and end.
+ fn along(img: &designcraft_render::Rendered) -> (u8, u8, u8) {
+ (img.pixel(26, 60)[0], img.pixel(100, 60)[0], img.pixel(174, 60)[0])
+ }
+
+ #[test]
+ fn a_gradient_on_a_stroke_runs_across_the_path_on_screen_and_in_pdf() {
+ let mut s = crate::Session::new();
+ s.execute("file.new", &json!({"width": 200, "height": 120, "facingPages": false})).unwrap();
+ let id = s.execute("line.create", &json!({"a": [20, 60], "b": [180, 60]})).unwrap()["id"].as_u64().unwrap();
+ s.execute("object.stroke", &json!({"ids": [id], "weight": 20})).unwrap();
+ let r = s
+ .execute(
+ "object.gradient",
+ &json!({"ids": [id], "target": "stroke", "stops": [{"location": 0, "color": "#000000"}, {"location": 100, "color": "#ffffff"}]}),
+ )
+ .unwrap();
+ let d = s.doc().unwrap().doc.clone();
+ let it = d.item(designcraft_doc::ItemId(id)).unwrap();
+ assert_eq!(it.stroke.swatch, r["swatch"].as_str().unwrap());
+ assert_eq!(it.fill.swatch, designcraft_color::swatch::NONE, "the fill is left alone");
+ let mut rr = designcraft_render::Renderer::new();
+ let (a, m, b) = along(&rr.render_page(&d, &s.cache, 0, 1.0, false, &Default::default()).unwrap());
+ assert!(a < 40 && (90..170).contains(&m) && b > 215, "screen: {a} {m} {b}");
+ // The PDF, placed back and drawn: the same.
+ let pdf = designcraft_pdf::export_pdf(&d, &s.cache, &Default::default()).unwrap();
+ let mut p = crate::Session::new();
+ p.execute("file.new", &json!({"width": 200, "height": 120, "facingPages": false})).unwrap();
+ p.execute("file.place", &json!({"base64": crate::cmd::file::base64_encode(&pdf), "name": "stroke.pdf", "x": 0, "y": 0, "width": 200}))
+ .unwrap();
+ let pd = p.doc().unwrap().doc.clone();
+ let (a, m, b) = along(&rr.render_page(&pd, &p.cache, 0, 1.0, false, &Default::default()).unwrap());
+ assert!(a < 40 && (90..170).contains(&m) && b > 215, "pdf: {a} {m} {b}");
+ // The Gradient Swatch tool's drag on the stroke: reversed by dragging right to left.
+ s.execute("object.gradient", &json!({"ids": [id], "target": "stroke", "from": [180, 60], "to": [20, 60]})).unwrap();
+ let d = s.doc().unwrap().doc.clone();
+ let (a, _, b) = along(&rr.render_page(&d, &s.cache, 0, 1.0, false, &Default::default()).unwrap());
+ assert!(a > 215 && b < 40, "dragged: {a} {b}");
+ assert!(s.execute("object.gradient", &json!({"ids": [id], "target": "gap"})).is_err());
+ }
+
+ /// A 20 pt horizontal line with a gradient on its stroke, drawn on screen and from its PDF.
+ fn line_with_stroke_gradient(g: serde_json::Value) -> (designcraft_render::Rendered, designcraft_render::Rendered) {
+ let mut s = crate::Session::new();
+ s.execute("file.new", &json!({"width": 200, "height": 120, "facingPages": false})).unwrap();
+ let id = s.execute("line.create", &json!({"a": [20, 60], "b": [180, 60]})).unwrap()["id"].as_u64().unwrap();
+ s.execute("object.stroke", &json!({"ids": [id], "weight": 20})).unwrap();
+ let mut g = g;
+ g["ids"] = json!([id]);
+ g["target"] = json!("stroke");
+ s.execute("object.gradient", &g).unwrap();
+ let d = s.doc().unwrap().doc.clone();
+ let mut rr = designcraft_render::Renderer::new();
+ let screen = rr.render_page(&d, &s.cache, 0, 1.0, false, &Default::default()).unwrap();
+ let pdf = designcraft_pdf::export_pdf(&d, &s.cache, &Default::default()).unwrap();
+ let mut p = crate::Session::new();
+ p.execute("file.new", &json!({"width": 200, "height": 120, "facingPages": false})).unwrap();
+ p.execute("file.place", &json!({"base64": crate::cmd::file::base64_encode(&pdf), "name": "line.pdf", "x": 0, "y": 0, "width": 200})).unwrap();
+ let pd = p.doc().unwrap().doc.clone();
+ let placed = rr.render_page(&pd, &p.cache, 0, 1.0, false, &Default::default()).unwrap();
+ (screen, placed)
+ }
+
+ #[test]
+ fn a_radial_gradient_on_a_straight_lines_stroke_shows_all_its_stops() {
+ // The line's box has no height: the gradient is a circle across the line's length.
+ let (screen, pdf) = line_with_stroke_gradient(
+ json!({"kind": "radial", "stops": [{"location": 0, "color": "#000000"}, {"location": 100, "color": "#ffffff"}]}),
+ );
+ for (what, img) in [("screen", &screen), ("pdf", &pdf)] {
+ let (a, m, b) = along(img);
+ assert!(m < 40 && a > 180 && b > 180, "{what}: {a} {m} {b}");
+ }
+ }
+
+ #[test]
+ fn a_linear_gradient_across_a_straight_line_paints_its_stroke_alike_on_screen_and_in_pdf() {
+ let (screen, pdf) =
+ line_with_stroke_gradient(json!({"angle": 90, "stops": [{"location": 0, "color": "#ff0000"}, {"location": 100, "color": "#0000ff"}]}));
+ let (s, p) = (screen.pixel(100, 60), pdf.pixel(100, 60));
+ // The line's box has no height: the gradient runs across the line's length, so the stroke
+ // shows its middle.
+ assert!(s[1] < 60 && s[0] > 80 && s[2] > 80, "screen: the stroke is painted, {s:?}");
+ assert!((0..3).all(|i| s[i].abs_diff(p[i]) < 40), "screen {s:?}, pdf {p:?}");
+ }
+ }
+
#[cfg(test)]
#[path = "text_color_tests.rs"]
mod text_color_tests;
diff --cc crates/pdf/src/export.rs
index cd802d22f,8da90186e..a6f05dce4
--- a/crates/pdf/src/export.rs
+++ b/crates/pdf/src/export.rs
@@@ -989,18 -978,10 +989,18 @@@ impl Exporter<'_>
/// A swatch fill (solid or gradient) in the item's inner space. `None` for [None]/unknown.
fn fill_paint(&mut self, fill: &designcraft_doc::Fill, bounds: Rect) -> Option<krilla::paint::Paint> {
- let (swatch, tint, angle) = (fill.swatch.as_str(), fill.tint, fill.gradient_angle);
+ let (swatch, tint) = (fill.swatch.as_str(), fill.tint);
if let Some(g) = designcraft_color::swatch::resolve_gradient(&self.doc.swatches, swatch) {
let kind = g.kind;
- let expanded = g.expanded_stops();
+ let mut expanded = g.expanded_stops();
+ // Grey and CMYK stops blend as inks, so a grey stop beside a CMYK one is the K ink.
+ if !self.rgb_only && expanded.iter().any(|(_, c, _)| matches!(c, Color::Cmyk { .. })) {
+ for (_, c, _) in &mut expanded {
+ if let Color::Gray { k } = *c {
+ *c = Color::cmyk(0.0, 0.0, 0.0, k);
+ }
+ }
+ }
// A PDF shading needs one colour space. Midpoint expansion can introduce RGB even
// when every authored stop is CMYK/Gray; PDF/A can also change the output space.
let components = |c: &Color| match c {
@@@ -1030,14 -1011,15 +1030,12 @@@
if stops.is_empty() {
return None;
}
-- let c = bounds.center();
-- let v = fill.gradient_vector;
return Some(match kind {
GradientKind::Radial => {
- let (c, r) = match v {
- Some([x0, y0, x1, y1]) => (designcraft_geom::Point::new(x0, y0), Vec2::new(x1 - x0, y1 - y0).hypot()),
- None => (c, bounds.width().max(bounds.height()) / 2.0),
- };
- let r = r.max(1e-3) as f32;
+ // A circle stretched into the object's ellipse, as on screen.
+ let (c, rx, ry) = fill.radial_ellipse(bounds);
+ let rx = rx.max(1e-3);
+ let stretch = Affine::translate(c.to_vec2()) * Affine::scale_non_uniform(1.0, ry / rx) * Affine::translate(-c.to_vec2());
let (cx, cy) = (c.x as f32, c.y as f32);
RadialGradient {
fx: cx,
diff --cc crates/render/src/lib.rs
index 6b7735e7b,07b08a812..f3fb7c1bd
--- a/crates/render/src/lib.rs
+++ b/crates/render/src/lib.rs
@@@ -877,29 -889,25 +888,25 @@@ pub fn color_of(c: &designcraft_color::
/// Set a swatch fill (solid or gradient) as the paint. Returns false for [None]/unknown.
fn set_fill_paint(ctx: &mut RenderContext, doc: &Document, fill: &designcraft_doc::Fill, bounds: Rect) -> bool {
- let (swatch, tint, angle) = (fill.swatch.as_str(), fill.tint, fill.gradient_angle);
+ let (swatch, tint) = (fill.swatch.as_str(), fill.tint);
if let Some(g) = designcraft_color::swatch::resolve_gradient(&doc.swatches, swatch) {
- let stops: Vec<peniko::ColorStop> = g.expanded_stops().iter().map(|(o, c, a)| peniko::ColorStop::from((*o, color_of(c, *a)))).collect();
+ // Sampled so process colours blend as inks, as InDesign shows them (and as the PDF's CMYK
+ // shading prints).
+ let stops: Vec<peniko::ColorStop> = g.display_stops().iter().map(|(o, c, a)| peniko::ColorStop::from((*o, color_of(c, *a)))).collect();
if stops.is_empty() {
return false;
}
-- let c = bounds.center();
let grad = match (g.kind, fill.gradient_vector) {
- (designcraft_color::GradientKind::Radial, Some([x0, y0, x1, y1])) => {
- let r = Vec2::new(x1 - x0, y1 - y0).hypot().max(1e-3);
- peniko::Gradient::new_radial((x0, y0), r as f32).with_stops(stops.as_slice())
- }
- (designcraft_color::GradientKind::Radial, None) => {
- let r = bounds.width().max(bounds.height()) / 2.0;
- peniko::Gradient::new_radial(c, r as f32).with_stops(stops.as_slice())
+ // Radial: a circle stretched into the object's ellipse (the paint transform).
+ (designcraft_color::GradientKind::Radial, _) => {
+ let (c, rx, ry) = fill.radial_ellipse(bounds);
+ let rx = rx.max(1e-3);
+ ctx.set_paint_transform(Affine::translate(c.to_vec2()) * Affine::scale_non_uniform(1.0, ry / rx) * Affine::translate(-c.to_vec2()));
+ peniko::Gradient::new_radial(c, rx as f32).with_stops(stops.as_slice())
}
- (_, Some([x0, y0, x1, y1])) => peniko::Gradient::new_linear((x0, y0), (x1, y1)).with_stops(stops.as_slice()),
_ => {
- let a = angle.unwrap_or(0.0).to_radians();
- let half = (bounds.width() * a.cos().abs() + bounds.height() * a.sin().abs()) / 2.0;
- let d = Vec2::new(a.cos(), -a.sin()) * half;
- peniko::Gradient::new_linear(c - d, c + d).with_stops(stops.as_slice())
+ let (a, b) = fill.linear_axis(bounds);
+ peniko::Gradient::new_linear(a, b).with_stops(stops.as_slice())
}
};
ctx.set_paint(grad);
diff --cc crates/ui-egui/src/i18n.rs
index 68ee69351,148ea76bf..bcaf86801
--- a/crates/ui-egui/src/i18n.rs
+++ b/crates/ui-egui/src/i18n.rs
@@@ -57,23 -55,16 +57,33 @@@ const TABLE: &[(&str, [&str; 5])] = &
("Cut", ["Ausschneiden", "Couper", "Cortar", "カット", "剪切"]),
("Copy", ["Kopieren", "Copier", "Copiar", "コピー", "复制"]),
("Paste", ["Einfügen", "Coller", "Pegar", "ペースト", "粘贴"]),
+ (
+ "Bulleted & Numbered Lists",
+ [
+ "Aufzählungszeichen und nummerierte Listen",
+ "Listes à puces et numérotées",
+ "Listas con viñetas y numeradas",
+ "箇条書き",
+ "项目符号列表和编号列表",
+ ],
+ ),
+ ("Current Page Number", ["Aktuelle Seitenzahl", "Numéro de page actuelle", "Número de página actual", "現在のページ番号", "当前页码"]),
+ ("Apply Color (,)", ["Farbe anwenden (,)", "Appliquer la couleur (,)", "Aplicar color (,)", "カラーを適用 (,)", "应用颜色 (,)"]),
+ ("Apply Gradient (.)", ["Verlauf anwenden (.)", "Appliquer le dégradé (.)", "Aplicar degradado (.)", "グラデーションを適用 (.)", "应用渐变 (.)"]),
+ ("View Options", ["Ansichtsoptionen", "Options d’affichage", "Opciones de visualización", "表示オプション", "视图选项"]),
+ ("Frame Edges", ["Rahmenkanten", "Bords du bloc", "Bordes del marco", "フレーム枠", "框架边缘"]),
+ ("Rulers", ["Lineale", "Règles", "Reglas", "定規", "标尺"]),
+ ("Hidden Characters", ["Verborgene Zeichen", "Caractères masqués", "Caracteres ocultos", "制御文字", "隐藏字符"]),
+ (
+ "The stroke isn't a gradient.",
+ [
+ "Die Kontur ist kein Verlauf.",
+ "Le contour n’est pas un dégradé.",
+ "El trazo no es un degradado.",
+ "線はグラデーションではありません。",
+ "描边不是渐变。",
+ ],
+ ),
("Reverse Path", ["Pfadrichtung umkehren", "Inverser le tracé", "Invertir trazado", "パスの方向反転", "反转路径"]),
("Set Anchor", ["Ankerpunkt festlegen", "Définir le point d’ancrage", "Definir punto de ancla", "アンカーポイントを設定", "设置锚点"]),
("Clear", ["Löschen", "Effacer", "Borrar", "消去", "清除"]),
diff --cc crates/ui-egui/src/i18n/ar.rs
index 66e70faf6,0ef9c7f03..0821042e0
--- a/crates/ui-egui/src/i18n/ar.rs
+++ b/crates/ui-egui/src/i18n/ar.rs
@@@ -30,13 -30,7 +30,14 @@@ pub(super) const TABLE: &[(&str, &str)
("Cut", "قص"),
("Copy", "نسخ"),
("Paste", "لصق"),
+ ("Bulleted & Numbered Lists", "القوائم ذات التعداد النقطي والرقمي"),
+ ("Current Page Number", "رقم الصفحة الحالية"),
+ ("Apply Color (,)", "تطبيق اللون (,)"),
+ ("Apply Gradient (.)", "تطبيق التدرج (.)"),
+ ("View Options", "خيارات العرض"),
+ ("Frame Edges", "حواف الإطار"),
+ ("Hidden Characters", "الأحرف المخفية"),
+ ("The stroke isn't a gradient.", "الحد ليس تدرجًا."),
("Reverse Path", "عكس المسار"),
("Set Anchor", "تعيين نقطة الارتساء"),
("Clear", "مسح"),
diff --cc crates/ui-egui/src/i18n/it.rs
index 440d64fce,69f5674a3..240ea4777
--- a/crates/ui-egui/src/i18n/it.rs
+++ b/crates/ui-egui/src/i18n/it.rs
@@@ -28,13 -28,7 +28,14 @@@ pub(super) const TABLE: &[(&str, &str)
("Cut", "Taglia"),
("Copy", "Copia"),
("Paste", "Incolla"),
+ ("Bulleted & Numbered Lists", "Elenchi puntati e numerati"),
+ ("Current Page Number", "Numero di pagina corrente"),
+ ("Apply Color (,)", "Applica colore (,)"),
+ ("Apply Gradient (.)", "Applica sfumatura (.)"),
+ ("View Options", "Opzioni di visualizzazione"),
+ ("Frame Edges", "Bordi cornice"),
+ ("Hidden Characters", "Caratteri nascosti"),
+ ("The stroke isn't a gradient.", "La traccia non è una sfumatura."),
("Reverse Path", "Inverti tracciato"),
("Set Anchor", "Imposta ancoraggio"),
("Clear", "Cancella"),
diff --cc crates/ui-egui/src/i18n/ja.rs
index 9cb7a9370,4d49c851b..b5b27bb5a
--- a/crates/ui-egui/src/i18n/ja.rs
+++ b/crates/ui-egui/src/i18n/ja.rs
@@@ -30,12 -30,7 +30,13 @@@ pub(super) const TABLE: &[(&str, &str)
("Cut", "カット"),
("Copy", "コピー"),
("Paste", "ペースト"),
+ ("Bulleted & Numbered Lists", "箇条書き"),
+ ("Apply Color (,)", "カラーを適用 (,)"),
+ ("Apply Gradient (.)", "グラデーションを適用 (.)"),
+ ("View Options", "表示オプション"),
+ ("Frame Edges", "フレーム枠"),
+ ("Hidden Characters", "制御文字"),
+ ("The stroke isn't a gradient.", "線はグラデーションではありません。"),
("Reverse Path", "パスの方向反転"),
("Set Anchor", "アンカーポイントを設定"),
("Clear", "消去"),
diff --cc crates/ui-egui/src/i18n/pt_br.rs
index 085b2add5,359512596..159cf4824
--- a/crates/ui-egui/src/i18n/pt_br.rs
+++ b/crates/ui-egui/src/i18n/pt_br.rs
@@@ -31,16 -31,7 +31,17 @@@ pub(super) const TABLE: &[(&str, &str)
("Cut", "Recortar"),
("Copy", "Copiar"),
("Paste", "Colar"),
+ ("Bulleted & Numbered Lists", "Listas com marcadores e numeradas"),
+ ("Show Hidden Characters", "Mostrar caracteres ocultos"),
+ ("Current Page Number", "Número da página atual"),
+ ("New Note", "Nova nota"),
+ ("Insert Endnote", "Inserir nota de fim"),
+ ("Apply Color (,)", "Aplicar cor (,)"),
+ ("Apply Gradient (.)", "Aplicar degradê (.)"),
+ ("View Options", "Opções de visualização"),
+ ("Frame Edges", "Bordas do quadro"),
+ ("Hidden Characters", "Caracteres ocultos"),
+ ("The stroke isn't a gradient.", "O traçado não é um gradiente."),
("Reverse Path", "Inverter demarcador"),
("Set Anchor", "Definir ponto de ancoragem"),
("Clear", "Limpar"),
diff --cc crates/ui-egui/src/i18n/uk.rs
index 0d372cc75,aa2601dac..91036383e
--- a/crates/ui-egui/src/i18n/uk.rs
+++ b/crates/ui-egui/src/i18n/uk.rs
@@@ -31,13 -31,7 +31,14 @@@ pub(super) const TABLE: &[(&str, &str)
("Cut", "Вирізати"),
("Copy", "Копіювати"),
("Paste", "Вставити"),
+ ("Bulleted & Numbered Lists", "Марковані й нумеровані списки"),
+ ("Current Page Number", "Номер поточної сторінки"),
+ ("Apply Color (,)", "Застосувати колір (,)"),
+ ("Apply Gradient (.)", "Застосувати градієнт (.)"),
+ ("View Options", "Параметри перегляду"),
+ ("Frame Edges", "Краї фреймів"),
+ ("Hidden Characters", "Приховані символи"),
+ ("The stroke isn't a gradient.", "Обведення не є градієнтом."),
("Reverse Path", "Розвернути контур"),
("Set Anchor", "Задати прив’язку"),
("Clear", "Очистити"),
diff --cc docs/target-app-parity.md
index 80b316c12,fab3bca5f..0a0cee649
--- a/docs/target-app-parity.md
+++ b/docs/target-app-parity.md
@@@ -424,7 -423,7 +424,7 @@@ 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 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. 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` (`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…`). The Gradient panel follows the Fill/Stroke proxy.
++- 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` (`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…`). The Gradient panel follows the Fill/Stroke proxy. 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).
- 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.
- 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.