Repository navigation
Fix symbol instance viewports and preserve drawing state - #145
Open
middlegrey wants to merge 1 commit into
Open
middlegrey wants to merge 1 commit into
middlegrey wants to merge 1 commit into
Conversation
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.
Fix symbol instance viewports and preserve drawing state
SVGs containing reusable symbols can render at the root document's size instead of the width and height requested by each use element. A symbol declared outside defs also triggers an unmatched graphics-state restore when its definition closes. When embedded through Dompdf, this can discard the image transform, making CSS width changes appear ineffective.
Apply use width and height to the referenced symbol's instance attributes, with length conversion, while preserving the shared definition. Do not end-render a symbol definition that was never rendered. Correct viewport alignment to read the normalized preserveaspectratio attribute, honor meet/slice, and apply YMid/YMax offsets on the vertical axis.
The new tests cover repeated instances, omitted dimensions, px lengths, negative viewBox origins, meet/slice/none alignment, and balanced graphics state for symbols declared outside defs. tests/fixtures/symbol-use.svg is a minimal standalone reproduction without application assets.
Validation: PHPUnit on PHP 8.2: 10 tests, 91 assertions pass. The repository's existing PHPUnit XML schema produces a deprecation notice.