PDF Fonts
How the formatter and PDF Viewer use fonts
The formatter (for example, FOP) creates the PDF and the PDF Viewer (typically Adobe's Adobe Reader) reads it.
In order to lay out the PDF, the formatter needs to know details about the fonts used in the document, particularly the widths of all the glyphs used. It needs this information to calculate line lengths, hyphenation, justification, etc. This information is known as the metrics of the font, and it is stored with each font. Some formatters can read the metrics directly from the system's font folder. Others (such as FOP) need the metrics in a special format it can understand. When the metrics of a font are available to the formatter, the formatter can successfully lay out the PDF. You must ensure that the font metrics files of all the fonts you use in your document are available to the formatter you are using.
The formatter can either reference a font or embed it in the PDF file. If the font is referenced, then the PDF Viewer (for example, Adobe Reader) typically will look for that font in its own font resource folder (which contains the Base 14 fonts) first, and then in the system's font folder. If the font is available, it will be used when the PDF is displayed. Otherwise the Viewer will use an alternative from its resource folder or generate an error. An alternative font may have different metrics and could therefore generate display errors.
If the formatter embeds a font in the PDF file, then the PDF Viewer uses the embedded font. The formatter may embed the entire character set of a font or only a subset that contains the glyphs used in the document. This factor affects the size of the PDF file and, possibly, copyright issues surrounding font use (see note below). You might be able to influence the choice between these two options when you set the options for your formatter.
XMLSpy and PDF fonts
In XMLSpy, a PDF is generated from an XSL-FO document (from now on FO document) by processing the XSL-FO document with an external FO processor such as FOP. (In the Options dialog, you can specify the location of the FO processor. This allows the FO processing to be started from within the XMLSpy GUI.)
The XSL-FO document itself is generated by processing an XML document with an XSLT stylesheet. (You can use either Altova's XSLT engine (which is built into XMLSpy) or an external XSLT engine to do this.)
The formatting for the PDF document, including the font properties of all text, is specified in the XSL-FO document. If the formatter you are using can read the metrics of the required font directly from the font, then all you need to do is to set up the formatter to access the font. If, however, you are using FOP as your formatter, you will need to provide it with the correct font metrics files for fonts other than the Base-14 fonts.
Making fonts available to the formatter
Most formatters (including FOP) already have available to them the Base 14 fonts. It is important to know the names by which the formatter recognizes these fonts so that you correctly indicate them to the formatter. This is the basic font support provided by formatters. You can, however, increase the number of fonts available to the formatter by carrying out a few straightforward steps specific to the formatter you are using. The steps for FOP are given below.
General procedure for setting up additional font support in FOP
To make additional fonts available to FOP, you would need to do the following:
1.Generate a font metrics file for the required font from the PostScript or TrueType font files. FOP provides PFM Reader and TTF Reader utilities to convert PostScript and TrueType fonts, respectively, to XML font metrics file. For details of how to do this, see the FOP: Fonts page.
2.Set up the FOP configuration file to use the required font metrics files. You do this by entering information about the font files in an FOP configuration file. See FOP: Fonts.
3.In the file fop.bat, change the last line:
"%JAVACMD%" […] org.apache.fop.cli.Main %FOP_CMD_LINE_ARGS%
to include the location of the configuration file:
"%JAVACMD%" […] org.apache.fop.cli.Main %FOP_CMD_LINE_ARGS% -c conf\fop.xconf
After the metrics files are registered with FOP (in a FOP configuration file) and the FOP executable is set to read the configuration file, the additional fonts are available for PDF creation.
Setting up the FOP configuration file
The FOP configuration file is called fop.xconf and is located in the conf folder in the FOP installation folder. This file, which is an XML document, must be edited so that FOP reads the font metrics files correctly. For each font that you wish to have FOP render, add a font element at the location indicated by the font-element placeholder in the document:
<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>
In the example above,
arial.xml | is the URL of the metrics file; it is best to use an absolute path. |
arial.ttf | is the name of the TTF file (usually located in %WINDIR%\Fonts). |
Arial | specifies that the above metrics and TTF files will be used if the font-family is defined as Arial. |
style="normal" | specifies that the above metrics and TTF files will be used if the font-style is defined as normal (not, say, italic). |
weight="normal" | specifies that the above metrics and TTF files will be used if the font-weight is defined as normal (not, say, bold). |
Note on font copyrights: Font usage is subject to copyright laws, and the conditions for use vary. Before embedding a font—especially if you are embedding the entire font—make sure that you are allowed to do so under the license you have purchased for that font.
Character sets
Note that the character sets of fonts differ from each other. The Base 14 fonts cover the ISO-8859-1 characters plus the glyphs in the Symbol and Zapf Dingbats fonts. If your document contains a character that is not covered by the Base 14 fonts, then you will have to use a font that contains this character in its character set. Some fonts, such as Arial Unicode, offer the characters covered by Unicode.