Skip to content

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

Merge #519: Corner Options keep curves and round every corner point

aiongg059f9a40ef36
diff --cc ROADMAP.md
index 0c8f1c855,8b073be07..a0f0151e5
--- a/ROADMAP.md
+++ b/ROADMAP.md
@@@ -129,31 -129,7 +129,32 @@@ list) · [roadmap.md](docs/roadmap.md)
Newest first.
+ - **2026-10-11** · Corner Options keep curved sides curved and round every corner point, including where an arc meets a line (a Pathfinder quarter circle with rounded corners stayed a triangle). No readiness percentage change.
+- **2026-10-11:** Type › Justification… (Cmd+Alt+Shift+J, also in the Paragraph panel menu) sets word and letter spacing, glyph scaling and the composer on the selected paragraphs, sharing the Paragraph Style Options section (#531). No readiness percentage change.
+- **2026-10-11** · Properties gains InDesign's Pathfinder section (Add, Subtract, Intersect, Exclude Overlap, Minus Back) with several objects selected; section titles and icon buttons have accessible names. No readiness percentage change.
+- **2026-10-11** · `transform.move {copy}`, Edit › Duplicate and Step and Repeat return the copies' ids, so a script can go on with them. No readiness percentage change.
+- **2026-10-11** · `object.fill` and `object.stroke` refuse a swatch name the document doesn't have (it painted nothing) and suggest the name meant (`Paper` → `[Paper]`). No readiness percentage change.
+- **2026-10-11** · Japanese captions now cover print ranges, imported style handling and table
+ row/column movement, including row-height distribution. Existing translation and RTL helpers
+ handle the display; command IDs, stored option values and user-defined style names are unchanged.
+- **2026-10-11** · Moving a sheared and rotated text frame no longer leaves trails of text behind: canvas repaints cover the frame's whole text box, not just its outline. No readiness percentage change.
+- **2026-10-11** · Live corners: the yellow widget on a selected rectangle frame shows corner
+ diamonds; dragging one rounds the corners, Alt-click steps the corner shape (#186).
+- **2026-10-11** · Optical kerning (#181): pairs are spaced from their outlines (ink gap per band,
+ pulled towards the font's stem gap, bounded) instead of silently using the font's kern pairs.
+- **2026-10-11** · New Document laid out like InDesign's (#325): Recent, Saved, Print, Web and
+ Mobile preset tabs beside the preset's details; saved document presets live in the engine
+ (`file.savePreset`, `file.deletePreset`, `file.new {preset}`); `file.new` takes intent, units,
+ start page and per-edge bleed and slug.
+- **2026-10-11** · macOS: fonts that font services and managers activate (Adobe Fonts,
+ RightFont) are listed, read from the files CoreText has available (#261, #327).
+- **2026-10-11:** Document pages take their parent page's margins and columns (left or right parent page by side) and follow its changes unless they have their own; parent ruler guides draw and snap on the pages based on it. IDML import marks a page margin preference that differs from its parent as the page's own. No readiness percentage change.
+- **2026-10-11** · Document Setup laid out like InDesign's: Page Size, Margins (new: every
+ page's, `layout.documentSetup {margins}`), Bleed and Slug with links, Adjust Layout.
+- **2026-10-11** · IDML reads and writes a spread's view rotation (Rotate Spread) as the
+ rotation part of the spread transform (#484).
+- **2026-10-11** · The document grid is drawn (View ▸ Grids & Guides ▸ Show/Hide Document Grid,
+ ⌘'), on the lines Snap to Document Grid uses, behind or in front of page items (#530).
- **2026-10-10 (UI.4–UI.5):** Panel tabs can move into other groups, split the dock, float, resize and return to their saved locations through shared docking transactions. Layouts persist in custom workspaces; UI and control commands share the same validated action path. Shared pane geometry and widget-state theme application retain all five palettes and local fonts. Split panes send keyboard input only to the focused canvas and scope contextual toolbar IDs per pane. No readiness percentage change.
- **2026-10-10** · Version 0.6.0; releases add a Linux riscv64 tar.gz (cross-compiled, CLI
smoke-tested under QEMU).
diff --cc crates/geom/src/corners.rs
index 846010e41,6b0c9cb0a..5f0e2cfda
--- a/crates/geom/src/corners.rs
+++ b/crates/geom/src/corners.rs
@@@ -243,50 -221,67 +279,111 @@@ mod tests
assert!((a - std::f64::consts::PI * 100.0).abs() < 1.0, "{a}");
}
+ /// InDesign draws a 28.35 pt radius on a 51.02 pt tall frame as 25.51 (half the shorter side),
+ /// as a circular arc (handles 0.5523 × the radius).
+ #[test]
+ fn radius_is_clamped_to_half_the_shorter_side() {
+ let r = rectangle(Rect::new(0.0, 0.0, 200.0, 51.02));
+ let bp = apply(&r, &CornerOptions::uniform(CornerShape::Rounded, 28.35));
+ let half = 51.02 / 2.0;
+ let mut arcs = 0;
+ let mut last = Point::ZERO;
+ for el in bp.elements() {
+ match *el {
+ kurbo::PathEl::MoveTo(p) | kurbo::PathEl::LineTo(p) => last = p,
+ kurbo::PathEl::CurveTo(c1, c2, p) => {
+ assert!(((p - last).x.abs() - half).abs() < 1e-9 && ((p - last).y.abs() - half).abs() < 1e-9, "{last:?} → {p:?}");
+ assert!(((c1 - last).hypot() - half * crate::shapes::KAPPA).abs() < 1e-9);
+ assert!(((c2 - p).hypot() - half * crate::shapes::KAPPA).abs() < 1e-9);
+ arcs += 1;
+ last = p;
+ }
+ _ => {}
+ }
+ }
+ assert_eq!(arcs, 4);
+ assert!((crate::shapes::KAPPA - 0.5523).abs() < 1e-4);
+ }
+
+ #[test]
+ fn box_outline_rounds_only_closed_corners() {
+ let r = Rect::new(0.0, 0.0, 100.0, 50.0);
+ let round = [Corner { shape: CornerShape::Rounded, size: 10.0 }; 4];
+ let closed = box_outline(r, &round, [true; 4]);
+ let curves = |bp: &BezPath| bp.elements().iter().filter(|e| matches!(e, kurbo::PathEl::CurveTo(..))).count();
+ assert_eq!(curves(&closed), 4);
+ assert!((closed.area().abs() - (5000.0 - (400.0 - std::f64::consts::PI * 100.0))).abs() < 1.0);
+ // Open at the top: the two bottom corners are rounded, the top ends are square.
+ let open = box_outline(r, &round, [false, true, true, true]);
+ assert_eq!(curves(&open), 2);
+ assert!(!open.elements().iter().any(|e| matches!(e, kurbo::PathEl::ClosePath)));
+ // Open at both ends: two separate sides.
+ let sides = box_outline(r, &round, [false, true, false, true]);
+ assert_eq!(sides.elements().iter().filter(|e| matches!(e, kurbo::PathEl::MoveTo(_))).count(), 2);
+ assert_eq!(curves(&sides), 0);
+ }
+
+ fn nearest(bp: &BezPath, p: Point) -> f64 {
+ use kurbo::ParamCurveNearest;
+ bp.segments().map(|s| s.nearest(p, 1e-6).distance_sq.sqrt()).fold(f64::INFINITY, f64::min)
+ }
+
+ /// A quarter disc of radius 100 centred on (0, 100): its arc from (0, 0) to (100, 100).
+ fn quarter_disc() -> PathData {
+ let k = 100.0 * crate::shapes::KAPPA;
+ let mut a0 = crate::path::Anchor::corner(Point::new(0.0, 0.0));
+ a0.h_out = Point::new(k, 0.0);
+ let mut a1 = crate::path::Anchor::corner(Point::new(100.0, 100.0));
+ a1.h_in = Point::new(100.0, 100.0 - k);
+ let a2 = crate::path::Anchor::corner(Point::new(0.0, 100.0));
+ PathData::new(vec![SubPath { anchors: vec![a0, a1, a2], closed: true }])
+ }
+
+ #[test]
+ fn rounded_corners_keep_curved_sides_and_round_where_an_arc_meets_a_line() {
+ let p = quarter_disc();
+ let bp = apply(&p, &CornerOptions::uniform(CornerShape::Rounded, 20.0));
+ // Still a quarter disc (area pi/4 * 100^2 = 7854), less three small rounded corners; a
+ // triangle would be 5000.
+ let area = bp.area().abs();
+ assert!(area > 7300.0 && area < 7854.0, "area {area}");
+ // The middle of the arc is kept.
+ let mid = Point::new(100.0 * std::f64::consts::FRAC_1_SQRT_2, 100.0 - 100.0 * std::f64::consts::FRAC_1_SQRT_2);
+ assert!(nearest(&bp, mid) < 0.05, "{}", nearest(&bp, mid));
+ // All three corners are rounded off: the line-line one and both where the arc meets a line.
+ for corner in [Point::new(0.0, 0.0), Point::new(100.0, 100.0), Point::new(0.0, 100.0)] {
+ assert!(nearest(&bp, corner) > 3.0, "{corner:?} is still sharp");
+ }
+ }
+
+ #[test]
+ fn straight_sides_are_trimmed_exactly() {
+ let r = rectangle(Rect::new(0.0, 0.0, 100.0, 60.0));
+ let bp = apply(&r, &CornerOptions::uniform(CornerShape::Bevel, 10.0));
+ // Every point a bevelled rectangle goes through sits exactly 10 pt from a corner.
+ let pts: Vec<Point> = bp
+ .elements()
+ .iter()
+ .filter_map(|e| match e {
+ kurbo::PathEl::MoveTo(p) | kurbo::PathEl::LineTo(p) => Some(*p),
+ _ => None,
+ })
+ .collect();
+ assert_eq!(pts.len(), 9, "{pts:?}");
+ for p in pts {
+ assert!([0.0, 10.0, 90.0, 100.0].contains(&p.x) && [0.0, 10.0, 50.0, 60.0].contains(&p.y), "{p:?}");
+ }
+ }
+
+ #[test]
+ fn smooth_points_are_not_corners() {
+ let e = crate::shapes::ellipse(Rect::new(0.0, 0.0, 100.0, 60.0));
+ for shape in CornerShape::ALL.into_iter().skip(1) {
+ let bp = apply(&e, &CornerOptions::uniform(shape, 20.0));
+ assert!((bp.area().abs() - e.to_bezpath().area().abs()).abs() < 1e-6, "{shape:?}");
+ }
+ }
+
#[test]
fn size_is_clamped_to_half_edge() {
let r = rectangle(Rect::new(0.0, 0.0, 10.0, 10.0));