SVG

Scott Palmer swpalmer at gmail.com
Tue Oct 11 16:26:21 UTC 2016


The issue was not related to WebView loading and rendering the SVG properly, it did.  The issue is that it is currently impossible to make a WebView with a transparent background unless you use reflection and hack it.  E.g.:

Field f = engine.getClass().getDeclaredField(“page”);
f.setAccessible(true);
com.sun.webkit.WebPage page = (com.sun.webkit.WebPage) f.get(engine);
page.setBackgroundColor(0);

There is already a JIRA issue for this: JDK-8090547

That severely limits the ability to show SVG images in the UI.  Given the prevalence of high DPI displays and the need to render images at various sizes, I think it would be great to have SVG image support in an ImageView instead of hacking it via a WebView (even if under the hood the WebEngine does the rendering).

Scott

> On Oct 11, 2016, at 11:17 AM, Guru Hb <guru.hb at oracle.com> wrote:
> 
> WebView renders SVG ( WebView.getWebEngine().load("PathToSvg.svg"); ).
> Could you please let us know which content (SVG) failed to rendered as expected. Please file a JBS with simplified test content , will analyze.
> 
> Thanks,
> Guru
> 
> On 11/10/16 6:56 PM, Scott Palmer wrote:
>>> On Oct 11, 2016, at 8:36 AM, Kevin Rushforth <kevin.rushforth at oracle.com> wrote:
>>> 
>>> JavaFX supports SVG paths both directly and via CSS, but there is no general support for SVG.
>> 
>> Perhaps there should be?  Is there an enhancement request in JIRA?
>> 
>> I just Worte a program that tried to get around this using WebView to render the SVG. It is more awkward than it should be, and due to an existing issue I had to use a workaround to get the background to be transparent that will surely break with Java 9.
>> 
>> Scott
> 



More information about the openjfx-dev mailing list