Table of contents

Abstract

A box of beautifully enticing promise

The extended analogy

The story on PDF files and fonts

Configuring the DITA Open Toolkit build file for FOP

Defining fonts in the FOP configuration file

XSL-FO stylesheets and FOP-registered fonts

Defining fonts in the FOP configuration file

The description of fonts in the FOP configuration file is documented in the FOP fonts page. The remaining discussions in this document assume that you have read that page and have familiarized yourself with the concepts and procedures on it.

Automated font registration

Font registration is the process by which FOP reads information about fonts so it can describe the fonts properly as it creates PDF. The information FOP needs about a font are stored in the font name, font weight, and font style attributes. These values are referred to as the font-triplet. FOP also needs to know the location of the font file and, if a font metrics file is needed, the location of the font metrics file.

Automated registration of fonts makes it difficult for you to reference the fonts accurately, so this method is not recommended.

Creating font metrics files (not needed for FOP 0.94 and later)

In FOP 0.94 and later, you do not need to supply metrics files to register fonts in most cases. For FOP 0.94 and later, you can skip to the next section, Individual registration of fonts.

The instructions on the Apache web page are a little sketchy on this part of the installation. For example, to create the metrics files, you are instructed to run the PFMReader for Type 1 fonts and the TTFReader for TrueType fonts using a command line for the PFMReader. The example command line shown on the Apache web site is not exactly right.

I found that I had to list all (or almost all) of the .jar files in the fop/lib directory in the -cp value for this command line rather than just the few specified by the web site. Also, the names of the .jar files shown in the example are generic names. The real names include the version numbers of the jar files.

The Apache instructions assume that you are running the command line from the fop directory.

Once I made these adjustments, my command line for generating the Palatino Linotype metrics file was as follows:

java -cp "build/fop.jar;lib/avalon-framework-4.2.0.jar;lib/commons-logging-1.0.4.jar;lib/commons-io-1.3.1.jar;lib/serializer-2.7.0.jar;lib/xmlgraphics-commons-1.3.1.jar" org.apache.fop.fonts.apps.TTFReader C:/Windows/Fonts/pala.ttf C:/fontmetrics/ttfpala.xml

In this example, the command reads the font file located at C:/Windows/Fonts/pala.ttf and creates a font metrics file at C:/fontmetrics/ttfpala.xml.

Individual registration of fonts

To register a font in the FOP configuration file, you use multiple <font> elements inside the <fonts> element, as instructed on the Apache web site. In addition to the information on the Apache web site, there are a couple of other points to consider:

 

Next Page:
XSL-FO stylesheets and FOP-registered fonts


Scriptorium Publishing | Post Office Box 12761 Research Triangle Park, NC 27709 | (919) 481 2701 | info@scriptorium.com