PDF stage 4.10: tiling patterns (PatternType 1)#574
Merged
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6af61917b6
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
89d2a36 to
8384b7b
Compare
Render `/PatternType 1` tiling patterns selected by `scn` in a `/Pattern` colour space, reusing the form-XObject content-stream machinery. - Parser: `parse_pattern` reads a tiling pattern's stream content, `/Resources`, `/BBox`, `/XStep`/`/YStep` and `/PaintType`. Patterns are memoized by reference (like XObjects) so a cycle through a tiling pattern's own `/Resources` resolves to the existing element instead of recursing. - Extractor: `paint_path` resolves a tiling pattern to `PathElement::fill_pattern` + the pattern `/Matrix`. `scn` now keeps the leading colour components for an uncoloured pattern (`/PaintType 2`), so its underlying fill colour is available. - HTML: a `PatternRegistry` runs the tile content as a mini page (`extract_page`) and emits an SVG `<pattern>` repeating it every `/XStep`/`/YStep`, with `patternTransform` placing the lattice; the fill references it as `fill="url(#…)"`. Uncoloured cells are painted in the path's fill colour (folded into the cache key). Only paths and images inside a tile are rendered; nested text/shadings/patterns are skipped. Tests: a tiling pattern fills a path (`fill_pattern` + matrix), and an uncoloured pattern carries its paint colour. Reference-output submodules intentionally not bumped (left for regeneration). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
andiwand
added a commit
that referenced
this pull request
Jun 28, 2026
…up (#575) Follow-ups on the stage-4.10 tiling-pattern work (#574): - Fix uncoloured-pattern colour resolution: `ColorSpaceDef::to_rgb` now defers `ColorSpaceKind::pattern` to its underlying base, so a `/PaintType 2` pattern selected through a named Pattern space (`[/Pattern /DeviceRGB]`) paints in its tint instead of black. Adds a regression test. - Clip each tiling-pattern cell to its `/BBox` so marks outside the cell, or in the gap when a step exceeds the BBox, don't leak into the tile. - Deduplicate the per-page `<defs>` registries (clip/gradient/pattern) behind a shared `DefsRegistry` base, and extract an `svg_matrix` helper for the repeated `matrix(...)` serialization. - Use `has_value` for the pattern `/Resources` lookup, matching `/BBox`. Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
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.
🤖 Generated with Claude Code
Stage 4.10 of the PDF→HTML pipeline: render
/PatternType 1tiling patterns selected byscnin a/Patterncolour space, reusing the form-XObject content-stream machinery. Stacked on #573 (4.9); targetspdf-stage-4.9.What
parse_patternreads a tiling pattern's stream content,/Resources,/BBox,/XStep//YStepand/PaintType. Patterns are now memoized by reference (mirroring XObjects), so a cycle through a tiling pattern's own/Resourcesresolves to the existing element instead of recursing forever.paint_pathresolves a tiling pattern toPathElement::fill_patternplus the pattern/Matrix.scnnow keeps the leading colour components for an uncoloured pattern (/PaintType 2), so its underlying fill colour is available to the renderer.PatternRegistryruns the tile content as a mini page (extract_page) and emits an SVG<pattern>repeating it every/XStep//YStep, withpatternTransform(the pattern/Matrix→ page box) placing the lattice; the fill references it asfill="url(#…)". Uncoloured cells are painted in the path's fill colour (folded into the cache key). Only paths and images inside a tile are rendered — nested text/shadings/patterns are skipped (rare).Tests
PdfPageExtractor: a tiling pattern fills a path (fill_pattern+ matrix resolved,fill_shadingnull), and an uncoloured pattern (/PaintType 2) carries its paint colour.All 199 PDF tests pass; full suite green.
Notes