I currently have the following code using Batik's SVGGraphics2D:
...
final SVGGraphics2D svgGraphics2D = new SVGGraphics2D(svgGeneratorContext, false);
svgGraphics2D.setSVGCanvasSize(new Dimension(width, height));
svgGraphics2D.setFont(font);
...
As a result, if font
is an available Font
on the system on which the code is executed, the correct attribute is added to the resulting SVG file.
However, if the font is missing (for instance "Verdana" on a linux box) a default font is used (font-family:'Dialog'
is added).
Thus, instead of specifying a font, I would like to pass a font-family in order to have font-family="DejaVu Sans,Verdana,Geneva,sans-serif"
in the resulting SVG. How can I achieve this knowing that, if I'm not wrong, the API only accepts Font
parameters ?
I hope that there's a easier way than using a xslt to transform the xml output.
Thank you in advance.