* Fix#9016: draw added Greek and Cyrillic text with the bundled Inter face
The Add-text path only accepted WinAnsi-encodable text (plus Arabic/Hebrew/
Thai via their shaped faces), so Greek and Cyrillic were refused even though
the bundled Inter face draws them. first_undrawable now uses undrawable_char
(a char is undrawable only if WinAnsi lacks it AND the Inter face can't
draw it), and draw now sets the embedded Inter face for such text, mirroring
doc_create and text_edit.
Co-authored-by: Copilot <[email protected]>
* Fix mixed-script added text and the Greek drawing test
Address the CodeRabbit review findings on the #9016 fix:
- draw_laid_shaped: a run the shaped layout leaves as a Piece::Latin
but that WinAnsi cannot encode (Greek or Cyrillic) is now drawn with
the bundled Inter face, embedded, instead of being silently lost to
WinAnsi '?'. The face is added only when a run needs it, so pure
Hebrew (or Arabic/Thai) text is unchanged.
- tests: the Greek drawing test now selects the added item's content
stream by its /PCMark /Added tag (the page's own "Hi" stream also has
a Tj, so the first Tj stream was the wrong one) and verifies the
embedded face (Type0, FontFile, ToUnicode to Greek). A new test covers
mixed Hebrew + Greek text, asserting the Greek run uses the embedded
face and the Hebrew run the shaped face.
Co-authored-by: Copilot <[email protected]>
* fix(edit): a second Greek item no longer takes the first item's font name (#9016)
draw_inter_face and the mixed-script path embedded the bundled face into a
dict that held none of the page's fonts, so the resource was always PCFull0
and `write` set it over any other PCFull0 the page already had. Seed the dict
with the page's PCFull* entries first, so embedding picks a free name or reuses
an identical face. The mixed-script Latin branch now draws a soft hyphen as a
hyphen, as draw_inter_face does.
Review: https://github.com/storytold/pdfcraft/pull/9078#pullrequestreview-6187655188
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
* test(ui): Greek added text is drawable with the default font (#9016)
Two UI tests still asserted that a standard font refuses Greek phi, which this
change makes drawable through the bundled Inter face. Assert the new behaviour;
an explicit document font keeps working and keeps its resource. Matches the
updates the 0.23.2 release branch made to the same tests.
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
---------
Co-authored-by: Copilot <[email protected]>
Co-authored-by: FredApps <[email protected]>
Co-authored-by: Claude Sonnet 5.5 <[email protected]>
* fix(edit): preserve occupied font names when adding text
* fix(edit): preserve reused indirect font resources
* fix(edit): reuse a matching font whatever the order of its entries
Dict compares its entries in order, so a Helvetica on the page with the
entries we write in another order was not reused, and added text took a
suffixed resource it didn't need. The fonts are compared by key now.
A test keeps a Helvetica that differs only in its /Encoding, has none, or has
an entry more: the Courier fixture also differs in /BaseFont and would pass
without the encoding check.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
* Adapt mixed-script font test to DrawnItem
---------
Co-authored-by: Claude Opus 5.5 <[email protected]>
Co-authored-by: FredApps <[email protected]>
* fix(edit): keep rows that start raised on their baselines when restyled
Restyling part of a paragraph takes the styled rewrite, which read each
row's baseline from its first run. A TextLine's baseline is the raised one
(the interpreter starts a run at Tm x (0, Ts), ISO 32000-2 9.3.7), so a row
starting with a footnote mark or an exponent was lifted by that run's rise:
colouring a word in "2x plus one" (the 2 raised 4 pt) redrew the row 4 pt
up, and a row added below such rows took a 4 pt larger step.
Every place the styled rewrite reads a row's baseline now takes the rise
off first: the paragraph anchor, RowSpacing::place (both cases),
source_baseline, the source leading, and the offset back into each
segment's own text matrix. Each run's own Ts is drawn on top as before.
- TextLine::rise(): the rise a run starts drawn with, in user space.
- raised_row_tests pins the row baselines, the added-row step, paragraph
gaps with spacing set, and a paragraph given a size.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
* fix(edit): measure a run's rise as its height across the baseline
TextLine::rise() scaled Ts by the length of the text-to-user matrix's
y axis. On a slanted matrix that axis is longer than the distance the
rise moves the baseline (Tm [1 0 0.5 1 72 700] with 4 Ts read as 4.47),
so the unraised baseline came out wrong. Scale by the y axis's
component square to the baseline instead: on upright text that is the
user-space height the rise moves it, and a quarter-turned run still
reads its rise (the y axis's plain vertical part is 0 there).
Co-Authored-By: Claude Opus 5.5 <[email protected]>
---------
Co-authored-by: KenM76 <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
Co-authored-by: FredApps <[email protected]>
Update now puts the replacement where the header and footer it replaces
was on each page, instead of on top of every mark added after it, so
marks that overlap stack as they did. The preview draws the page in two
layers around the draft: the marks under it, then the ones over it on a
transparent page, so it still shows what OK will leave.
Added text could only use the standard Helvetica, Times and Courier
faces, so characters outside WinAnsi (Greek, Cyrillic, CJK) were
refused. An added text item can now name a page font resource
(`AddedText::font_resource`): it is drawn with that embedded font
(Type 0, Identity-H, wrapped with the font's own advances), kept in
`/PCAdded` across saves, and painted in the item's ink like other text.
The Format text panel offers the page's document fonts, Load font… and
the installed fonts for added text as well as for edited paragraphs; a
pick or a loaded font applies to the draft, the selected added text
(undoable) or the style for the next text. Bold and italic are off for
an explicit font resource.
Rebased onto the craft framework UI port (#8160).
Co-Authored-By: Claude Opus 5.5 <[email protected]>
A header-and-footer scan that ran out of its text budget treated the settings
it skipped as a header that records none: a listed mark then covered only the
pages before that, Update removed it from those alone, and the skipped ones
were offered as an older header and footer. Skipped settings are now Unread,
not offered as older, and remove_header_footer refuses while any are.
command_run now runs edit.header_footer.update as doc_header_footer's update,
and refuses it without an index rather than adding a header and footer.
main replaced the marks dialogs with hosted parameter dialogs
(craft::ui::patterns::form_dialogs), so Update's header and footer
choice (#5785) is ported onto them rather than merged line by line:
- The "Which header and footer:" choice is a choice row (hf.which).
Picking one fills the dialog in from it; whether the range is still
the one it filled in travels in the dialog's fields (hf.range_kept),
so the build pass, the host pass and OK all read the same pages.
- finish_marks refuses an Update read from another document, as
finish_edits did.
- The page range is craft::pages::PageRange: the preview helpers take
the pages OK applies to.
FredApps' review: the Update preview took away every header and footer
on the page (doc.without_marks), while OK removes only the chosen one,
so a header and footer OK keeps was missing from the preview. The
preview now takes away only the chosen one (new
Document::without_header_footer over pdfcraft_edit::remove_header_footer,
the removal update_header_footer itself does), and its cache is keyed
by the choice, so choosing another draws the page again. An older
header and footer with no recorded settings is still replaced
page-wide, and previewed that way.
Tests: an engine test and a dialog-level test with two headers and
footers on one page, unit tests for what the preview takes away and
for the fields, and the PR's two UI tests ported to the new harness.
Text rendering mode 3 hides the text a Form shows, not its paths and images,
so a Form XObject after Tr 3 can still paint over or under the image. Counting
it as no paint refused moves that change what is visible. The unit test now
checks that such a Form counts.
The fields left after pruning are now found by walking the kept tree from /Fields, each node once, so a field below the pruning depth cutoff keeps its /CO entry and still counts for /SigFlags. Pruning also cleans /CO and /SigFlags when it only took a field out of a kept parent's /Kids, which left /Fields as long as it was.
A calculation order that loses some fields but not all was written back into its indirect array, so any other reference to that array saw the shorter list. The form now gets a direct array with the fields that are left, and the shared object is untouched.
- HeaderFooter::from_object reads every value in place: a direct
settings dictionary, array or string is no longer copied before its
count and sizes are checked.
- A scan of the headers and footers (header_footers and
unrecorded_header_footer_pages) reads each stream and each settings
entry given by reference once, however many pages share it, and
converts at most 16 MiB of text in all.
- Redaction keeps the content read for a stream it only takes the
header settings off (it keeps its /Filter and /DecodeParms, perhaps
by reference), instead of decoding it again without its parameters;
a stream it rewrote that won't decode is an error, not empty content.
An image only such a stream still draws keeps its resource.
- HeaderFooter::check refuses a box longer than the listing decodes
(MAX_RECORDED_TEXT, measured as recorded), so every header that is
added can be listed and updated, not only replaced page-wide.
- Redaction takes /PCHeaderFooter off a shrink stream whose entry
resolves or decodes to the redacted header's settings, so one stream
storing it indirectly no longer leaves the template in the file.
- doc_header_footers numbers index from 1, like pages and the other
tools' indices; update takes that number and refuses 0.
- The automation test also updates with explicit pages.
Conflicts with Thai in headers and footers (#6632) and printer marks:
Update keeps main's Thai drawing and thai_refusal check ahead of the
shared HeaderFooter::check, and UpdateHeaderFooter sits beside
AddPrinterMarks in the permission and undo-scope lists.
Main rewrote prune_fields to remember each visited node, and moved the
watermark and background tools to documents.rs and the integration tests
to tests/it. The fix now sits on that code:
- prune_fields drops removed fields from /AcroForm /CO, and /CO once it is
empty, using the nodes the traversal kept. /SigFlags goes when no
surviving field is a signature field, its /FT read through /Parent.
- doc_watermark and doc_background reject an opacity outside 0..1.
- The opacity assertions move to tests/it/automation.rs.
- The flatten test's surviving signature field is now signed: since #4017
flattening removes an undrawable field with no value.
Fixes#3913 (also reported as #6822, closed as its duplicate).
## What was wrong
The field value was never lost: `/V` is stored losslessly as UTF-16BE, and PdfCraft sets `/NeedAppearances`, which is why other viewers show the Greek correctly. The `?` is only in the appearance PdfCraft draws itself: when the field's `/DR` font can't encode the text, `field_appearance_fit` falls back to Helvetica/WinAnsi, and every character outside WinAnsi is drawn as `?` (and reported through the "This field's font can't draw…" notice).
## The fix
At that fallback decision, characters that neither the field's font nor Helvetica holds but the bundled Inter face does (Latin, Greek, Cyrillic) are now drawn as Type 3 glyphs built from Inter — the same mechanism Thai text already uses in field appearances. Characters no available face holds (e.g. CJK in a Helvetica field) are still drawn as `?` and reported, exactly as before. Text the field's font holds is byte-for-byte unchanged, and no font resource is added in that case.
## Behaviour change to be aware of
Date names in Russian, Czech, Greek, etc. in Helvetica fields (#5303) are now drawn in the date language rather than falling back to English — the "a font that holds them keeps them" rule applied to the bundled face. Japanese still falls back to English. Push-button captions are unchanged (still `?`); same mechanism, possible follow-up.
## Tests
- New forms test `greek_a_field_font_cannot_hold_is_drawn_from_the_bundled_face`: Greek, mixed Latin+Greek (multiline), and exact-WinAnsi strings in a `/Helv` field; asserts the `/V` bytes, no `?` in the appearance, a `PCLa` Type 3 font with ToUnicode, and no undrawn report; a CJK character is still reported. It fails on unmodified code and passes with this change.
- New fonts unit test for splitting a line between the standard font and Inter.
- Updated the engine signature test and the #5303 `form_date_language` tests where they pinned the old `?` behaviour.
Verified locally: `cargo test` for fonts, forms, edit and engine — 1,813 passed, 0 failed; `cargo fmt --check` clean; clippy clean on the touched crates.
*Disclosure: this change was drafted with AI assistance (Claude) under my direction; the diff was reviewed and the verification above was run before opening this PR.*
## Follow-up after #6806
The main mixed-script font change landed in #6806. This PR covers the remaining case where the source font lacks only a variation selector (U+FE00–U+FE0F). A visible letter now selects the fallback face. The regression compares implicit and explicit fallback in two source fonts, including character spacing, alignment, and save/reopen.
Verified locally on macOS arm64 with the CI-pinned craft-fonts input: `cargo test --locked -p pdfcraft-edit` and `cargo test --locked -p pdfcraft-automation --test it mixed_script` passed, as did formatting, scoped Clippy, the layer and asset checks, and the UI WebAssembly build.
<!-- evening-module-refresh-20261027:start -->
**Latest compatibility update (2026-10-27):** [d10080eb](https://github.com/PerchAnton/pdfcraft/commit/d10080eb060d112d75bbcfd0a74e4e0bab38af61) includes main `1dd2737b` through a normal merge.
Source/fallback helpers follow the extracted text modules. The original per-rewrite advance cache, source spaces and batched missing-glyph fallback are preserved. The cache regressions were run with the pinned optional OFL font input.
Local macOS arm64 / Rust 1.99.1: focused regression tests, formatting, scoped all-target Clippy with `-D warnings`, layering and scoped WebAssembly checks pass. Assets and parity checks also pass. Hosted CI is tracked separately on this head. Temporary build outputs and fixtures are cleaned after validation.
<!-- evening-module-refresh-20261027:end -->
<!-- integration-refresh-20261025:start -->
**Latest integration checks (2026-10-25):** head `54423364bba795cff0b56e7c8f168f355062e3bb` includes main `418ac6a2af49b7ac2fed44ca2cae8d5d1d2cec0d` through a normal merge. On macOS arm64 with Rust 1.99.1, 980 scoped tests pass (0 failed, 5 ignored). Formatting, scoped all-target Clippy with `-D warnings`, layers, assets, parity, and the scoped wasm check pass. Test executables and fixtures were removed after each target. Full-workspace and other-platform checks belong to CI on this head. Six permitted OFL craft-fonts faces at release pin `3d9ab3a1` were SHA-256 verified for the font-dependent regressions.
<!-- integration-refresh-20261025:end -->
## What this changes
Fixes#2750.
Adding `шалом` to an upright, single-style Helvetica paragraph used to redraw the Latin text in the fallback face. Keep source fonts now preserves characters with actual source glyphs and batches only missing glyphs in Type 3 fallback fonts. Unencodable boundary spaces remain real, extractable fallback glyphs; source spaces with glyphs keep their face. Original font dictionaries stay intact.
Mixed-run classification and width measurement share a per-character cache within one paragraph rewrite. It stores both source advances and missing-glyph results for that rewrite's metrics, size and character spacing. Wrapping, alignment, justification and underline measurements reuse these widths; the normalized `Tw = 0` state, scaling and summation order stay consistent with drawing. The cache never survives into another rewrite.
## How you verified it
<!-- pdfcraft-conflict-refresh-20261019:start -->
**Current integration verification (2026-10-19):** main `43550c44` is included through a normal merge, preserving published history. Current head [5ea12797](https://github.com/PerchAnton/pdfcraft/commit/5ea127978fce56e64b93e70e7172cda5a193c41c).
Both roadmaps retain every current-main record and estimate, with only this PR's own status, progress and single milestone-row additions. Automatically merged hunks in the touched modules were reviewed.
**732 scoped tests passed, 0 failed, 4 ignored** (edit, engine and automation). Formatting, strict scoped all-target Clippy, scoped WebAssembly and layers/assets/parity pass; whitespace and both roadmap MD028 scans pass. Checks ran on macOS with Rust 1.95, the existing low-disk profile, two Cargo jobs, locked offline dependencies and command timeouts. Optional fonts use the verified release pin `3d9ab3a1`; no new assets or persistent build settings.
These are the checks of the refreshed branch. Broader/native UI observations below are historical; full-workspace and other operating-system checks belong to current-head hosted CI and are tracked separately.
<!-- pdfcraft-conflict-refresh-20261019:end -->
The deterministic work-budget regression was actually RED before caching: 32 source-character measurements for eight distinct characters. It now passes eight cases across two fonts, short/repeated drafts, narrow/maximum-width frames, justification and underlines. A separate saved-document test checks cache isolation across fonts, sizes, spacing and scale against the saved font metrics, wrapped baselines and underline endpoints. Existing extraction, font preservation, fallback batching and refusal regressions pass.
### Reproducible performance probe
`cargo test -p pdfcraft-edit --lib mixed_script_paragraph_rewrite_timing_probe --profile low-disk --locked --offline -j 2 -- --ignored --nocapture`
macOS arm64, Rust 1.95.0, the same existing optimized development profile and release-pinned craft-fonts `3d9ab3a132ed0eff457e424226a435a901da30d3`. Medians of three full `rewrite_block` calls, excluding fixture open, Cargo and extraction. Input repeats `The quick brown fox шалом ` with centre alignment, underline, `Tc = 1.25` and `Tz = 80`.
| UTF-8 bytes | Frame width (pt) | Before (ms) | Cached (ms) | Speedup |
|---|---|---|---|---|
| 992 | 480 | 3.845 | 0.730 | 5.27x |
| 15872 | 480 | 26.913 | 5.333 | 5.05x |
| 63488 | 480 | 103.914 | 19.830 | 5.24x |
| 15872 | 14400 | 418.305 | 28.449 | 14.7x |
Baseline production code is head `7de05471`. These are synthetic measurements, not release-build or 4 MB draft results. Normal tests enforce a deterministic measurement budget rather than a wall-clock threshold. Greedy wrapping still scans candidates, and final run encoding remains necessary.
## Never-crash, provenance and security
- [x] No new production panic paths, input-derived slicing or unsafe code. UTF-8 encoding uses a fixed four-byte buffer; cache keys are distinct input characters.
- [x] Contributor-original synthetic fixtures only; no Adobe assets, font binaries or copied copyleft implementation.
- [x] Existing atomic refusal, root confinement and opt-in MCP/control behaviour are retained; no new network or permission surface.
## Parity and reach
Existing `text_edit`, `text_edit_layout`, CLI and MCP reach this path. Both roadmaps retain one product note with unchanged estimates; text-editing parity remains partial.
## Anything a reviewer should look at first
This applies to upright single-style paragraphs in Keep source fonts mode. Explicit family/weight changes and turned/RTL/visual-order text retain their selection paths. The separate styled-path one-font-per-character issue (#2592), wider glyph coverage (#2593), unused-resource cleanup (#2487) and a different wrapping algorithm remain outside this PR.
## What this changes
`edit.line-paragraph-spacing` was partial: line spacing existed, the space between paragraphs did
not. Now a line break in the edited text starts a paragraph, and the paragraphs are set apart:
- `BlockStyle.paragraph_spacing: Option<f64>` (points, beyond the line spacing). `rewrite_block`
splits the text at line breaks, wraps and justifies each paragraph on its own (the last line of
each paragraph is never stretched), and steps down by the line spacing plus the gap before a
paragraph's first line; underlines follow. `None` is half the font size when the text has
several paragraphs, so a plain Enter already reads as a paragraph; a non-finite value is refused.
- The row-model rewrite (`text_regions`) keeps the rows a line break started apart from wrapped
ones: the gap goes before those, and a row the page already had sits where it was, shifted by
the spacing added above it.
- Format text panel: a Paragraph spacing field (points) next to the line spacing; the tool
`text_edit` takes `paragraph_spacing`.
- Rows for the two labels in all 21 languages; `parity/acrobat-features.toml`
`edit.line-paragraph-spacing` → shipped (notes: space before and after as separate values are
still missing).
## How you verified it
Re-run on 2026-10-15 after merging `main` into the branch (41809cf7, then afa8e184). The merge needed the language catalogs (upstream's rows and this PR's kept), ATTRIBUTION.toml's checksums and the tests both sides had appended at the same place; the new Vietnamese catalog got this PR's 2 labels (written by an AI model, like the other languages' rows, so a native speaker's review is welcome). Reconciled with #1486 (line breaks kept when editing a multi-line paragraph): the default gap between paragraphs applies to upright text only; turned text keeps its rows where they were unless a spacing is set. #1539 merged without conflict. A needless borrow clippy found on Windows is fixed.
Full run on Windows (Rust 1.98) at the branch merged with `main` 41809cf7; after `main` afa8e184 was merged, re-checked on macOS (this PR's tests, the `i18n` tests, `cargo clippy --all-targets -- -D warnings` on the changed crates and their dependents (automation, edit, engine, ui-egui, audit, redact, the apps), `cargo xtask assets`):
- [x] `cargo fmt --all --check`, `cargo xtask assets`, `cargo xtask layers`, doctests: exit 0
- [x] `cargo clippy --workspace --all-targets -- -D warnings`: clean on Windows; on macOS the only warnings are `main`'s own (`crates/ui-egui/tests/view.rs`: two helpers used only by a non-macOS test)
- [x] This PR's tests pass: `paragraph_breaks_get_their_own_spacing`, `the_format_panel_has_a_paragraph_spacing_field`, and `main`'s `turned_paragraph_keeps_its_line_breaks_when_a_word_is_added`
- [ ] `cargo nextest run --workspace`: 3422 of 3433 passed on Windows. The 11 failures fail the same way on `main` without this change: the parity file's duplicate keys (also `cargo xtask parity`; #2419 / #2473), the zh-hant duplicates and the Vietnamese coverage tests in `i18n` (none lists this PR's labels), `signing_with_translated_labels_through_tools` (#2429), `canvas::tests::explicit_search_jumps_record_history_and_keep_match_destination`, `view::single_page_swipe_that_reaches_the_edge_does_not_turn_but_a_fresh_one_does`, `editing::files_dropped_beside_the_pages_panel_still_open_as_documents` (intermittent)
**Tests.** `paragraph_breaks_get_their_own_spacing` (edit): a one-line source rewritten as
"First one\nSecond one" gets the row step alone (15 pt for a 10 pt one-liner), 35 pt with a 20 pt
spacing, 15 pt with 0, and a wrapped single paragraph keeps the ordinary 12 pt step.
`the_format_panel_has_a_paragraph_spacing_field` (ui-egui): the field is in the panel while a
paragraph is being edited.
## Anything a reviewer should look at first
- The labels in the 20 non-English language files were written by an AI model from the English
wording; a native speaker's review of those rows would be welcome.
- Justification now stops at each paragraph's last line (before, only the block's last line was
left unstretched); with a single paragraph nothing changes.
- **Overlap with #1487** ("M7: line and paragraph spacing", opened the day before this one): it adds the
same `BlockStyle.paragraph_spacing`, a spacing field in the Format panel and the `text_edit` argument.
On top of that, this PR stops justification at each paragraph's last line, adds a UI test beside the
edit-crate test, and carries the label in all 21 catalogs. Whichever you prefer is fine: if #1487
lands first I'll rebase this down to what it adds on top of it, or close it.
- **Fits #2249** ("lay out Format text as Acrobat's panel"): that redesign shows paragraph spacing
disabled as *Planned* and replaces `edit_text_ui::extras_panel`, where this PR's field lives. This PR
supplies what the control would drive (`BlockStyle.paragraph_spacing` applied by `text_regions.rs`);
if #2249 lands first I'll move the field into its panel and enable it there.
## Never-crash
- [x] No new `unwrap`/`expect`/`panic!` outside tests
- [x] The spacing is validated (finite, clamped to 0–14 400 pt); rows are indexed with `get`
- [x] No `unsafe`
## Provenance
- [x] No asset added; no code from another implementation
## Security
- [x] No network access
## Parity and reach
- [x] `parity/acrobat-features.toml` updated with what is still missing
- [x] Headless through `text_edit` (`paragraph_spacing`)
- [x] No documented behaviour changed (`docs/` has no entry for it)
- **Merged with main dc41044b** (2026-10-15): #2510's Vietnamese and Lithuanian catalogs added rows beside this branch's in `vi.tsv` and `lt.tsv` (and `ATTRIBUTION.toml`'s sha256 lines), nothing else. Main's rows kept, this branch's rows main lacks after them, hashes recomputed. Re-checked after the merge: `cargo xtask assets` ok, `i18n::tests` 117/117.
- **Merged with main 5fdd820b** (2026-10-15): #1895's catalog rows conflicted with this branch's in `es.tsv` and `vi.tsv` (and `ATTRIBUTION.toml`'s sha256 lines), nothing else. Main's rows kept, this branch's rows main lacks after them, hashes recomputed. Re-checked after the merge: `cargo xtask assets` ok, clippy -D warnings on this branch's crates ok, `i18n::tests` 117/117.
- **Merged with main bc7a12b9** (2026-10-17): only the translation catalogs' new rows and `ATTRIBUTION.toml`'s hashes met this branch (both sides kept, hashes recomputed). Re-checked on macOS: `cargo check --workspace --all-targets`, `cargo xtask assets`, `i18n::tests` 115/115.
- **Merged with main 3f5a784c** (2026-10-17): tests and docs both sides added kept (upstream's first), translation rows and `ATTRIBUTION.toml`'s hashes by key. Re-checked on macOS: `cargo check --workspace --all-targets`, `cargo xtask assets`, `i18n::tests` 115/115.
- **Merged with main dab31491** (2026-10-18, in two steps: 932bf9c6, then dab31491 without conflicts): main and this branch both added tests at the end of `crates/edit/src/tests.rs` and `crates/ui-egui/tests/editing.rs`; both kept, each with its own closing brace (this branch's first), no test lost: the `#[test]` count is main's plus this branch's; and `ATTRIBUTION.toml`'s sha256 lines (main's file kept, every hash recomputed from the merged tree). Re-checked after the merge: `cargo check --workspace --all-targets` ok, `cargo xtask assets` ok, `i18n::tests` 119/119, this branch's tests 2/2.
- **CodeRabbit fixes** (2026-10-21): choosing a font family no longer spreads rows apart when no spacing is set, and applying a spacing replaces the gap a paragraph already had instead of adding to it, so repeating it gives the same result. Each has a test in its own file that fails without the fix.
- **Merged with main 6dec57bf** (2026-10-21): upstream rebuilt the Format text panel and deleted the function this PR's Paragraph spacing row lived in, so the row moved into the new panel, replacing its disabled placeholder; upstream already had the "Paragraph spacing" label in every catalog, so this PR's duplicate rows were dropped, and ATTRIBUTION.toml took main's copy with the hashes recomputed.
- **Merged with main 6898094e** (2026-10-21): only the translation-catalog hashes in ATTRIBUTION.toml met this branch.
- **Round-2 CodeRabbit fixes** (2026-10-21): the draft's line breaks are matched to the source rows by where they came from instead of by position, so a break inserted inside a source row puts the spacing before the new paragraph and later rows keep their source steps. Each has a test in its own file.
- **Merged with main dbc7130b** (2026-10-21): only the translation-catalog hashes in ATTRIBUTION.toml met this branch.
- **Merged with main ffaf3123** (2026-10-21): only the translation-catalog hashes in ATTRIBUTION.toml met this branch.
- **Merged with main adea2c90** (2026-10-23): the parity row both sides changed keeps upstream's evidence with this PR's entries on top; this PR's test moved into upstream's new tests/it layout.
- **Merged with main 57e531cc** (2026-10-23): only the translation-catalog hashes in ATTRIBUTION.toml met this branch.
- **Merged with main a2ec27b4** (2026-10-23): upstream's changes met this PR in pdfcraft-automation, pdfcraft-edit, pdfcraft-ui-egui; checked.
- **Merged with main 6718f1f3** (2026-10-24): upstream's changes met this PR in pdfcraft-automation, pdfcraft-edit, pdfcraft-ui-egui; checked.
- **Merged with main 418ac6a2** (2026-10-25): upstream's changes met this PR in pdfcraft-automation, pdfcraft-edit, pdfcraft-ui-egui; checked.
- **Merged with main 1dd2737b4** (2026-10-27): upstream's changes met this PR in pdfcraft-automation, pdfcraft-edit, pdfcraft-ui-egui; checked.
- **Merged with main 0cba87ae** (2026-11-01): upstream's changes met this PR in pdfcraft-automation, pdfcraft-edit, pdfcraft-ui-egui; checked.
- **Merged with main 3936f93a** (2026-11-02): upstream's changes met this PR in pdfcraft-automation, pdfcraft-edit, pdfcraft-ui-egui; checked.
Four more fixtures for the census branches the first batch could not reach:
annotation_appearances_are_walked_and_the_unreadable_ones_keep_the_image
(a form appearance reached through a state dictionary and an array; an appearance
dictionary naming its own /Resources; appearance states that come back to it)
alternate_arrays_naming_the_image_are_rewritten_through_references
(the rewrite drops the target's entries from a direct and an indirect /Alternates
array and keeps the entry naming another image)
type3_glyph_programs_are_walked_and_a_broken_one_keeps_the_image
(a glyph program that draws the image, and one that is not a stream)
another_page_with_contents_that_are_not_a_stream_keeps_the_image
Two shapes I first wrote turned out not to be uncertain at all and are not claimed as
such: an appearance array holding a number is simply followed, and a damaged Flate
content stream decodes tolerantly, so both leave the image prunable. The fixtures above
are the shapes the census really refuses.
The census keeps an image whenever it cannot prove the image unused, and that
"uncertain" outcome is what most of its code decides. These fixtures pin it:
a form that draws itself, a form chain past the depth limit, soft masks and
alternates that are malformed (against the benign null/None/array-of-null
spellings, which still let an unused image go), gs/Tf naming a font or mask the
census cannot read, a Do naming something that is not a stream, /Annots that is
not an array, and more aliases than the rewrite will stage.
Two positive controls sit beside them: an unused alias inside an indirect
/XObject dictionary is still pruned, and a shading painted through scn is no
consumer at all, so that image still goes.
Each asserts a full save: the marker bytes are present when the census was
uncertain, absent when it proved nonuse. With the "uncertain means unused"
mutation (treating `census.incomplete` as no reason to stop) six of these fail.
A full save renumbers the objects it keeps, so comparing the alias with the
object number the image had before the save fails once the save compacts. The
test now checks what the alias keeps: the image carrying the marker bytes.
Resolutions:
- crates/edit/src/images.rs: take main's file, which it rewrote around this branch's
insertions, and re-apply the branch's three additions (the image-use census and the
two call sites in change_image). No behaviour of main's is reverted.
- crates/automation/tests/automation.rs: main deleted it and moved the tests to
tests/it/automation.rs, so the one hunk (the relaxed unused_xobjects assertion in
a_deleted_image_is_not_kept_by_reduce_or_optimize) is applied there and the old file
stays deleted.
- One ported test compared an image's object number before and after write_full, which
renumbers the objects it keeps; it now follows the alias to the payload instead.
* M7: replacing a line keeps the source font for the words it can show (#2378) (#2955)
* Fit #2955's line edit to #4514's /ActualText spaces
Since #4514, source_show wraps a run whose spaces the subset lacks in a
/Span /ActualText BDC ... EMC, so the moves standing in for those spaces
read back. #2955's two-font /PCEdLine path writes its source runs through
source_show, so they now carry that span too. Three of its tests were
written against the operator stream from before that:
- replacing_a_mixed_font_line_again_replaces_its_sequence counted BMC and
EMC as the /PCEdLine sequences alone. It now also counts each edit's
own /ActualText spans (BDC, and EMC = sequences + spans), so a sequence
that nests or survives a re-edit still fails it.
- a_leading_space_does_not_make_a_source_font_run looked for the leading
move right after the Tf; it now sits inside the run's span.
- a_row_replaced_inside_a_shared_sequence_starts_in_its_own_font put its
second row before the first EMC, which is now the span's: the row was
read as part of the span's text. It now goes before the EMC that closes
/PCEdLine, the case the test describes. A paragraph rewrite drops an
/ActualText span with its line (the span's BDC and EMC are among the
line's operators), so it never leaves a row inside one.
The code needs no change: re-editing drops the spans inside a /PCEdLine
sequence with it (BDC/EMC are in the dropped set), and a span's merged
run keeps the sequence it is in, so the line still reads back as one.
Also drops the same_font import lines.rs no longer uses.
* Tests: fit #2955's three line-edit tests to #4514's /ActualText spans
* Tests: the replaced sequence's check allows the new text's own /ActualText span
---------
Co-authored-by: mtlcl410 <[email protected]>
Co-authored-by: FredApps <[email protected]>
* fix(edit,a11y): font aliases share the metrics built for their font
Text extraction and heading extraction built and kept font metrics per resource name, so
many names for one font object each held a copy of its Unicode and width tables.
* fmt
* address review: font metrics are cached by the object at the end of the reference chain