Using fonts

Embedding fonts in the common formats is very easy. The formats TrueType and OpenType (files .ttf and .otf) are supported.

To make fonts known and used by the publisher, two steps are necessary. The first step is to load a font file:

<LoadFontfile name="MinionRegular" filename="MinionPro-Regular.otf" />

This assigns the file name MinionPro-Regular.otf the internal name MinionRegular. In the second step, these internal names are then used to define families:

<DefineFontfamily name="textfont" fontsize="9pt" leading="11pt">
  <Regular fontface="MinionRegular"/>
  <Bold fontface="MinionBold"/>
  <Italic fontface="MinionItalic"/>
  <BoldItalic fontface="MinionBoldItalic"/>

The last three cuts (bold, italic and bold italic) do not have to be specified if they are not used in the layout. fontsize is the font height, leading is the distance between two baselines.

14 fontsize leading
Font size and line spacing

The font is used in different ways: in the commands <Textblock>, <Text>, <Paragraph>, <Table>, <NoBreak> and <Barcode>, a font can be specified with the attribute fontfamily, e.g. <Paragraph fontfamily="text font">. Temporarily you can switch to another family with the command <Fontface fontfamily="…​">:

  <Fontface fontfamily="title">
  <Value> more text</Value>

Text markup in the layout rules

There are several ways to switch to the cuts bold, italic and bold-italic. The most direct one is to switch with the commands <B> and <I>, these can also be nested within each other:

  <Textblock fontfamily="textfont">
      <Value>A wonderful </Value>
      <Value> has taken possession </Value>
      <I><Value>of my</Value>
        <Value> </Value>
        <B><Value>entire soul,</Value></B>
      <Value> like these sweet mornings.</Value>
14 fonts
Text markup in layout. Underline (not shown) is possible with the command <U>.

Text markup in the data

If there are markups in the data (e.g. as HTML tags), then this works in principle in exactly the same way:

  <Textblock fontfamily="textfont">
      <Value select="."/>

with the corresponding data:

<data>A wonderful <b>serenity</b> has taken possession
  <i>of my <b>entire soul,</b></i> like these sweet

The result is the same as above. The tags can also be written in capital letters in the data: <B> instead of <b>. Nesting is also allowed and again <u> is underlined.

If the data is not in well-formed XML but in HTML format for example, you can use the layout function sd:decode-html() to interpret it.

OpenType Features

The OpenType format knows so-called OpenType features, such as old style figures or small caps. Some of these features can be activated at <LoadFontfile>.


  <!-- Oldstyle figures / text figures -->
    oldstylefigures="yes" />

  <!-- Small caps -->
    smallcaps="yes" />

  <DefineFontfamily name="osftext" fontsize="10" leading="12">
    <Regular fontface="MinionRegular-osf"/>

  <DefineFontfamily name="smcptext" fontsize="10" leading="12">
    <Regular fontface="MinionRegular-smcp"/>

  <Record element="data">
        <Paragraph fontfamily="osftext">
          <Value>Text with oldstyle figures 1234567890</Value>
        <Paragraph fontfamily="smcptext">
          <Value>Text with small caps 1234567890</Value>
Text figures (above) often make reading the numbers more pleasant. Real small caps (below) differ significantly from mathematically reduced capital letters. The line width and proportions must be adjusted. Depending on the font used, smallcaps also switches to "old style figures".

Outline font

The font-outline attribute can be used to specify the line width for an outline font:

        <Paragraph font-outline="0.3pt">
            <Value>Hello nice world</Value>
An outline font is created by specifying a line thickness with the font-outline attribute at Paragraph.


Since version 4 of speedata Publisher there is a new mode for loading font files: HarfBuzz. It activates the library of the same name, which not only loads the font files, but is also responsible for the arrangement of characters in a word (text shaping). This is not as important for western writing systems as for e.g. Arabic. A side effect of the harfbuzz library is the extensive support for OpenType features.

Using the harfbuzz mode is as follows:

  mode="harfbuzz" />

The OpenType features can be set with the features attribute, for example

