Many thanks Sergiu!
I solved this. My comments are inline.
Even the FOP developers say that generating font
metrics is not needed,
and deprecated. FOP should correctly find and use system fonts, and
should correctly work with TTF fonts.
I checked this and that's correct.
The problem is that FOP doesn't
find the fonts provided by XWiki because Tomcat doesn't use an URI
scheme that FOP understands. You can extract
WEB-INF/lib/xwiki-core-XYZ.java#fop-config.xml into WEB-INF/classes and
adjust the <fonts> settings so that you manually specify the path to the
right font files. The syntax for the config xml should be on the FOP site.
Copied Courier_New.ttf and Times_New_Roman.ttf
into ../webapps/xwiki/WEB-INF/fonts
Added following lines to
the ../webapps/xwiki/WEB-INF/classes/fop-config.xml
<fonts>
...
<!-- /webapps is symlink to /var/lib/tomcat5.5/webapps/ -->
<font kerning="yes"
embed-url="/webapps/xwiki/WEB-INF/fonts/Courier_New.ttf">
<font-triplet name="Courier New" style="normal"
weight="normal"/>
</font>
<font kerning="yes"
embed-url="/webapps/xwiki/WEB-INF/fonts/Times_New_Roman.ttf">
<font-triplet name="Times New Roman" style="normal"
weight="normal"/>
</font>
...
</fonts>
Extract xhtml2fo.xsl from
WEB-INF/lib/xwiki-core-XYZ.jar into
WEB-INF/classes and search for the line:
<xsl:attribute name="font-family">FreeSerif,serif</xsl:attribute>
Changed FreeSerif,serif to Times New Roman and FreeMono,monospace to Courier New
Ran PDF export, got
exception ... /usr/share/tomcat5.5/.fop/fop-fonts.cache (No such file or
directory)...
mkdir /usr/share/tomcat5.5/.fop/
chown tomcat5:root /usr/share/tomcat5.5/.fop/
chmod 775 /usr/share/tomcat5.5/.fop/
restarted tomcat
and viola!
It is working now!
Valdis