DesignCraft: An open-source page and layout design editor written by scratch in pure Rust
Merge text-stroke-behind: Text: stroke behind fill (#619)
aiongge391002be619
diff --cc ROADMAP.mdindex ccda3d1eb,6106d978f..b9fe40292--- a/ROADMAP.md+++ b/ROADMAP.md@@@ -1,8 -1,8 +1,8 @@@# DesignCraft roadmap-**Stage: pre-alpha** · next: alpha, ~0% and ~15–25 h away; beta ~28 points and ~420–750 h beyond that (the core-workflow gate, not the percentage: ready for real work is already ~47%)+**Stage: pre-alpha** · next: alpha, ~5–7 h away; beta ~28 points and ~420–750 h beyond that (the core-workflow gate, not the percentage: ready for real work is already ~47%)- > **Last reviewed:** 2026-10-11 · **Last updated:** 2026-10-12 · **Change:** minor (text threads by hand; the alpha gate waits on Primary Text Frame page fixes; Japanese print, import and table controls localized; Live corners (#186); Optical kerning from outlines (#181); window and menu quit confirmation; failed writes preserve live save and collection state; spring-loaded Zoom navigation; orderly native exit recovery; Pages panel parents; cancelable macOS Dock Quit) · **Target:** Adobe InDesign 2026-> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-12 · **Change:** minor (text stroke behind fill) · **Target:** Adobe InDesign 2026++> **Last reviewed:** 2026-10-11 · **Last updated:** 2026-10-12 · **Change:** minor (text threads by hand; the alpha gate waits on Primary Text Frame page fixes; Japanese print, import and table controls localized; Live corners (#186); Optical kerning from outlines (#181); window and menu quit confirmation; failed writes preserve live save and collection state; spring-loaded Zoom navigation; orderly native exit recovery; Pages panel parents; cancelable macOS Dock Quit; text stroke behind fill) · **Target:** Adobe InDesign 2026DesignCraft aims at full Adobe InDesign parity, and to be better: faster, open (documented JSONformat + IDML), scriptable by agents (MCP), and available on the web.@@@ -128,39 -129,8 +128,40 @@@ list) · [roadmap.md](docs/roadmap.md)Newest first.+ - **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 and IDML import, 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/paths.rsindex a512fdaab,53eb4aff0..3541bd231--- a/crates/engine/src/cmd/paths.rs+++ b/crates/engine/src/cmd/paths.rs@@@ -255,9 -255,8 +255,9 @@@ fn create_outlines(s: &mut Session, p:continue;}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 a = Affine::translate((g.x, l.baseline + g.y)) * skew * Affine::scale_non_uniform(g.sx, g.sy);+ let shatai = st.shatai_xf(g, l.baseline).unwrap_or(Affine::IDENTITY);+ let a = shatai * Affine::translate((g.x, l.baseline + g.y)) * skew * Affine::scale_non_uniform(g.sx, g.sy);- let key = (st.fill.clone(), st.fill_tint, st.stroke.clone(), st.stroke_tint, st.stroke_weight);+ let key = (st.fill.clone(), st.fill_tint, st.stroke.clone(), st.stroke_tint, st.stroke_weight, st.stroke_behind_fill);let k = match runs.iter().position(|r| r.0 == key) {Some(k) => k,None => {diff --cc crates/idml/src/tests.rsindex 592ce6764,e4c6e9f92..06990f531--- a/crates/idml/src/tests.rs+++ b/crates/idml/src/tests.rs@@@ -1420,33 -842,25 +1420,52 @@@ fn cjk_character_attributes_import_fromassert_eq!(a.leading_model, b.leading_model);}+#[test]+fn composers_import_by_kind_and_round_trip() {+ use designcraft_doc::Composer as C;+ let para = |composer: &str, text: &str| {+ format!(+ r#"<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/$ID/[No paragraph style]" Composer="{composer}"><CharacterStyleRange AppliedCharacterStyle="CharacterStyle/$ID/[No character style]"><Content>{text}</Content><Br /></CharacterStyleRange></ParagraphStyleRange>"#+ )+ };+ let cases = [+ ("HL Composer", C::Paragraph),+ ("HL Single Optyca", C::SingleLine),+ ("HL Composer Optyca", C::Paragraph),+ ("HL Composer J", C::Japanese),+ ("$ID/HL Single J", C::JapaneseSingleLine),+ ];+ let body: String = cases.iter().enumerate().map(|(i, (name, _))| para(name, &format!("p{i}"))).collect();+ let story =+ format!(r#"<idPkg:Story xmlns:idPkg="http://ns.adobe.com/AdobeInDesign/idml/1.0/packaging"><Story Self="s1">{body}</Story></idPkg:Story>"#);+ let doc = import_idml(&fixture_with_story(&story)).unwrap();+ let back = import_idml(&export_idml(&doc)).unwrap();+ for d in [&doc, &back] {+ let st = d.stories.values().find(|s| s.text.contains("p0")).unwrap();+ let got: Vec<_> = st.paras.iter().take(cases.len()).map(|p| p.para.composer).collect();+ assert_eq!(got, cases.iter().map(|(_, c)| Some(*c)).collect::<Vec<_>>());+ }+}++ #[test]+ fn text_stroke_alignment_imports_as_stroke_behind_fill_and_round_trips() {+ let story = r#"<idPkg:Story xmlns:idPkg="http://ns.adobe.com/AdobeInDesign/idml/1.0/packaging"><Story Self="s1">+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/$ID/[No paragraph style]">+ <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/$ID/[No character style]" StrokeColor="Color/Black" StrokeWeight="2" StrokeAlignment="OutsideAlignment"><Content>Behind</Content></CharacterStyleRange>+ <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/$ID/[No character style]" StrokeColor="Color/Black" StrokeAlignment="CenterAlignment"><Content>Over</Content></CharacterStyleRange>+ <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/$ID/[No character style]"><Content>Plain</Content></CharacterStyleRange>+ </ParagraphStyleRange></Story></idPkg:Story>"#;+ let flags = |d: &Document| -> Vec<(String, Option<bool>)> {+ let st = d.stories.values().find(|s| s.text.contains("Behind")).unwrap();+ st.runs().map(|(r, f)| (st.text[r].to_string(), f.over.stroke_behind_fill)).filter(|(t, _)| !t.trim().is_empty()).collect()+ };+ let want = vec![("Behind".to_string(), Some(true)), ("Over".to_string(), Some(false)), ("Plain".to_string(), None)];+ let doc = import_idml(&fixture_with_story(story)).unwrap();+ assert_eq!(flags(&doc), want);+ let back = import_idml(&export_idml(&doc)).unwrap();+ assert_eq!(flags(&back), want);+ }+#[test]fn warichu_imports_from_idml_and_round_trips() {let story = r#"<idPkg:Story xmlns:idPkg="http://ns.adobe.com/AdobeInDesign/idml/1.0/packaging"><Story Self="s1">diff --cc crates/pdf/src/text.rsindex fb0f17ea2,0cd4770a9..aaf00e995--- a/crates/pdf/src/text.rs+++ b/crates/pdf/src/text.rs@@@ -440,40 -298,70 +440,79 @@@ 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);+ // 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);++ 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, tan, size, fill, stroke, st.stroke_weight);- return;- }- let Some(font) = self.font(&face) else {- self.paint_outlines(s, &glyph_outlines(glyphs, size), origin, fill, stroke, weight);++ 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, fill, stroke, weight);++ 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, tan, size, fill, stroke, st.stroke_weight);- return;- };- self.paint_outlines(s, &glyph_outlines(glyphs, size), origin, fill, stroke, weight);++ 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>,+ stroke_weight: f64,+ ) {- let (text, ranges) = self.run_text(glyphs, story);++ 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: st.stroke_weight as f32, ..Default::default() }));+ s.set_stroke(stroke.map(|c| Stroke { paint: c.into(), width: stroke_weight as f32, ..Default::default() }));- s.draw_glyphs(Point::from_xy(0.0, 0.0), &kg, font, &text, size as f32, false);+ 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();@@@ -542,3 -427,18 +578,20 @@@s.set_fill(None);}}+-/// A run's glyph outlines at `size`, relative to its first glyph's origin.-fn glyph_outlines(glyphs: &[PlacedGlyph], size: f64) -> BezPath {++/// A run's glyph outlines at `size`, relative to its first glyph's origin. A vertical offset (a++/// mark above or below its base) is undone by the skew `tan` so it lands where it was composed.++fn glyph_outlines(glyphs: &[PlacedGlyph], size: f64, tan: f64) -> BezPath {+ let db = FontDb::global();+ let mut bp = BezPath::new();+ let Some(g0) = glyphs.first() else { return bp };+ let k = size / g0.face.upem;+ for g in glyphs {- let a = Affine::translate(((g.x - g0.x) / (g0.sx / g0.sy), 0.0)) * Affine::scale(k);++ let dy = g.y - g0.y;++ let a = Affine::translate(((g.x - g0.x + tan * dy) / (g0.sx / g0.sy), dy)) * Affine::scale(k);+ let mut o = (*db.outline(&g.face, g.gid)).clone();+ o.apply_affine(a);+ bp.extend(o.iter());+ }+ bp+ }diff --cc crates/render/src/text.rsindex 33f938be5,57103a234..8dbc115b6--- a/crates/render/src/text.rs+++ b/crates/render/src/text.rs@@@ -382,45 -358,9 +382,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, st.overprint_fill);- 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,- );- }- ctx.set_paint(c);- ctx.fill_path(bp);- if op {- ctx.pop_layer();- }- }let st = &cs.styles[*si as usize];- if st.stroke != designcraft_color::swatch::NONE- && let Some(c) = doc.resolve_color(&st.stroke, st.stroke_tint)- {- let op = crate::overprints(f, &st.stroke, st.stroke_tint, st.overprint_stroke);- 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,- );- }- ctx.set_paint(color_of(&c, 1.0));- ctx.set_stroke(kurbo::Stroke::new(st.stroke_weight));- ctx.stroke_path(bp);- if op {- ctx.pop_layer();- }- }- let fill = fill_of(*si).map(|c| (c, crate::overprints(f, &st.fill, st.fill_tint, false)));- paint_glyphs(ctx, bp, fill, stroke_of(doc, st), st.stroke_weight, st.stroke_behind_fill);++ 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);}}for &i in &shown {@@@ -504,17 -432,70 +469,89 @@@ impl Renderer}}-/// Kurbo stroke for a table edge.+ /// A run's stroke colour, if it has one.+ fn stroke_of(doc: &designcraft_doc::Document, st: &designcraft_compose::RunStyle) -> Option<peniko::Color> {+ if st.stroke == designcraft_color::swatch::NONE {+ return None;+ }+ doc.resolve_color(&st.stroke, st.stroke_tint).map(|c| color_of(&c, 1.0))+ }+-/// Paint glyph outlines: the fill (multiplied when it overprints), then the stroke over it. 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.++/// 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.+ fn paint_glyphs(+ ctx: &mut RenderContext,+ bp: &BezPath,+ fill: Option<(peniko::Color, bool)>,- stroke: Option<peniko::Color>,++ stroke: Option<(peniko::Color, bool)>,+ weight: f64,+ behind: bool,+ ) {+ let paint_fill = |ctx: &mut RenderContext| {+ let Some((c, overprint)) = fill else { return };- if overprint {- ctx.push_layer(None, Some(peniko::BlendMode::new(peniko::Mix::Multiply, peniko::Compose::SrcOver)), None, None, None);- }- ctx.set_paint(c);- ctx.fill_path(bp);- if overprint {- ctx.pop_layer();- }++ overprinting(ctx, overprint, |ctx| {++ ctx.set_paint(c);++ ctx.fill_path(bp);++ });+ };- let Some(sc) = stroke else {++ let Some((sc, stroke_overprint)) = stroke else {+ paint_fill(ctx);+ return;+ };+ if !behind {+ paint_fill(ctx);- ctx.set_paint(sc);- ctx.set_stroke(kurbo::Stroke::new(weight));- ctx.stroke_path(bp);++ overprinting(ctx, stroke_overprint, |ctx| {++ ctx.set_paint(sc);++ ctx.set_stroke(kurbo::Stroke::new(weight));++ ctx.stroke_path(bp);++ });+ return;+ }- ctx.set_paint(sc);- ctx.set_stroke(kurbo::Stroke::new(weight * 2.0));+ if fill.is_some() {- ctx.stroke_path(bp);++ overprinting(ctx, stroke_overprint, |ctx| {++ ctx.set_paint(sc);++ ctx.set_stroke(kurbo::Stroke::new(weight * 2.0));++ ctx.stroke_path(bp);++ });+ paint_fill(ctx);+ } else {- ctx.push_layer(None, None, None, None, None);- 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();++ overprinting(ctx, stroke_overprint, |ctx| {++ ctx.push_layer(None, None, None, None, None);++ ctx.set_paint(sc);++ 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();++ });+ }+ }+-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() => {+/// 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,}}@@@ -536,17 -517,8 +573,8 @@@ impl Rendererctx.set_transform(f.view * xf);for (si, bp) in designcraft_compose::path_glyphs(cs, ft, path, pt) {let st = &cs.styles[si as usize];- if let Some(c) = doc.resolve_color(&st.fill, st.fill_tint) {- ctx.set_paint(color_of(&c, 1.0));- ctx.fill_path(&bp);- }- if st.stroke != designcraft_color::swatch::NONE- && let Some(c) = doc.resolve_color(&st.stroke, st.stroke_tint)- {- ctx.set_paint(color_of(&c, 1.0));- ctx.set_stroke(kurbo::Stroke::new(st.stroke_weight));- ctx.stroke_path(&bp);- }+ 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), st.stroke_weight, st.stroke_behind_fill);++ paint_glyphs(ctx, &bp, fill, stroke_of(doc, st).map(|c| (c, false)), st.stroke_weight, st.stroke_behind_fill);self.stats.glyphs += 1;}}diff --cc crates/ui-egui/src/dialogs.rsindex 10a7eb8fa,cee849a99..fe0c0f6c2--- a/crates/ui-egui/src/dialogs.rs+++ b/crates/ui-egui/src/dialogs.rs@@@ -4492,113 -3441,123 +4492,116 @@@ fn basic_character_formats(app: &mut De});}-/// One parameter of a command, parsed from its params documentation-/// (`{name, type?: a|b|c, count?, flag?: bool, …}`).-#[derive(Clone, Debug, PartialEq)]-pub struct CommandField {- pub key: String,- pub optional: bool,- /// Enumerated values (`a|b|c`).- pub choices: Vec<String>,- pub boolean: bool,- /// The documented value spec (shown as a hint).- pub hint: String,+/// Advanced Character Formats: scaling, baseline shift, skew and language.+fn advanced_character_formats(lang: &str, ui: &mut egui::Ui, d: &mut Dialog, cf: &CharFields) {+ egui::Grid::new("csa").num_columns(2).spacing([8.0, 6.0]).show(ui, |ui| {+ crate::rtl::label(ui, crate::i18n::tr(lang, "Horizontal Scale:"));+ char_number(ui, d, cf, "hScale", "%", 100.0, (1.0, 1000.0));+ ui.end_row();+ crate::rtl::label(ui, crate::i18n::tr(lang, "Vertical Scale:"));+ char_number(ui, d, cf, "vScale", "%", 100.0, (1.0, 1000.0));+ ui.end_row();+ crate::rtl::label(ui, crate::i18n::tr(lang, "Baseline Shift:"));+ char_number(ui, d, cf, "baselineShift", " pt", 1.0, (-5000.0, 5000.0));+ ui.end_row();+ crate::rtl::label(ui, crate::i18n::tr(lang, "Skew:"));+ char_number(ui, d, cf, "skew", "°", 1.0, (-85.0, 85.0));+ ui.end_row();+ crate::rtl::label(ui, crate::i18n::tr(lang, "Language:"));+ let opts: Vec<(Value, &str)> = crate::panels::properties::LANGUAGES.iter().map(|l| (json!(l), *l)).collect();+ char_choice(lang, ui, d, cf, "language", &opts);+ ui.end_row();+ });}-/// Parameters of a command from its documentation string: the top-level keys of the first `{…}`.-pub fn command_fields(doc: &str) -> Vec<CommandField> {- let Some(start) = doc.find('{') else { return vec![] };- let mut depth = 0i32;- let mut end = doc.len();- for (i, c) in doc[start..].char_indices() {- match c {- '{' | '[' | '(' => depth += 1,- '}' | ']' | ')' => {- depth -= 1;- if depth == 0 {- end = start + i;- break;- }- }- _ => {}- }- }- let body = &doc[start + 1..end];- let mut parts = Vec::new();- let (mut depth, mut from) = (0i32, 0usize);- for (i, c) in body.char_indices() {- match c {- '{' | '[' | '(' => depth += 1,- '}' | ']' | ')' => depth -= 1,- ',' if depth == 0 => {- parts.push(&body[from..i]);- from = i + 1;+/// Character Color: the fill or stroke swatch, its tint and the stroke weight.+fn character_color(lang: &str, ui: &mut egui::Ui, d: &mut Dialog, cf: &CharFields, doc: &designcraft_doc::Document) {+ let stroke = d.s("colorTarget") == "stroke";+ ui.horizontal(|ui| {+ for (target, label) in [("fill", "Fill"), ("stroke", "Stroke")] {+ if ui.selectable_label((target == "stroke") == stroke, crate::rtl::widget(ui, crate::i18n::tr(lang, label))).clicked() {+ d.fields.insert("colorTarget".into(), json!(target));}- _ => {}}- }- parts.push(&body[from..]);- let ident = |s: &str| !s.is_empty() && s.chars().all(|c| c.is_ascii_alphanumeric() || c == '_') && !s.starts_with(|c: char| c.is_ascii_digit());- let mut out = Vec::new();- for part in parts {- // `key`, `key?`, `key: spec` or `key (spec)`: the key is the leading word.- let part = part.trim();- let k_end = part.find(|c: char| c.is_whitespace() || c == ':' || c == '(').unwrap_or(part.len());- let (k, rest) = part.split_at(k_end);- let rest = rest.trim_start();- let spec = match rest.strip_prefix(':') {- Some(v) => v.trim(),- None => rest.strip_prefix('(').and_then(|r| r.strip_suffix(')')).unwrap_or(rest).trim(),- };- let optional = k.ends_with('?');- let key = k.trim_end_matches('?');- if !ident(key) || out.iter().any(|f: &CommandField| f.key == key) {- continue;+ });+ let key = if stroke { "stroke" } else { "fill" };+ let cur = cf.get(d, key).as_str().unwrap_or("").to_string();+ egui::ScrollArea::vertical().id_salt(("cscolor", key)).max_height(220.0).show(ui, |ui| {+ for sw in &doc.swatches {+ let (c, g) = crate::widgets::swatch_colors(doc, &sw.name, 1.0);+ ui.horizontal(|ui| {+ let (r, _) = ui.allocate_exact_size(egui::vec2(14.0, 14.0), egui::Sense::hover());+ crate::widgets::paint_chip(ui.painter(), r, c, g);+ if ui.selectable_label(sw.name == cur, &sw.name).clicked() {+ // A character style's chosen swatch, clicked again, is no longer set.+ cf.set(d, key, if cf.sparse && sw.name == cur { Value::Null } else { json!(sw.name) });+ }+ });}- let word = spec.split_whitespace().next().unwrap_or("");- let choices: Vec<String> =- if word.contains('|') && word.split('|').all(ident) { word.split('|').map(str::to_string).collect() } else { vec![] };- let boolean = spec.starts_with("bool") || spec.starts_with("true|false") || spec.starts_with("true") && spec.len() <= 5;- out.push(CommandField { key: key.into(), optional, choices: if boolean { vec![] } else { choices }, boolean, hint: spec.into() });- }- out+ });+ egui::Grid::new("cscg").num_columns(2).spacing([8.0, 6.0]).show(ui, |ui| {+ crate::rtl::label(ui, crate::i18n::tr(lang, "Tint:"));+ char_number(ui, d, cf, if stroke { "strokeTint" } else { "fillTint" }, "%", 100.0, (0.0, 100.0));+ ui.end_row();+ crate::rtl::label(ui, crate::i18n::tr(lang, "Weight:"));+ char_number(ui, d, cf, "strokeWeight", " pt", 1.0, (0.0, 800.0));+ ui.end_row();++ ui.label("");++ char_check(ui, d, cf, "strokeBehindFill", crate::i18n::tr(lang, "Stroke Behind Fill"));++ ui.end_row();+ });}-fn humanize(key: &str) -> String {- let mut s = String::new();- for (i, c) in key.chars().enumerate() {- if i == 0 {- s.extend(c.to_uppercase());- } else if c.is_uppercase() {- s.push(' ');- s.extend(c.to_lowercase());- } else {- s.push(c);+/// OpenType Features: the feature switches, figure style and stylistic sets (one `otfFeatures`+/// list: changing any feature sets the whole list).+fn open_type_features(lang: &str, ui: &mut egui::Ui, d: &mut Dialog, cf: &CharFields) {+ use designcraft_doc::otf;+ let mut list: Vec<String> =+ cf.get(d, "otfFeatures").as_array().map(|a| a.iter().filter_map(|v| v.as_str().map(str::to_string)).collect()).unwrap_or_default();+ let mut changed = false;+ egui::Grid::new("csot").num_columns(2).spacing([16.0, 4.0]).show(ui, |ui| {+ for (i, (tag, label, _)) in otf::TOGGLES.iter().enumerate() {+ let mut on = otf::is_on(&list, tag);+ if ui.checkbox(&mut on, crate::rtl::widget(ui, crate::i18n::tr(lang, label))).changed() {+ otf::set(&mut list, tag, on);+ changed = true;+ }+ if i % 2 == 1 {+ ui.end_row();+ }}- }- s-}--/// A form for any command, from its parameter documentation.-fn command_form(app: &crate::DesignApp, ui: &mut egui::Ui, d: &mut Dialog) {- let doc = designcraft_engine::find_command(&d.id[4..]).map_or("", |c| c.params);- let fields = command_fields(doc);- let dim = crate::theme::Tokens::get(ui.ctx()).text_dim;- egui::Grid::new("cmdform").num_columns(2).spacing([8.0, 6.0]).show(ui, |ui| {- for f in &fields {- ui.label(crate::rtl::widget(- ui,- format!("{}{}", crate::i18n::tr(&app.ui.language, &humanize(&f.key)), if f.optional { "" } else { " *" }),- ));- if f.boolean {- check(ui, d, &f.key, "");- } else if !f.choices.is_empty() {- let mut opts: Vec<(&str, &str)> = vec![("", "—")];- let labels: Vec<_> = f.choices.iter().map(|c| humanize(c)).collect();- opts.extend(f.choices.iter().zip(&labels).map(|(value, label)| (value.as_str(), crate::i18n::tr(&app.ui.language, label))));- combo(ui, d, &f.key, &opts);- } else {- let mut s = d.s(&f.key);- let hint = if f.hint.is_empty() { String::new() } else { f.hint.clone() };- if ui.add(egui::TextEdit::singleline(&mut s).hint_text(egui::RichText::new(hint).color(dim)).desired_width(240.0)).changed() {- d.fields.insert(f.key.clone(), Value::String(s));+ });+ ui.add_space(6.0);+ ui.horizontal(|ui| {+ crate::rtl::label(ui, crate::i18n::tr(lang, "Figure Style:"));+ let fig = otf::figures(&list);+ let shown = otf::FIGURES.iter().find(|f| f.0 == fig).map_or("", |f| f.1);+ egui::ComboBox::from_id_salt("csfig").selected_text(crate::rtl::widget(ui, crate::i18n::tr(lang, shown))).width(180.0).show_ui(ui, |ui| {+ for (id, label, ..) in otf::FIGURES {+ if ui.selectable_label(fig == *id, crate::rtl::widget(ui, crate::i18n::tr(lang, label))).clicked() && otf::set_figures(&mut list, id)+ {+ changed = true;}}- ui.end_row();+ });+ });+ ui.add_space(4.0);+ crate::rtl::label(ui, crate::i18n::tr(lang, "Stylistic Sets"));+ let mask = otf::stylistic_sets(&list);+ egui::Grid::new("csss").num_columns(10).spacing([2.0, 2.0]).show(ui, |ui| {+ for n in 1..=20u32 {+ let bit = 1u32 << (n - 1);+ if ui.add_sized([28.0, 20.0], egui::Button::selectable(mask & bit != 0, format!("{n}"))).clicked() {+ otf::set_stylistic_sets(&mut list, mask ^ bit);+ changed = true;+ }+ if n % 10 == 0 {+ ui.end_row();+ }}});- if let Some(st) = d.fields.get("status").and_then(Value::as_str) {- ui.label(egui::RichText::new(st).color(crate::theme::Tokens::get(ui.ctx()).text_dim));+ if changed {+ cf.set(d, "otfFeatures", json!(list));}}diff --cc docs/typography-parity.mdindex 41d278a76,093058395..6828f7946--- a/docs/typography-parity.md+++ b/docs/typography-parity.md@@@ -1,6 -1,6 +1,6 @@@# Typography and composition parity- > **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-12 · **Change:** minor (Optical kerning from outlines (#181); macOS lists fonts that font services and managers activate; Justification dialog for the selected paragraphs; anchored objects wrap text; Tabs panel listed as present (#343)) · **Target:** Adobe InDesign 2026 (21.6)-> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-12 · **Change:** minor (character stroke behind fill) · **Target:** Adobe InDesign 2026 (21.6)++> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-12 · **Change:** minor (Optical kerning from outlines (#181); macOS lists fonts that font services and managers activate; Justification dialog for the selected paragraphs; anchored objects wrap text; Tabs panel listed as present (#343); character stroke behind fill) · **Target:** Adobe InDesign 2026 (21.6)Typesetting is what InDesign is bought for. A feature can exist and still set text differentlyfrom InDesign: different line breaks, different page count, overset where InDesign fits. This@@@ -35,11 -35,12 +35,12 @@@ Fidelity: **unmeasured** unless stated| Paragraph Composer | Adobe's multi-line composer | Knuth–Plass total fit, fitness classes, hyphen penalties | ~ | same family of algorithm, Adobe's weights unknown; breaks will differ on some paragraphs || Single-line Composer | greedy | greedy with the same ranges | ✓ | || World-Ready composers | Paragraph / Single-line World-Ready | RTL, Arabic and bidi in the main composer | ~ | Indic scripts (Devanagari etc.) shape through harfrust but are untested |-| Justification | word/letter spacing, glyph scaling min/desired/max, single-word, last line | all of these | ✓ | a justified line with a tab now justifies after the tab (#284) |-| Hyphenation | per-language dictionaries (~40), zone, limits, capitalized, last word, across columns | Liang patterns: English (trained from the public-domain Moby list) and Spanish (Bezos); zone, limits, exceptions in the user dictionary | ~ | other languages don't hyphenate (#87 reported "doesn't work") |+| Justification | word/letter spacing, glyph scaling min/desired/max, single-word, last line | all of these | ✓ | a justified line with a tab justifies after the tab (#284); set per paragraph in Type › Justification… and the Paragraph panel menu (#531) |+| Hyphenation | per-language dictionaries (~40), zone, limits, capitalized, last word, across columns | Liang patterns: English (trained from the public-domain Moby list), Spanish (Bezos), Portuguese (hyph-pt) and Norwegian (hyph-no); zone, limits, exceptions in the user dictionary | ~ | other languages don't hyphenate (#87 reported "doesn't work") || Spelling | per-language dictionaries | English (Moby) + document/user dictionary | ~ | |-| Kerning | Metrics, Optical, manual, none | Metrics, manual, none | ~ | **Optical treated as Metrics** (#181): imported display text sets wider and can overset |+| Kerning | Metrics, Optical, manual, none | Metrics, Optical (outline-based: pairs pulled towards the font's stem gap, `crates/compose/src/optical.rs`), manual, none | ~ | Optical is an approximation of Adobe's algorithm (#181), not a match: imported display text can still break differently || Tracking, scale, skew, baseline shift | ✓ | ✓ | ✓ | |+ | Character fill and stroke | fill, stroke, tint, weight, stroke aligned to centre or outside | fill, stroke, tints, weight, stroke behind fill (screen, PNG, PDF, IDML `StrokeAlignment`) | ~ | text strokes have no join or miter limit settings (#619 for stroke behind fill) || OpenType features | ligatures, discretionary, swash, fractions, ordinals, figures, small caps, stylistic sets, positional forms | through harfrust | ✓ | || Variable fonts | axes in Character panel | named instances and free axis values; PDF embeds the instance | ✓ | || Leading | auto (120%), absolute, leading model | ✓ | ✓ | CJK leading models in cjk-typography.md |