Define Your Own Font in FOP cfg.xml


How to provide my own font definitions for FOP to generate PDF files? I have my font definition created in an XML file.



If you have your font definition files generated as shown in the previous tutorial, you can provide them to FOP command through a configuration XML file.

First, build the configuration XML file, cfg-font.xml, as shown below:

<?xml version="1.0"?>
<!-- cfg-font.xml
     Copyright (c) 2018
<fop version="1.0">
    <renderer mime="application/pdf">
        <font metrics-url="\fyicenter\calibri.xml" kerning="no" 
          <font-triplet name="Calibri" style="normal" weight="normal"/>
        <font metrics-url="\fyicenter\gothic.xml" kerning="no" 
          <font-triplet name="Gothic" style="normal" weight="normal"/>

Generate the PDF output from again with the above configuration file. You see no more missing font error:

\local\fop-2.2\fop>fop \fyicenter\ \temp\missing-font.pdf
   -c \fyicenter\cfg-font.xml processEvent
INFO: Rendered page #1.

Open the PDF output file, missing-font.pdf in Acrobat Reader and check the font properties, you will see your own fonts are embedded in the PDF:
FOP Missing Font Embedded in PDF

This tutorial is valid in FOP 2.2, 2.1, and 2.0.


FOP Missing Italic and Bold Fonts for PDF

FOP TTFReader - Build Font Definitions

Managing Fonts in FOP PDF Output

⇑⇑ FAQ for FOP (Formatting Object Processor)

2018-04-12, 134👍, 0💬