<Layout xmlns=""

    <LoadFontfile name="CrimsonPro-Regular"
      mode="harfbuzz" />
    <LoadFontfile name="CrimsonPro-Regular-frac"
      features="+frac" />

    <DefineFontfamily fontsize="10" leading="12" name="regular">
        <Regular fontface="CrimsonPro-Regular" />
    <DefineFontfamily fontsize="10" leading="12" name="frac">
        <Regular fontface="CrimsonPro-Regular-frac" />

    <Record element="data">
                <Paragraph fontfamily="regular">
                    <Value>Use 1/4 cup of milk.</Value>
                <Paragraph fontfamily="frac">
                    <Value>Use 1/4 cup of milk.</Value>
frac feature hb
Upper text without the frac feature, lower text with the feature.

A complete description of the OpenType features can be found on The default features are the ones that are mentioned in the harfbuzz manual but without liga.

The default mode is now the Harfbuzz mode. Set the old mode with mode="fontforge".

In which directory must the font files be located?

The organization of the files, and thus the fonts, is described in the directory File Organization. With sp --systemfonts when calling the publisher, you can access the system-wide font files.

Tips and tricks

In order to save yourself work in defining fonts, you can use the command

$ sp list-fonts --xml

This will then list all font files found, together with a line that can be used directly in the layout.

$ sp list-fonts --xml
<LoadFontfile name="DejaVuSans-Bold"
              filename="DejaVuSans-Bold.ttf" />
<LoadFontfile name="DejaVuSans-BoldOblique"
              filename="DejaVuSans-BoldOblique.ttf" />
<LoadFontfile name="DejaVuSans-ExtraLight"
              filename="DejaVuSans-ExtraLight.ttf" />
If no font is specified for a paragraph or text block (etc.), the system uses the text font family, which is also predefined in the Publisher and can be overwritten. See the Preferences in the Publisher appendix.

Missing characters and replacement fonts

The character sets in the font files are usually very limited. For example, the speedata Publisher is delivered with the free font "TeXGyreHeros" (a very good Helvetica clone). However, the font file only contains characters that cover western languages, but not, for example, Greek, Arabic, Chinese etc. Also the whole Unicode special characters like U+2685 DIE FACE-6 (⚅) are not included. If a character is requested that is not contained in the font, an error message is displayed.

Error: Glyph f1c7 (hex) is missing from the font "TeXGyreHeros-Regular"

This error can be suppressed with the command <Options>:

<Options reportmissingglyphs="no"/>

Alternatively, you can also specify a replacement font at <LoadFontfile>, which will be searched as soon as a character is not found:

<LoadFontfile name="helvetica" filename="texgyreheros-regular.otf">
  <Fallback filename="fontawesome-webfont.ttf" />
  <Fallback filename="line-awesome.ttf" />

First the font texgyreheros-regular.otf is searched, then fontawesome-webfont.ttf and finally line-awesome.ttf.


There is a command to add an alternate name for an existing font name to the list of known font names:

<DefineFontalias existing="..." alias="..."/>

The commands

<LoadFontfile name="DejaVuSerif"
        filename="DejaVuSerif.ttf" />
<LoadFontfile name="DejaVuSerif-Bold"
        filename="DejaVuSerif-Bold.ttf" />
<LoadFontfile name="DejaVuSerif-BoldItalic"
        filename="DejaVuSerif-BoldItalic.ttf" />
<LoadFontfile name="DejaVuSerif-Italic"
        filename="DejaVuSerif-Italic.ttf" />

<DefineFontalias existing="DejaVuSerif" alias="serif"/>
<DefineFontalias existing="DejaVuSerif-Bold" alias="serif-bold"/>
<DefineFontalias existing="DejaVuSerif-Italic" alias="serif-italic"/>
<DefineFontalias existing="DejaVuSerif-BoldItalic"

now allow to define font families in general as follows:

<DefineFontfamily name="title" fontsize="15" leading="17">
  <Regular fontface="serif"/>
  <Bold fontface="serif-bold"/>
  <BoldItalic fontface="serif-bolditalic"/>
  <Italic fontface="serif-italic"/>

i.e. independent of the font actually used. With the options described in the section Splitting layout sets of rules into individual files, you can now swap the font definition into a separate file and, if necessary, quickly choose between different fonts by including the desired files.