Configuring fonts for Apache FOP

Fonts can be configured for Apache FOP using a fop.xconf configuration file.

A fop.xconf configuration file has been created and configured.

You want to configure Apache FOP to use one or more custom fonts in your PDF output.

  1. Copy your custom font files to a folder of your choice.
    Note: Refer to the documentation on the Apache FOP web site for the list of supported font types.
  2. Open the fop.xconf configuration file for editing.
    1. Set the <font-base> to the folder where your font files are located.
      Note: The value of the <font-base> is an absolute URI that will be used to resolve any relative paths to your font files. Any type of URI can be used including file:/, classpath:/, site://sitename/.
      Important: Spaces and non US-ASCII characters must be encoded and the path must end with a / (forward slash).
    2. Add one or more font elements with the required options.
      Refer to the documentation on the Apache FOP web site for detailed information about the font configuration options.
        <font metrics-url="arial.xml" kerning="yes" embed-url="arial.ttf">
          <font-triplet name="Arial" style="normal" weight="normal"/>
          <font-triplet name="ArialMT" style="normal" weight="normal"/>
        <font metrics-url="arialb.xml" kerning="yes" embed-url="arialb.ttf">
          <font-triplet name="Arial" style="normal" weight="bold"/>
          <font-triplet name="ArialMT" style="normal" weight="bold"/>
      Note: The paths in the embed-url and metrics-url are relative to the <font-base>.
      Note: The name attribute on the <font-triplet> elements correspond to the <font-face> element values defined in your pdf2 (FO plugin) font-mappings.xml file.
The custom fonts should now be used in your PDF output.