Repository navigation
pdf: exact route paints TikZ opacity through pgf's /pgf@CA and /pgf@ca ExtGStates (stacked on #527) - #533
Merged
Conversation
…Z path items
What changed:
- v2: `pdf_number` formats an f64 as a bounded PDF number (shortest decimal
rounded half away from zero, no exponent, -0 -> 0); sRGB colour components
use 5 digits (pdflatex measured: RGB{20,80,170} -> 0.07843 0.31374 0.66667
rg). Replaces the exact-binary requirement that refused 0.8 and 0.07843.
- v2: `path_fill` / `path_stroke` items (with clips) become
q [rg RG] [clip W n] [w M d J j] path f|f*|S Q, in pgf's pdfTeX order.
- exact: `M` (miter limit) joins the bounded operator set.
What was run:
- cargo test (crates/pdf): lib 53 passed; tests/v2 7 passed; all targets 0 failed
- cargo check --tests (crates/rendering-core): ok
Next step: re-pin crates/render-pipeline/vendor/pdf so `flashtex build` uses it.
Implementation-Agent: claude-opus-5 subagent of daniel-parent
Commit-Executor: daniel-parent subagent
Claude-Session: https://claude.ai/code/session_012c9XLkHjePPGBuarrmE2mz
…tates What changed: - exact: Op::StrokeAlpha / Op::FillAlpha, written `/pgf@CA<a> gs` and `/pgf@ca<a> gs`, the names and one-key dictionaries pgf's pdfTeX driver writes (measured with pdflatex 1.40). `gs` joins the bounded operator set for those names only; any other ExtGState is still refused. Validation refuses an alpha outside [0, 1] and `gs` during path construction. Each page declares the states it selects once, sorted by name, inline: `/ExtGState << /[email protected] << /ca 0.4 >> >>`. - v2: a paint alpha below 1 is no longer an error. It is rounded like a colour component and selected right after the colour inside the item's `q … Q`: path_stroke sets CA, path_fill, rule and glyph_run set ca. - Tests: exact operator stream and resources for stroke and fill alpha, per-page dedup, refusal of other gs names, text alpha on a glyph run. What was run: - cargo test (crates/pdf): test result: ok. 53 passed; 0 failed (lib), 12 passed (tests/exact), 5 (images), 11 (navigation), 28 (render), 3 (type1), 10 passed; 0 failed (tests/v2). - cargo check --tests (crates/rendering-core): Finished. Next step: build extended/tikz-clipping-patterns with a scratch copy whose render-pipeline/vendor/pdf is this crate. Implementation-Agent: claude-opus-5 subagent of daniel-parent Commit-Executor: daniel-parent subagent Claude-Session: https://claude.ai/code/session_012c9XLkHjePPGBuarrmE2mz
This was referenced Sep 15, 2026
#533 is stacked on #527. Squashing the parent onto main rewrote its commits, so crates/pdf/src/v2.rs and tests/v2.rs conflicted wholesale. The branch already contains #527's work, and the only commit on main touching those two paths since the merge base is #527's squash, so the branch side is the complete one. Implementation-Agent: orchestrator-astra Commit-Executor: orchestrator-astra (direct; Cursor usage limit)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #527. Review and merge #527 first; this PR's diff against main includes #527's commit until then.
What
Constant alpha on the
crates/pdfexact route (exact.rs,v2.rs). Nothing undervendor/changes.gsfor pgf's alpha states only. NewOp::StrokeAlpha(a)andOp::FillAlpha(a)write/pgf@CA<a> gsand/pgf@ca<a> gs. The writer, parser and validator all handle them. Any othergsname is still refused (ExtGState /GS0 is outside the exact export's bounded set). The validator also refuses an alpha outside [0, 1] and agswhile a path is being built./ExtGStateresources. Each page declares every state it selects once, sorted by name, inline, with pgf's one-key dictionaries:/ExtGState << /[email protected] << /CA 0.5 >> /[email protected] << /ca 0.4 >> >>. No page/Groupis added, and pdflatex writes none. Object numbering does not change.0.30000000000000004becomes0.3). It is selected right after the colour, inside the item's ownq … Q:path_strokegets/pgf@CA<a>(fromdraw opacity).path_fill,ruleandglyph_runget/pgf@ca<a>(fromfill opacityandtext opacity).q … Qtoo.Oracle (pdflatex 1.40 + pgf, uncompressed, measured)
pgf builds the name from the option's own text (
opacity=.4→/[email protected],0.40→/[email protected],1/3→/[email protected]). The display list only carries anf64, so this route writes the shortest 5-decimal form (0.4).Deviation from the task text: the task suggested one
/GSnstate per distinct (CA, ca) pair. This PR follows pgf instead: one state per distinct component value, namedpgf@CA<a>orpgf@ca<a>. The display list has one alpha per item anyway.Why
extended/tikz-clipping-patterns(from #42's cases; only the.texwas used, no reference PDFs) still failed on the #527 route withpaint alpha 0.4 is not 1; alpha needs an ExtGState.flashtex build main.tex, run with a scratch copy (not committed) whosecrates/render-pipeline/vendor/pdfwas replaced by the givencrates/pdf:vendor/pdfsourcee7e6405dflashtex: error: pdf: payload.pages[0].items[3]: paint alpha 0.4 is not 1; alpha needs an ExtGState, which is outside the bounded operator set14c152efflashtex: main.tex: recovered, 1 page, 1 error, 3 warnings -> pdf main.pdf, v2 main.jsonThe remaining "1 error" is the existing
\usetikzlibrarypreamble recovery, and it also appears before. The output page has/ExtGState << /[email protected] << /ca 0.4 >> >>andq 1 0 0 rg 1 0 0 RG /[email protected] gs … f Q. A Ghostscript rasterisation shows the red and blue circles overlapping translucently (purple where they overlap), plus the clippedblue!20disc with its red stroke.Overlap check
gh pr list --repo flash-tex/flashtex --state open --searchforExtGState,opacityandalpha: only pdf: exact route rounds colours to xcolor's 5 decimals and paints TikZ path_stroke/path_fill #527 (the base of this PR) and unrelated compiler/cli/render-pipeline PRs (compiler: \( … \) is inline math; \allowdisplaybreaks is a preamble no-op #276, cli: did-you-mean suggestions in output, and flashtex check --fix [--dry-run] with symlink-safe atomic writes #362, render-pipeline: sectioning headings from class-geometry's \@startsection specs (oracle 38/41 exact) #151, compiler: 50 LaTeX kernel math symbols (\odot, \prec, \sqcup, \bigsqcup, the suits, harpoons and diagonal arrows) #185).coord.py claims: none for ExtGState or opacity. This task is claimed asGH-PDF-EXACT-ROUTE-ALPHA(daniel-parent).Test results
cargo test(crates/pdf):test result: ok. 53 passed; 0 failed(lib;rejects_operators_outside_the_bounded_setnow checksshplus a non-pgfgsname)test result: ok. 12 passed; 0 failed(tests/exact)test result: ok. 5 passed; 0 failed(images)test result: ok. 11 passed; 0 failed(navigation)test result: ok. 28 passed; 0 failed(render)test result: ok. 3 passed; 0 failed(type1)test result: ok. 10 passed; 0 failed(tests/v2)tikz_alpha_selects_pgf_ext_gstates_inside_the_items_save_restore: checks the exact operator stream for fill, stroke, rule, a repeated alpha and CA/ca at the same value. It also reads the page's/ExtGStatedictionary back throughPdfFile, and runsverify::check_structure, a content round-trip and a determinism check.alpha_ext_gstates_are_deduplicated_per_page: 10 selections on 2 pages give one entry per page, and an opaque page declares none.only_pgf_alpha_ext_gstates_are_acceptedhand_built_envelope_…now covers a glyph run at alpha 0.5:q 0.5 0 1 rg /[email protected] gs BT … ET Q.cargo check --tests(crates/rendering-core):Finished.Not done
flashtex builddoes not use this untilcrates/render-pipeline/vendor/pdfis re-pinned to a main that has pdf: exact route rounds colours to xcolor's 5 decimals and paints TikZ path_stroke/path_fill #527 and this PR (per VENDORING.md). This PR does not edit vendor/.opacity=pgf writes bothCAandca. The display list has one alpha per item, so only the state the item paints with is written. For a fill-only or stroke-only item this changes no pixel.f64(0.4), not the option's own text (.4).pattern=is still ignored (the square renders solid black) and\shadeis skipped. Both happen upstream in the TikZ subset.🤖 Generated with Claude Code
https://claude.ai/code/session_012c9XLkHjePPGBuarrmE2mz