Bug with fonts containing spaces in family name

A discussion forum for JFreeSVG (a fast, lightweight, SVG generator for the Java platform).
Locked
mhilpert
Posts: 497
Joined: Wed Apr 02, 2003 1:57 pm
Location: Germany

Bug with fonts containing spaces in family name

Post by mhilpert » Tue May 26, 2020 10:32 am

When a JFreeChart ist converted to SVG with JFreeSVG, the Font is not found when the resulting document is rendered. When using Batik to create the SVG file from the same JFreeChart object, the font is found. Reason: Batik encloses the font-family name in quotes and JFreeSVG does not. Font family names with spaces will result in font not found with JFreeSVG.
Java 11, JFreeChart 1.0.15, JFreeSVG 4.0

david.gilbert
JFreeChart Project Leader
Posts: 11734
Joined: Fri Mar 14, 2003 10:29 am
antibot: No, of course not.
Contact:

Re: Bug with fonts containing spaces in family name

Post by david.gilbert » Wed Jul 01, 2020 7:30 pm

Thanks for the report - I opened a bug here:

https://github.com/jfree/jfreesvg/issues/27
David Gilbert
JFreeChart Project Leader

:idea: Read my blog
:idea: Support JFree via the Github sponsorship program

david.gilbert
JFreeChart Project Leader
Posts: 11734
Joined: Fri Mar 14, 2003 10:29 am
antibot: No, of course not.
Contact:

Re: Bug with fonts containing spaces in family name

Post by david.gilbert » Sun Jul 26, 2020 7:35 pm

I was just trying this out, and I don't get any issue in Chrome, Safari or Firefox on a Mac. Which browser gives you the font not found error? Or is it some other SVG viewer?
David Gilbert
JFreeChart Project Leader

:idea: Read my blog
:idea: Support JFree via the Github sponsorship program

mhilpert
Posts: 497
Joined: Wed Apr 02, 2003 1:57 pm
Location: Germany

Re: Bug with fonts containing spaces in family name

Post by mhilpert » Mon Aug 03, 2020 12:59 pm

It is generating a PDF with Apache FOP. We usually generate the SVgs (that are referenced in the XSLs) with Batik. Batik generates code like this:

Code: Select all

<g style="font-size:6px; fill:rgb(0,224,163); text-rendering:geometricPrecision; font-family:'78bcfc3c15c0b3bc - subset of LuminSans Std Reg'; stroke-linejoin:bevel; shape-rendering:crispEdges; stroke:rgb(0,224,163);">
and JFreeSVG generates:

Code: Select all

<g ><text x="134.04" y="173.46" style="fill: rgb(0,0,0); fill-opacity: 1.0; font-family: 78bcfc3c15c0b3bc - subset of LuminSans Std Reg; font-size: 6px;" clip-path="url(#_2993957146285518clip-0)">
The problem is the font name "78bcfc3c15c0b3bc - subset of LuminSans Std Reg" that contains spaces. This leads to "font not found error" when Apache FOP generates the final PDF from the XSl/XML/SVG As you can see: Batik (above) encloses the font name in quotes, JFreeSVG does not. The problem only occurs with fonts that have such names with spaces and special characters.
Java 11, JFreeChart 1.0.15, JFreeSVG 4.0

Locked