<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<p>Hi Knut,<br>
</p>
<br>
<div class="moz-cite-prefix">Am 19.01.2018 um 13:38 schrieb Knut
Petersen:<br>
</div>
<blockquote type="cite"
cite="mid:b76c559d-2890-adbe-310a-af3474a5ba97@t-online.de">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<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"
moz-do-not-send="true">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>
</blockquote>
<br>
Yes, it's awesome when included scores use the same fonts as the
surrounding text.<br>
<blockquote type="cite"
cite="mid:b76c559d-2890-adbe-310a-af3474a5ba97@t-online.de"> <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, </blockquote>
<br>
That's not an issue, the lyluatex package needs that anyway to start
LilyPond.<br>
<br>
<blockquote type="cite"
cite="mid:b76c559d-2890-adbe-310a-af3474a5ba97@t-online.de">and it
is not OS-independent. </blockquote>
<br>
That's probably true.<br>
<br>
<blockquote type="cite"
cite="mid:b76c559d-2890-adbe-310a-af3474a5ba97@t-online.de">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>
</blockquote>
<br>
I can do that with little effort in the Lua layer (I'm working in
anyway):<br>
<ul>
<li>get the absolute filename from the font object.</li>
<li>run otfinfo -a with that filename</li>
</ul>
<p>This should be straightforward to implement but hard to make OS
independent. While I personally don't care about that I vividly
recall that in an earlier life I felt strongly offended by the
attitude "YOU made the mistake of using Windows, so don't complain
now" ...</p>
<p>otfinfo seems to be available on Windows and even included in
<a class="moz-txt-link-freetext" href="http://w32tex.org/">http://w32tex.org/</a> , but I'm not sure if that will be an
acceptable dependency. Of course I can start with implementing it
for Linux and make the option be limited to that.</p>
<p><br>
</p>
<p>But still I can't really believe that Lua can tell me the
postscriptname, "fullname", filename, but not the family.</p>
<p>Does anybody know if that's a deliberate limitation?</p>
<p>Urs<br>
</p>
<p><br>
</p>
<blockquote type="cite"
cite="mid:b76c559d-2890-adbe-310a-af3474a5ba97@t-online.de"> Knut<br>
</blockquote>
<br>
</body>
</html>