Using TrueType Fonts for StyleVision PDF Generation

The following solution and download files will enable Apache FOP users to make TrueType fonts available for PDF generation in StyleVision.

In order for StyleVision to utilize your TrueType fonts, the following prerequisites must be met:

Activating the FOP compliant option in StyleVision

You can activate this option in the Options Dialog; it is called “FOP 0.93 compliant” in StyleVision 2017.

Creating the TrueType font metrics files

A metrics file is created by calling the Java application TTFReader. TTFReader is included with Apache FOP, so if you have Apache FOP installed, TTFReader is already installed, too.

If you are proficient in calling a Java application, you can call TTFReader yourself to create the metrics file for each TrueType font. Alternatively, we have provided a set of command files below that ease this task. With these command files, you can easily create metrics files for all the TrueType fonts installed on your computer.

  1. Download the necessary command line scripts for this exercise here. (1.45 KB)
  2. Copy the GenerateMetricsFileSingle.cmd and GenerateMetricsFileAll.cmd files into the same directory that holds your FOP folder (this will be C:\Program Files\Altova for users who downloaded the FOP installer from the Altova Web site).
  3. Using a text editor, open the GenerateMetricsFileSingle.cmd file.
  4. For each .jar file referenced in GenerateMetricsFileSingle.cmd, check that the version number contained in the file name matches the version number of the corresponding file in your FOP installation folder. Modify the version number in the file name if necessary.
  5. Open a Command Prompt window and run GenerateMetricsFileAll.cmd.
  6. When the command completes, there will be a folder “C:\Font Metrics” containing a number of .xml files; these are the metrics files for the TTF fonts.

Modifying the Apache FOP configuration file

The Apache FOP configuration file is named fop.xconf and is located in the folder “conf” below the FOP installation folder. It is an XML file and contains several <font> elements that are commented out by default:

<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>

For each TTF file your PDF file will contain, add one <font> element. In each element, substitute the correct information for the font.

In the example above,

.arial.xml.is the name of the metrics file.
.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 name in StyleVision is defined as “Arial”..
.style="normal".specifies that the above metrics and TTF files will be used if the font style in StyleVision is defined as “normal” (not “italic”)..
.weight="normal".specifies that the above metrics and TTF files will be used if the font weight in StyleVision is defined as “normal” (not “bold”)..

When the configuration file is complete, it needs to be supplied with the actual call to Apache FOP. In a text editor, open the file fop.bat (located in the Apache FOP installation folder) and change the last line from

"%JAVACMD%" […] org.apache.fop.cli.Main %FOP_CMD_LINE_ARGS%

to

"%JAVACMD%" [..] org.apache.fop.cli.Main %FOP_CMD_LINE_ARGS% -c conf\fop.xconf