[luatex] luaotfload - problems with bitmap fonts

Pali Rohár pali.rohar at gmail.com
Fri Sep 2 09:44:39 CEST 2016

Hi! I found two bugs in luaotfload when using bitmaps fonts.

First one: The font loader does not automatically create tfm metric if
one does not exists in cache.

Here is test file:

\input luatexiniconfig.tex
\input luaotfload.sty
\bitmap test

It uses CM font cmb12 for which texlive installation does not have
pregenerated metric file (but problem is with any bitmap font, I chose
cmb12 as this is "standard" and easy for testing). When I run luatex
with font loader I just got this error message:

luaotfload | db : Reload initiated (formats: otf,ttf,ttc); reason: "File
not found: cmb12.".
! Font \bitmap=file:cmb12.tfm:reencode=8r.enc;bitmap=yes not loadable:
metric data not found or bad.
<to be read again>
l.4 \bitmap

When I specify cmb12 in pdftex, it automatically generate metric file to
disk cache (/home/pali/.texmf-var/fonts/tfm/public/sauter/cmb12.tfm).

Is there any reason why metric files are not automatically generated
when needed? Like in pdftex? Btw, this command can do that job:

$ kpsewhich -format=tfm -mktex=tfm cmb12


Second run of luatex (after pdftex finished job) I see under strace that
cmb12.tfm was read but luatex "crash" in fontloader...

luaotfload | main : initialization completed in 0.094 seconds)(load luc:
e/generic/fonts/enc/8r.luc)(save: /home/pali/.texmf-var/luatex-
nts/enc/8r.lua)(save: /home/pali/.texmf-var/luatex-
table index
 is nil.
<to be read again>
l.4 \bitmap

I suspect that luaotfload should not crash with such error like "table
index is nil".

First problem can be solved by this patch:

--- a/src/luaotfload-database.lua
+++ b/src/luaotfload-database.lua
@@ -685,6 +685,11 @@ lookup_font_file = function (filename)
         if resolvers.findfile(filename, format) then
             return file.addsuffix(filename, format), format, true
+        if type1_metrics[i] == "tfm" then
+            if os.execute("kpsewhich -format=tfm -mktex=tfm " .. filename) then
+                return file.addsuffix(filename, format), format, true
+            end
+        end

     if not fonts_reloaded and config.luaotfload.db.update_live == true

And after that metric file was generated when needed.

I tried "kpse.lookup(filename, { format = "tfm", mktextfm = true })" but
for unknown reason mktextfm was not called and so metric file not
generated :-(

Pali Rohár
pali.rohar at gmail.com

More information about the luatex mailing list