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

Urs Liska lists at openlilylib.org
Fri Jan 19 17:05:42 CET 2018

Am 19.01.2018 um 15:00 schrieb Hans Hagen:
> On 1/19/2018 2:37 PM, Urs Liska wrote:
>> Hi Knut,
>> Am 19.01.2018 um 13:38 schrieb Knut Petersen:
>>> Am 19.01.2018 um 09:37 schrieb Urs Liska:
>>>> I'm contributing to a LuaLaTeX package 
>>>> (https://github.com/jperon/lyluatex) that uses an external program...
>> ...
>> But still I can't really believe that Lua can tell me the 
>> postscriptname, "fullname", filename, but not the family.
>> Does anybody know if that's a deliberate limitation?
> Something like this
> \directlua {
>     function FontInfoField(id,name)
>         local t = fonts.hashes.identifiers[id]
>         if t and t.shared and t.shared.rawdata and 
> t.shared.rawdata.metadata then
>             local s = t.shared.rawdata.metadata[name]
>             if t then
>                 tex.print(s)
>             end
>         end
>     end
> }

Thank you, this seems to be the information I needed. (Just out of 
curiousity: where would I have found the reference for the font table 
that includes this information? I did realize that luatex.pdf spoke of 
"first level" table elements, but it didn't go any further.

Could you please explain to me in what case any of the conditionals 
could fail? That is, why is it necessary to do all these checks? If I 
know that the font passed into the function exists (for example because 
its font.current() ) wouldn't it be sufficient to return
    fonts.hashes.identifiers[id].shared.rawdata and 

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

I imagine I could change to each, retrieve the "current" font, do *not* 
print anything, and reset in the end.
But is there another, more elegant way, for example some other table 
where I can directly read out the information?


More information about the luatex mailing list