Commit Graph
6348 Commits
Author SHA1 Message Date
Grzegorz MartensandClaude Opus 5.5 69e26167e4 M2.6: a page's content is read with its /DecodeParms given by reference
`decode_with_damage` and `decode_contents_with_damage` read a stream's
`/DecodeParms` only when direct, as `Stream::decoded` does, so content behind
a predictor whose parameters, or a number in them, are an indirect object
decoded with the predictor's tag bytes left in, and was taken as whole. Edit
then listed and wrote back the wrong bytes, and pruning dropped an image such
a form draws. ISO 32000-2 lets those values be indirect.

- `decode_with_damage` takes the document and reads the parameters through
  it, and so does `decode_contents_with_damage`, and `decode_contents` with
  it: printing, accessibility's reading of a page and a page copied as a form
  read them too. Code that calls `decode` on a stream itself doesn't yet.
- It reads through `Document::decoding_view`: `with_direct_parms`, but a copy
  of the stream holds only its `/Filter` and the parameters, its data shared,
  so a stream a page's `/Contents` lists again and again isn't copied whole
  for each.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AmsdeUCdTaD72jkDw2pJKY
2026-11-07 12:37:35 +01:00
Grzegorz MartensandClaude Opus 5.5 3fec35e1ea M2.6: tests pin that content which doesn't decode is kept and edited around
A stream that doesn't decode at all is not damage to write over: edit and
accessibility keep it as stored and go on with the page's other streams,
and only running past the page's decode allowance refuses. Nothing pinned
either, nor that selecting objects reads a stream of a few MB.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AmsdeUCdTaD72jkDw2pJKY
2026-11-07 12:37:35 +01:00
Grzegorz MartensandClaude Opus 5.5 50d0fcc403 M2.6: pruning keeps what a page or form damaged partway may draw
Extracting, splitting and combining pages drops the `/XObject` entries no
page draws. A page or form damaged partway was read up to the damage as the
whole of it, so an image named only after the damage was dropped, though
the stream still names it and other readers may still read that far.

- `content_bytes` says whether a page's stream is damaged, and pruning keeps
  everything such a page could reach, as it does for content that doesn't
  decode. A form is read the same way.
- A page made a form XObject (stamps, watermarks, backgrounds from a PDF)
  still draws what decoded before the damage.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AmsdeUCdTaD72jkDw2pJKY
2026-11-07 12:37:35 +01:00
Grzegorz MartensandClaude Opus 5.5 480fdb114a M2.6: Optimize leaves a page damaged partway as it is stored
Optimize read a page's content up to any damage in its streams as the whole
of it. Merging a page's image strips then wrote the page's content again as
one stream, without what followed the damage, and the image pass measured
each image by its uses before the damage only, so one drawn larger past it
could be resampled below that use.

- `DecodeBudget::decode_contents_with_damage` reads a page's `/Contents` as
  `decode_contents` does, each stream also saying whether it is damaged
  partway; `decode_contents` is it without the flag.
- `content_bytes` gives `None` for a page with a damaged stream, as for one
  that doesn't decode: the content is not all known. Its strips aren't merged
  (`merge_page` already leaves such a page alone), and no image is resampled
  (`effective_resolutions` gives every image `INFINITY`).
- A form damaged partway leaves the measuring incomplete in the same way.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AmsdeUCdTaD72jkDw2pJKY
2026-11-07 12:37:35 +01:00
Grzegorz MartensandClaude Opus 5.5 712345d7a1 M2.6: an edit never rewrites a content stream from the part before its damage
A Flate stream damaged partway decodes to what came before the damage, and
`DecodeBudget::decode` gave that back as the stream's data: the decoder's
partial flag was dropped in `Stream::decoded_within_counted`. Editing a text
line, a block, an image or an added item in such a stream wrote it again from
that part, so everything after the damage was lost on save, though other
readers may still read it.

- `DecodeBudget::decode_with_damage` decodes as `decode_within` does and says
  whether the stream is damaged partway. A missing checksum or end-of-data
  marker is no damage, as before.
