PDF tiling patterns: colour-through-base fix, BBox clip, registry dedup#575
Merged
Conversation
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> Claude-Session: https://claude.ai/code/session_01Negfa31h7p7vRYJzGUhjdE
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
Follow-ups on the stage-4.10 tiling-pattern work (#574), addressing the Codex review comments plus some cleanup.
Correctness
ColorSpaceDef::to_rgbreturned black forColorSpaceKind::pattern, ignoring itsbase. When a/PaintType 2pattern is selected through a named Pattern colour space (/CS1 [/Pattern /DeviceRGB]),set_colorfeeds the leading components intoto_rgb, so/CS1 cs 1 0 0 /P scnpainted black instead of red.to_rgbnow defers thepatterncase to its underlying base. Adds a regression test (the existing test used the inline/Pattern csform, wherecolor.defstays null and the device-by-count path masks the bug)./BBox(ISO 32000-1 8.7.3.1). When/XStep//YStepdiffer from/BBox, marks drawn outside the cell — or in the gap when a step exceeds the BBox — leaked into the repeated tile. The tile content is now wrapped in a<clipPath>rect sized by the BBox. (An overlapping lattice, a step smaller than the BBox, can't be expressed as a single SVG<pattern>and is left unreproduced.)Cleanup / dedup
DefsRegistrybase for the three per-page<defs>registries (clip/gradient/pattern), which carried identicalm_page/m_count/m_id_by_signature/m_defsmembers, an identicaldefs(), and the same intern-and-mint-id idiom.svg_matrixhelper for the repeatedmatrix(a,b,c,d,round2(e),round2(f))serialization (gradient/pattern transforms and the image fragment).has_valuefor the pattern/Resourceslookup, matching the/BBoxcheck.Tests
All 200 PDF tests pass locally (199 + the new
scn_uncoloured_tiling_pattern_colour_through_base).