Commit Graph
404 Commits
Author SHA1 Message Date
dotCooCoo 9ef2e64f9f Merge main into the column rule extent fix 2026-10-27 07:16:50 -07:00
aiongg 0982b3da03 refactor(compose): move the border_tests module of table.rs to table/border_tests.rs 2026-10-26 18:18:14 +00:00
aiongg 29d10be435 refactor(compose): move hyphen/mod.rs to hyphen.rs 2026-10-26 18:18:13 +00:00
dotCooCoo 00d0867d50 Merge branch 'main' into fix/column-rules-span-the-text 2026-10-25 21:39:36 -07:00
Dylan M. Taylor 42463ce99d Reduce cognitive complexity in variables, PDF graphics, compose frames and menu shortcuts (#1847)
* refactor(engine): split convert_all's per-story plan into convert_plan

Resolves SonarCloud rust:S3776 on convert_all (cmd/variables.rs).

* refactor(pdf): split graphic_unclipped into per-kind helpers

Resolves SonarCloud rust:S3776 on graphic_unclipped (pdf/src/export.rs).

* refactor(compose): extract wrap exclusions and frame text area from frame_specs_placed

Resolves SonarCloud rust:S3776 on frame_specs_placed (compose/src/lib.rs).

* refactor(ui): extract command shortcut lookup from shortcut_key

Resolves SonarCloud rust:S3776 on shortcut_key (ui-egui/src/menus.rs).
2026-10-25 21:25:52 -04:00
dotCooCoo 5f77ea123b Text frames: column rules run from the top line's ascent to the bottom line's descent
A column rule ran from the top of the columns to their bottom, so a frame
that the text only half fills drew its rules down to the empty bottom of
the frame. InDesign draws them from the top line's ascent to the bottom
line's descent. column_rule_rects now takes that extent from the frame's
lines, and the top and bottom insets shorten the rule from there. A frame
without lines draws no rules. Existing documents draw their column rules
at the new length, on screen, in PDF and in PowerPoint export.
2026-10-24 18:54:30 -07:00
skylar taylor-barrick 9fc02f8f7b Merge contributor branch codex/placed-graphic-layer-overrides (PR #1647) into main
Conflict resolutions:
- crates/pdf/src/export.rs: keep main's `graphic(.., hidden)` signature from
  #1241 and report retained graphic-layer overrides that drawing cannot apply.
- docs/gaps.md: keep main's change list and add the graphic-layer entry.
2026-10-24 15:30:03 -06:00
aiongg a16f29a669 Optical margin alignment: lines with a tab hang their edge glyphs, as both line breakers measure them (#1760)
layout_line set a line with a tab or a right indent tab without the optical
margin or CJK edge hangs, while the greedy breaker and the paragraph composer
counted them. A line that fit only because its period hangs was then squeezed
into the measure or set past it.

layout_line now hangs the edge glyphs of every line. Tabs are measured from the
hung start, so tab stops stay where they are, and a right indent tab fills to
the hung end. A tab at a line edge hangs nothing. Lines without tabs lay out as
before.
2026-10-24 14:45:04 -04:00
Brandon Thomas 12c6c721e7 Merge pull request #1753 from Hamza0101/fix/grep-scan-bounds
GREP styles: a scan and the pattern cache are bounded (#1598)
2026-10-24 10:23:12 -04:00
Brandon Thomas 8d6989c508 Merge pull request #1740 from Silvertree2010/fix/h1918-footnote-numbering-overflows-u32
Saturate footnote and endnote numbering at u32::MAX
2026-10-24 10:22:43 -04:00
aiongg 5def4a8c01 Story Optical Margin Alignment with a size, and Ignore Optical Margin (Story panel, engine and IDML) (#1705)
* Type: story Optical Margin Alignment with a size, and Ignore Optical Margin (engine, IDML)

A story's Optical Margin Alignment applies to every paragraph except those
with Ignore Optical Margin; hang amounts scale with the story's size.
story.options sets it, type.para and paragraph styles take
ignoreOpticalMargin. IDML imports and exports StoryPreference
OpticalMarginAlignment/OpticalMarginSize and IgnoreEdgeAlignment. The
per-paragraph opticalMargin switch keeps hanging at the text's own size.

Part of #947.

* Type: the Story panel, and Ignore Optical Margin in the Paragraph panel menu and Paragraph Style Options

Window > Type & Tables > Story sets Optical Margin Alignment and its size
for the stories of the text selection or the selected text frames through
story.options, and is disabled without either. type.selectionAttrs
reports the stories' values as storyOptions, null where they differ.
The Paragraph panel menu toggles ignoreOpticalMargin, and Paragraph Style
Options > Indents and Spacing has an Ignore Optical Margin checkbox.

Part of #947.

* ROADMAP: the story Optical Margin Alignment entry names its default and scope
2026-10-24 10:08:40 -04:00
Brandon ThomasandClaude Opus 5.5 637c32506a GREP styles: empty matches don't count toward the per-paragraph cap
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-24 10:05:52 -04:00
Brandon ThomasandClaude Opus 5.5 5fca302ff6 Endnotes: saturate the remaining numbering sites at u32::MAX
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-24 10:01:04 -04:00
aiongg d767fcf41e Text frames: a custom baseline grid's Relative To (page, margin, frame or inset) (#1758) 2026-10-24 09:55:47 -04:00
aiongg 4be45a713a Anchored text frames compose against the grid and page where they are placed (#1710)
* Anchored text frames compose against the grid and page where they are placed

An anchored text frame is not a spread item, so frame_specs composed it at
its stored transform: no page, no page side, no page rect, and a baseline
grid phase taken from that transform. A note set to Only Align First Line
to Grid snapped to the wrong line, and page-number markers and
spine-relative alignment inside it saw no page.

The composer now looks up the host story's composition first, finds where
it placed the frame (in its frames' anchored objects, footnotes or table
cells) and composes the frame's story against that placement
(ComposeOptions::placed). The cache does the same and adds the placement
to the entry's signature, so a note recomposes when its host moves it.
Host lookups stop after eight levels, which bounds stories anchored in
each other.

* Anchored text frames: the cache keys on the placed spread's pages
2026-10-24 08:30:03 -04:00
andeecollard 7074dc8a85 M6: preserve per-placement graphic layer options 2026-10-24 13:22:08 +01:00
aiongg d4c1322d97 Merge pull request #1709 from aiongg/w65-batch
Integration batch: book-chapter IDML baseline grids, hyphenation, and the Paragraph panel stack
2026-10-24 08:14:29 -04:00
Hamza d5a6a7ddd5 GREP styles: a scan and the pattern cache are bounded (#1598)
Two unbounded things in the GREP-style path.

`BACKTRACK_LIMIT` bounds one search, not a scan: `find_all` was called with
`usize::MAX` and pays the limit again for every match, so a pattern tuned just
under it cost `200_000 x matches` per paragraph on every relayout. A scan now
stops at `MAX_MATCHES_PER_PARAGRAPH` (4096) -- more styled runs than a
paragraph can usefully carry -- and says which pattern reached it.

The `PATTERNS` thread-local never evicted, so it grew across every pattern a
session ever composed. It now holds at most 64, least recently used dropped
first: a tick counter marks each use, so the entry evicted is the one longest
unused rather than the one inserted earliest. The test checks that the pattern
just used is still there after the cache overflows, which insertion-order
eviction would not give.

Left for a separate change: DC-17 also asks for a per-compose step budget, so
the cost cannot add up across paragraphs. That means threading a budget from
`compose_story` through `shape` into `overlays`, a compose-internal signature
change that wants its own review rather than riding along here.
2026-10-24 16:26:39 +05:00
NetterSilverandClaude Haiku 5.5 f0ce96138c Saturate footnote and endnote numbering at u32::MAX
Found while testing crates/compose/src/notes.rs:133 (also crates/doc/src/notes.rs:265 footnote_start and crates/doc/src/endnotes.rs:150 endnote_start)

Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-24 09:07:37 +00:00
Dylan M. TaylorandClaude Sonnet 5.5 c313c53497 refactor: split complex functions in ruby, warichu, pdf text, render text, epub, pdfx (Sonar S3776) (#1728)
Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-24 04:51:58 -04:00
Dylan M. TaylorandClaude Sonnet 5.5 cb763c2583 refactor: split complex functions in psd, table, parabox, index, trace, pdf export, render (Sonar S3776) (#1724)
Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-24 04:51:26 -04:00
Dylan M. TaylorandClaude Sonnet 5.5 8299d26400 chore: replace trivial closures with method paths (Sonar S1612) (#1714)
Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-24 04:30:43 -04:00
Dylan M. TaylorandDylan Taylor f90d286721 chore: resolve SonarCloud maintainability issues (#1698)
* chore: resolve SonarCloud maintainability issues

- Replace lambda closures with method references (S1612)
- Replace wildcard imports with explicit imports (S2208)
- Refactor complex functions with extracted helpers (S3776)
- Replace OR pattern with range pattern in math parser (S9047)

* style: apply rustfmt to warichu helper

* fix(compose): revert slice conversion in tests and remove unused var in warichu

* Group warichu row layout scalars to satisfy S107 parameter limit

* style: satisfy rustfmt in warichu.rs

---------

Co-authored-by: Dylan Taylor <dylan@craftmaker.dev>
2026-10-24 03:54:24 -04:00
aiongg 0143633930 Batch: the compose cache keeps both halves of each number's bits on 32-bit targets 2026-10-24 07:26:09 +00:00
aiongg 5905cd3d9a Batch: the compose cache keys on the page geometry under a frame; one copy of each progress-log line 2026-10-24 07:09:46 +00:00
aiongg 0cfbc756d6 Hyphenate Across Column: overflow-safe re-lay budget; drop the stale ROADMAP clause 2026-10-24 05:53:02 +00:00
aiongg 4cbeea2232 Merge #1572: Hyphenate Across Column: no column or frame ends in a hyphen when it's off 2026-10-24 05:52:41 +00:00
aiongg e79da41ce9 Merge #1704: Text frames: a custom baseline grid keeps its start and increment through IDML
# Conflicts:
#	crates/compose/src/lib.rs
#	crates/idml/src/tests.rs
2026-10-24 05:52:12 +00:00
aiongg e11f9f6202 Merge #1703: Baseline grid: Relative To Top Margin starts the grid at each page's top margin
# Conflicts:
#	crates/compose/src/lib.rs
2026-10-24 05:51:57 +00:00
aiongg d8d7885172 Anchored objects: Relative to Spine mirrors custom positions on right-hand pages (#1702)
* Anchored objects: Relative to Spine mirrors custom positions on right-hand pages

* Anchored objects: page side from the frame's spread position; footnote cache keyed by page side
2026-10-24 01:34:05 -04:00
aiongg df6ba617d3 Text frames: a custom baseline grid keeps its start and increment through IDML 2026-10-24 04:58:04 +00:00
aiongg 05901d3ec1 Baseline grid: find the page under a grouped frame from its spread position
A group's transform can move a frame onto another page; the page lookup
used the frame's bounds without its parents' transforms, so the grid took
the wrong page's top margin.
2026-10-24 04:39:34 +00:00
aiongg 14da000a35 Baseline grid: Relative To Top Margin starts the grid at each page's top margin
The setting was imported and editable but never read: the composer, the
canvas grid and baseline snapping measured the grid from the page top.
BaselineGrid::origin gives the first line on a page (start, plus the
page's top margin for Top Margin), and all three use it. The composition
cache tracks the setting and the pages' top margins.

Also adds a left-to-right facing-pages guard test for mirrored margins
and the right parent page's guides and running head.
2026-10-24 04:28:34 +00:00
Brandon Thomas 807d9b5723 Merge pull request #1491 from Hamza0101/fix/underline-under-tabs
An underline runs across a tab, as the rest of the line's text (#1466)
2026-10-23 17:29:54 -04:00
Brandon Thomas 98f957ed6b Merge storytold/main into fix/rtl-first-line-indent
# Conflicts:
#	crates/compose/src/tests.rs
2026-10-23 17:29:07 -04:00
MarekSpodBiedry c0daace441 Lay out the parent-page side lookup so rustfmt passes (#1577) 2026-10-23 16:08:36 +02:00
MarekSpodBiedry 62c71d004a Align towards/away from spine on parent-page folios by page side (#1577) 2026-10-22 21:03:00 +02:00
Hamza e6d78a71d0 A right-to-left paragraph's first-line indent is at its right edge (#1448)
The first-line indent was added to the left indent whatever the paragraph's
direction, so a right-to-left paragraph's first line moved the wrong way. With
the hanging indent a numbered list uses — right indent 10 mm, first line
−10 mm — the first line went 10 mm outside the frame on the left while the
wrapped lines sat where it should have been.

It is the paragraph's start-side indent, which is the right one in a
right-to-left paragraph; the drop-cap case beside it already made that
distinction.

Measured on a 200 pt column with that hanging indent:

  first line    right edge 200     (the frame's edge, as InDesign sets it)
  wrapped       right edge 171.65  (10 mm in)
  every line    left edge >= 0     (nothing outside the frame)

and the same paragraph left to right is unchanged, first line at 0 and wrapped
lines 10 mm in.

The test checks both directions; the right-to-left half fails without the
change. 359 composition tests pass unchanged.
2026-10-22 22:20:41 +05:00
moppeeerandClaude Opus 5.5 2088cee52d Hyphenate Across Column: nested line styles and its own re-lay bound
The points left out are recorded as story bytes, so the nested line styles
prepass (which indexes glyphs differently) leaves them out too, and a
style still covers exactly the lines it is set on. Their re-lays have a
bound of their own: each leaves out one more point of the paragraph, and
the keep options' budget no longer stops them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-22 14:55:59 +02:00
moppeeerandClaude Opus 5.5 bc50eb5564 Hyphenate Across Column: no column or frame ends in a hyphen when it's off
With Hyphenate Across Column off, a paragraph whose line ending at an
automatic hyphenation point would end a column or frame is re-laid
without that point, so the word moves on whole, as InDesign does. The
points left out are kept per paragraph across re-lays and cleared when an
earlier paragraph is re-laid. On by default, as in InDesign.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-22 14:09:12 +02:00
aiongg 2aa5da5950 Paragraph rules: Rule Above's offset is measured from the baseline (#1535)
* Paragraph rules: Rule Above's offset is measured from the first line's baseline

* ROADMAP: Rule Above offset progress line
2026-10-21 20:40:26 -04:00
Hamza 0fc845750a An underline runs across a tab, as the rest of the line's text (#1466)
A tab draws nothing, so it was left out of the underline and strikethrough
bars: they stopped at the last letter before each tab and began again after it.
Forms rule their fill-in lines with underlined tabs — `Name ⇥⇥⇥⇥, city ⇥⇥⇥⇥` —
so an imported form lost every writing line, and an IDML `Underline="true"` on
a run of tabs drew nothing at all.

A tab is a character with an advance, and InDesign rules its whole width.
`PlacedGlyph::spans_rules` says which glyphs a rule runs across: the drawn
ones, and a tab or a right-indent tab that advances. The spaces a line break
trimmed off the end, the break characters and the markers' carriers are not
part of the line's text and are still skipped, so an underline stops at the
text and not at the frame edge.

Both places that draw the bars from the glyphs use it: the renderer
(`build_line`) and the PDF export (`text_rules`). The HTML and PPTX exports
mark up runs of text, which already included their tabs.

Measured on the repro in the issue, a 420×120 pt page at 2×:

  before   one underline, 63 px: the word "Name"
  now      three, 63 + 219 + 231 px: the word and both tab stretches

and the exported PDF gains the two fills for them. A tab with a leader is one
continuous bar across the leader dots to the right-aligned text after it.

Tests: the renderer's bars and the PDF export's bars for "Name<tab>City" are
one bar covering the tab's width, not two with a gap where it is. Both fail
without the change (two bars, 36→67.7 and 72→93.2, the tab's 67.7–72 unruled).
2026-10-21 20:04:12 +05:00
Brandon Thomas 8e7c9504d5 Merge pull request #1148 from y-az/fix/page-number-digits
Breaker: keep a page number's digits together
2026-10-19 02:50:38 -04:00
Brandon Thomas ea3263ef0b Merge pull request #1184 from seanth/drop-cap-size
(fix)Drop caps: scale with the cap's point size, as InDesign doesDrop cap size
2026-10-19 02:50:15 -04:00
Aykut FiratandClaude Opus 5.5 08ce444054 Tables: cell First Baseline offset (Cell Options › Text › First Baseline)
Cells and cell styles had no first-baseline setting, so every cell set its first line by the
Ascent offset (the font's typographic ascender). IDML documents that set FirstBaselineOffset on a
cell style (CapHeight is common, often through a table style's body region) composed every row
taller than the document asked for. With a font whose typographic ascender is a full em (Avenir),
each row grew about 2.6 pt and long tables overset, losing their last rows.

- doc: Cell.first_baseline / first_baseline_min; CellStyle.first_baseline / first_baseline_min,
  applied by CellStyle::apply_to and carried through resolve_cell_style's BasedOn chain.
- idml: FirstBaselineOffset and MinimumFirstBaselineOffset read and written on cells and cell styles.
- compose: a cell's text frame uses the cell's first baseline offset and minimum.
- engine: table.setCell, style.cell.create/edit take firstBaseline / firstBaselineMin; table.get
  reports them; style.cell.create fromSelection captures them.
- tests: import through BasedOn and a table style's body region, a cell's own override, IDML round
  trip; composer cap height vs ascent and a fixed minimum; command parameters and validation.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-17 15:07:46 -04:00
Claude beb5ac0243 Merge upstream main into drop-cap-size
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CgGsJkVe5GYG9qK6VFdECa
2026-10-16 17:11:07 +00:00
Youssef Azriouil ec86a8fd3c Breaker: keep a page number's digits together
The emergency break inside a word wider than the measure could fall
between glyphs of one source character: an automatic page number wider
than its frame came out as "13" over "4". Glyphs sharing a cluster (the
generated digits of a page number, multi-glyph clusters) now stay together
and the number hangs out of its frame, as in InDesign.
2026-10-16 11:55:18 +02:00
aiongg 21a6e6d90f Merge branch 'batch-tB' into next-integ
# Conflicts:
#	docs/gaps.md
2026-10-16 04:48:56 +00:00
aiongg 6e4f122b8c Merge PR #1100: Placed greyscale and bitmap images take the swatch applied to them (IDML, screen, PDF)
Graphic literals (cli perf, doc assets/item, engine datamerge/export/file/links/mathexpr/media/table/sample, epub, format, pdf, pptx, render, tools, ui-egui properties, and tests): name the branch's clip and wrap (#561, #381) and the PR's fill.
crates/doc/src/item.rs: Graphic keeps wrap and gains fill.
crates/idml/src/import.rs: read the image swatch, then the branch's styled FrameFittingOption lookup; the graphic keeps its wrap.
crates/idml/src/tests/assets.rs: keep both new tests.
crates/render/src/lib.rs: keep #362's crop-box sizing of placed PDFs and colour the resulting pixmap.
crates/render/tests/colorize.rs, crates/epub/tests/grouped_reading_order.rs, crates/compose/src/tests.rs: literals name the branch's Asset and Graphic fields.
crates/pdf/src/export.rs: the soft mask interpolates by the standard's raster mode (the branch has no per-exporter interpolate switch).
docs/gaps.md, docs/target-app-parity.md: status lines list both sides' changes; gap text keeps the clipping-path items and adds the image swatch.
2026-10-16 04:07:57 +00:00
moppeeer a254f0e6e0 Integration: #384 rebreak check (from #1086 by moppeeer)
Past the estimated line slots the breaker assumes the whole column; the
rebreak check compares against that fallback too, so lines beside a wrap
object stay inside their segments.

(cherry picked from commit 94a06ed881)
2026-10-16 04:05:57 +00:00