Fix text clipping itself by inheriting the clip-path and tranforming it#66
Merged
gentledepp merged 1 commit intodevelopfrom Apr 24, 2026
Merged
Fix text clipping itself by inheriting the clip-path and tranforming it#66gentledepp merged 1 commit intodevelopfrom
gentledepp merged 1 commit intodevelopfrom
Conversation
- According to [w3.org](https://www.w3.org/TR/SVG11/propidx.html), the clip-path property is not inherited and clip-rule is - The [SVG.NET library](svg-net#541) also corrected that a few years ago - What was happening is that the text element would inherit the clip-path from its parent, and if the text had a transform, the clip-path would effectively be transformed as well, causing the text to clip itself. - For example, if there was a clip-path going from y=-51 with height=50, and the text had a transform="translate(0, 20)": - The text would be rendered beginning from y=20 upwards, - The clip path would be transformed to y=-31 with height=50 hiding everything outside y=-31 to y=19, so you could see the whole text except for the small part at the bottom - The expected behavior for these values would be that the text is not visible at all because the clip-path should have hidden everything outside y=-51 to y=-1 - I also needed to call `SetClip` before and `ResetClip` after calling `RenderChildren` so that the group element would actually apply the clip-path. This wasn't the case before - Also wrote some unit tests
Collaborator
Author
|
@gentledepp Should I also increment the version number in Svg.Editor etc.? |
dariostrm
commented
Apr 24, 2026
| public override object ConvertFromString(string value, Type targetType, SvgDocument document) | ||
| { | ||
| if (value == "none") | ||
| return SvgFontVariant.Normal; |
Collaborator
Author
There was a problem hiding this comment.
A change unrelated to the bug.
When testing something I got hundreds of exceptions when the font was set to none in an svg
Owner
There was a problem hiding this comment.
Only necessary if you changed something in the editor
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.
SetClipbefore andResetClipafter callingRenderChildrenso that the group element would actually apply the clip-path. This wasn't the case beforeBefore
13227_before.mp4
After
13227_after.mp4