Embedding Fonts

Depending on what fonts readers have available on their local computer, fonts used in your PDF will be seen as you intended it to be seen, or the computer may substitute fonts. Substitution can result in significant differences between your intended output and what the reader will see.

Embedding fonts prevents font substitution. This ensures that text is displayed and printed in its original font.

True Type Fonts

Offer-Ready supports embedding of True Type fonts, which have a “ttf” file extension.

Create a directory “fonts” in the root directory of your configuration. Within this “fonts” directory, there is

  • an overall fonts configuration file called “apache-fop-config.xml”.

  • A TTF file for each font refered to in the apache-fop-config.xml. For example: “HelveticaNeue-Light.ttf”.

The “apache-fop-config.xml” declares the ttf fonts in the fop processor:

<fop>
    <renderers>
        <renderer mime="application/pdf">
            <fonts>
                <!-- zero or many font tags -->
                <font kerning="yes" embed-url="the-name-of-the-ttf-file.ttf">
                      <font-triplet name="Font Name as used in your XSL Template" style="normal" weight="normal">
                </font>
            </fonts>
        </renderer>
    </renderers>
</fop>

How-to use your embedded fonts in XSL-FO

On developing your XSL-FO template, use the (embedded) font-triplet name as if it were available on your local computer. Technically your XSL-FO file may contain any font-name with any font-style and font-weight. The behaviour of a common PDF reader will be:

  1. If a font-name/font-style/font-weight triplet used in the PDF is available as an embedded font-triplet, than this will be used.

  2. If a font-name/font-style/font-weight triplet used in the PDF is not available as an embedded font-triplet, but on the local computer, than the font from the local computer will be used.

  3. If both previous options do not apply, the PDF reader will substitute that font by some other font.

Beware of these “traps”:

  • If your PDF for example does not show a text in bold letters, although your intention was to use bold letters, than you maybe have defined the font-triplet for “weight=normal”, but not also for “weight=bold”. You need to declare all required combinations of name/style/weight.

  • If your local computer has a font “Helvetica Neue”, and your font-triplet name is “HelveticaNeue” (without a blank), than you must use “HelveticaNeue” in your XSL-FO. A WYSIWYG editor (like Altova Stylevision) likely will offer local fonts only in a dropdown.

  • The preview of your PDF in a local development environment may look different than the PDF generated by Offer-Ready. The fonts used by the local development environment will use fonts on your computer, and not fonts checked in in the above structure.

Third Party License Constraints

Using a font may require a licence

It is your responsibility to respect license constraints. While many fonts can be used without restrictions, other fonts for example might require to pay a license fee.

Last updated