Version 5.8.0

# `LoadFontfile`

Load a font file (.otf, .ttf, .pfb) and associate it with an internal name. If a glyph is not found in the font file, an error will be raised (this can be configured via the `Options` command). You can specify fallbacks as a child element of Loadfontfile.

Type 1 fonts (.pfb) are deprecated: they are always loaded with the old fontforge font handler, which is scheduled for removal in version 6.0. Please convert Type 1 fonts to OpenType.

## Child elements

`Axis`, `Fallback`

## Parent elements

`AtPageCreation`, `AtPageShipout`, `Case`, `Contents`, `ForAll`, `Include`, `Layout`, `Loop`, `Otherwise`, `Record`, `SavePages`, `Section`, `Until`, `While`

## Attributes

`features` (text, optional, since version 3.9.29)
  A comma separated list of OpenType features, such as `+liga,-kern`
`filename` (text)
  The name (with extension) of the font file.
`marginprotrusion` (0 up to 100, optional)
  The amount of protrusion glyphs like -, . and - stick into the right margin. Defaults to 0. The value is multiplied with 0.001em from the current font, so a setting of 200 allows these characters to stick out of the margin 0.2em.
`mode` (optional, since version 3.9.29, deprecated)
  Set the shaping mode of the font. Defaults to `harfbuzz`. This attribute is deprecated: it is only needed to select the old fontforge font handler, which is scheduled for removal in version 6.0.
  - `fontforge`: The old font handler. Renders western scripts, but no right-to-left or other complex scripts. Deprecated: this font handler is scheduled for removal in version 6.0. Type 1 fonts (.pfb) are always loaded with this handler, regardless of the mode setting.
  - `harfbuzz`: The renderer that handles all scripts including right-to-left (default).
`name` (text)
  The internal name of the font file. To be used within `DefineFontfamily`.
`oldstylefigures` (optional)
  Use oldstyle figures if the font includes them. (OpenType feature “onum”)
  - `yes`: Use oldstyle figures.
  - `no`: Use lining figures.
`shrink` (number, optional, since version 4.19.17)
  Set the maximum shrinkage factor of the fonts. Default is disabled. Values divided by 10 = percent. For example 20 means shrink by maxium of 2%.
`smallcaps` (optional)
  Use small caps glyphs when the font supplies them.
  - `yes`: Use small caps for this font.
  - `no`: Don’t switch to small caps (default).
`space` (0 up to 100, optional)
  The natural width between words. Can be stretched by 30% and shrunk by 10%. Defaults to 25. The value is a percentile of the font size.
`step` (number, optional, since version 4.19.17)
  Set the step values for shrinkage / stretching. Value divided by 10 is step in percentage. For example: a value of 20 means increase / decrease size in 2% steps. Default 10.
`stretch` (number, optional, since version 4.19.17)
  Set the maximum stretch factor of the fonts. Default is disabled. Values divided by 10 = percent. For example 20 means stretch by maxium of 2%.
`weight` (number, optional, since version 5.5.12)
  Set the weight axis (wght) of a variable font. This is a shortcut for using the `Axis` child element with `name="wght"`. Common values are 100 (Thin), 400 (Regular), 700 (Bold), 900 (Black).
`width` (number, optional, since version 5.5.12)
  Set the width axis (wdth) of a variable font. This is a shortcut for using the `Axis` child element with `name="wdth"`. A value of 100 is normal width, lower values are condensed, higher values are expanded.

## Example

    <LoadFontfile name="Helvetica" filename="texgyreheros-regular.otf" />
    <LoadFontfile name="Helvetica Bold" filename="texgyreheros-bold.otf" />
    <LoadFontfile name="Helvetica Italic" filename="texgyreheros-italic.otf" />
    <LoadFontfile name="Helvetica Bold Italic" filename="texgyreheros-bolditalic.otf" />

    <!-- Variable font with weight shortcut -->
    <LoadFontfile name="MyFont Regular" filename="MyFont-Variable.ttf" weight="400" />
    <LoadFontfile name="MyFont Bold" filename="MyFont-Variable.ttf" weight="700" />

    <!-- Variable font with generic axes -->
    <LoadFontfile name="MyFont Custom" filename="MyFont-Variable.ttf">
      <Axis name="wght" value="600" />
      <Axis name="wdth" value="75" />
    </LoadFontfile>

## Info

The fonts are optionally taken from the local search path. On Windows the path `%WINDIR%\Fonts` (usually `C:\Windows\Fonts`) and on Mac OS X the paths `/Library/Fonts` and `/System/Library/Fonts` can be used as fallbacks for fonts. This can be configured with the setting `fontpath`.

#### On this page