-
Notifications
You must be signed in to change notification settings - Fork 286
Open
Description
This PR asks for supporting light-dark(), a newly available feature, in style.
Background and Motivation
light-dark() enables setting two colors for an element. For example, draw.io generates the following SVG segment:
<g>
<rect
x="120"
y="0"
width="120"
height="60"
fill="#ffffff"
stroke="#000000"
pointer-events="all"
style="fill: light-dark(#ffffff, var(--ge-dark-color, #121212)); stroke: light-dark(rgb(0, 0, 0), rgb(255, 255, 255));"/>
</g>When using this kind of SVG in downstream crates (e.g., typst), usvg fails to parse them and falls back to black:
> resvg test.drawio.svg test.png
Warning (in usvg::parser::style:140): Failed to parse fill value: 'light-dark(#ffffff, var(--ge-dark-color, #121212)'. Fallback to black.It would be nice to support parsing light-dark().
Discussion
It's weird for me to have two colors for an SVG that will be converted to PNG or PDF. Thus, my first thought would be to ignore the color of the dark theme and only use the color of the light theme. Since downstream users may use this feature to decide how to render SVG themselves, providing both color codes in svgtypes::Paint may be helpful.
Metadata
Metadata
Assignees
Labels
No labels