Repository navigation
Conversation
Matrix3x2 transforms row vectors, so the left operand of a product applies first. SvgGlyphSource composed transforms the other way round: - A transform list such as "translate(100 0) scale(2)" was applied left to right; SVG applies it right to left. - A child's transform was applied after its parent's instead of before. - A <use> element's parent transform was applied before its own transform and x/y offset instead of last. Also honour the centre point of rotate(angle cx cy), which was ignored.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #571 +/- ##
=====================================
Coverage 80% 80%
=====================================
Files 408 408
Lines 35802 35802
Branches 5542 5543 +1
=====================================
+ Hits 28885 28914 +29
+ Misses 5488 5448 -40
- Partials 1429 1440 +11
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
4 tasks done
This branch has not been deployed
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.
Prerequisites
Description
Fixes #570.
Matrix3x2transforms row vectors, so ina * bthe transformaapplies first.SvgGlyphSourcecomposed SVG transforms the other way round. This PR fixes the order in three places, and the rotation centre:ParseTransformnow prepends each entry (m = t * m), so the list applies right to left as SVG requires.Walknow computesnodeTransform * parentLocalTransform.<use>: now computestranslate(x, y) * nodeTransform * parentLocalTransform. The x/y offset and the element's own transform were already in the right order relative to each other; only the parent transform was misplaced.rotate(angle cx cy): now rotates about(cx, cy), usingMatrix3x2.CreateRotation(radians, centerPoint).gradientTransformgoes through the sameParseTransform, so a gradient with more than one transform in its list is fixed as well.Tests
SvgTransformTestsrenders a triangle under each transform and compares its device-space points with an untransformed triangle at hand-calculated coordinates. Five of the six cases fail onmain. The sixth checks the x/y-before-transform order inside<use>, which was already correct.SvgTestFontsis a small shared helper that adds anSVGtable toSixLaborsSampleAB.ttf, so tests can write SVG glyph documents inline. #569 has a private copy of the same helper. Whichever of the two merges second can switch to the shared one.The full suite passes on net10.0 in Release, apart from
HarfBuzzCorpusTests(2 tests) andTextShaperTests.ZawgyiScriptOverrideAppliesThroughTextOptionsAndTextRun, which fail the same way on a cleanmainin my environment.I also enabled
SUPPORTS_DRAWINGlocally to compare theIssues_462emoji snapshots. Their differences from the reference images are identical with and without this change, so it doesn't change the Noto Color Emoji SVG output. (12 of those 16 snapshots differ from the references onmainon my machine anyway, the COLRv1 ones included.)Noticed but not changed
Two more transform issues in the same file, left out to keep this PR focused:
transformon the root<svg>element is passed toWalkas the starting transform and is also stored inPaintedCanvasMetadata.RootTransform, whichPaintedGlyphMetrics.ComputeSourceToUpemapplies again. When the glyph is the root element itself,Walkparses the attribute a third time.BuildLinearGradientandBuildRadialGradientmultiplygradientTransformtogether along anhrefchain. In SVG, a referencing gradient inherits the attribute only when it doesn't set its own.