W3C home > Mailing lists > Public > www-xsl-fo@w3.org > December 2008

Re: Fonts in Linux environment

From: Jeremias Maerki <dev@jeremias-maerki.ch>
Date: Tue, 02 Dec 2008 20:28:02 +0100
To: www-xsl-fo@w3.org
Message-Id: <20081202201641.7F4F.60BA733C@jeremias-maerki.ch>

On 02.12.2008 19:56:11 Ashish Baijal wrote:
> Hi
> 
> I am creating a PDF in my application using XSL:FO
> 
> Following are working perfectly in Windows server but when I deploy in linux
> environment, the generation fails.
> 
> FOP Version : 0.95
> 
> *Config file *
> <fonts>
>  <!-- Windows Dev environment configuration
>           <font metrics-url="/Arial.xml" kerning="yes"
> embed-url="file:///C:/WINDOWS/Fonts/arial.ttf">
>           <font-triplet name="Arial" style="normal" weight="normal"/>
>           <font-triplet name="ArialMT" style="normal" weight="normal"/>
>           <font-triplet name="arial" style="normal" weight="normal"/>
>         </font>
>        <font metrics-url="/ArialB.xml" kerning="yes"
> embed-url="file:///C:/WINDOWS/Fonts/arialbd.ttf">
>           <font-triplet name="Arial" style="normal" weight="bold"/>
>           <font-triplet name="ArialMT" style="normal" weight="bold"/>
>           <font-triplet name="arial" style="normal" weight="bold"/>
>         </font>     -->
> <!-- UAT Configuration        -->
>    <font metrics-url="/Arial.xml" kerning="yes"

Is that your intention to have Arial.xml in the root of the Unix file
tree? Maybe that's your mistake?

BTW, with FOP 0.95 you don't need to create XML font metrics files
anymore. You can simply do this:

<font embed-url="/usr/openwin/lib/X11/fonts/TrueType/Arial.ttf">
  <font-triplet name="Arial" style="normal" weight="normal"/>
  <font-triplet name="ArialMT" style="normal" weight="normal"/>
  <font-triplet name="arial" style="normal" weight="normal"/>
</font>

or even skip all the individual font registrations and use:

<auto-detect/>

as explained here:
http://xmlgraphics.apache.org/fop/0.95/fonts.html#custom

> embed-url="/usr/openwin/lib/X11/fonts/TrueType/Arial.ttf">
>           <font-triplet name="Arial" style="normal" weight="normal"/>
>           <font-triplet name="ArialMT" style="normal" weight="normal"/>
>           <font-triplet name="arial" style="normal" weight="normal"/>
>         </font>
>        <font metrics-url="/ArialB.xml" kerning="yes"
> embed-url="/usr/openwin/lib/X11/fonts/TrueType/Arial-Bold.ttf">
>           <font-triplet name="Arial" style="normal" weight="bold"/>
>           <font-triplet name="ArialMT" style="normal" weight="bold"/>
>           <font-triplet name="arial" style="normal" weight="bold"/>
>        </font>
>        <auto-detect/>
>       </fonts>
> 
> *In XSL file*
> For Normal display
>                             <fo:block xsl:use-attribute-sets="Arial11"
> xmlns:st1="urn:schemas-microsoft-com:office:smarttags">
>                                 <fo:leader/>
>                             </fo:block>
> For Bold Display
> 
>                             <fo:block xsl:use-attribute-sets="Arial11"
> font-weight="bold" xmlns:st1="urn:schemas-microsoft-com:office:smarttags">
>                                 <fo:leader/>
>                             </fo:block>
> 
>   <xsl:attribute-set name="Arial11" >
>       <xsl:attribute name="font-size">0.95em</xsl:attribute>
>       <xsl:attribute name="font-family">Arial</xsl:attribute>
>       <xsl:attribute name="display-align">center</xsl:attribute>
>       <xsl:attribute name="language">EN-US</xsl:attribute>
>   </xsl:attribute-set>
> *
> On Console*
> 
> [2008-12-02 12:23:01,915] [pool-1-thread-12] ERROR FopDocumentRenderSystem -
> javax.xml.transform.TransformerException: org.xml.sax.SAXException:
> Mismatch: page-sequence (http://www.w3.org/1999/XSL/Format) vs. root (
> http://www.w3.org/1999/XSL/Format)
> Exception in thread "pool-1-thread-12"
> com.marsh.itg.ddeepa.services.contract.bobject.exception.LogicExecutionException:
> org.xml.sax.SAXException: Mismatch: page-sequence (
> http://www.w3.org/1999/XSL/Format) vs. root (
> http://www.w3.org/1999/XSL/Format)
>         at
> com..blogic.document.utils.FopDocumentRenderSystem.renderDocument(FopDocumentRenderSystem.java:164)
>         at
> com..blogic.document.utils.RenderSystemDocumentRenderer$RenderSystemInputStreamProvider$1.run(RenderSystemDocumentRenderer.java:75)
>         at
> java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:650)
>         at
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:675)
>         at java.lang.Thread.run(Thread.java:595)

For this error, the following FAQ entry might help:
http://xmlgraphics.apache.org/fop/faq.html#saxexception-mismatch

> Metrics URL is created using the following command
> 
> java -cp
> ./fop-0.95-1.jar:./xmlgraphics-commons-1.3.1.jar:commons-logging-1.0.4.jar:./commons-io-1.3.1.jar
> org.apache.fop.fonts.apps.TTFReader  -enc ansi
> /usr/openwin/lib/X11/fonts/TrueType/Arial.ttf Arial.xml
> 
> I tried to generate the file using with and without the -enc option. On
> windows I found that only the file created with -enc works. Without the
> option I get font error when PDF is generated on Windows and only dots
> appear.

Since you're on FOP 0.95 I'd really avoid TTFReader. It just makes the
stuff more complicated than necessary.

> The autodetect feature loads all the fonts but substitute with "any" before
> displaying.

Some things to check:
- Are you sure that the configuration file has the right format (I've
only seen a snippet above)?
- And is the configuration file properly given to FOP?
- Do you have an older FOP still in the classpath?

> Please help me with this issue. I have spent hours on it without any
> success.
> 
> Thanks
> 
> Regards
> Ashish Baijal

BTW, for FOP-specific support it's a good idea to use the
FOP Users Mailing List:
http://xmlgraphics.apache.org/fop/maillist.html#fop-user

HTH

Best regards,
Jeremias Märki
_________________________________________________________
Jeremias Märki, Software-Development and Consulting
Contact Information: http://www.jeremias-maerki.ch/contact.html
Blog: http://www.jeremias-maerki.ch/blog/
Received on Tuesday, 2 December 2008 19:28:37 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 2 December 2008 19:28:37 GMT