[prev in list] [next in list] [prev in thread] [next in thread] 

List:       fop-user
Subject:    Can't use relative path to fonts metrics file in userconfig.xml (even while
From:       s-oualid () artefrance ! fr
Date:       2004-08-30 10:31:28
Message-ID: OF8D66BFF9.1ABC608B-ONC1256F00.0037D853-C1256F00.00391BA2 () artefrance ! fr
[Download RAW message or body]

--=_alternative 00391B8EC1256F00_=
Content-Type: text/plain; charset="us-ascii"

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
--=_alternative 00391B8EC1256F00_=
Content-Type: text/html; charset="us-ascii"


<br><font size=2 face="sans-serif">Hello,</font>
<br>
<br><font size=2 face="sans-serif">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.</font> <br>
<br><font size=2 face="sans-serif">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 &quot;host&quot; the fonts at a single \
place).</font> <br>
<br>
<br><font size=2 face="sans-serif">Here is the way i want to access my fonts :</font>
<br>
<br><font size=2 face="sans-serif">File userConfigFile = new \
File(PDFRenderer.class.getResource(&quot;/ressources/fop-config/userconfig.xml&quot;).getFile());</font>
 <br><font size=2 face="sans-serif">org.apache.fop.configuration.Configuration.put(&quot;fontBaseDir&quot;,&quot;ressources/fop-fonts/&quot;);</font>
 <br>
<br><font size=2 face="sans-serif">Then in my userconfig.xml file :</font>
<br>
<br><font size=2 face="sans-serif">&lt;font \
metrics-file=&quot;helvetica-narrow.xml&quot; kerning=&quot;yes&quot; \
embed-file=&quot;Type1Fonts/HVB_____.PFB&quot;&gt;</font> <br><font size=2 \
face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; &lt;font-triplet \
name=&quot;Helvetica&quot; style=&quot;normal&quot; \
weight=&quot;bold&quot;/&gt;</font> <br><font size=2 \
face="sans-serif">&lt;/font&gt;</font> <br>
<br><font size=2 face="sans-serif">Everything is working ok when my application isn't \
embedded in a JAR file... </font> <br>
<br><font size=2 face="sans-serif">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 :</font> <br>
<br><font size=2 face="sans-serif">[ERROR] Failed to read a font metrics file: \
Invalid font metrics file: helvetica-narrow.xml (no protocol: \
helvetica-narrow.xml)</font> <br>
<br><font size=2 face="sans-serif">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 &quot;final&quot; jar file) ?</font> <br>
<br><font size=2 face="sans-serif">Sorry if this problem was already solved, I didn't \
find it in the archives. </font> <br>
<br><font size=2 face="sans-serif">Waiting for answers, I will look the source code \
to see how FOP loads custom fonts... :o)</font> <br>
<br><font size=2 face="sans-serif">Help please ! ^^</font>
<br>
<br><font size=2 face="sans-serif">Symon</font>
--=_alternative 00391B8EC1256F00_=--


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic