<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<div class="moz-cite-prefix">Am 19.01.2018 um 09:37 schrieb Urs
Liska:<br>
</div>
<blockquote type="cite"
cite="mid:18b98e86-cfd6-9936-3ab4-cafb394f1156@openlilylib.org">I'm
contributing to a LuaLaTeX package
(<a class="moz-txt-link-freetext" href="https://github.com/jperon/lyluatex">https://github.com/jperon/lyluatex</a>) 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.
<br>
<br>
What I need is
<br>
<br>
a) which families are currently set as roman, sans and mono fonts
<br>
b) the "family" name of these.
[...]<br>
</blockquote>
<br>
So you want to teach lilypond to use the fonts latex uses. <br>
<br>
In a similar project I use this code fragment to get information
about the current TeX font and to pass it to lilypond:<br>
<br>
<blockquote><tt> \else</tt><br>
<tt> {</tt><br>
<tt> \mdseries\@llftmp</tt><br>
<tt> \immediate\write18{</tt><br>
<tt> LANG=c</tt><br>
<tt> FONT=`echo '\fontname\font'</tt><br>
<tt> | sed -e 's/"//g' </tt><br>
<tt> | sed -e
's/\@esc[\@esc([[:print:]]*\@esc)\@esc][[:print:]]*/\@esc1/'`</tt><br>
<tt> ;</tt><br>
<tt> otfinfo --info `kpsewhich $FONT` </tt><br>
<tt> | grep "Full name:" </tt><br>
<tt> | sed -e 's/Full
name:[[:blank:]]*\@esc([[:print:]]*\@esc)/\@esc\@esc</tt><br>
<tt> def \@esc\@esc fontfullname\@cbopen\@esc
1\@cbclose/'</tt><br>
<tt> > ourfont.tex}</tt><br>
<tt> \input "ourfont.tex"</tt><br>
<tt> \@imwrtof{\@ht(define lyinlaFontName "\fontfullname")}</tt><br>
<tt> \@imwrtof{\@ht(define lyinlaFontSize (absFontSize
\f@size))}</tt><br>
<tt> }</tt><br>
<tt> \fi<br>
</tt></blockquote>
<br>
\@imwrtof is defined to immediately write to an output file that
will be processed by lilypond,<br>
\@esc gives a literal "\", <br>
\@ht gives a literal "#", <br>
\@cbopen gives a literal "{", <br>
\@cbclose gives a literal "}"<br>
<br>
Obviously it does not compile, it requires --shell-escape, and it is
not OS-independent. Bt it might be a starting point for you.<br>
<br>
The idea of the code is to take \fontname\font,<br>
to process it as shown,<br>
to get the font filename from kpsewhich,<br>
and to use otfinfo to get the needed information.<br>
<br>
The output of otfinfo is filtered and written to a TeX file,<br>
that file is read after return from the shell,<br>
and two scheme expression (for fontname and fontsize) are<br>
written to a file that later will be processed by lilypond.<br>
<br>
Knut<br>
</body>
</html>