Make SVG currentColor configurable - #3552
Conversation
|
This pull request changes some projects for the first time in this development cycle. An additional commit containing all the necessary changes was pushed to the top of this PR's branch. To obtain these changes (for example if you want to push more changes) either fetch from your fork or apply the git patch. Git patchFurther information are available in Common Build Issues - Missing version increments. |
0f9b0e6 to
2f29779
Compare
|
So what is "currentColor" used for? The background of the image? Can you pls. explain |
SVG allows to use "currentColor" as color. Part of the spec. If you use acurrentColor in your SVG files, SWT hard-codes this to BLACK in 2026-09 and WHITE in 2026-06. With this change, we could configure the target color. Your icons need no change. The change gives you the option to switch to "currentColor". Change would be easy, search and replace. You could set grey-isch as default or use different colors. In short, with this change you gain flexility for the color. If not desired you do not have to change anything. |
This statement contradicts the findings that led to the change in 2026-09, as it was supposed to preserve pre-existing behavior rather than changing it:
How can we reproduce the assumed currentColor change between 2026-06 and 2026-09? |
ok understood. Do we have any concrete SVGs in Platform or other products that use the "currentColor" and currently have issues with the current implementation? Is there a way in the SVG spec to define additional colors (next to currentColor)? If that would be possible we could also "externalize" also the definition of the accent colors |
Create a Eclipse RCP with a template add a svg file to its toolbar using currentColor and run it against a target platform with 2026-06 and afterwards 2026-09. IMHO BLACK is the better default for curentColor so the 2026-09 change is an improvement. |
No, I discovered that working for a RCP client. AFAIK all platform svg use fixed colors.
I don't know. |
SVG icons using fill="currentColor" are rasterized with a hardcoded color in JSVGRasterizer. Until 2026-06 that was white (the AWT default), since 2026-09 it is black. Either default is wrong for one of the themes, so the color must be configurable to support both dark and light themes. Add a global current color, settable via JSVGRasterizer.setCurrentColor(RGB) or the system property swt.svg.currentColor. Default stays black and explicit fills are unaffected. Assisted-by: multiple AI agents and layers of automated tooling 🤖
2f29779 to
817f0a4
Compare
It used to be the default before as well. 2026-06 just had the regression from the change in the JSVG implementation. Regarding the actual PR I have some questions/comments: the configuration is static, which means that you are limited to sharing the same |

SVG icons using
fill="currentColor"are rasterized with a hardcoded color inJSVGRasterizer. Until 2026-06 that was white (the AWTGraphics2Ddefault), since 2026-09 it is black. Either default is wrong for one of the themes, so the color must be configurable to support both dark and light themes.Adds a global current color, settable via
JSVGRasterizer.setCurrentColor(RGB)or the system propertyswt.svg.currentColor(e.g.#FFFFFF). Default stays black; onlycurrentColorreferences are affected, explicit fills are untouched. Images already rasterized keep their color.Intended consumer is the platform CSS/theme engine, which can push the theme color before the workbench renders its icons.