FOP TTFReader - Build Font Definitions


How to build font definition file with FOP? I have the font file for my favorite font in TTF format.



If you the font file in TTF format, you can build the font definition file with the FOP TTFReader program.

For example, you see "Calibri" and "Gothic" font files located in \windows\fonts folder:

   813,876 calibri.ttf
   137,568 gothic.ttf

You can run FOP TTFReader program to build the "Calibri" font definition file:

\local\fop-2.2\fop>java -cp %FOP_PATH%\build\fop.jar;
   -d \windows\calibri.ttf \fyicenter\calibri.xml

org.apache.fop.fonts.apps.TTFReader main
INFO: TTF Reader for Apache FOP 2.2

org.apache.fop.fonts.apps.TTFReader main
INFO: Parsing font...
org.apache.fop.fonts.apps.TTFReader loadTTF
INFO: Reading C:\windows\fonts\calibri.ttf...
org.apache.fop.fonts.apps.TTFReader loadTTF
INFO: Font Family: [Calibri]
org.apache.fop.fonts.apps.TTFReader constructFontXML
INFO: Creating xml font file...
org.apache.fop.fonts.apps.TTFReader main
INFO: Creating CID encoded metrics...
org.apache.fop.fonts.apps.AbstractFontReader writeFontXML
INFO: Writing xml font file calibri.xml...
org.apache.fop.fonts.apps.TTFReader main
INFO: This font contains no embedding license restrictions.
INFO: XML font metrics file successfully created.

Run FOP TTFReader program again to build the "Gothic" font definition file.

Open the \fyicenter\calibri.xml to see details of a font definition file:

<font-metrics metrics-version="2" type="TYPE0">

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


Define Your Own Font in FOP cfg.xml

FOP Missing Font Error for PDF

Managing Fonts in FOP PDF Output

⇑⇑ FAQ for FOP (Formatting Object Processor)

2018-04-12, 1755🔥, 0💬