Cannot load font: failed to create Source from metrics file

Here should go questions about transforming XML with XSLT and FOP.
mblee
Posts: 2
Joined: Tue Jul 24, 2007 12:01 am

Cannot load font: failed to create Source from metrics file

Post by mblee »

Hello FOP Users,

I am new to using FOP and have been encountering this problem, hopefully some of you gurus out there can shed some light.

Currently I am using FOP 0.93, attempting to use the Arial font on some of my fo:blocks.

I followed the instructions on the Apache FOP site on how to set up the configuration file, and here's a snippet within my pdf renderer. Note that both the metrics file and the ttf file are in the same directory as the config file:

<font metrics-url="arial.ttf.xml" kerning="yes" embed-url="ARIAL.TTF">
<font-triplet name="Arial" style="normal" weight="normal"/>
<font-triplet name="ArialMT" style="normal" weight="normal"/>
</font>

<font metrics-url="ARIALUNI.TTF.xml" kerning="yes" embed-url="ARIALUNI.TTF">
<font-triplet name="Arial" style="normal" weight="normal"/>
<font-triplet name="ArialMT" style="normal" weight="normal"/>
</font>


I get the following error when I attempt to render a pdf:

org.xml.sax.SAXException: Cannot load font: failed to create Source from metrics file ARIALUNI.TTF.xml

I generated my metrics file with the following command:

java -cp fop-0.93.jar;avalon-framework-api-4.3.jar;commons-logging-1.0.4.jar;commons-io-1.2.jar org.apache.fop.fonts.apps.TTFReader -fn Arial ArialUni.ttf ArialUni.ttf.xml

Any help is greatly appreciated.

-Betty
sorin_ristache
Posts: 4141
Joined: Fri Mar 28, 2003 2:12 pm

Re: Cannot load font: failed to create Source from metrics f

Post by sorin_ristache »

mblee wrote:Note that both the metrics file and the ttf file are in the same directory as the config file
You have to set the path of the folder that contains the metrics file file in the base element of the config file:

Code: Select all


  <base>file:/C:/path/to/FOP/font/metrics/files/</base>

Regards,
Sorin
mblee
Posts: 2
Joined: Tue Jul 24, 2007 12:01 am

e: Cannot load font: failed to create Source from metrics fi

Post by mblee »

Hello Sorin, thank you so much for your quick reply.

Currently my <base> is set to the current directly, by being set <base>.</base>.

I attempted your suggestion and gave it an absolute path, but I still get the same result. I'd appreciate any additional ideas. I have also posted a more complete portion of my config file:

<fop version="1.0">

<base>file://C:/Program Files/Apache Software Foundation/Tomcat 5.0.28/webapps/infoMaestro_pubfrmwrk/RWD/MBR/Issuance/resources/fop-fonts/</base>

<source-resolution>72</source-resolution>
<target-resolution>72</target-resolution>

<default-page-settings height="11in" width="8.26in"/>

<renderers>
<renderer mime="application/pdf">
<filterList>
<value>flate</value>
</filterList>

<fonts>
<font metrics-url="arial.ttf.xml" kerning="yes" embed-url="ARIAL.TTF">
<font-triplet name="Arial" style="normal" weight="normal"/>
<font-triplet name="ArialMT" style="normal" weight="normal"/>
</font>

<font metrics-url="ARIALUNI.TTF.xml" kerning="yes" embed-url="ARIALUNI.TTF">
<font-triplet name="Arial" style="normal" weight="normal"/>
<font-triplet name="ArialMT" style="normal" weight="normal"/>
</font>

</fonts>

</renderer>
sorin_ristache
Posts: 4141
Joined: Fri Mar 28, 2003 2:12 pm

Re: e: Cannot load font: failed to create Source from metric

Post by sorin_ristache »

mblee wrote:<base>file://C:/Program Files/Apache Software Foundation/Tomcat 5.0.28/webapps/infoMaestro_pubfrmwrk/RWD/MBR/Issuance/resources/fop-fonts/</base>
You should use:

Code: Select all

<base>file:/C:/Program%20Files/Apache%20Software%20Foundation/Tomcat%205.0.28/webapps/infoMaestro_pubfrmwrk/RWD/MBR/Issuance/resources/fop-fonts/</base>
mblee wrote:<fonts>
<font metrics-url="arial.ttf.xml" kerning="yes" embed-url="ARIAL.TTF">
<font-triplet name="Arial" style="normal" weight="normal"/>
<font-triplet name="ArialMT" style="normal" weight="normal"/>
</font>

<font metrics-url="ARIALUNI.TTF.xml" kerning="yes" embed-url="ARIALUNI.TTF">
<font-triplet name="Arial" style="normal" weight="normal"/>
<font-triplet name="ArialMT" style="normal" weight="normal"/>
</font>

</fonts>
You should not define the same FOP font name (Arial, ArialMT) with the same style (normal) and the same weight (normal) two times. You should use the same FOP name only if you define also the bold or italic variant of the normal font.

How do you set the Arial font in the FO file? If it is a DocBook or TEI transformation did you apply the procedure specified in the article available on our Documentation page?


Regards,
Sorin
Post Reply