[luatex] Loading fonts in a format.

Paul Isambert zappathustra at free.fr
Tue Apr 2 11:49:12 CEST 2013


Hello all,

Following the previous discussion on fonts and formats, I've come to
the following. Suppose I create this dummy format:

    %%% run "luatex --ini format.tex" %%%
    \catcode`\{=1
    \catcode`\}=2

    \directlua{
    callback.register("define_font",
      function (_, _, id)
        local f = font.read_tfm("cmr10", -1000)
        font.setfont(id, f)
        return f
      end)
    }

    \font\test=cmr10

    \dump
    %%%%%%%%%%%%%%%%%%

(Note that the line "font.setfont(id, f)" doesn't change anything when
removed.)

The font is properly loaded, however in:

    %%% run "luatex --fmt=format test.tex" %%%
    \test hello

    \directlua{local x = font.getfont(1)}
    \end
    %%%%%%%%%%%%%%%%

the "\directlua" line produces the error (verbatim):

    ! LuaTeX error attempt to index a nil value

This looks like a bug to me, because at the very least
"font.getfont(n)" returns "nil" if no font has id "n" (and the error
doesn't look properly formatted to me); and anyway since the font
works ("hello" is printed), then the font should exist.

(Replacing "font.setfont/getfont" with "font.fonts[n]" doesn't change
anything.)

However, I'm not quite sure how LuaTeX code is supposed to be
remembered from an IniTeX run to a normal run, so maybe I've
encountered a normal behavior, albeit somewhat puzzling. So...?

Best,
Paul



More information about the luatex mailing list