On a page turned 90 or 270 degrees the stamp's rectangle has its sides
swapped in user space, and the appearance is counter-rotated so viewers fit
its turned bounding box to /Rect (ISO 32000-2 12.5.5). The lined layout was
computed in user-space axes, so that fit scaled the two displayed axes
differently: the picture came out squashed and the band stretched.
The layout is now made in the displayed box (the rectangle with its sides
swapped) and the stamp records the page's turn in /PCPictureRotate, so the
appearance carries the counter-rotation itself and a later restyle rebuilds
it the same way.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Pq7HyCfwzyRXj4VfQAVVdv
Review on #2345 (gabglus): the line was filled by chained replaces, so a
placeholder inside the author's name ("Ada {date}") was filled in too.
stamp_line now walks the template once and expands only the {name},
{date} and {time} it finds there; the author's text is kept as written.
Trimming and the MAX_STAMP_LINE cut are unchanged. The loop advances by
whole characters (strip_prefix, or get() past the next char), so it
cannot panic.
stamp_lines_fill_in_the_name_date_and_time gains the review's case and
a name made only of a placeholder; both fail with the chained replaces.
The UI test checks the saved /PCByLine has no placeholder left (from
gabglus's commit f6760b37).
Co-Authored-By: gabglus <gabglus@hotmail.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Catalan, Sorani, Finnish, Hindi, Indonesian, Korean, Lao, Norwegian Bokmål, Romanian, Albanian and Thai joined main after this branch was written. AI-assisted, as noted in each catalogue.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Create Custom Stamp offers an optional line under the picture, a
template with {name}, {date} and {time} filled in when the stamp is
placed, in the built-in dynamic stamps' format, and kept with the stamp
library. The picture keeps its shape above the line and the stamp widens
to fit the line. stamp_custom takes the same line.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
An Undo of Apply redactions while the dialog that proposed the _Redacted
name was open saved the unredacted content under that name. Save now asks
again whenever an Apply redactions or an Undo of one changes what the
dialog's proposed name was based on.
The Save dialog proposes its name when it opens, and the document's bytes
are taken once the user chooses. An Undo past a saved Apply redactions in
between wrote the restored content to the redacted copy the dialog had
proposed. Save now asks again, proposing the name for the restored content.
After Undo past a saved Apply redactions, Save asks where but proposed the
redacted copy's own name, so the dialog's default was the redacted file.
It now proposes the name without _Redacted.
In the web build Save kept sending Save As to the host after the redacted
file was delivered, because the delivered steps stay counted for the
_Redacted name. Save now asks where only for steps applied since the last
delivery.
In the web build a delivered save keeps Apply redactions steps counted, so
Undo of a delivered step left Save writing to the host in place. Save now
asks where while fewer steps are in effect than were delivered, and a new
Apply after such an Undo marks the delivered steps as cut off.
A link annotation listed twice in one page's /Annots, or by two pages, kept its later references after the first one stripped its external action, leaving inert links on the page. Every reference to a link that ends up with no action and no /Dest is now removed. A shared link counts once in external_links.
Each JBIG2 bitmap is bounded, but nothing bounded how many a stream asks for, so a few hundred
bytes could tie up a render worker for minutes, and CodeRabbit raised the same on #5461. Measured
through pdfcraft-cli, before and after:
- one halftone segment, a 795-byte PDF: 265 s, now refused at once;
- 66 halftones over patterns 1 wide, a 3,894-byte PDF: about 330 s, now refused at once;
- about 226,000 generic regions behind nested Flate, a 923-byte PDF: unfinished at 40 s, some
88 hours by extrapolation, now 4.8 s;
- 8 dictionaries of symbols of no width, a 983-byte PDF: 81 s, now 0.7 s;
- about 1,048,000 generic regions of no width, a 34 KB PDF: unfinished at 90 s, now 2.6 s;
- an aggregated dictionary over 2^20 symbols, a 713-byte PDF: unfinished at 90 s, now 9.1 s;
- 10,000 instances of an 8192 × 8192 symbol, an 18 KB PDF: 64 s, now 3.2 s;
- 30 generic regions of no data: 48 s, now 4.7 s.
A stream may now ask for 2^30 units of work: four of the largest pages, about 6 s on data the
decoder predicts and about 17 s on data it can't, inside the viewer's 20 s watchdog. Decoding a
bitmap costs a unit a pixel and 4 a row, since a row costs time at any width. Copying one costs a
unit a word and 1 a row, so a tall thin bitmap costs its rows. Each item is charged before it is
decoded, apart from what is known only as it goes: new symbols and text instances are charged in
their loops. An aggregated symbol is charged for the symbol table it rebuilds. Past the bound the
image isn't drawn, as with the other caps, and the rest of the page is.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AmsdeUCdTaD72jkDw2pJKY
Review follow-up on #4358: the secondary-click path still selected with cx.hit, which misses a group subordinate lying outside its primary's rectangle and cleared the selection, so the menu offered page actions instead of the comment's. It now uses the group-aware cx.click_hit, as the click does (ISO 32000-2 §12.5.6.2). Double-click editing goes through the same group-aware hit as the click since the rebase onto main, where the press owner comes from the module's hit test; the test covers both.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Pq7HyCfwzyRXj4VfQAVVdv
An ordinary scan stored as JBIG2 was decoded for Group 4 by default, at 0.26 s a page at 300 ppi,
and came out unchanged: Group 4 of a symbol-coded page was 201,132 bytes against 17,291. Over a
500-page scan that is minutes for nothing. Dropping the guard changed no output, as a cost guard
wouldn't, so its test counts the pixels decoded.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AmsdeUCdTaD72jkDw2pJKY
Review on #4358:
- Make Current Properties Default on a Replace Text group selected the
caret, the group's primary, and updated the Insert Text tool. A caret whose
group holds a grouped /IT /StrikeOutTextEdit strikeout now updates the
Replace Text tool; a caret of its own still updates Insert Text.
Test: a_replace_text_group_makes_replace_text_defaults.
- fill_group_text let an empty caret take the primary's slot, so a later caret
with the replacement text was not listed. Only a caret with text lends it.
Test: an_empty_caret_does_not_hide_the_next_carets_text.
Both tests fail with their fix reverted.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Pq7HyCfwzyRXj4VfQAVVdv
A single squashed port of the branch's four commits onto current main, which
split annot's lib.rs (info.rs, modify.rs), render's inspect.rs (model.rs,
annotations.rs, tests.rs), engine's lib.rs (comments.rs, edit/run.rs) and
ui-egui's comments.rs (tools/comments/*). The behaviour and tests are the
branch's (ISO 32000-2 §12.5.6.2):
- a group subordinate is part of its primary's comment: listed, selected,
exported and deleted with it, with the primary's attributes;
- Replace Text writes the caret as the primary and the strikeout as its
subordinate; earlier groups (strikeout primary, text on the caret) still
list their text, through a map;
- deleting a group refuses a locked member, and a subordinate whose primary
is past the depth limit.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Pq7HyCfwzyRXj4VfQAVVdv
Review follow-up on #4378: HiddenInterface::mode_bar skipped the bar only when both the toolbar and the menu bar were hidden. With the native macOS menu bar the bar never draws the menus, so a document setting only HideToolbar (ISO 32000-2 Table 147) left an empty 48 px bar above the page. The bar now goes when the tools are hidden and the menus are hidden or native.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Pq7HyCfwzyRXj4VfQAVVdv
Review on #5010: MAX_TEMPLATE_TEXT allowed for a UTF-16 packet growing
into UTF-8, but not for the other ways a packet's text can grow past its
bytes. Each byte that isn't valid UTF-8 becomes a three-byte replacement
character, and the packets of an array are joined by newlines, so a
document within the 64 MB packet limit could hand parse a template it
refuses. read_packets now checks the text it assembles, each packet and
its newline before they are added, and the text of a single stream,
against MAX_TEMPLATE_TEXT, and refuses past it as too large; a template
it returns always parses.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Pq7HyCfwzyRXj4VfQAVVdv
Review on #3969: for a symbolic TrueType font without an encoding, the
editor overlaid only the codes whose glyph has a name with a Unicode
value on its Standard table. A code whose glyph name has none kept
Standard's reading (0xC4 `tilde`, 0x80 nothing), while extraction falls
back to WinAnsi (vendored hayro-interpret patch (53)): `Ä`, `€`. Such a
code now reads as WinAnsi in the editor as well, so editing and
extraction show the same text.
vendor/README.md: patch (53) names the function it adds,
`EmbeddedKind::symbolic_text`, states the glyph-name rules it shares with
the editor, and lists the pdfcraft-fonts test too.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Pq7HyCfwzyRXj4VfQAVVdv
A single squashed port of the branch's five commits onto current main, which
split ui-egui's lib.rs (app.rs, app/files.rs), canvas.rs (canvas/zoom.rs,
canvas/tests.rs) and control.rs (control/host.rs), replaced the Menu button
with a menu bar and moved the rail and panels into panels/side_panels.rs. The
behaviour and tests are the branch's (ISO 32000-2 Table 147):
- HideToolbar, HideMenubar and HideWindowUI apply in the document's tab, and
F8 (view.toggle_interface) brings them back; on main the toggle is listed in
the View menu beside Full Screen and Read Mode, HideMenubar hides the menu
bar, and HideWindowUI skips the side panels;
- FitWindow measures the spread the view shows, and FitWindow and CenterWindow
wait only while the document is the window's only one;
- a reloaded document keeps its tab's hidden interface; one-page-at-a-time
layouts open at fit page;
- the two strings are in every catalog, fa.tsv (added on main since) too.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Pq7HyCfwzyRXj4VfQAVVdv
main added hayro-interpret patches 51 and 52 (bounded saved graphics
states, /W2 runs past the largest CID), so this branch's patch is now
53 in vendor/README.md; the code comments that cite it follow.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0175FWj4xFhMhSH3UpMU8DSC
CodeRabbit on #3969 (nitpick): Post::glyph_name walks a version 2.0 table's name data
from its start for each glyph, and symbolic_glyph_texts asks for up to 256, so an
untrusted font program (up to 16 MiB) could make opening a document slow. The names the
table spells out are now read once (post_custom_names) and looked up by index
(post_name), giving what Post::glyph_name gives; a test checks that for every glyph of
Inter's version 2.0 table.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
CodeRabbit on #3969: symbolic_glyph_texts read `post` straight from the font, so a
version written with its halves swapped (00 00 00 02 for 2.0, which the renderer
repairs since #2946, vendored hayro-interpret patch (49)) gave the editor no glyph
names while the renderer drew the font. The table is now read as the version it means
first. The test builds the same symbolic font with the swapped version and gets the same
text. Also removes a stray `|` main had left in hayro-interpret's test list, which split
it into a sixth cell.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review follow-up. symbolic_glyph_texts tried each offset across every cmap
subtable, while the renderer reads the records in order, each with its
offsets, and only Windows (3,0)/(3,1) and Macintosh or Unicode-platform
encoding-0 records. A font with a (3,0) and a (3,1) cmap could give the editor
another glyph, and so another name, than the page shows.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review follow-up. The renderer kept only glyph names it could look up whole,
so a variant such as `a.ss01` fell back to WinAnsi while the editor's
glyph_text dropped the suffix and read `a`. The vendored patch now reads names
by the same Adobe Glyph List rules (suffix dropped, `_` components, uniXXXX
groups, uXXXX to uXXXXXX), giving several characters for a ligature, and
checks /Differences itself now that the step sits outside the name chain.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
FrameMaker files distilled with Distiller 3 embed symbolic TrueType subsets
with no /Encoding and no /ToUnicode, whose codes are glyph positions in the
Macintosh order, 29 below ASCII; the font's own cmap maps them to the right
glyphs. Read as WinAnsi (extraction, Word export) or as Standard (the
editor), `Solid` came out as `6ROLG`.
Both readers now take the post-table name of the glyph a code selects, when
that name has a Unicode value, as MuPDF does; the editor's reverse map makes
typing set the same glyphs. Fonts flagged Nonsymbolic, fonts with a named
base encoding, and fonts the editor already treats as Symbol or ZapfDingbats
by name keep their old reading. Vendored hayro-interpret patch (46).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review on #4474: past the text budget every link still resolved and
parsed its whole /QuadPoints array before dropping the result, so many
links sharing one long array cost its length each. Now no array is read
once less than one quadrilateral's bytes is left, and an indirect array
that did not fit is remembered and skipped for later links (the budget
only shrinks). A guard on the budget being exactly zero alone would
rarely trigger, since URIs spend from the same budget.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Pq7HyCfwzyRXj4VfQAVVdv
From a review of the spellings an indexed image can take:
- The palette was read for every 1-bit indexed image, resampled or not, and twice each. Images
share a table, so 1,000 images sharing one with 16 MiB of raw data took 16 to 60 s, none of
them resampled. It is now read only for an image about to be resampled, and a table over
4 KiB is refused before it is copied or decoded, since no palette needs that.
- A colour key can hide the dark sample a tie goes to, so a thin rule of the other was lost: a
white rule on a hidden black went from 255 to the backdrop's 128. An image with a colour key
now keeps its resolution. Grey had this since #5426 and is covered too.
- `/Indexed` by reference, and a base of `[/DeviceRGB]`, are the same colour space and are read
so. `/I`, an inline abbreviation, and a real hival aren't, and such an image is left alone.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AmsdeUCdTaD72jkDw2pJKY