- Edit reads the page's streams with it (`ContentStream`), and
  `rewritten_contents` refuses, before adding anything, a change to a damaged
  stream. Changes in the page's other streams go on, and the damaged one stays
  as stored.
- Selecting objects (`editable_objects`, moving added items) refuses a page
  with a damaged stream, as it refuses one that doesn't decode: what follows
  the damage could change every later item's graphics state.
- Marking a tag as an artifact or a figure as decorative refuses when the
  tag's content is in a damaged stream (`ArtifactError::Damaged`,
  `AltError::Damaged`), and changes nothing, the structure tree included.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AmsdeUCdTaD72jkDw2pJKY
2026-11-07 12:37:35 +01:00
xullul 4b2a151012 M7: count each grouped placement once across preparation passes
Change:
- Read and count only the placements a preparation pass newly inlines. The
  others were read on an earlier pass in the context they still have, so a
  group refused where it is drawn (translucent, for example) is no longer
  counted again on every pass: 33 such placements beside one text group used
  to reach the 64-placement limit on the second pass and prepare nothing. A
  form refused in one place is still read where an expanded parent draws it
  anew. If the page doesn't parse back to the operators written, every
  placement is read again, as before.
- Read a group refused because its resources needed renaming again, without
  counting it, once names merged in for other groups make the renaming
  unnecessary (checked from its resource dictionaries alone, without decoding
  its content), and drop its earlier refusal when it is then prepared.

Validation: edit 470 and the 2 automation text_prepare tests passed;
formatting, strict Clippy for pdfcraft-edit, layers and assets passed. The
wasm check was not run locally (the wasm32 target is not installed), nor were
the engine suite and the workspace sweep. Each new regression failed with its
fix disabled.
2026-11-07 18:34:05 +07:00
mtlcl410andClaude Opus 5.5 ea2e0a0e10 test(fonts): the u glyph-name form reads with four, five and six digits (hayro-interpret patch 92)
The test of the glyph list's hex forms now has well-formed `u` names too,
so a change that broke that branch of `glyph_text` would fail it. The rule
itself is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Pq7HyCHD1R3rywQBPCHXZA
2026-11-07 19:17:57 +08:00
mtlcl410andClaude Opus 5.5 121bf5ecce test(render): a JPEG 2000 picture that doesn't decode is decoded once at each size it is drawn at (hayro-interpret patch 91)
The failure is kept per key, and a JPX decode's key includes the size it
decodes for, so the same failed picture drawn at two sizes is decoded once
at each. The test fails if the cache key leaves the target out.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Pq7HyCHD1R3rywQBPCHXZA
2026-11-07 19:16:16 +08:00
mtlcl410andClaude Opus 5.5 09669f6c31 M1: renumber the numbered glyph name patch to hayro-interpret (100) (create.text-extraction)
Patch 99 is taken by #6542.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Pq7HyCHD1R3rywQBPCHXZA
2026-11-07 19:16:03 +08:00
mtlcl410andClaude Opus 5.5 cd9b6b8a0f fix(render): only Symbol's style variants are Symbol, and SymbolMT keeps its differences and embedded program (hayro-interpret patch 98)
- is_symbol_name: after `,` or `-` only a style name (SYMBOL_STYLES) keeps
  the Symbol font, so `Symbol-Helvetica` keeps its declared encoding and
  Latin stand-in.
- Tests: the negative names draw the same letters as Helvetica; a SymbolMT
  with /Differences [109 /alpha] draws alpha; an embedded SymbolMT draws
  its own program.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Pq7HyCHD1R3rywQBPCHXZA
2026-11-07 19:01:05 +08:00
mtlcl410andClaude Opus 5.5 22d211fa4a fix(render): the CFF subfonts read once are kept, and a program with no usable font dict renders as if absent (hayro-interpret patch 93)
- CffFontBlob::new moves the subfonts it validated into the yoke instead
  of reading every font dict a second time.
- a_program_with_no_usable_font_dict_draws_no_square now checks that the
  page renders exactly as it does with no embedded program; the old
  inequality passed with the empty-dict check removed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Pq7HyCHD1R3rywQBPCHXZA
2026-11-07 18:55:11 +08:00
vangel76andClaude Sonnet 5.5 81af7f1cd9 Merge upstream/main into feat/redact-mark-regex
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-07 11:54:30 +01:00
vangel76andClaude Sonnet 5.5 8fabc86f3a Merge upstream/main into perf/write-full-retain-parsed-objects
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-07 11:52:43 +01:00
mtlcl410andClaude Opus 5.5 3a3fe00f69 M2: without codespace ranges, a bfchar CID mapping matches only codes of its own source length (view.render-cid-fonts)
hayro-cmap patch 4: text CMaps record each bf entry's source length
(BfRange::code_len). Where no codespace range gives a code its length,
the bfchar fallback of lookup_cid_code takes the entry's own length, so
the first byte of <fe96> is no longer taken for <00fe>. CMaps with
codespace ranges are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Pq7HyCHD1R3rywQBPCHXZA
2026-11-07 18:50:32 +08:00
mtlcl410andClaude Opus 5.5 2c1b903075 M2: a page whose /MediaBox has no area is US Letter and shows its content (view.render-pages)
- hayro-syntax patch 44: a /MediaBox without area counts as missing, so
  the page is sized, placed and clipped by the same Letter region and its
  content is drawn (MuPDF and PDFium both draw it on 612 x 792).
- pdfcraft-model: Page::crop falls back to Letter for such a box too.
- vendor/README.md: the raw-crop summary names the Letter fallback.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Pq7HyCHD1R3rywQBPCHXZA
2026-11-07 18:44:18 +08:00
mtlcl410andClaude Opus 5.5 6ef85c7536 fix(render): a patch mesh painted through a path its own size draws every patch (hayro-interpret patch 99)
The mesh sampler walked each triangle's whole bounding box. A patch is cut
into a fixed 19 x 19 grid, so across a narrow curved band the triangles are
thin and lie at every angle, with boxes many times their area. Painted through
a path the size of the mesh's own box (a pattern fill of a polygon, or `sh`
under a clip), the visit budget (eight per pixel of the area, four per
triangle) ran out before the last patches, and a rainbow of type 7 patches
lost its inner bands (PDFBOX-1915 asy-tensor-rainbow).

Each row of a triangle is now walked only across the columns where that row's
sample points can lie in it; a box at most two columns wide is walked whole,
and a row with no column still costs a visit. The budget is unchanged.
ISO 32000-2 8.7.4.5.8, 8.7.4.2.

