Using new fonts with Apache FOP in Java

I have to internationalize the application and therefore must allow the user to select the font for the PDF that I will create at runtime. I want to be able to display a list of font options from a user system using

GraphicsEnvironment.getLocalGraphicsEnvironment().getAllFonts(); 

This is great for getting fonts, but then it seems like I need to jump over some hoops to get this font to play well with FOP, as described here . I can follow all the instructions that they set out, except that I'm not sure how to get the font layout for TTFReader to start.

  • Does anyone know how to specify the path of each font that java is compiling with the getAllFonts () command?
  • Can I embed fonts in PDF files? For example, the Arial Unicode MS TFF file is ~ 30 MB.
  • Is this the only way to create internationalized pdf files with FOP and XSL?
+6
java xslt pdf fop
source share
1 answer

The latest version (FOP 0.95) made significant improvements in font settings, so please just consult the document there for a simpler approach: http://xmlgraphics.apache.org/fop/0.95/fonts.html#basics

XML font metric files are no longer needed.

To your questions:

  • It's impossible. Java will not give you this information. This is partly because FOP has its own font subsystem.
  • Yes, it is really recommended. Note that FOP supports a subset of fonts, so only glyphs embedded in it are embedded in PDF.
  • Not sure what you mean. With the above information and updating to the latest version should be quite simple.
+7
source share

All Articles