Skip to content

SVG icons with fill="currentColor" render as white due to missing default foreground color in JSVGRasterizer #3398

Description

@joeljohansson99

Describe the bug
When rendering SVGs with property fill="currentColor", it will take the foreground color from the graphics. And since JSVGRasterizer creates the graphics with BufferedImage.createGraphics(), and dont set the default foreground color, it will take it from its default which is always white. This causes all SVG icons which has fill="currentColor" to be white.

To Reproduce
Use an SVG with fill="currentColor".

Expected behavior
I would expect it to be black for light mode and white for dark mode. You can do this with g.setColor(color) after creating the graphics. (It wont override the fill="color") property when its specified, just the default when fill="currentColor", I have tested it already.

Environment:

  1. Select the platform(s) on which the behavior is seen:
    • All OS
    • Windows
    • Linux
    • macOS
  1. Additional OS info (e.g. OS version, Linux Desktop, etc)

  2. JRE/JDK version
    25

Version since
Eclipse 4.40

Workaround (or) Additional context
This issue was introduced with this commit in the underlying Java SVG renderer: weisJ/jsvg@55c481e.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions