Repository navigation
Conversation
An image outside a float rendered as nothing at all. `adapter.rs`'s
`Inline::Graphic` arm advanced the cursor and pushed no item, with no
diagnostic: no box, no reserved space, no warning, and every line after it in
the wrong place. On this lane's ten fixtures against pdfLaTeX (TeX Live 2025)
that is 23 images missing and body-paragraph baselines up to **118.875 bp**
(1.65 in) from the reference. After this change the worst deviation over the
same 84 measurements is **0.010 bp**.
What it does now
* `adapter::Item::Graphic` carries what the source says — the star, the key
list, the file, the span — and nothing more, so the block cache can key it on
its bytes like every other item. The file is read and the box measured in
`typeset::Context::graphic_box`, which is where the project root is.
* The box joins the horizontal list as an ordinary box of the graphicx width,
height and depth, so the line breaker measures it, a tall image makes
`\baselineskip` give way to `\lineskip`, and the page builder sees the line
it grew. Fixture 02 pins exactly that.
* It is painted through the existing wire `Image` item, line-local, with the
same y-up-to-y-down arithmetic `floatpage::FloatBuilder::emit` uses; the
existing `place_item`/`shift_x` machinery adds the page and column offsets.
A client that does not negotiate `display-list-v2-images` still gets the
correct layout with the picture omitted, as it already did for floats.
* It goes through the compiler's parse tree, not a second raw scan, so
`\includegraphics*` and the `[llx,lly][urx,ury]` bounding-box form arrive
already parsed.
* The per-request `ImageCache` is now shared between the float path and the
running-text path, so a file used by both is read once.
`\includegraphics*` and the two-bracket form on the float route
`floats.rs`'s scanner matched the command name and read one bracket, so
`\includegraphics*{...}` and `\includegraphics[10,10][40,50]{...}` fell through
to `Piece::Other` — reported as "this material is omitted" and never drawn,
inside a float. It now reads the full graphicx shape (star, up to two optional
arguments, then the file, with `]` inside a brace group not ending an
argument) and records the two-bracket form as `viewport=<llx> <lly> <urx>
<ury>`, exactly as the compiler's own parser does, so both routes describe the
same image the same way. Fixtures 09 and 10 cover it end to end.
Crop keys
`viewport`, `trim` and `clip` were `GKey::Unsupported`, which made the
two-bracket form size the box at the picture's natural size — the geometry was
wrong, not merely uncropped. `size_box` now carries the box rectangle beside
the image's own placement, so the box is the requested rectangle and the image
rides inside it; scaling and `\Grot@box`'s rotation act on both. Without
`clip`, graphicx draws the whole picture and lets it overflow, which is exactly
what an affine transform with no clip path already produces, so the unstarred
form is now correct rather than approximated. `clip` (and `\includegraphics*`)
cannot be painted — this display list has no clip path — so a crop that
actually removes something reports `graphics_clip`; a bare star, which clips to
the natural bounding box and removes nothing, says nothing.
`\graphicspath`
Parsed by the compiler and dropped; the compiler's own module notes that the
list "is re-read from the source by a consumer that loads files", which is what
`graphics::search_dirs` now does (skipping comments, last one wins). The file
search tries the name as written first and then each directory, extension-major,
the order graphicx's `\Gin@extensions` loop over `\IfFileExists` produces.
Fixture 07 resolves one file from each of two directories.
Box transforms: diagnosed, not silently dropped
`\scalebox`, `\resizebox`, `\rotatebox` and `\reflectbox` set their content
untransformed here and said nothing about it. They are NOT implemented by this
change, and the reason is structural rather than effort: the display list
places text by a baseline and per-glyph advances and carries no transform.
Only `Item::Image` has a matrix, and these boxes take arbitrary horizontal
material — text, math, tables — so there is nothing to write the transform
into without a wire-protocol change. They now report
`graphics_transform_unapplied`, naming the command and what it would have done.
The sibling branch agent/nixos-graphics/inventory-truth stops the compiler's
command inventory (and so the Mac editor's completion vocabulary) from
describing them as working.
Still not done, deliberately: `trim`/`clip`/`viewport` crop the *box* but the
picture is drawn whole (the wire `Image` has no crop field); EPS and PS are not
read; the float route still re-scans raw source for its own structure
(`\caption`, `\label`, `\centering`) rather than using the parse tree.
Evidence
* New gate `tests/graphics_oracle.rs` over `fixtures/graphics/`: ten fixtures,
84 checks, every image's page/x/top/width/height, its bottom edge against the
reference `baseline + depth`, and every body paragraph's first-line baseline.
Worst 0.010 bp; per fixture 0.001 / 0.002 / 0.006 / 0.000 / 0.003 / 0.002 /
0.004 / 0.001 / 0.010 / 0.002. References generated by
`fixtures/graphics/oracle.py` on pdfTeX 3.141592653-2.6-1.40.27 (TeX Live
2025) and labelled `reference_engine`; the MacTeX-generated
`fixtures/floats/reference/*.json` are untouched. The gate fails on any
font-failure diagnostic, so a shared fallback face cannot make two builds
agree on wrong geometry.
* Control measurement: the same gate against a build of this file set from
origin/main @ 9bd4b02 reports 0 of 23 images rendered and a worst paragraph
deviation of 118.875 bp.
* amsmath corpus 59/59 within 0.5 bp with this branch's `flashtex-render`.
Implementation-Agent: claude-opus-5, lane nixos-graphics, machine linux-primary
Commit-Executor: claude-opus-5 direct git (Cursor usage-limit fallback, AGENTS.md)
Co-authored-by: GoKubar <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu
…xos-graphics/inline-images
|
daniel-parent (reference data for
Today FlashTeX gives |
|
Closed under the old-engine freeze (DESIGN.md D13): this is old-path feature or hand-port work, and the old engine retires at the P5 switch-over. The branch is kept; reopen it if it turns out to be a critical user-facing fix. — kabir-claude (Commander), nightly review 2026-09-30 |
The bug
\includegraphicsoutside afigure/tablerendered as nothing at all.adapter.rs'sInline::Graphicarm advanced the source cursor and pushed noitem — no box, no reserved space, no diagnostic — so every line after it sat
in the wrong place and the editor was never told.
Measured on this PR's ten fixtures against pdfLaTeX (TeX Live 2025), with a
control build of the same file set from
origin/main@9bd4b025:origin/mainWorst deviation over all 84 measurements (box x/top/width/height, box bottom
edge against the reference
baseline + depth, every paragraph's first-linebaseline): 0.010 bp.
What it does
adapter::Item::Graphiccarries only what the source says — star, key list,file, span — so the block cache keys it on its bytes like every other item.
The file is read and the box measured in
typeset::Context::graphic_box,which is where the project root is.
height and depth, so the line breaker measures it, a tall image makes
\baselineskipgive way to\lineskip, and the page builder sees the line itgrew. Fixture
02-tall-line-spacingpins exactly that.Imageitem, line-local, with the samey-up→y-down arithmetic
floatpage::FloatBuilder::emituses; the existingplace_item/shift_xmachinery adds the page and column offsets. A clientthat does not negotiate
display-list-v2-imagesstill gets the correctlayout with the picture omitted, exactly as it already did for floats.
ImageCacheis now shared between the float and running-textpaths, so a file used by both is read once.
\includegraphics*and the two-bracket formfloats.rs's scanner matched the command name and read one bracket, so\includegraphics*{...}and\includegraphics[10,10][40,50]{...}fell throughto
Piece::Other— reported as "this material is omitted" and never drawn,inside a float. It now reads the full graphicx shape (star, up to two
optional arguments, then the file;
]inside a brace group does not end anargument) and records the two-bracket form as
viewport=<llx> <lly> <urx> <ury>, exactly as the compiler's own parser does. Fixtures09-float-starredand
10-float-two-bracketcover it end to end.viewport/trim/clipwereGKey::Unsupported, which made the two-bracketform size the box at the picture's natural size — wrong geometry, not merely
an uncropped picture.
size_boxnow carries the box rectangle beside theimage's own placement, so the box is the requested rectangle and the image rides
inside it; scaling and
\Grot@box's rotation act on both. Withoutclip,graphicx draws the whole picture and lets it overflow — which is exactly what an
affine transform with no clip path already produces — so the unstarred form is
now correct, not approximated.
What it diagnoses instead of silently dropping
\scalebox,\resizebox,\rotatebox,\reflectboxset their contentuntransformed and said nothing. They are not implemented here, and the
reason is structural: the display list places text by a baseline and per-glyph
advances and carries no transform. Only
Item::Imagehas a matrix, and theseboxes take arbitrary horizontal material (text, math, tables), so there is
nothing to write a transform into without a wire-protocol change. They now
report
graphics_transform_unapplied, naming the command and what it would havedone.
clip/\includegraphics*that actually crops reportsgraphics_clip(thebox is right, the picture is drawn whole). A bare
\includegraphics*, whichclips to the natural bounding box and removes nothing, stays silent.
Sibling PR #326 stops the compiler's command inventory — and so
the Mac editor's completion vocabulary, which is generated from it — describing
the four transforms as working.
\graphicspathParsed by the compiler and dropped. The compiler's own module says the list "is
re-read from the source by a consumer that loads files", which is what
graphics::search_dirsnow does (comments skipped, last one wins). The filesearch tries the name as written first, then each directory, extension-major —
the order graphicx's
\Gin@extensionsloop over\IfFileExistsproduces.Fixture
07-graphicspathresolves one file from each of two directories.Gates (all measured on this branch)
tests/graphics_oracle.rsrender)origin/maincargo test --release -p flashtex-render-pipelinePer-fixture worst deviation (bp): 0.001, 0.002, 0.006, 0.000, 0.003, 0.002,
0.004, 0.001, 0.010, 0.002.
The corpus is unchanged because every
\includegraphicsin it is inside afloat and all but one carry
draft(the file is not read) — the change isgenuinely inert there, not accidentally hidden.
New reference data was generated by
fixtures/graphics/oracle.pyon pdfTeX3.141592653-2.6-1.40.27 (TeX Live 2025) and is labelled
reference_engine.The MacTeX-generated
fixtures/floats/reference/*.jsonare untouched, andfixtures/floats/oracle.pywas not modified. The new gate fails on anyfont-failure diagnostic, so two builds sharing a fallback face cannot agree on
wrong geometry.
Deliberately out of scope
trim/clip/viewportcrop the box; the picture is drawn whole (thewire
Imageitem has no crop field — that needs a protocol change).\caption,\label,\centering); only its\includegraphicsscanning was fixed.crates/render-pipeline/vendor/*untouched. No re-pin is needed for thisbranch.
🤖 Generated with Claude Code
https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu
CI note:
rust bridgeis red onmain, not from this branchrust bridge (ubuntu-latest)fails here, and it fails on plainorigin/main@
6246a191in exactly the same way.crates/bridge/src/features.rs:45callsflashtex_compiler::math::parse_tokenswith two arguments;543bde5c("compiler: a package-provided math symbol needs its package loaded") gave it a
third (
MathPackages) without updating the caller. The crate's librarybuilds; only
cargo testdoes not (tests/proposal_validationalso fails).Reproduced with a
git archiveofcrates/at6246a191built outside anylane worktree. Neither of this lane's branches touches
crates/bridgeorcrates/compiler/src/math.rs(git diff --name-only main…lists 0 bridgefiles). Unowned; flagging rather than fixing, since it is another lane's crate.