[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
\font\bitmap=file:cmb12.tfm:reencode=8r.enc;bitmap=yes
\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>
\bitmap
l.4 \bitmap
          test

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:
/home/pali/.texmf-var/luatex-cach
e/generic/fonts/enc/8r.luc)(save: /home/pali/.texmf-var/luatex-
cache/generic/fo
nts/enc/8r.lua)(save: /home/pali/.texmf-var/luatex-
cache/generic/fonts/enc/8r.l
uc)...otfload/src/fontloader/runtime/fontloader-basics-gen.lua:376:
table index
 is nil.
<to be read again>
\bitmap
l.4 \bitmap
          test

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
         end
+        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
     end

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

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