LoadFontfile
Load a font file (.otf, .ttf) 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 not supported since version 6.0. Please convert Type 1 fonts to OpenType.
Child elements
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.
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. This attribute takes precedence over
spacefromfont. spacefromfont(optional, since version 5.9.6)- Take the width of the interword space from the font itself instead of the fixed percentage of the font size. This also applies to preserved spaces in preformatted text (
white-space: pre), which otherwise get the width of the digit zero. An explicitspaceattribute takes precedence, fonts without a space glyph keep the default.yes: The interword space gets the width that the font designer intended. It can stretch by half and shrink by a third of that width.no: Default: the interword space is 25 percent of the font size (or the value ofspace), it can stretch by 30 percent and shrink by 10 percent 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
Axischild element withname="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
Axischild element withname="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.