First, thank you for you effort!We are using JFreeChart in our software and recently bought the developer guide including JFreeSVG. It was my hope that we could replace batik.The library works nicely and easy so far, but there seems to be a problem with the font rendering. When exporting a PNG or an SVG generated with Batik the font looks fine. However with JFreeSVG (and OrsonPDF) the kerning or space between characters are off at some places. This image shows a comparison (SVG rendered in Firefox:

Is there a way to improve the rendering quality? I have also noticed that JFree seems to convert text to vectors (which also increases the file size). The output from Batik contains this tag:

Thanks for the feedback. I'll add the 'text-rendering' hint to the text element generated by the drawString() method, and provide a (Java2D) rendering hint to allow the value to be configured. But I think that will only help with horizontal text, since rotated text is being converted to vectors (as you noticed). I need to check, but I believe that's happening within JFreeChart because it is using a TextLayout somewhere. Hopefully we can find a way to improve this text.

I've uploaded a new version of JCommon (1.0.21) to the JFreeChart project page at SourceForge. This has modifications to the TextUtilities class which should result in some improvements for both JFreeSVG and OrsonPDF. Most strings were being drawn to the Graphics2D target using TextLayout - now by default they will go directly via the drawString() method. This results in much smaller SVG and PDF files, and hopefully should also improve the rendering quality for you.

JFreeSVG 1.4 will include the new rendering hint to control the 'text-rendering' attribute in the SVG output. I don't know if you'll need this to see quality improvements and, in any case, it will take me a bit longer to get a new JFreeSVG release done. Let me know if you see improvements just from the changes in JCommon.

JFreeSVG 1.4 is now uploaded to SourceForge. It has the addition of the text-rendering attribute in the SVG text element, the rendering hints to configure this via SVGGraphics2D, plus a bug fix for the style attribute that was causing some bad output in Firefox (I found this while testing the changes). Let me know how it goes for you.

Thank you very much for the prompt reaction!Both JFreeSVG and OrsonPDF now generate beautiful images.

The only problem remaining is the font type when saving as SVG. In our case we would like to use a sans-serif font. When comparing the output with the batik SVG the difference seems to at "SansSerif" instead of "sans-serif".With this workaround it works fine however:

Some feedback/ideas based on scenarios I've come across in my own usage:

1. To be able to specify a url for an image (possibly a setImageUrl(String url) method in SVGGraphics2D). It would be the responsibility of the caller to set the image source prior to calling drawImage() and clear afterwards.

2. To be able to specify an ID for the next element drawn (for example, useful for attaching event handlers in the browser). Perhaps an interface IdProvider with a method called getId(Object context) or something like that which can be set in SVGGraphics2D.

3. Not all of the gradients supported in JFreeChart work yet (GradientPaintTransformType.CENTER_VERTICAL and GradientPaintTransformType.CENTER_HORIZONTAL).

What is the best way for us to support this project? We brought the JFreeChart developer guide a few years back, but we will gladly purchase it again if that's how you're taking contributions.

Fluxim wrote:The only problem remaining is the font type when saving as SVG. In our case we would like to use a sans-serif font. When comparing the output with the batik SVG the difference seems to at "SansSerif" instead of "sans-serif".

Thanks for the feedback. This will be fixed for the JFreeSVG 1.5 release, I've introduced a FontMapper (assigned to the SVGGraphics2D) and the default implementation will map the Java logical fonts ("Dialog", "DialogInput", "SansSerif", "Serif" and "Monospaced") to the equivalent SVG generic fonts ("serif", "sans-serif", "monospace").

remiohead wrote:1. To be able to specify a url for an image (possibly a setImageUrl(String url) method in SVGGraphics2D). It would be the responsibility of the caller to set the image source prior to calling drawImage() and clear afterwards.

At the moment there is a RenderingHint (SVGHints.KEY_IMAGE_HANDLING) to control whether the image is embedded or referenced. The referencing option isn't very flexible (there isn't a way to specify a custom URL) but I think it could be modified to support what you are looking for. I'll try some options.

remiohead wrote:2. To be able to specify an ID for the next element drawn (for example, useful for attaching event handlers in the browser). Perhaps an interface IdProvider with a method called getId(Object context) or something like that which can be set in SVGGraphics2D.

This could also be achieved by adding a new rendering hint (the advantage of using RenderingHints is that you can add them to any Graphics2D and they will be silently ignored by different Graphics2D implementations, so your code doesn't need to check for SVGGraphics2D specifically). I'm undecided yet about whether to validate the ids (for uniqueness) or leave that as a responsibility for the caller. Any thoughts?

remiohead wrote:3. Not all of the gradients supported in JFreeChart work yet (GradientPaintTransformType.CENTER_VERTICAL and GradientPaintTransformType.CENTER_HORIZONTAL).

I'll take a look at this. I have a feeling it is not completely straightforward, but I'll see.

remiohead wrote:What is the best way for us to support this project? We brought the JFreeChart developer guide a few years back, but we will gladly purchase it again if that's how you're taking contributions.

I've created a couple of products for sale so please take a look at those and see if there is something that would be useful for you. Orson Charts is a 3D chart library for Java (and soon Android), and OrsonPDF is similar to JFreeSVG but generates PDF output. Another useful contribution is just to make people aware of JFreeChart, JFreeSVG, Orson Charts and Orson PDF (via word-of-mouth, blogs, Twitter etc). I have a limited advertising budget and, in any case, word of mouth is the best.