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

Ulrike Fischer luatex at nililand.de
Mon Jan 22 10:53:05 CET 2018

Am Sun, 21 Jan 2018 22:33:56 +0100 schrieb Urs Liska:

>> \csname TU/\rmdefault/m/n\endcsname
>>
>> and extract the font name "Arial" from the output:
>>
>>> \TU/Arial(0)/m/n=macro:
>> ->\<->"Arial:mode=node;script=latn;language=DFLT;+tlig;" .
>>
>
> I was just about to test what you had suggested earlier (didn't have
> access to my LaTeX environment over the weekend :-( )
>
> I have a hard time to understand your code examples. As far as I can see
> your original code "shows" the definition of \rmdefault in certain
> variants, and it puts in in the log output. If that's correct how would
> I get it not to print to the console but be stored somewhere I can
> process it further, and how would I process it in a way that LaTeX or
> Lua's objects can tell me the "family"?

Something like this should work:

\documentclass{article}
\usepackage{expl3}
\usepackage{fontspec}
\setmainfont{Arial}
\begin{document}

\ExplSyntaxOn
\newcommand\currentromanfamily{}
\cs_generate_variant:Nn \regex_extract_once:nnNTF {no}

\tl_set:Nx \l_tmpa_tl { \tl_to_str:c {TU/\rmdefault/m/n}}

\regex_extract_once:noNTF
{ \"(.+?)\: }
{\l_tmpa_tl}
\l_tmpa_seq
{
\tl_set:Nx\currentromanfamily {\seq_item:Nn \l_tmpa_seq {2}}
}
{
No Match
}

\ExplSyntaxOff

\currentromanfamily

\end{document}

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