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

Urs Liska lists at openlilylib.org
Wed Jan 24 10:23:24 CET 2018



Am 23.01.2018 um 17:47 schrieb Hans Hagen:
> On 1/23/2018 5:06 PM, Urs Liska wrote:
>>
>>
>> ...
>>
>>
>> While this compiles the three fonts always show the font that is 
>> active before the function starts to execute.
>>
>> So is there a way to select one of the three predefined font families 
>> *from within Lua* so subsequent statements in the same Lua chunk see 
>> the results?
> I'm not sure if this thread belongs to this list as it relates more to 
> a macro package than to luatex

I see that - by now. Originally I thought I was looking for the right 
incantation to ask Lua for the relevant information. Actually I still 
think it would be good if it were available as some property in the font 
tables.

> but anyhow, you can do something like this (untested):
>
> \begingroup
>   \rmfamily \edef\rmfamilyid{\fontid\font}%
>   \ssfamily \edef\ssfamilyid{\fontid\font}%
>   \ttfamily \edef\ttfamilyid{\fontid\font}%
>   \directlua{
>     myfonts = { }
>     myfonts.rm = 
> fonts.hashes.identifiers[\rmfamilyid].shared.rawdata.metadata['familyname']
>     myfonts.sf = 
> fonts.hashes.identifiers[\ssfamilyid].shared.rawdata.metadata['familyname']
>     myfonts.tt = 
> fonts.hashes.identifiers[\ttfamilyid].shared.rawdata.metadata['familyname']
>     print("")
>     print('Main font: '..myfonts.rm)
>     print('Sans font: '..myfonts.sf)
>     print('Mono font: '..myfonts.tt)
>   }%
> \endgroup
>
> or just
>
> \begingroup
>   \rmfamily \edef\rmfamilyid{\fontid\font}%
>   \ssfamily \edef\ssfamilyid{\fontid\font}%
>   \ttfamily \edef\ttfamilyid{\fontid\font}%
>   \directlua{
>     print('Main font: 
> '..fonts.hashes.identifiers[\rmfamilyid].shared.rawdata.metadata['familyname'])
>     print('Sans font: 
> '..fonts.hashes.identifiers[\ssfamilyid].shared.rawdata.metadata['familyname'])
>     print('Mono font: 
> '..fonts.hashes.identifiers[\ttfamilyid].shared.rawdata.metadata['familyname'])
>   }%
> \endgroup
>

Thank you, this finally made it to a working state. Instead of the print 
statements I set these values to entries in a table which I can then 
read in the Lua part.

Thank you to all contributors to this thread.
Best
Urs

> Hans
>
>
> -----------------------------------------------------------------
>                                           Hans Hagen | PRAGMA ADE
>               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
>        tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
> -----------------------------------------------------------------



More information about the luatex mailing list