NFSS-like selection of font weights using fontspec and xelatex

Ulrike Fischer’s answer is good, but I’ll give an example with the GitHub version of EB Garamond.

\newfontfamily\ebgaramond{EBGaramond}[
  UprightFont = *-Regular ,
  ItalicFont = *-Italic ,
  BoldFont = *-Bold ,
  ItalicFont = *-Italic ,
  FontFace = {mb}{n}{*-Medium},
  FontFace = {mb}{it}{*-MediumItalic},
  FontFace = {sb}{n}{*-SemiBold},
  FontFace = {sb}{it}{*-SemiBoldItalic},
  FontFace = {eb}{n}{*-ExtraBold},
  FontFace = {eb}{it}{*-ExtraBoldItalic},
  Extension = .otf ]

The abbreviations for the font series, such as sb and eb, are taken from The LaTeX Font Installation Guide. Note that mb and db are not present in many other lists (such as the one in The LaTeX Companion). Medium ({mb}) is between Regular and Semibold, and Demibold ({db}) is between Semibold and Bold. If there’s only one weight between Regular and Bold, I recommend making it {sb}, as for example Computer Modern Demi does.

You might also find it convenient to define commands such as:

\DeclareRobustCommand\sbseries{\fontseries{sb}\selectfont}
\DeclareTextFontCommand{\textsb}{\sbseries}

This declares \textsb{...} and \sbseries commands analogous to \textbf{} and \bfseries.


If you want to setup a family with more shapes/weights than you can get with the standard options of fontspec it is imho the best to write suitable .fd files. You can find examples (for the lmr/lmss/lmtt families) in the euenc package. For xelatex you should write eu1XXX.fd files. eu2 is for lualatex. –

Edit 2017

fontspec has now an option FontFace to add more shapes and weights, so .fd-files are not really needed anymore.

But if one want to do it: In current texsystems the name of the standard encoding for lualatex and xelatex is now TU, so one should write TUxxx.fd-files.

Tags:

Xetex

Fontspec