- View::project divides by z (or the orthographic half-height) before it
multiplies, so an on-screen corner no longer turns NaN when x times the
focal length, or the half-height times the aspect ratio, overflows.
- View::clip cuts each edge from the same end whichever triangle meets it,
so two triangles sharing an edge across the near plane get one cut point.
- Scene::draw takes each edge with vec3::span, which halves the
difference when it overflows, so a finite triangle wider than f64::MAX
keeps its face normal.
- assemble charges each file structure's meshes to the assembly ceilings
as they are decoded, so decoding stops at the structure that passes one.
Tests, each shown failing with its fix reverted:
a_shared_edge_is_cut_at_the_same_point_from_either_triangle,
an_on_screen_triangle_is_drawn_when_projecting_it_would_overflow,
a_triangle_whose_edges_overflow_is_drawn,
span_keeps_the_direction_of_a_difference_that_overflows,
decoding_stops_at_the_structure_that_passes_the_ceiling.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SqmHYx8FiWM5PcsoiErgp9
The Bookmarks panel's item menu gets Cut, Copy and Paste, and Bookmark
options gets Paste bookmarks (to the end of the outline, which is how you
paste into a document without one). The clipboard lives in the app
(`PdfCraftApp::bookmark_clipboard`), like the Organize Pages clipboard, so
it works across tabs and on the web build.
- Copy reads the subtree with `outline_tree`; a copy cut at the listing
depth says so.
- Cut copies first and deletes only if the copy succeeded: one undo step.
- Paste is one `ImportBookmarks` edit after the bookmark it was asked on,
at its level. A bookmark whose page the document lacks keeps its place
without a destination, and a notice counts them (plural forms through
`trn`).
Parity: new `organize.bookmark-clipboard` entry with what is missing
(shortcuts, system clipboard, multi-select, page-ordered insertion).
Test: cut_copy_and_paste_a_bookmark_subtree_within_and_between_documents.
Reverting copy, cut, paste, the paste's parent, the one-step undo or the
notice each fails it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SqmHYx8FiWM5PcsoiErgp9
- organize: a /FitR destination missing one of its four numbers is copied
with its page and no view, instead of failing the whole copy (the
rectangle can't be kept, and import refuses a partial one).
- organize: `visit` keeps the visited node's path in step with its stack
instead of rebuilding it per node (O(depth) per node before).
- automation: an empty title is accepted when present, so a bookmark a
file left untitled exports and imports back; a missing title is still
refused.
- automation: "no bookmark at" names the path 1-based, as it was given.
- automation: `bookmark_copy` and `bookmark_import` report `truncated`;
an exported file carries `"truncated": true` when the export left
bookmarks out, and importing it says so.
- automation: `bookmark_export` is marked destructive (it overwrites
`out`) and idempotent for MCP.
Tests: a_fit_r_missing_a_value_copies_with_its_page_and_no_view (organize),
odd_bookmarks_round_trip_and_a_cut_tree_says_so (automation). Each fix
reverted alone fails one of them; the visit change is behaviour-neutral
and covered by the existing outline tests.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SqmHYx8FiWM5PcsoiErgp9
Review of #3858 (aiongg):
- An area-shrunk image with a soft mask, a stencil's ink included,
built its full-resolution RGBA before shrinking. A 10718 x 13701
stencil at page size peaked at 1.16 GB (587 MB of RGBA). It is now
premultiplied a source row at a time as it is averaged, and the
shrink works a target row at a time, so it peaks at 1.03 GB, as the
nearest-neighbour path did. Same bytes; about 5% slower per shrink.
- An image whose f32 scale passed 1 only by rounding was smoothed
bilinearly and blurred by half a pixel at a half-pixel offset. It is
now smoothed only above 1.01.
- A shrunk /ImageMask stencil keeping its thin strokes (#4800) is now
tested.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A soft mask no larger than its area-shrunk image is sampled onto the
image's grid, and it was always sampled nearest-neighbour: a mask that
asks for /Interpolate became a hard step where main drew a ramp
(jpeskov's 64 x 64 image at 32 x 32 under a 2 x 2 mask). An interpolated
mask is now blended bilinearly onto the grid, centres aligned; one
without /Interpolate is still sampled nearest, which keeps the
colour-fringe fix.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Scanned pages looked thin and broken at screen size. An image that does not
ask for /Interpolate (most scans) was pre-shrunk with nearest-neighbour since
about one sample in ten and dropped most strokes of its text, and the nearest
sampler then read the shrunk raster again at a fractional offset.
- Shrinking (vendored hayro patch 21): non-interpolated images outside Type 3
glyphs are area-averaged (area_shrink: each device pixel the
coverage-weighted mean of the samples it covers, 16.16 fixed point whose
weights sum to exactly one, premultiplied when masked) to their snapped
device rectangle and drawn 1:1. /Interpolate governs smoothing when an image
is enlarged (ISO 32000-2 8.9.5.3); averaging adds nothing between samples
and drops none. PicScale's Box/Area filters were not usable: shrinking, they
average a window four target pixels wide.
- Enlarging (patch 28): an image of page-scan size (512+ samples on its
shorter side) is drawn bilinearly when enlarged, so a zoomed scan has no
staircase edges; icons, QR codes and pixel art keep their hard pixels.
- A snapped image whose shrink failed keeps the full transform instead of
being drawn at its source size (latent in the interpolated path too).
Measured on a 13-page 300 dpi scan at 96, 120 and 192 dpi: every rendered
sample is within 1 of the exact area average (it was up to 255 off, 17-23%
of samples by more than 1). Bilinear zoom costs nothing measurable (four
1024 px tiles at 400%: 50 ms, nearest 48 ms; bicubic was 267 ms).
Review fixes:
- a tile snaps a shrunk image's half-pixel edges where the whole page does
- a scan shrunk one way is smoothed the way it is stretched
- a smaller soft mask doesn't let transparent colour through the area shrink
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
bookmark_export returns an outline, or one bookmark's subtree, as JSON:
titles, nesting, open state, colour, bold/italic and destinations as page
plus view in PDF user space (ISO 32000-2 12.3.2.2), optionally written to
a file. bookmark_import takes it back, inline or from that file, under any
bookmark at any position or in place of the outline, as one undoable edit;
bookmark_copy does the same from another open document by page number.
A bookmark whose page the target lacks keeps its place without a
destination and is reported in `unmapped`. Every node is checked before
anything is written (title, page, colour, view type and arity, 33 levels,
100,000 bookmarks), and the error names the node.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SqmHYx8FiWM5PcsoiErgp9
Review of #5758: with the preference off, the startup request stayed
pending, so turning the preference on later in the session sent a
network request at once. The request is now consumed on the first poll
whatever the preference says, and a later change waits for the next
start.
The desktop app asks for a newer release on its first frame, and nothing
could stop it, though the README says PdfCraft works offline. A preference,
on by default so nothing changes for anyone who leaves it, keeps the app off
the network until Help ▸ Check for updates is chosen. It has its own settings
key: check_updates_at_start was an opt-in, off unless chosen, so settings
written then would turn this off unasked.
- vec3: length divides by the largest component before squaring, so
a camera 1e200 away keeps a finite near plane; unit_cross normalizes
each edge first, so edges of very different sizes keep their normal.
- render: MAX_RENDER_WORK (2^31) caps the pixel centres one render
tests, charged per triangle's clipped bounding box before scanning;
past it, RenderError::TooMuchWork.
- Bounds::centre halves each end before adding, finite for any finite
box. Bounds::of and fit_meshes use only corners of triangles render
draws. Camera::frame builds its basis from the direction, not from
points near the model, so a small model far from the origin fits.
Each new test fails with its fix reverted.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SqmHYx8FiWM5PcsoiErgp9
Review fixes from #6087:
- Picture and uncompressed blocks are charged to the parse ceiling before
they are copied. File-structure headers may overlap, so each structure's
copy counts. The ceiling test now includes the 3-byte picture.
- Schema expressions use checked multiply, add and subtract; an overflow is
Malformed rather than a wrapped loop count.
- Each face's triangles are counted from its entity sizes and charged before
it is triangulated.
- Matrix::mirrors divides each row by its largest entry before taking the
determinants, so a mirror whose determinant underflows still reverses the
winding.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SqmHYx8FiWM5PcsoiErgp9
normalize already scales by the largest component, but the face normal
was the normalized cross product of two edges, and edges near 1e160
overflow that product to infinity first, so the triangle was dropped.
unit_cross divides both edges by their largest component before the
cross product. a_huge_square_is_drawn fails with the old line (white
instead of [190,192,200]).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SqmHYx8FiWM5PcsoiErgp9
A negative w (uniform or projective) turns mapped triangles inside out
though the 3x3 block does not mirror; the flip and the normal sign now
follow the 4x4 determinant, falling back to the 3x3 block when the last
row is zero.
The tree walk read each structure's globals schema with its own full
allowance, then again for the globals. It now reads it once, charged to
the walk, and continues from there for the globals.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SqmHYx8FiWM5PcsoiErgp9
A 3D reference dictionary holds the shared stream under /3D (ISO
32000-2 §13.6.3), not /3DD; it is followed once, and the caller refuses
anything that is not a stream, so a chain or cycle of references ends.
The tool is renamed model_render, since MCP tool names here are lowercase
letters and underscores only, and to match model_add.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SqmHYx8FiWM5PcsoiErgp9