I resolved it by myself ... If someone is interested by this workaround, here it is :

// I just added this line in my static initializer to dinamycally set the font base directory to the directory where my app was started ... Then fop just have to use the relative path setted in the userconfig file.
org.apache.fop.configuration.Configuration.put("fontBaseDir",PDFRenderer.class.getResource("/").getFile());

Bye,

Symon

------------------------------------------------------------------------------------------------------------------------------------------------------------------


Hello,

I can't use relative path to my fonts file (xml + ttf). Even if I use the fontBaseDir property in the Configuration fop's object.

I need to do that because my app will be deployed on different platform using a single JAR file which contains all the needed fonts stuff (there is not shared server which can "host" the fonts at a single place).


Here is the way i want to access my fonts :

File userConfigFile = new File(PDFRenderer.class.getResource("/ressources/fop-config/userconfig.xml").getFile());
org.apache.fop.configuration.Configuration.put("fontBaseDir","ressources/fop-fonts/");

Then in my userconfig.xml file :

<font metrics-file="helvetica-narrow.xml" kerning="yes" embed-file="Type1Fonts/HVB_____.PFB">
        <font-triplet name="Helvetica" style="normal" weight="bold"/>
</font>

Everything is working ok when my application isn't embedded in a JAR file...

But once I launch it within a JAR (and a manifest file, which is the classical way for deploying java application here), it seems FOP have a problem to localise my custom fonts file in a relative way ! Here is the console output :

[ERROR] Failed to read a font metrics file: Invalid font metrics file: helvetica-narrow.xml (no protocol: helvetica-narrow.xml)

How can I use the class loader to load my custom fonts (this way I already can load images, config files and other resources directly embedded in my "final" jar file) ?

Sorry if this problem was already solved, I didn't find it in the archives.

Waiting for answers, I will look the source code to see how FOP loads custom fonts... :o)

Help please ! ^^

Symon

Reply via email to