[luatex] First question: Retrieve *family* name of a font / the three main families
Urs Liska
lists at openlilylib.org
Fri Jan 19 09:37:17 CET 2018
Hi all,
this is my first post to this list, and I must say I haven't found a way
to search the list archives. If there is any I apologize for asking
without searching the list archives before posting. But search engines
and the manual haven't provided any help for me, nor did I receive much
feedback on stackexchange. So I think asking here is "the right thing".
I'm contributing to a LuaLaTeX package
(https://github.com/jperon/lyluatex) that uses an external program
(LilyPond) to generate images to be included in the LaTeX document. I
need to pass the used fonts to LilyPond, and I didn't manage to retrieve
the necessary information in Lua.
What I need is
a) which families are currently set as roman, sans and mono fonts
b) the "family" name of these.
ad a)
I have managed to retrieve the "current" font, i.e. the one that is
currently used for typesetting. This is basically done with
local current_font = fonts.hashes.identifiers[font.current()]
although I don't know if that's the most direct way to get to that
information.
But this is not the *family* of the font but actually the font face
currently in use. And I have no idea how to get to the three defined
font families.
ad b)
According to the documentation (chapter 5 of luatex.pdf) I can access
the following vlaues from the font object:
.name
.fullname
.psname
.filename
but none of those provides me reliably with what I need to pass on to
LilyPond, which seems to be the "family".
For Linux Libertine O it works, but this seems somewhat accidentally.
This is what the font object gives me:
fullname: Linux Libertine O
psname: LinLibertineO
name:
[LinLibertine_R.otf]:mode=node;script=latn;language=DFLT;+tlig;+tnum;+lnum;
filename:
/usr/share/texlive/texmf-dist/fonts/opentype/public/libertine/LinLibertine_R.otf
Other fonts don't work. This is the result for "Adobe Garamond Pro":
fullname: AGaramondPro-Regular
psname: AGaramondPro-Regular
name: AdobeGaramondPro:mode=node;script=latn;language=DFLT;+tlig;
filename: /home/shared/fonts/Adobe Garamond Pro/AGaramondPro-Regular.otf
If I compare this to the output Fontconfig is giving me:
$ fc-list -v | grep -i libertine
family: "Linux Libertine O"(s)
fullname: "Linux Libertine O Semibold"(s)
file:
"/usr/share/fonts/opentype/linux-libertine/LinLibertine_RZ.otf"(s)
postscriptname: "LinLibertineOZ"(s)
... and the same sets for all font faces
$ fc-list -v | grep -i "adobe.*garamond"
family: "Adobe Garamond Pro"(s)
fullname: "AGaramondPro-SemiboldItalic"(s) "Adobe Garamond Pro Sb
Italic"(s) "Adobe Garamond Pro Semibold Italic"(s)
file: "/home/uliska/.fonts/Adobe Garamond Pro/AGaramondPro
it seems that the "fullname" property is quite unreliable, and I
definitely need to get the "family" name.
However, from the "Font structure" section in the LuaTeX manual I don't
find any way to get that information.
Maybe there's a way to retrieve that information from the actual font
file? But it would be nice to be able to get it directly from Lua - and
of course it has to be OS independent, so I guess I can't make use of
Fontconfig?
Any suggestions are highly welcome.
Thanks in advance and best regards
Urs
More information about the luatex
mailing list