Cannot load font: failed to create Source from metrics file
Here should go questions about transforming XML with XSLT and FOP.
-
- Posts: 2
- Joined: Tue Jul 24, 2007 12:01 am
Cannot load font: failed to create Source from metrics file
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
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
-
- 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 »
You have to set the path of the folder that contains the metrics file file in the base element of the config file:mblee wrote:Note that both the metrics file and the ttf file are in the same directory as the config file
Code: Select all
<base>file:/C:/path/to/FOP/font/metrics/files/</base>
Regards,
Sorin
-
- Posts: 2
- Joined: Tue Jul 24, 2007 12:01 am
e: Cannot load font: failed to create Source from metrics fi
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>
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>
-
- 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 »
You should use:mblee wrote:<base>file://C:/Program Files/Apache Software Foundation/Tomcat 5.0.28/webapps/infoMaestro_pubfrmwrk/RWD/MBR/Issuance/resources/fop-fonts/</base>
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>
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.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>
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
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service