[luatex] First question: Retrieve *family* name of a font / the three main families

Ulrike Fischer luatex at nililand.de
Sat Jan 20 17:36:06 CET 2018

Am Fri, 19 Jan 2018 17:05:42 +0100 schrieb Urs Liska:

> Which leaves me with my second question: how can I retrieve the three
> font families specified for \rmfamily, \sffamily, and \ttfamily?

Well as I already wrote on tex.SX it is rather unclear what you mean
by family and how you want to use it.

Assuming that you use latex: \rmfamily addresses a bunch of fonts
which are normally somehow "of the same family" but this is not a
must. As an example you could do:

\setmainfont{Arial}[ItalicFont=Consolas/I,
BoldFont=TeX Gyre Termes/B]

And then the upright font of this "roman family" will be Arial, the
italic shape Consolas and the bold font a times clon.

The family name of this bunch of fonts (stored in \rmdefault) will
be "Arial(0)" in fontspec, but obviously this name is not of much
use for you, it is a rather arbitrary key and not connected to the
real fonts.

If you want to retrieve the fonts connected with the various shape
you can do something like this:

\documentclass{article}
\usepackage{fontspec}
\setmainfont{Arial}[ItalicFont=Consolas/I,BoldFont=TeX Gyre
Termes/B]
\begin{document}
abc %Arial
\textbf{abc}%TeX Gyre Termes
\textit{abc}%Consolas

\expandafter\show\csname TU/\rmdefault/m/n\endcsname
\expandafter\show\csname TU/\rmdefault/m/it\endcsname
\expandafter\show\csname TU/\rmdefault/bx/n\endcsname

\end{document}

Or you could ask Will to store the two arguments of the \setmainfont
command for later use.

--
Ulrike Fischer
http://www.troubleshooting-tex.de/