Apache FOP and Arial font

2019-05-16 08:16发布

问题:

My XSL style uses Arial font

<fo:block font-family="Arial" font-size="8pt" font-weight="normal"> 

Configuration file fonts.xml:

<?xml version="1.0"?>
<fop>
  <renderers>
    <renderer mime="application/pdf">
      <fonts>   
        <base>file:///C:/windows/fonts</base>
      </fonts>
    </renderer>
  </renderers>
</fop> 

also tried using this:

 <auto-detect/>

and

 <directory>C:\windows\fonts</directory>

I am always getting:

WARNING: Font "Arial,normal,400" not found. Substituting with "any,normal,400".

What should I fix in order to use Arial font?

回答1:

This worked for me, need to specify the Arial font explicitly in configuration file:

<?xml version="1.0"?>
    <fop>
      <renderers>
        <renderer mime="application/pdf">       
          <fonts>                           
                <font kerning="yes"  embed-url="file:///C:/windows/fonts/arial.ttf">
                      <font-triplet name="Arial" style="normal" weight="normal"/>
                    </font>                     
            </fonts>
        </renderer>
      </renderers>     
</fop>