Skip to content

Conversation

@tacshi
Copy link

@tacshi tacshi commented Dec 19, 2025

Closes #900

Added support for the CSS light-dark() function to handle SVGs exported from Draw.io with dark mode support. Previously, usvg failed to parse light-dark() and fell back to black, making text invisible on dark backgrounds.

Already tested in Zed

@tacshi
Copy link
Author

tacshi commented Dec 19, 2025

@Its-Just-Nans Can you review this PR? I came here to fix a bug from Zed. Thanks.

@Its-Just-Nans
Copy link
Contributor

Its-Just-Nans commented Dec 19, 2025

@Its-Just-Nans Can you review this PR? I came here to fix a bug from Zed. Thanks.

Hi,

Maybe you should add an option to usvg::Options for the current theme and choose the light-dark value based on the option?

Note that I'm not a maintainer of resvg, only a contributor so, this is just a suggestion, but maybe not the best idea


Edit: there is the color-scheme css props that can be in usvg Options

@tacshi
Copy link
Author

tacshi commented Dec 19, 2025

@Its-Just-Nans Can you review this PR? I came here to fix a bug from Zed. Thanks.

Hi,

Maybe you should add an option to usvg::Options for the current theme and choose the light-dark value based on the option?

Note that I'm not a maintainer of resvg, only a contributor so, this is just a suggestion, but maybe not the best idea

Edit: there is the color-scheme css props that can be in usvg Options

Suggestion applied.

@RazrFalcon
Copy link
Collaborator

In general, a low-level attribute parsing is done at the svgtypes level. It also has necessary parsing utilities to simplify resolve_light_dark implementation.

Yes, it's technically not a "SVG type", but that's how resvg is "layered".

But if it is too much work, you can just add // TODO: move to svgtypes before resolve_light_dark.

@tacshi
Copy link
Author

tacshi commented Dec 20, 2025

In general, a low-level attribute parsing is done at the svgtypes level. It also has necessary parsing utilities to simplify resolve_light_dark implementation.

Yes, it's technically not a "SVG type", but that's how resvg is "layered".

But if it is too much work, you can just add // TODO: move to svgtypes before resolve_light_dark.

Submitted: linebender/svgtypes#59

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.

FR: Support parsing style with light-dark()

3 participants