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.
* 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>
* 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
`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
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
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
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
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
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
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
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>
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>
- 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>