0

Im trying to generate a pdf with an XSL Stylesheet
and a XML file with a fop.bat ( I am using the 1.1 Version). Now I need to add a custom Font to my FOP but I doesnt seem to work. I just have a TTF-File of the Font and installed it already. I tried to add the Font to the Confi File but maybe I did it wrong. I tried to give the path (C:\Windows\Fonts\Trade Gothic bd.ttf) and to use the but I still cant use the font-family in the Stylesheet and it rolls back to TimesNewRoman.

       <font kerning="yes" embed-url="'C:/Windows/Fonts/Trade Gothic bd.ttf'" embedding-mode="subset">
           <font-triplet name="TradeGothic" style="normal" weight="normal"/>
   </font>

The message from the Commandline

WARNUNG: Font "TradeGothic,normal,400" not found. Substituting with "any,normal,400".
Okt 21, 2015 11:10:10 AM org.apache.fop.events.LoggingEventListener processEvent

These lines are from my Stylesheet

        <fo:block color="rgb(0,108,183)" font-family="TradeGothic" font-style="normal" font-weight="normal">
                <xs:value-of select="headdescription"/>
            </fo:block>

Can someone give me a Step by Step Introduction on how to add fonts? Or a correction of my try?

Andy96
  • 1
  • 2
  • 1
    Possible duplicate of [Apache FOP Displaying ### with SunSim](http://stackoverflow.com/questions/25895984/apache-fop-displaying-with-sunsim) – lfurini Oct 21 '15 at 09:30
  • Could it be that you are calling FOP (either from command line or from code) without telling it to use your configuration file? – lfurini Oct 21 '15 at 09:41
  • I didnt specifically told the command line to do so since its the normal config file just edited. I tried it with following : C:\Users\alisch\Desktop\xml xsl test>fop.bat -xml "C:\Users\alisch\Desktop\xml x sl test\test\xmltest.xml" -xsl "C:\Users\alisch\Desktop\xml xsl test\test\xsltes t.xsl" -pdf zpdf.pdf -c "C:\Users\alisch\Desktop\xml xsl test\conf\fop.xconf" and named the confi file but it still says the same . – Andy96 Oct 21 '15 at 09:53

1 Answers1

0

I've found a solution for my Problem!

I needed to add inside the conf file (fop.xconf) :

 <font kerning="yes" embedurl="/Users/alisch/desktop/TradeGothicbold.ttf" embedding-mode="subset">
    <font-triplet name="TradeGothic" style="normal" weight="bold"/>
    </font>
    <directory>/Users/alisch/desktop/TradeGothicbold.ttf</directory>

in between the :

 <renderer mime="application/pdf">
 <fonts>

  </fonts>
</renderer>

after that I needed to add

 -c "C:\Users\alisch\Desktop\xml xsl test\conf\fop.xconf"

to my command line and it worked !

Andy96
  • 1
  • 2
  • The `embedurl` attribute should be `embed-url` (but maybe it's just a typo); the `directory` element should point to a _directory_, not a single font file, and _if_ it is having any effect it is redundant as the same font file has been configured with the `font` element. – lfurini Oct 21 '15 at 17:31
  • Yes thanks ,you are right ! The directory was unnecessary and yes it was a typo which I had to search for a while ! – Andy96 Oct 22 '15 at 06:07