Setting up fonts for FOP
Posted by mholmes on 15 Mar 2013 in Activity log
I'm now trying to get the Gentium Plus font working with FOP, to handle our non-ascii characters. It is possible to use the "simple method", which involves giving the FOP processor a special config file telling it to parse the system fonts to find the font it needs. However, because I want to be able to make PDF generation a part of the portable webapp, I need to do it in the "hard" way as well, so I've started figuring it out.
The process is confusing, because FOP behaviour has changed. It seems to involve three steps:
- Generate a font metrics file for each font you want to use. This was quite hard, because I was trying to follow these instructions, which are out of date, as I reported to the Oxygen forum here; this is what I eventually had to do, at the command line:
java -cp lib/fop.jar:lib/avalon--framework-4.2.0.jar:lib/xercesImpl.jar:lib/commons-logging-1.1.1.jar:lib/commons-io-1.3.1.jar:lib/xmlgraphics-commons-1.5.jar:lib/xml-apis.jar org.apache.fop.fonts.apps.TTFReader /usr/share/fonts/truetype/gentium-plus/GentiumPlus-R.ttf GentiumPlus-R.xml java -cp lib/fop.jar:lib/avalon--framework-4.2.0.jar:lib/xercesImpl.jar:lib/commons-logging-1.1.1.jar:lib/commons-io-1.3.1.jar:lib/xmlgraphics-commons-1.5.jar:lib/xml-apis.jar org.apache.fop.fonts.apps.TTFReader /usr/share/fonts/truetype/gentium-plus/GentiumPlus-I.ttf GentiumPlus-I.xml
- Creating a FOP configuration file which tells it where the fonts are.
- Calling FOP and pointing it at that configuration file.
Still working on the second and third steps...