# What is a direct way of specifying a font family in XeLatex and how do you know what the “name” of the family is

This question replaces my previous, unclear, question.

I want to use OTF fonts in XeLatex. To be concrete, here, for example, are some of the Linux Libertine fonts/fontfamilies available on my computer:

(Serif)
/usr/share/texmf-dist/fonts/opentype/public/libertine/LinBiolinum_R.otf
/usr/share/texmf-dist/fonts/opentype/public/libertine/LinBiolinum_RB.otf
/usr/share/texmf-dist/fonts/opentype/public/libertine/LinBiolinum_RBO.otf
/usr/share/texmf-dist/fonts/opentype/public/libertine/LinBiolinum_RI.otf
.....

(Sans Serif)
/usr/share/texmf-dist/fonts/opentype/public/libertine/LinLibertine_R.otf
/usr/share/texmf-dist/fonts/opentype/public/libertine/LinLibertine_I.otf
/usr/share/texmf-dist/fonts/opentype/public/libertine/LinLibertine_M.otf
/usr/share/texmf-dist/fonts/opentype/public/libertine/LinLibertine_MB.otf
....


Suppose that I want to use to able to use all of LinLibertine fonts; roman, italics etc without defining \rm, \it individually. Is there a simple command(s) to do this? Can one do this for both LinLibertine (serif) and LinBiolinum (sans serif) at once. I was unable to find a suitable answer to what surely is a fundamental question.

What "name" does one use in such a command and how does one know what the "name" is. In the above example is it libertine or LinLibertine or an abbreviation (such as "cm") and does the "name" have capitals?

• \usepackage{libertine} and everything should be fine. – user2478 Nov 20 '18 at 21:29
• The fontspec manual has lots of examples of how you can set things up how you want them easily. – David Purton Nov 21 '18 at 6:21
• Please clarify what you mean by “direct way”. The fonts provided in your question are included in Tex Live (so any computer that has TeX Live with fonts installed, not just your computer). Do you consider that relevant? – Jonathan Komar Nov 24 '18 at 9:57

First things first, xelatex has one mandatory package to make use of other fonts (see texdoc fontspec documentation)

\usepackage{fontspec}


After that, it makes sense to define the font family name to be the part of the filename that is common across all styles (case sensitive).

1. LinBiolinum
2. LinLibertine

Then after searching for font family in the fontspec documentation, you might think to create the two new font families like this:

# Define n fonts \newfontfamily

You define the command name but it makes sense to use semantically relevant names.

\newfontfamily\LinBiolinum[%
Extension = .otf ,
UprightFont = *_R , % roman font style (segment of file path)
ItalicFont = *_RI , % italic font style (segment of file path)
BoldFont = *_RB , % bold font style (segment of file path)
]{LinBiolinum}

\newfontfamily\LinLibertine[%
Extension = .otf ,
UprightFont = *_R ,
ItalicFont = *_I ,
BoldFont = *_MB ,
]{LinLibertine}


Then anytime you want to "activate" that font in your document, just call \LinBiolinum or \LinLibertine. You told fontspec how to load the different styles: bold, italic, regular:

\rm = /path/LinLibertine_R.otf \it = /path/LinLibertine_RI.otf etc.

However, fontspec uses a few built-in font family commands. The one for the main font is called \normalfont, and can be manually set using \setmainfont like this:

\setmainfont[%
Extension = .otf ,
UprightFont = *_R ,
ItalicFont = *_I ,
BoldFont = *_MB ,
]{LinLibertine}


The way these macros work are by loading fonts based on breaking font path segments into components so that some of them may be used as variables (UprightFont, ItalicFont, BoldFont, Extension, and others listed in the fontspec documentation).

The /path/ segment is set as an environment variable. Each TeX Live Installation sets a few paths by default for its internal fonts.

cat \$(kpsewhich -var-value TEXMFSYSVAR)/fonts/conf/texlive-fontconfig.conf


If you want to load a font from someplace other than those, you have two options

1. Use the Path parameter in your font family definitions