views:

277

answers:

1

Hi,

I'm having an issue with the rendering of a truetype font inside an svg being rendered to a pdf through fop.

In the final pdf the font comes out with Times New Roman instead of the truetype font I had expected.

The main font family of the document is using Type 1 fonts and are also using font metrics that I generated and these are appearing correctly. I think the truetype version of the font was added simply for the chart in the past.

The strange thing is that this was working at one stage and appears to have stopped working and I now cannot get it back working as I don't understand how it would have worked in the first place. To try and get it back working I have gone through different combinations of Java 6, Java 5 and FOP 0.95 and 0.93 and the latest FOP trunk all without success. Even with full trace enabled in the fop generation I see no mention of the font being substituted with Times New Roman but I assume this is because Batik takes responsibilty for this rendering.

I have run some sample Java code and the TrueType font seems to be correctly seen by AWT which I believe is what Batik is using.

I've also tried using font-substitions in the fop.xconf file but this didn't seem to have an effect. In the fop.xconf I have only defined the Type 1 fonts and one other True Type Font Zapfdingbats which are handled correctly in the pdf. Should I also add the other truetype font here but checking our version history it doesn't seem to have been there in the past.

Is there anything I'm missing here as I thought the batik would take the windows ttf font and render it but this doesn't seem to work. Any help would be greatly appreciated. Thanks, Crocked

+1  A: 

Take a look at the following answers made on the FOP users mailing list:

So, to make this work, you should do the following:

  • Use FOP 0.95
  • Don't work with XML font metrics files generated through TTFReader. These are no longer necessary.
  • Make sure the fonts you want to use are installed in your operating system (so Batik has access to them via AWT/Java2D) and configured for FOP (easiest way: , http://xmlgraphics.apache.org/fop/0.95/fonts.html#basics)
  • Use the right font family name of the font in SVG. The font's PostScript name won't work.
Jeremias Märki
Thanks. I'd already read both posts and was using the windows font name and had already checked if the font was found by java via that code snippet. What I was missing was the <auto-detect/> tag in my xconf. Was this added first in 0.95? Now it's working again. Thanks for your help and have a good Christmas break
Crocked