Fonts

Viewer Fonts

The Xinc viewer supports all of the fonts which are available to the Java Runtime you are using. This includes the standard, Sun provided, java fonts as well as TrueType fonts.

PDF Fonts

The Xinc PDF renderer supports the following fonts:

No special configuration is necessary to use the Adobe Base14 fonts. Type1 and TrueType fonts require some extra configruation steps before they can be used. Examples of the steps required are shown below.

IMPORTANT NOTE!

If you are going to change the configuration file as described below, you must restart the viewer before your changes will take effect.

Configuring Adobe Type 1 fonts

In order to use a Type 1 font with Xinc, you need to have a font metrics file, it should have a .pfm extension, and, if you are embedding the font in the PDF file, the font data file (which should have a .pfb extension.)

You also need to have a font metrics file which is in the Apache Fop xml format. These font metrics files are created with an Apache utility called pfmreader. A batch file to invoke this utiltity is included in your install directory at <installDir>/bin/windows/pfmreader.bat. The rest of this example assumes that your path is set to include the <installDir>/bin/windows directory. It is usually necessary to create multiple font metrics files per font.

After creating the font metrics files, you need to let Xinc know where they are located. You will need to do this by editing .xincconfig.xml. It is located in your User home directory. On most Windows systems that directory will be something like: "c:\Documents and Settings\John". You may wish to look at the sample configuration provided in <installDir>/config/SampleXincConfig.xml.

Assuming that the Type 1 font information is located in /tmp/psfonts, the following commands will build the required files in /tmp/fonts:

call pfmreader /tmp/psfonts/pfm/mtbi____.pfm /tmp/fonts/mtbi____.xml
call pfmreader /tmp/psfonts/pfm/mtb_____.pfm /tmp/fonts/mtb_____.xml
call pfmreader /tmp/psfonts/pfm/mti_____.pfm /tmp/fonts/mti_____.xml
call pfmreader /tmp/psfonts/pfm/mtr_____.pfm /tmp/fonts/mtr_____.xml
copy \tmp\psfonts\mtbi____.pfb \tmp\fonts
copy \tmp\psfonts\mtb_____.pfb \tmp\fonts
copy \tmp\psfonts\mti_____.pfb \tmp\fonts
copy \tmp\psfonts\mtr_____.pfb \tmp\fonts

Now add the following lines to the <fonts> element in .xincconfig.xml:

<font metrics-url="file:///tmp/fonts/mtbi____.xml" kerning="no" embed-url="file:///tmp/fonts/mtbi____.PFB">
<font-triplet style="italic" name="TimesNewRomanTest" weight="bold" />
</font>
<font metrics-url="file:///tmp/fonts/mtb_____.xml" kerning="no" embed-url="file:///tmp/fonts/mtb_____.PFB">
<font-triplet style="normal" name="TimesNewRomanTest" weight="bold" />
</font>
<font metrics-url="file:///tmp/fonts/mti_____.xml" kerning="no" embed-url="file:///tmp/fonts/mti_____.PFB">
<font-triplet style="italic" name="TimesNewRomanTest" weight="normal" />
</font>
<font metrics-url="file:///tmp/fonts/mtr_____.xml" kerning="no" embed-url="file:///tmp/fonts/mtr_____.PFB">
<font-triplet style="normal" name="TimesNewRomanTest" weight="normal" />
</font>

You should be abe to use the newly configured font by specifying the font-family="TimesNewRomanTest" attribute in your XSL-FO file.

Configuring TrueType fonts

Configuring a TrueType font is quite similar to configuring a Type 1 font. The primary difference is that you need to use ttfreader instead of pfmreader. Assuming that we want to use the Verdana TrueType font, and the font files are located in \windows\fonts, the following commands will generate the required Apache Fop font metrics files:

rem ** Copy the Font data to \tmp\fonts.
rem ** This isn't really necessary, but it keeps
rem ** everything in one place...

copy \windows\fonts\Verdana*.ttf \tmp\fonts
rem ** 'Normal'
call ttfreader /tmp/fonts/Verdana.ttf /tmp/fonts/Verdana.xml
rem ** 'Bold'
call ttfreader /tmp/fonts/Verdanab.ttf /tmp/fonts/Verdanab.xml
rem ** 'Italic'
call ttfreader /tmp/fonts/Verdanai.ttf /tmp/fonts/Verdanai.xml
rem ** 'Bold,Italic'
call ttfreader /tmp/fonts/Verdanaz.ttf /tmp/fonts/Verdanaz.xml

Now add the following lines to the <fonts> element in .xincconfig.xml:

<font metrics-url="file:///tmp/fonts/Verdana.xml" kerning="no" embed-url="file:///tmp//fonts/verdana.ttf">
<font-triplet style="normal" name="Verdana" weight="normal" />
</font>
<font metrics-url="file:///tmp/fonts/Verdanab.xml" kerning="no" embed-url="file:///tmp/fonts/verdanab.ttf">
<font-triplet style="normal" name="Verdana" weight="bold" />
</font>
<font metrics-url="file:///tmp/fonts/Verdanai.xml" kerning="no" embed-url="file:///tmp/fonts/verdanai.ttf">
<font-triplet style="italic" name="Verdana" weight="normal" />
</font>
<font metrics-url="file:///tmp/fonts/Verdanaz.xml" kerning="no" embed-url="file:///tmp/fonts/verdanaz.ttf">
<font-triplet style="italic" name="Verdana" weight="bold" />
</font>

You should be abe to use the newly configured font by specifying the font-family="Verdana" attribute in your XSL-FO file.