tags:

views:

285

answers:

1

I have to internationalize an application, and therefore have to let a user chose a font for a PDF that I will create at runtime. I want to be able to display a list of font choices from the user's system using

GraphicsEnvironment.getLocalGraphicsEnvironment().getAllFonts();

This works fine for getting fonts, but then it seems that I have to jump through some hoops to get that font to play nice with FOP, as outlined here. I can follow all the instructions that they've outlined, except I'm not sure how to get the location of fonts in order to run TTFReader.

  1. Does anyone know how to list the path of each font that java gathers with the getAllFonts() command?
  2. Is it a good idea to embed fonts in PDFs? For instance the Arial Unicode MS TFF file is ~ 30 MB.
  3. Is this the only way to create internationalized pdfs with FOP and XSL?
+2  A: 

There have been major improvements in font configuration with the last release (FOP 0.95), so please just consult the document there for a much easier approach: http://xmlgraphics.apache.org/fop/0.95/fonts.html#basics

The XML font metrics files are no longer necessary.

To your questions: 1. That's impossible. Java won't give you that information. That's partly why FOP has its own font subsystem. 2. Yes, it's actually recommended. Please note that FOP supports font subsetting so only the glyphs needed are embedded in the PDF. 3. Not sure what you mean. With the above information and an upgrade to the latest release should make this simple enough.

Jeremias Märki
The website, you posted worked perfectly, and embedded the font correctly. However, it doesn't display all characters correctly. I'm using Arial Unicode MS (which has glyphs for most unicode characters), and I'm trying to render a random Chinese character, 丞, even though that's supported in Arial Unicode MS, and the font of the PDF is Arial Unicode MS (which I've verified is embedded), it renders it as ä¸ Any ideas?
Jon