This week's book giveaway is in the OCAJP forum.
We're giving away four copies of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) and have Khalid A Mughal & Rolf W Rasmussen on-line!
See this thread for details.
Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

fontsize in Scaled vector graphics (SVG) generated by batik

 
Detlef Amberg
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 669
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 669
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
>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
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
>>>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
Posts: 669
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic