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

List:       fop-user
Subject:    =?iso-8859-1?Q?R=E9f=2E_=3A_Can't_use_relative_path_to_fonts_metrics_file?=
From:       s-oualid () artefrance ! fr
Date:       2004-08-30 11:47:28
Message-ID: OF1475241A.B27A173B-ONC1256F00.0040429E-C1256F00.004010C6 () artefrance ! fr
[Download RAW message or body]

--=_alternative 004010ADC1256F00_=
Content-Type: text/plain; charset="us-ascii"

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

--=_alternative 004010ADC1256F00_=
Content-Type: text/html; charset="us-ascii"


<br><font size=2 face="sans-serif">I resolved it by myself ... If someone is \
interested by this workaround, here it is :</font> <br>
<br><font size=2 face="sans-serif">// 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.</font> \
<br><font size=2 face="sans-serif">org.apache.fop.configuration.Configuration.put(&quo \
t;fontBaseDir&quot;,PDFRenderer.class.getResource(&quot;/&quot;).getFile());</font> \
<br> <br><font size=2 face="sans-serif">Bye,</font>
<br>
<br><font size=2 face="sans-serif">Symon</font>
<br>
<br><font size=2 face="sans-serif">--------------------------------------------------- \
---------------------------------------------------------------------------------------------------------------</font>
 <br>
<br>
<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>
<br>
--=_alternative 004010ADC1256F00_=--


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

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