486 Commits
Author SHA1 Message Date
chamber074 79b76e609b fix(forms): draw field text the field font cannot hold from the bundled face instead of ?
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.*
2026-11-18 16:37:14 +07:00
Perchenko Anton cc0edc29d1 fix(edit): preserve source fonts in mixed-script paragraphs
## 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.
2026-11-18 16:30:26 +07:00
regendorf-ux 3516508589 Edit text: space between paragraphs
## 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.
2026-11-18 16:29:06 +07:00
358e33a307 M7: replacing a line keeps the source font for the words it can show (#2378, re-lands #2955) (#6842)
* 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 <2368091+mtlcl410@users.noreply.github.com>
Co-authored-by: FredApps <FredApps@users.noreply.github.com>
2026-11-14 13:25:27 +01:00
Dylan M. Taylor 1d7a9f9ffe fix(edit,a11y): font aliases share the metrics built for their font (#5998)
* 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
2026-11-11 15:51:22 -05:00
Dylan M. Taylor d46d9daea5 fix(edit): editor font enumeration reads a face name without building font metrics (#6086) 2026-11-11 14:46:47 -05:00
FredApps 22974ca874 Merge pull request #6813 from Piohrun/fix/fonts-refusal-counted
M7: a font's metrics are past their allowance only when it refused a read
2026-11-11 14:34:48 +01:00
mtlcl410 41d959d94c M7: replacing a line keeps both of two dropped quote copies' line move and spacing (edit.text-edit) (#2961) 2026-11-11 11:04:56 +07:00
regendorf-ux b7cfbd3980 Find and replace text in Edit text mode: a Replace row in the Find box, Replace all as one undo step (#2467) 2026-11-10 15:19:55 +07:00
BFlat f48cf6eeba Merge pull request #6806 from storytold/merge/mixed-script-2778
fix(edit): preserve source fonts in mixed-script paragraphs (#2778, merged with main)
2026-11-10 14:22:36 +07:00
mtlcl410 67cd69050e M7: paragraph edits keep the advance of the text they drop (edit.text-edit) (#2968) 2026-11-10 14:21:29 +07:00
Grzegorz MartensandClaude Opus 5.5 7cea6dfead M7: a font's metrics are past their allowance only when it refused a read
`Reads::decode` and the Type 3 glyph-box read took any failed read, with
nothing left of the allowance after it, for one the allowance refused. The
Thai edit refuses on what the allowance itself counts
(`DecodeBudget::refused`), so the two could disagree: once the edit's
allowance was spent to the byte, an empty stream behind a filter nothing
decodes, which is unread with any allowance, made a font's metrics read
past it with no refusal counted. The edit then skipped that font of the
face and went through without it, which its refusal is there to prevent.

Both now take a read as refused only when `DecodeBudget::refused` grew
during it, so `Metrics::past_allowance` is set exactly when the allowance
counted a refusal, as its doc now says.

Tests:
- `an_empty_stream_reads_with_nothing_left` adds such a stream: it isn't
  past the allowance, and the flag agrees with the count in each case.
- `a_type3_description_unread_on_its_own_is_not_past_the_allowance`: the
  same for a glyph description after one that spends the allowance to the
  byte; a description with data after it is still refused.
- `a_font_of_the_face_unread_on_its_own_once_the_allowance_is_spent_still_refuses_the_edit`:
  the edit above is refused, where it went through.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AmsdeUCdTaD72jkDw2pJKY
2026-11-10 06:19:08 +01:00
bflatastic 10755a9da9 Merge remote-tracking branch 'origin/main' into merge/mixed-script-2778
# Conflicts:
#	parity/acrobat-features.toml
2026-11-10 10:45:45 +07:00
bflatastic f6fd408419 Merge remote-tracking branch 'origin/main' into merge/fonts-budget-6239
# Conflicts:
#	crates/edit/src/tests.rs
2026-11-10 10:09:08 +07:00
jonathanwxh-cell c6d9c13002 fix(ui): keep added image corner resize responsive and clip out-of-bounds drag preview (#4477, #3938) (#4625) 2026-11-10 10:00:18 +07:00
PerchAnton 8dfa52c9b5 Merge main into PR #2778 preserving feature behavior 2026-11-10 01:16:46 +02:00
Grzegorz MartensandClaude Opus 5.5 4fca5783a7 M7: a Thai edit refuses only a read past its allowance, and reads its subsets' metrics within it
CodeRabbit's review of 674a20899:

- The Thai edit refused when nothing was left of its allowance, so an
  edit whose reads spent it to the byte was refused. It now refuses when
  a read was refused for want of it (`DecodeBudget::refused`).
- `LegacyThaiFont::from_pdf` read its metrics with `from_dict`, outside
  the edit's allowance, and so did the edit for each subset it measures.
  Both now read them within it (`from_dict_within`), and metrics read
  past it adapt nothing: `from_pdf` refuses the font before reading its
  program, and the edit leaves the subset unread and is refused. The
  edit's scan of every font on the page for its face name stays outside
  the allowance, as on `main`: charged, each alias of a font would pay
  again, and other faces would spend what the face's subsets need.
  `MAX_THAI_PROGRAMS` says what it pays for.
- When the `/CIDToGIDMap` a THSarabunPSK subset's Thai mappings are
  rebuilt from was left unread for want of the editor's allowance,
  `composite_glyph_maps` gave nothing, and a subset with a Latin-only
  cmap of its own was listed as it was, without its Thai mappings. The
  editor now lists no copy of it, as for metrics read past the
  allowance.

Tests: `a_thai_edit_that_spends_its_allowance_to_the_byte_goes_through`
(`pdfcraft-edit`: a subset costing exactly the 64 MiB is edited, and
one three bytes past it is refused),
`a_legacy_fonts_metrics_are_paid_for_from_the_edits_allowance` and
`a_map_left_unread_for_the_allowance_lists_no_copy` (`pdfcraft-fonts`).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AmsdeUCdTaD72jkDw2pJKY
2026-11-09 21:45:29 +01:00
Grzegorz MartensandClaude Opus 5.5 4d6ff291d7 M7: Reads::decode says what a stage past its limit is charged
The Claims review of the description at b7224cbc9. `Reads::decode` said a
stream past its limit is unread, not refused, "when what is left can pay
for its stages". What `DecodeBudget::decode_stages_within` does, and
`a_stage_past_its_limit_charges_what_came_before_and_the_limit` pins:
with more left than what the stages before the stopped one made and the
limit, it is charged those two; otherwise, with more left than the
stages' total (behind one filter, the limit), it is charged that total;
with no more left than that total, it spends all of it and counts as
refused.

`MAX_THAI_PROGRAMS` also names the second read of a subset's program,
for which of its glyphs have outlines, among what it pays for.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AmsdeUCdTaD72jkDw2pJKY
2026-11-09 16:52:47 +01:00
Grzegorz MartensandClaude Opus 5.5 92e8e6eff0 M7: Repair Thai maps reads a /CIDToGIDMap given by reference, and takes a missing one as Identity
The Consumers review of ba28458ad..b7224cbc9:

- `recovered_thai_map` read the descendant's /CIDToGIDMap with
  `Dict::name`, on the line after e9142b03b's /Encoding check, so a map
  given by reference made Repair Thai maps pass the font over, and so
  did a missing one, which is Identity (ISO 32000-2 Table 115), as
  `composite_glyph_maps`, `LegacyThaiFont` and the renderer read it. It
  now resolves the map and takes a missing one as Identity.
- `MAX_THAI_PROGRAMS` says what it pays for: the programs, and the CMaps
  and glyph maps read to adapt their cmaps. The metrics read to find and
  measure the subsets aren't charged to it. Its refusal ("MiB of font
  data") still says what it counts.

Test: `recovered_thai_map_checks_every_kept_glyph_against_the_font_program`
recovers the same map with the font's /CIDToGIDMap given by reference and
with none.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AmsdeUCdTaD72jkDw2pJKY
2026-11-09 16:48:01 +01:00
Grzegorz MartensandClaude Opus 5.5 b7224cbc9a Merge main again into fix/fonts-decode-budget
A third merge, of ba28458ad, with nothing to resolve. main's commits since
b6cbf9bb3 add no font program, metrics or CMap read in pdfcraft-fonts or
the editor's font code for this PR's allowance to cover.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AmsdeUCdTaD72jkDw2pJKY
2026-11-09 16:31:54 +01:00
bflatastic 2ce2d3cf81 Merge main into merge/ui-print-optimize2
# Conflicts:
#	crates/automation/src/redact.rs
#	crates/automation/src/tools.rs
#	crates/print/src/lib.rs
#	crates/render/src/inspect.rs
#	crates/render/src/lib.rs
2026-11-09 20:56:15 +07:00
Grzegorz MartensandClaude Opus 5.5 509cf9f9fd M7: the editor reads no metrics for a composite font it can't adapt
The Resources review of 8eead8ecd:

- `embedded_sfnt_within` read a composite font's metrics within the
  editor's allowance before `composite_glyph_maps` refused any `/Encoding`
  but Identity-H, so an Identity-V or UniJIS font spent its ToUnicode and
  `/CIDToGIDMap` for nothing. Its `/Encoding` is now checked first; a
  program with a cmap of its own is kept as it is, as when the rebuild
  finds nothing.
- The Thai edit's allowance, `MAX_THAI_PROGRAMS`, now also pays for the
  CMaps and glyph maps its subsets' metrics and codes are read from: its
  doc and its refusal say "font data", not "font programs".
- `a_symbolic_truetype_font_without_an_encoding_reads_its_glyph_names`
  also reads its font, whose `post` table names its glyphs, within an
  allowance: the program is paid for by the glyph-name reading, by the
  Mac OS Roman one and for the widths, and a byte short of the first the
  names go unread.

Tests: `a_composite_font_that_cant_be_adapted_spends_only_its_program`,
and `adapting_a_programs_cmap_is_paid_for` again expects a composite font
whose codes aren't Identity-H to pay for its program only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AmsdeUCdTaD72jkDw2pJKY
2026-11-09 13:36:44 +01:00
Grzegorz MartensandClaude Opus 5.5 d4abe80671 Merge main again into fix/fonts-decode-budget
main's #3962 (symbolic TrueType glyph names, 63a6f8ace and nearby) reads a
symbolic TrueType font's codes by the `post` names of the glyphs its cmap
selects, before the Mac OS Roman reading:

- crates/fonts/src/pdf.rs, `unicode_map`: both readings stay, in main's
  order, each given the metrics read's allowance. The program read main
  added (`symbolic_glyph_texts`) goes through `Reads::decode`, as
  `symbolic_mac_roman_texts` does since the last merge: paid for from the
  allowance, `past_allowance` set when it can't be, behind several
  filters within the stream's own limit.
- crates/fonts/src/pdf/tests.rs: both sides added tests at the same place;
  all are kept.

Tests: `adapting_a_programs_cmap_is_paid_for` now expects the program to
be paid for a fourth time, and `the_symbolic_mac_roman_reading_is_paid_for`
becomes `the_symbolic_readings_of_a_program_are_paid_for`, paying for both
readings.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AmsdeUCdTaD72jkDw2pJKY
2026-11-09 13:06:32 +01:00
bflatastic 6404602e63 Merge #5075: fix(edit): Office export respects a form's /BBox and a page's re/W/n clip
# Conflicts:
#	crates/edit/src/text/lines.rs
2026-11-09 18:22:16 +07:00
bflatastic a4a600573e Merge #1998: Print production: Convert colours (grayscale, RGB, CMYK by the device formulas)
# Conflicts:
#	crates/automation/tests/it/automation.rs
#	crates/edit/src/lib.rs
#	crates/edit/src/tests.rs
#	crates/engine/src/commands.rs
#	crates/engine/src/lib.rs
#	crates/optimize/tests/optimize.rs
#	crates/ui-egui/src/app.rs
#	crates/ui-egui/src/dialogs.rs
#	crates/ui-egui/src/lib.rs
#	crates/ui-egui/src/state.rs
#	crates/ui-egui/tests/it/editing.rs
2026-11-09 18:17:38 +07:00
bflatastic b6ddc51ea0 Merge #1918: Print production: Add printer marks (dialog, edit, tool)
# Conflicts:
#	crates/engine/src/edit/run.rs
2026-11-09 18:15:36 +07:00
BFlat 9ee213eff7 Fix main's build and tests after the latest merges (#6706) 2026-11-09 19:12:07 +08:00
Osvaldo Duran MelendezandClaude Sonnet 5.5 e0dc822b9c Merge upstream/main into pr/convert-colours
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-09 06:10:00 -05:00
Osvaldo Duran MelendezandClaude Sonnet 5.5 d1da3905c8 Merge upstream/main into pr/printer-marks
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-09 06:01:48 -05:00
Grzegorz MartensandClaude Opus 5.5 8eead8ecdd Merge main: the font reads main added are paid for from the allowance too
main's Thai work (#6249, #3492) and the Type 3 and symbolic TrueType
metrics changed the code this PR bounds. Each conflict, and each read main
added that this PR's allowance must cover:

- crates/fonts/src/pdf.rs, the editor's program read: this PR's read is
  kept, its stage-scaled limit and its check for an allowance already
  spent; main's read had /DecodeParms by reference too, which it has.
- The editor's loop: main rebuilds a cmap for a composite subset without
  one from its ToUnicode and /CIDToGIDMap, where this PR skipped Type 0.
  main's composite support stays, with the metrics read within the
  editor's allowance (`from_dict_within`) and no copy adapted from metrics
  read past it, as for a simple font. The /CIDToGIDMap the cmap is rebuilt
  from (`composite_glyph_maps`) reads as the font's other streams do
  (`Reads::decode`): within the allowance, behind several filters too.
- Reads main added to the metrics read: a Type 3 font's glyph
  descriptions (`type3_glyph_box`), and the program read that tells a
  symbolic TrueType font's codes as Mac OS Roman
  (`symbolic_mac_roman_texts`). Both are now paid for from the allowance
  the metrics are read within, and a refusal sets `past_allowance`. The
  glyph descriptions keep their own limits (64 KiB each, 4 MiB a font).
- Constants and helpers both sides added beside one another, and the
  tests both appended, are all kept. Callers main added of
  `unicode_map` pass a reading without a total, as `from_dict` does.
- crates/edit/src/rules.rs: the refusal of a page whose content didn't
  all decode stays, and the operators come from main's `text::joined`.

Tests: `adapting_a_programs_cmap_is_paid_for` now expects a composite
font's ToUnicode, and a simple font's program read again for the Mac OS
Roman reading, to be paid for. Four are new:
`adapting_a_composite_subsets_cmap_is_paid_for`,
`a_full_cid_map_rebuilds_a_composite_subsets_cmap_behind_two_filters`,
`type3_glyph_boxes_are_paid_for_from_the_allowance` and
`the_symbolic_mac_roman_reading_is_paid_for`. The fixture of main's test
of a composite subset without a cmap moves into `cmapless_composite`,
which both use.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AmsdeUCdTaD72jkDw2pJKY
2026-11-09 12:00:17 +01:00
mtlcl410 b8d9497b93 M5: cloudy squares, circles and text boxes are drawn (comment.cloud) (#4195) 2026-11-09 18:32:44 +08:00
oracola91 476effc1c8 Text from a justified line keeps one space between words (#5496) 2026-11-09 18:31:47 +08:00
NetterSilver 69571065b9 Split edit-text paragraphs at headings and blank lines (#3642) 2026-11-09 18:23:57 +08:00
mtlcl410 a2ad6b77f8 M7: replacing a line keeps the source font for the words it can show (#2378) (#2955) 2026-11-09 18:22:25 +08:00
mtlcl410 8d9f8d5f30 M5: a reply is not drawn on the page or flattened into it (comment.reply) (#5632) 2026-11-09 18:15:44 +08:00
jonathanwxh-cellandjonathanwxh-cell ab502255cb edit: preserve gap-drawn spaces and indents in subset fonts via /ActualText (#4229) (#4514)
Co-authored-by: jonathanwxh-cell <jonathanwxh-cell@users.noreply.github.com>
2026-11-09 18:13:34 +08:00
regendorf-ux e63736d2e7 Print production: Fix hairlines (dialog, edit, tool) (#1906) 2026-11-09 18:08:46 +08:00
Osvaldo Duran MelendezandClaude Sonnet 5.5 1b3e0e5630 Merge upstream/main into pr/convert-colours
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-08 22:07:06 -05:00
bflatastic 08c0a59212 Merge main into merge/redact-forms-misc
# Conflicts:
#	ROADMAP.md
#	crates/render/src/text/tests.rs
2026-11-09 09:56:59 +07:00
Ozt-y 9792328d67 fix(edit): preserve annotation optional-content membership in marked content (#3213) (#3275) 2026-11-09 10:14:10 +08:00
midasmatterhorn 98b4761934 edit: a variation selector after existing text draws the base glyph instead of failing the edit (#4899) 2026-11-09 10:09:30 +08:00
bflatastic 8a39399b80 Format merged import lists 2026-11-09 08:22:26 +07:00
bflatastic cf10038885 Merge #6650: fix(edit): editing an OCR phrase redraws only the words it changes (refs #3313)
# Conflicts:
#	crates/edit/src/text.rs
#	crates/edit/src/text_regions.rs
2026-11-09 08:21:42 +07:00
mtlcl410 83a6a8394e M7: Edit text lines set in a Type 3 font are as high as their glyphs (edit.text-edit) (#6571) 2026-11-09 08:57:56 +08:00
Oliver H. 616f245b04 fix(edit): break the row on every Unicode row break (#6295) 2026-11-09 08:54:37 +08:00
Fatih Kunak 2ef2e2b822 fix(fonts): a subset that gives the space no width can't encode one (#6131) (#6158) 2026-11-09 08:44:48 +08:00
Dylan M. Taylor ae21773fef fix(edit): stop rescanning what a loop already holds in wrapping, grouping and flattening (#5963) 2026-11-09 08:40:50 +08:00
Tiago KielandClaude Opus 5.5 19450d7cdf fix(edit): an OCR word edit can't land on the wrong word (refs #3313)
A rewrite also takes away copies of its words. With a copy earlier on the
page, the words after it moved up the list, so the next change rewrote the
word after the one it meant: deleting John removed Smith and left John.

Before each change, the words up to the next one that stays must still be
where they were. If they aren't, the edit falls back to the whole-phrase
rewrite.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 16:41:17 -05:00
Tiago KielandClaude Opus 5.5 9f5166f297 fix(edit): spaces a deleted word leaves don't redraw the OCR phrase (refs #3313)
Backspacing over a word leaves the spaces either side of it, and the rule
that sent spacing to the whole-phrase rewrite took that for spacing someone
asked for, so the most ordinary deletion redrew the whole line again.

Spaces beside a change are nothing to draw: the words around it stay where
the scan has them, with the gap already between them. Only what has to be
drawn goes to the whole rewrite: spacing inside the new words, between two
words nothing else changed, or any whitespace other than spaces.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 16:10:47 -05:00
Tiago KielandClaude Opus 5.5 a6229de16d fix(edit): review follow-ups to keeping OCR words (refs #3313)
- A draft with the same words (a space typed after the last) changes
  nothing and is no undo step. It used to redraw the whole phrase.
- Rewriting words alone is refused when it would move any other text on
  the page, visible text too, not only other OCR words.
- A cover stops at the words either side that stay: the padding of a
  large word could reach over the ink of a small one beside it.
- Spacing other than one space between words goes to the whole-phrase
  rewrite, which keeps it, instead of being dropped.
- A squeeze is relative to the scale the words already have.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 15:43:19 -05:00