[luatex] Logging of font names in box log output
David Carlisle
d.p.carlisle at gmail.com
Wed Sep 9 17:21:34 CEST 2015
With much help from Hans (and ignoring anything other than classic tfm
fonts for now)
I thought I'd close this thread with some successful code. This
reports \b for both x and y
in texlive 2015 luatex, to match pdftex output:
\directlua{
function mydeffont(n,s,i)
for ii,vv in font.each() do
if (n == vv.name) then
% and s == vv.size
% need to normalize size representations
% just equality here fails to match
print('font callback: ' .. n .. ' ' .. s .. ' ' .. vv.size)
f=ii
end
end
return f or font.read_tfm(n,s)
end
callback.register('define_font',mydeffont)
}
\font\a=cmr10
\font\b=cmr10
\setbox0\hbox{\a x\b y}
\scrollmode
\tracingonline1
\showbox0
\immediate\write16{a: \number\fontid\a}
\immediate\write16{b: \number\fontid\b}
\bye
If I may could I request two additions to the luatex manual?
a) list the new primitive \fontid in section 2.7 (or wherever else you
feel makes sense)
b) document that the define_font callback can return a fontid
(integer) The manual
documents it as returning a table, which meant I didn't know what to do having
detected a duplicate, but I found this text in the changelog which led
to the above.
* The 'define_font' callback interface has changed a little.
It is now:
retval = function (name,size,fontid)
where fontid is the internal font number of the font that
is currently being defined, and retval can be either a table
(as before) or a different, previously defined fontid. This is
useful if a previous definition can be reused instead of
creating a whole new font structure.
Thanks again for the help, I learned quite a bit about luatex font loading:-)
David
More information about the luatex
mailing list