Reputation: 75
I want to use a custom font (Vito-Regular.otf) for the pdf documents generated inside a java programm - using Apache FOP 2.1.
Most of the samples found on the web refer to FOP 1.0 and .ttf fonts. So this will help me at all.
My FOP user config:
<?xml version="1.0"?>
<fop version="1.0">
<renderers>
<renderer mime="application/pdf">
<fonts>
<font embed-url="file:C://Windows//Fonts//Vito-Regular.otf" kerning="yes" >
<font-triplet name="Vito" style="normal" weight="normal" />
</font>
</fonts>
</renderer>
</renderers>
Using in the template:
<fo:block-container font-size="9pt" font-family="Vito">
Will lead to use the default font (any) but not the (for me expected) Vito font:
WARNUNG: Font "Vito,normal,400" not found. Substituting with "any,normal,400".
So here are my main questions on this issue:
Any help on these questions is appreciated.
Upvotes: 1
Views: 4441
Reputation: 497
It seams an URI problem under Windows (on OSX no problem). I have solved this issue with a few a workaround.
My java code is standard
String filename = "xfop.xml";
FopFactory fopFactory = FopFactory.newInstance(new File (filename));
First
<font-base>\\<computername>\C$\Windows\Fonts</font-base>
Second, please note note that localhost does not work,
<font-base>\\127.0.0.1\Windows\fonts</font-base>
Third, I copy the fonts I need in (and this is my production solution)
<font-base>\\<server>\<share>\fonts</font-base>
Upvotes: 0
Reputation: 44813
My fop.xml is like this
<renderers>
<renderer mime="application/pdf">
<fonts>
<font embed-url="MSMINCHO.TTF" kerning="yes" sub-font="MS Mincho">
<font-triplet name="MS Mincho" style="normal" weight="normal"/>
<font-triplet name="MS Mincho" style="normal" weight="bold"/>
</font>
</fonts>
</renderer>
and my TTF
file is in the same directory as my xml
file.
So maybe you are either missing the sub-font
tag or there is a problem with the file location and/or file type.
Upvotes: 0