Skip to content

Font fallback (mainfontfallback/monofontfallback) crashes LuaLaTeX: attempt to index a nil value in luaotfload-fallback.lua #11678

@cderv

Description

@cderv

Problem

A document that sets monofontfallback (or mainfontfallback / sansfontfallback)
fails to compile with --pdf-engine=lualatex: LuaLaTeX crashes with attempt to index a nil value inside luaotfload, before any PDF is produced.

Reproduction

meta.yaml:

monofont: "Latin Modern Mono"
monofontfallback:
  - "Latin Modern Roman"
echo 'Some `inline code`.' | pandoc --metadata-file meta.yaml -o doc.pdf --pdf-engine=lualatex

Result:

luaotfload | resolve : sequence of 3 lookups yielded nothing appropriate.
...luaotfload-fallback.lua:50: attempt to index a nil value (local 'f').
Error producing PDF.

The generated LaTeX contains:

\directlua{luaotfload.add_fallback("monofontfallback",{
  "Latin Modern Roman"
})}

Cause

This traces to how luaotfload parses fallback names — confirmed by a luaotfload
maintainer in latex3/luaotfload#331. luaotfload appends a ;-fallback feature to
each name passed to add_fallback, and its font-name parser ends a name only at
:, ( or /. So a bare "Latin Modern Roman" absorbs the appended feature
(Latin Modern Roman;-fallback), the lookup fails, and the resulting nil is then
indexed. The fix confirmed in that thread is to terminate each fallback name with a
colon — "Latin Modern Roman:".

The template emits the name without a trailing colon here:

$for(mainfontfallback)$"$mainfontfallback$"$sep$,$endfor$

Environment

  • pandoc 3.9.0.2 (latest release)
  • TeX Live 2026, luaotfload 3.29

Related: #11252. Font fallback support was added in #9204.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions