File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes XML and Related Technologies and the fly likes fontsize in Scaled vector graphics (SVG) generated by batik Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "fontsize in Scaled vector graphics (SVG) generated by batik" Watch "fontsize in Scaled vector graphics (SVG) generated by batik" New topic
Author

fontsize in Scaled vector graphics (SVG) generated by batik

Detlef Amberg
Greenhorn

Joined: Jan 17, 2011
Posts: 3
Hi,

I generate a .svg file using batik. In this file the font size is tailored:

<g style="font-family:'Times New Roman'; font-size:30;"

The browser (firefox, chrome works ok)ignores the fontsize.

It exspects
<g style="font-family:'Times New Roman'; font-size:30px;"
i.e appending a pt or px to the fontsize.

How can I achieve this?

I now use
g.setFont(new Font("Times New Roman", Font.PLAIN, 30));

JDK 1.6.0_18, jre6, Windows

Thank you.
Cheers
Detlef
g tsuji
Ranch Hand

Joined: Jan 18, 2011
Posts: 547
    
    3
One of the remedy you can take is to embed used SVG Fonts in the SVG document. The downside is that it would inflat the document size, by what proportion depends on the ratio of size taking up by the fonts relative to the rest. Whether it is tolerable depends on the real needs.

The mechanism of embedding SVG Fonts can be read in the documentation:
http://xmlgraphics.apache.org/batik/using/svg-generator.html#Use+embedded+SVG+Fonts+in+the+generated+SVG+file

I have used the approach with positive result.
Detlef Amberg
Greenhorn

Joined: Jan 17, 2011
Posts: 3
I embedded the fonts and it did not work, either.

But I found a ad hoc solution: I used 'useCSS=false' in the generating Java script, that helped. A longer term solution is a fix in the batik-sources, that was introduced some days ago and is discussed in the batik forum.


Cheers
Detlef
g tsuji
Ranch Hand

Joined: Jan 18, 2011
Posts: 547
    
    3
>I embedded the fonts and it did not work, either.
I am not going to argue about it, just to note that I use embedded fonts for the purpose and it works as expected in that particular regard at least of rendering in firefox without unit of measure.

>But I found a ad hoc solution: I used 'useCSS=false'
I know that option. It will alter the styling attributes in the svg. As far as the rendering in firefox is concerned, it does not change its behaviour.

> A longer term solution is a fix in the batik-sources
I do not disagree. They're still arguing...
Detlef Amberg
Greenhorn

Joined: Jan 17, 2011
Posts: 3
>>>They're still arguing...

No, David Cameron provided a fix:

>>>
http://mcc.id.au/batik-nightly/
Ensure font-size is serialized with "px" units by SVGGraphics2D. (This will
be the case regardless of 'useCss', even though it is only needed for
'useCss = true'.)
Fixes bug 50100.
<<<

But i's not yet in the released version, sure.

Cheers
Detlef

g tsuji
Ranch Hand

Joined: Jan 18, 2011
Posts: 547
    
    3
Good to have it standby. But their statement:
>Ensure font-size is serialized with "px" units by SVGGraphics2D. (This will
be the case regardless of 'useCss', even though it is only needed for
'useCss = true'.)

if read between the lines, is the accurate. I don't think useCss=false would do without as it seems to imply or as your previous reply seems to!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: fontsize in Scaled vector graphics (SVG) generated by batik