fix(svg): support font-family attribute on SVG text elements - #581
Open
hjl12345 wants to merge 2 commits into
Open
fix(svg): support font-family attribute on SVG text elements#581hjl12345 wants to merge 2 commits into
hjl12345 wants to merge 2 commits into
Conversation
Modified the getUsedFonts function to traverse SVGElement child nodes, so that fonts set via the font-family attribute on SVG text elements can be correctly collected. Added corresponding test cases and test samples in test\resources\svg-font.
- Modified getUsedFonts function to traverse SVGElement child nodes - Added test cases for SVG text elements with font-family attribute - Fixed issue where custom fonts were not applied when exporting SVG to PNG
Contributor
|
💖 Thanks for opening this pull request! 💖 Please follow the contributing guidelines. And we use semantic commit messages to streamline the release process. Examples of commit messages with semantic prefixes:
Things that will help get your PR across the finish line:
We get a lot of pull requests on this repo, so please be patient and we will get back to you as soon as we can. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #581 +/- ##
=======================================
Coverage 66.50% 66.50%
=======================================
Files 10 10
Lines 612 612
Branches 150 150
=======================================
Hits 407 407
Misses 144 144
Partials 61 61 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Author
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.
Description
Modified
getUsedFontsfunction to traverse SVGElement child nodes, and added test cases for SVG text elements withfont-familyattribute.Motivation and Context
This PR fixes the issue reported in #534.
When using
toPngto export an SVG containing<text>elements with custom fonts (e.g.,font-family="zihunlieridangkongti"), the exported PNG does not apply the custom font. The root cause is thatgetUsedFontsonly traversesHTMLElementand ignoresSVGElementnodes, so the font-family attribute on SVG text elements is never collected.This change ensures that fonts set via SVG
font-familyattribute are properly collected and embedded during the export process.Closes #534
Types of changes
Self Check before Merge