Test: raster::tests::thin_patches_of_a_mesh_in_a_tight_path_are_all_painted
(fails on main: the inner band is white).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Pq7HyCHD1R3rywQBPCHXZA
2026-11-07 18:40:06 +08:00
vangel76andClaude Sonnet 5.5 e09f87ad55 Merge upstream/main into contributors-vangel76
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-07 11:36:39 +01:00
mtlcl410andClaude Opus 5.5 f1bd39e578 M3: a stacked, raised or squeezed combining mark stays with its letter (view.copy-text, view.find)
A second mark stacked on a letter now rides on the letter as well as on the
mark before it; a mark drawn up to an em above or below its letter stays on
the letter's line, and the glyph after it continues from the letter; marks in
a zero-width run are ordered by their letter; and a word gap after a mark is
measured from the letter's advance, not the mark's offset start.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Pq7HyCHD1R3rywQBPCHXZA
2026-11-07 18:32:56 +08:00
mtlcl410andClaude Opus 5.5 63a6f8ace6 M10: glyph names in a symbolic TrueType font's post table read as text only in the glyph list's uni and u forms (#3962)
The glyph list specification (ISO 32000-2 §9.10.2) writes the hex digits
of its `uniXXXX` and `uXXXX`-`uXXXXXX` forms in uppercase, `uni` taking
groups of exactly four and `u` four to six, outside the surrogate range.
`glyph_name_text` (hayro-interpret patch 79) took lowercase digits too, so
a glyph named `uni1eae` read as U+1EAE; it now names nothing and the code
reads as WinAnsi, as for any glyph without a name. The editor's reading of
the same `post` names in pdfcraft-fonts applies the same rule, so both
agree.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Pq7HyCHD1R3rywQBPCHXZA
2026-11-07 18:11:55 +08:00
mtlcl410andClaude Opus 5.5 9b3991990d fix(render): a Type 3 font without /Widths is reported as a render warning (hayro-interpret patch 90)
The fallback to the glyph procedures' d0/d1 widths keeps such a page
readable, but ISO 32000-2 Table 110 requires /Widths in a Type 3 font,
so the reader should also be told the font is malformed. Selecting a
Type 3 font without /Widths (or /FirstChar, /LastChar) now reports
InterpreterWarning::Type3WidthsMissing, surfaced once per page as
RenderWarning::Type3WidthsMissing: `pdfcraft-cli render` prints it and the
automation render tools list it with the page's other warnings.

Test: raster::tests::type3_proc_widths::a_type3_font_without_widths_is_reported
(fails with the report switched off).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Pq7HyCHD1R3rywQBPCHXZA
2026-11-07 18:10:35 +08:00
xullul a453112151 M7: read each grouped form once and check PUA alternate meanings
Change:
- Leave a form found to be artwork, or refused for a reason in the form
  itself, out of later preparation passes, so a page with many logos or
  unsupported groups no longer reaches the 64-placement limit and prepares
  nothing. ungroup_ops now marks each refusal as intrinsic or contextual;
  contextual ones (translucency, the resources it would merge into, pattern
  placement, the decode budget) are re-evaluated where the form appears, so
  a form refused in one place is still prepared where a parent draws it.
- Refuse a page-level Do with an operand too many for that placement only:
  the form found by its first operand may not be the one drawn. Check a
  form's own operand counts before the nested walk, as an intrinsic refusal.
- Use the Windows PUA alternates only when every kept alternate whose code
  the PDF's map names a Thai character names that alternate's base
  character, so alternates in another order that the map reveals are refused.

Chores:
- Say that the font program confirms each recovered glyph's advance class,
  not its identity, and document the alternate check.

Validation: with and without craft-fonts, fonts 105 (+3 build-input), edit
468, engine 482 (+28 integration) and automation 50 + 352 passed; editor flows
248 passed. Formatting, strict Clippy, layers, assets and parity passed; the
wasm check was not run locally. Each new regression failed with its fix
reverted. Real-PDF edits on Royal Gazette 26288 kept their source fonts.
2026-11-07 17:00:48 +07:00
mtlcl410 9dfd49cc94 Merge remote-tracking branch 'upstream/main' into HEAD 2026-11-07 18:00:33 +08:00
mtlcl410andClaude Opus 5.5 f75451380c M1: numbered Type 3 glyph names above 126 read as their codes too (create.text-extraction)
A Type 3 font already reads codes 32-126 by the code when its glyph names
say nothing. Above 126 a name that only numbers its glyph (`C174` at 174,
`GE9` at 0xE9) now reads as the code's Latin-1 character, under the same
font-level guard as a Type 1 font: every numbered name in the encoding
names its own code, so `/C1` at 233 turns the font back to nothing.

Test: text::tests::numbered_type3_glyph_names_read_as_their_own_code
(fails with the fallback switched off, and with the guard switched off).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Pq7HyCHD1R3rywQBPCHXZA
2026-11-07 17:50:16 +08:00
mtlcl410andClaude Opus 5.5 218fbcf1b5 M1: numbered glyph names read as their codes only in fonts where every one does (create.text-extraction)
The previous commit read a glyph name that only numbers its glyph (`C70`,
`MT72`, `G4E`) as its code's Latin-1 character whenever the number, in
decimal or hexadecimal, was that code. In fonts whose names number
something else (`/Differences [1 /C70 /C105 ...]`, a subset's order), a
name can match its code by coincidence: `/MT40` at 0x40 read `@` where the
page draws `(` (PDFBOX-1078), `/C39` at 0x39 read `9` (PDFBOX-1783).

The rule now applies only in a Type 1 font where every numbered name in
its encoding names its own code (`numbered_names_name_their_codes`,
worked out once per font). `/C1` at 233 beside `/C70` at 70, the review
counterexample on #3239, turns the whole font back to nothing, and
#3239's test font (`c251` at 97, `C1` at 233 beside `C39` at 39) reads
exactly as #3239 expected again. Codes 128-255 read as Latin-1
(`C174` = `®`), as pdftotext, PDFium, MuPDF and Acrobat read them.

Vendor ledger: hayro-interpret patch 99.

Test: text::tests::numbered_glyph_names_read_as_their_own_code (fails
with the guard switched off, and with the fallback switched off).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Pq7HyCHD1R3rywQBPCHXZA
2026-11-07 17:36:40 +08:00
mtlcl410andClaude Opus 5.5 cdb94e6611 M2: a page without a /MediaBox is US Letter (view.render-pages)
A page with no /MediaBox, its own or inherited, rendered as A4, while
PdfCraft's page model and inspector already sized it as US Letter and
other readers draw it at 612 x 792 pt (PDFBOX-4001-reduced.pdf).
ISO 32000-2 §7.7.3.3 Table 31 requires the box and gives no default;
follow the readers. `base_dimensions`' fallback for a visible region
without area uses the same Letter size, so a /MediaBox [0 0 0 0] page
is Letter too. Vendored hayro-syntax patch 44. The model test pins the
size it already gave.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Pq7HyCHD1R3rywQBPCHXZA
2026-11-07 17:17:26 +08:00
mtlcl410andClaude Opus 5.5 c420a0edf8 M2: a non-embedded SymbolMT draws Symbol's glyphs, whatever encoding it declares (hayro-interpret patch 98)
A non-embedded TrueType `SymbolMT` (Symbol's TrueType name) with
/WinAnsiEncoding and the nonsymbolic flag was not recognised as the
standard Symbol font and fell back to Helvetica, so code 0x6D drew "m"
where PDFium, MuPDF and Poppler draw "mu". `SymbolMT`, and `Symbol` or
`SymbolMT` with a `,`/`-` style suffix, now select Symbol, which draws
through its built-in encoding like `/Symbol` already does.

ISO 32000-2 §9.6.2.2, §9.6.5.1. PDFBOX-5844 (13069708-exportByExcel.pdf).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Pq7HyCHD1R3rywQBPCHXZA
2026-11-07 17:11:10 +08:00
mtlcl410andClaude Opus 5.5 8da439e320 M2: a font without a /Subtype is drawn by its /BaseFont (view.render-pages)
A font dictionary whose /Subtype is missing or the empty name
(`/Subtype /`) was refused, and its text drew in the Helvetica
fallback: a `/Courier-Bold` lost its fixed pitch and its columns
shifted (PDFBOX-1988 Test1.pdf). /Subtype is required (ISO 32000-2
§9.6.2.1, Table 109), but other readers read such a font as Type 1 by
its /BaseFont, and so does this. Any other unknown subtype is still
refused. Vendored hayro-interpret patch 94.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Pq7HyCHD1R3rywQBPCHXZA
2026-11-07 17:09:18 +08:00
mtlcl410andClaude Opus 5.5 5307510f66 M3: copied and found text keeps each combining mark after its letter (view.copy-text, view.find)
Text drawn one glyph per show operation, with zero-advance Thai tone marks
starting a hair past their base's advance, came out with the mark after the
next letter ("ห้อง" read "หอ้ง") because a line's glyphs were sorted by x
alone. A combining mark (Mn/Me) of a left-to-right script drawn right after
the glyph it sits over now rides on that glyph: placement sorts clusters, so
the mark keeps its content-stream place. Word gaps are measured between
clusters, and the tight-cluster rule now guards only loose combining signs,
so a Thai or Indic word gap with no space glyph reads as a space.

Fixes #6517

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Pq7HyCHD1R3rywQBPCHXZA
2026-11-07 17:08:09 +08:00
mtlcl410andClaude Opus 5.5 ef37d634b2 M2: a CID-keyed CFF font with an emptied font dict still draws its other glyphs (hayro-interpret patch 93)
A CID CFF program whose subsetter emptied the font dicts no kept glyph
uses (no Private DICT) dropped the whole font: CffFontBlob collected its
subfonts with `collect::<Option<Vec<_>>>()?`. The subfonts are now kept
as `Option`s; a glyph whose font dict can't be read is missing, the rest
draw. The program is still refused when no font dict is usable.

ISO 32000-2 §9.7.4.2, §9.9 Table 124; Adobe TN #5176 (FDArray, FDSelect,
Private DICT). PDFBOX-5843 (13069603-123.pdf) now matches PDFium, MuPDF
and Poppler.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Pq7HyCHD1R3rywQBPCHXZA
2026-11-07 17:05:57 +08:00
Josias Eli Rodriguez 6e0d0fde3f redact: treat unusable /QuadPoints as absent in every reader
A quad counts only when all 8 entries are present, numeric and finite.
Anything else contributes nothing — never folded, shifted or zero-filled
into a box the document does not describe. With no usable quad the
existing /Rect fallback runs, and with neither the mark stays unreadable.

The rule lives in one helper, geom::quad_points::usable_quads, and redact,
render-inspect, annot summaries and annot appearance drawing all read
through it, so the outline shown is the area apply removes. Redact also
follows indirect numbers in /QuadPoints now, which it used to drop.
2026-11-07 03:04:51 -06:00
mtlcl410andClaude Opus 5.5 37e5708ed2 M2: a CMap's bfchar mappings read codes at their codespace length (view.render-cid-fonts)
A CMap that writes its CID mappings as `bfchar` was looked up without
the code's byte length, so the first byte of a two-byte code matched a
two-byte entry of the same value and drew as its own glyph: `<fe96>`
drew as "þ–" (PDFBOX-1282, Characters_Arial.pdf page 3). The bfchar
fallback of `lookup_cid_code` now applies only when the codespace
ranges give the code the length being tried (ISO 32000-2 §9.7.6.2),
byte by byte; a CMap without codespace ranges keeps the old fallback.
An unmapped code still advances one byte. Vendored hayro-cmap patch 4.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Pq7HyCHD1R3rywQBPCHXZA
2026-11-07 17:03:56 +08:00
xullul 7634ac8064 M7: address review of grouped Thai text preparation
Add:
- Report text grouped more than eight levels deep instead of leaving it
  silently grouped, and refuse forms whose resource-naming operators carry
  surplus operands, which would otherwise lose nested artwork when inlined.
- Return the applied preparation's own counts from Session::prepare_text, so
  text_prepare no longer reports a separate preview's.
- Shape a THSarabunPSK program that has its own Thai mark positioning by that
  layout, in its own codes. A span the subsets can't show in place is shaped
  whole, Latin rows included, by a complete program of the same face and style,
  such as a CFF face from Load font.

Change:
- Expand only forms that show text, directly or through nested forms; image-
  and vector-only forms stay grouped and uncounted. Match a Do's raw resource
  name bytes, and refuse RGB-blended groups on pages naming no blending space.
- Check the recovered THSarabunPSK map and the Windows PUA alternates glyph by
  glyph against the subset's advances, leave dropped glyphs unmapped, and
  insert the repair after the last endcmap.
- Shape a Thai run split across same-face subsets cluster by cluster and skip
  subset glyphs that are empty. Take the legacy path only for programs in the
  legacy glyph order, needing only the glyphs the new text uses.
- Require GPOS mark/mkmk in the script and language system HarfRust selects.
- Match same-face candidates by weight and slant from the name, descriptor
  weight or a non-zero ItalicAngle; the Italic flag alone is ignored, as
  exporters set it on upright faces. Never complete bold or italic text with
  the Regular bundled Thai face.
- Name the missing character, or the unavailable builtin:thai choice, in errors.

Chores:
- Document text_prepare's fields, builtin:thai, the app's refusal reporting
  limits and the new routing; extend the text-edit parity evidence. Tests that
  need craft-fonts now say they skipped instead of returning silently.

Validation: with and without craft-fonts, fonts 105 (+3 build-input), edit
465, engine 482 (+28 integration) and automation 50 + 352 passed; editor flows
248 passed. Formatting, strict Clippy, layers, assets and parity passed; the
wasm check was not run locally. Each new regression failed with its fix
reverted. Real-PDF edits on Royal Gazette 26288 kept their source fonts.
2026-11-07 15:59:38 +07:00
Combiler01 12ad3e67f6 fix(print): reset unoverridden custom paper to standard preset on printer change 2026-11-07 14:01:48 +05:30
mtlcl410andClaude Opus 5.5 4a213e06b3 M3: glyph names read as text only in the glyph list specification's uni and u forms
`uni` takes groups of exactly four uppercase hex digits and `u` four to six,
outside the surrogate range, so `uni65`, `u65`, `uni20ac` and `uni+065` read
as nothing instead of `e` and the euro sign. hayro-interpret patch 92 reads a
glyph's text by `agl_unicode_from_name` and keeps upstream's lenient reading
for finding glyphs in a font, so drawing is unchanged; pdfcraft-fonts'
`glyph_text` stops accepting lowercase digits.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Pq7HyDBXygTf7jcqdsjcfn
2026-11-07 15:39:37 +08:00
Helen Kwok a9ccca5b71 pdfcraft-web: say ui.open answers with an error on the web 2026-11-07 15:30:00 +08:00
mtlcl410andClaude Opus 5.5 558ffd7f8a perf(render): a picture that doesn't decode is decoded once, not at every draw (hayro-interpret patch 91)
The decoded-image cache stored a failed decode as an empty entry and read
an empty entry as a miss, so a picture or stencil mask that doesn't decode
(damaged data, a JPX or JBIG2 stream its decoder refuses) was decoded again
at every draw, and at every tile, preview and zoom of a render worker that
shares the cache.

The cache now keeps a failure for its key, with the warnings the decode
reported; a later draw reports the same warnings and gets nothing, as the
decode did. A failure counts 128 bytes towards the cache's 64 MiB budget.
A failure the page's JBIG2 allowance may have caused (ContentTruncated, or
the allowance spent) isn't kept, since the next page starts afresh.
Successful decodes are cached as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Pq7HyDBXygTf7jcqdsjcfn
2026-11-07 15:22:28 +08:00
Zhihui Song 014b67915b M10: adopt file-backed loading and record review fixes in the progress log 2026-11-07 15:07:16 +08:00
Zhihui Song 596f8169e3 M10: use approved printing dependencies and retain the Direct2D crash fix 2026-11-07 14:49:08 +08:00
mtlcl410andClaude Opus 5.5 30164b6973 M2: the soft-mask tests count image and mask decodes apart and check a truncated mask's size
decoded_images_serve_every_size_they_are_drawn_at asserts image and mask
decodes separately, through a new InterpreterCache::decoded_mask_decodes
(hayro-interpret patch 82), so a wrong split behind the same total fails.
The truncated-stream case of
an_averaged_down_soft_mask_follows_its_samples_and_its_drawn_size asserts
the exact mask handed over: 32 x 10 (the decoded rows), all opaque.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Pq7HyDBXygTf7jcqdsjcfn
2026-11-07 14:45:30 +08:00
mtlcl410 327fddec5b Merge remote-tracking branch 'upstream/main' into fix/render-shared-soft-mask-cache 2026-11-07 14:38:22 +08:00
Zhihui Song d20f563ad7 M10: preserve existing LF endings in dependency update 2026-11-07 14:17:01 +08:00
Zhihui Song b56cb0ca9e M10: avoid Windows StorageFile access denial when printing 2026-11-07 14:15:26 +08:00
Combiler01 0a65e0f44c fix(print): reset previous printer papers to standard presets on printer change 2026-11-07 11:41:33 +05:30
mtlcl410andClaude Opus 5.5 6a238f9fd7 M5: finding a referenced object too large to copy is charged to the budgets (view.render-annotation-appearances)
A referenced object rejected as over the per-annotation budget was walked
up to that budget and charged nothing, so many annotations (or many
references in one annotation) pointing at the same oversized nested array
each walked it again, and PASS_BUDGET did not bound the work. The walk is
now charged to the annotation's budget and through it to the pass, and a
spent budget follows no further references.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Pq7HyDBXygTf7jcqdsjcfn
2026-11-07 14:01:34 +08:00
Combiler01 f1e2c49d55 fix(print): apply cached papers immediately, refresh in background, and document functions 2026-11-07 11:20:24 +05:30
xullul c7e8d127af M7: edit grouped Thai text while preserving source formatting
Add:
- Prepare supported Form placements as original page operators through the
  existing-text UI and text_prepare, with shared-form isolation and undo/redo.
- Repair narrowly identified Thai exporter maps on copied page fonts, recording
  repairs without changing the embedded source glyph programs.

Change:
- Reuse legacy Thai Regular/Bold glyph codes and same-face punctuation subsets;
  retain point size, spacing, horizontal scale, rise, colour and paint settings.
- Keep cross-family Thai replacement explicit and write matching bundled Thai
  subsets through the existing bounded outline path rather than static embedding.
- Keep replacement-only menu choices out of the source-font preview atlas so
  opening an ordinary paragraph does not wait an extra frame for unused fonts.
- Refuse unsafe compositing, tagged or malformed groups, and missing contextual
  glyphs without losing the user's document or changing other placements.

Chores:
- Document the editing limits and headless workflow; keep text-edit parity partial.

Builds on dekkeng's Thai fallback work in #2811 (fba0a29a) and mtlcl410's Form
Ungroup implementation in #3067 (6eafca9c), adapted to the current module layout.
The Ungroup menu and older UI font-priority changes are not included.

Refs #3185, #2964 and #2142. Synthetic regressions cover source-font preservation,
shared forms, unsafe refusals, layout, undo/redo, rendering and save/reopen.

Validation: library suites 1,675 passed; automation integration 331 passed;
document-font integration 2 passed; editor flows 248 passed. Existing ignored
tests remain. Formatting, scoped strict Clippy, layers, assets, parity and wasm
checks passed. The unchanged opacity regression failed before the choice-only
atlas correction and passed afterwards.
2026-11-07 12:27:29 +07:00
xullul 77cebccda2 M7: adapt embedded Thai source fonts without replacing their programs
Add:
- Recover editor-only Unicode cmaps for Identity-H TrueType subsets and shape
  verified THSarabunPSK positional glyphs into their original PDF character codes.
- Recognize narrowly fingerprinted damaged Thai exporter maps without guessing
  mappings for unrelated fonts; callers must record and isolate any repairs.

Change:
- Preserve the original PDF font programs and refuse missing contextual glyphs.
- Allow modern Thai GPOS positioning without requiring optional GSUB, adapting
  that correction from dekkeng's PR #2811 at fba0a29a.

Refs #3185 and #2142. Font/edit tests: 535 passed. Formatting, scoped strict
Clippy, layers, assets, parity and the fonts/edit wasm check passed.
2026-11-07 12:26:35 +07:00
Combiler01 25b6280ac6 fix(print): read papers in background, restore properties handler, and pass dialog owner 2026-11-07 10:30:49 +05:30
mtlcl410andClaude Opus 5.5 5c2f4b8383 M2: the oversized-/Rows fax test also checks white rows after the first (hayro-syntax patch 41)
Through /Indexed, samples past the decoded data read as black, so an
all-black image could not tell a decoder that stopped after one row
from one that decoded all four. A second Group 4 image striped black,
white, black, white (horizontal-mode rows, ITU-T T.6 §2.2.3.3) is now
rendered through both colour spaces with every /Rows value, and each
row is checked for its own colour.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Pq7HyDBXygTf7jcqdsjcfn
2026-11-07 12:54:37 +08:00
mtlcl410andClaude Opus 5.5 b5e3de67fb M5: properties and edits read referenced colours as drawn; following references is bounded per display pass (view.render-annotation-appearances)
props() reads the whole annotation with references followed, so an
indirect /C or /IC (ISO 32000-2 7.3.10) shows its colour, and
"restylable" and the set_style / set_fill / set_part_opacity checks use
the same build and fallback as the display (draw::can_draw), so such a
comment can be restyled.

Following references now counts every value copied, inner arrays and
dictionaries included, and one display pass copies at most 4M values in
all, so an object many annotations point at is not copied for each of
them without bound. A cached appearance keeps what storing it needs
(the undrawable character and a note's /Rect), so a cache hit follows
no references at all.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Pq7HyDBXygTf7jcqdsjcfn
2026-11-07 12:51:22 +08:00