2

How can I change the default font features for the fontspec package? For example, I have a lot of definitions like:

\setromanfont{FontName}[
    Path = ../fonts/,
    Extension = .otf,
    ItalicFont = *-It,
    BoldFont = *-Bd,
    BoldItalicFont = *-BdIt,
    Numbers = OldStyle
]

Can I factor out those attributes to make the individual definitions shorter and more flexible?

1

You can set font features that will be shared with all fonts you define (unless overridden) with \defaultfontfeatures[<font name>]{<font features}] (documented in part III §1, p. 20 in the fontspec manual).

The manual’s example is:

\defaultfontfeatures[\rmfamily,\sffamily]{Ligatures=TeX}
\setmainfont{texgyreadventor-regular.otf}% will use standard TeX ligatures

But you could also set defaults like:

\defaultfontfeatures{
    Path = ../fonts/,
    Extension = .otf,
    Numbers = OldStyle,
}

Which would cut down the size of your font definitions to:

\setromanfont{FontName}[
    ItalicFont = *-It,
    BoldFont = *-Bd,
    BoldItalicFont = *-BdIt,
]
1
  • And now accept your own answer, please. Otherwise the question will remain in the unanswered list.
    – Keks Dose
    May 15 '18 at 8:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.