Skip to content

Inherit dominant-baseline into nested <tspan> elements - #1086

Merged
LaurenzV merged 1 commit into
linebender:mainfrom
StefanoD:fix/864-dominant-baseline-inheritance
Oct 7, 2026
Merged

LaurenzV merged 1 commit into
linebender:mainfrom
StefanoD:fix/864-dominant-baseline-inheritance

Conversation

@StefanoD

Copy link
Copy Markdown
Contributor

dominant-baseline was listed in is_non_inheritable, so usvg only let a <tspan> pick up the value from its direct parent element. For a nested <tspan> whose immediate parent does not carry the property, the value of an ancestor <text> was therefore lost and the span fell back to auto (alphabetic baseline). The nested run then sat on a different baseline than its siblings — the "weird" positioning reported in #864.

dominant-baseline is actually an inherited property, unlike its siblings alignment-baseline and baseline-shift:

Removing it from is_non_inheritable makes find_attribute/resolve_inherit walk the full ancestor chain, matching Chrome's rendering (verified by comparison) and the spec.

Fixes #864.

Generated with Claude


Note: I accidentally closed the original PR (#1070) by deleting my fork, which auto-closed it. This reopens the same change — the branch and commits are unchanged.

@luisbg

luisbg commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

lgtm

Approach is correct but I'm not sure the comment block in crates/usvg/src/parser/svgtree/mod.rs is needed.

@StefanoD

StefanoD commented Sep 9, 2026

Copy link
Copy Markdown
Contributor Author

I won't have the time to continue with the PR. You can take it over.

Treat dominant-baseline as inherited so nested spans resolve the value through the full ancestor chain. Add a render regression test for an unstyled intermediate span.

Fixes linebender#864.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@LaurenzV
LaurenzV force-pushed the fix/864-dominant-baseline-inheritance branch from 7ff45ee to 30d315b Compare October 7, 2026 17:47
@LaurenzV

LaurenzV commented Oct 7, 2026

Copy link
Copy Markdown
Collaborator

Thanks!

@LaurenzV
LaurenzV merged commit adb61c7 into linebender:main Oct 7, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Nested tspan positioning is weird

3 participants