I have a document:

Program the μC, please.

When I compile with xelatex or lualatex, there is a missing "μ" character in the output. This makes sense because the default font doesn't contain that character, but I need to know when it happens.

With xelatex, the log file contains a warning:

Missing character: There is no μ in font [lmroman10-regular]:mapping=tex-text!

Cool. But with lualatex, the output is wrong and there's not a single warning or error to be found. How can I detect missing characters in LuaLaTeX?

It seems that ConTeXt can use \checkcharactersinfont or \enabletrackers[fonts.missing], while XeLaTeX controls it with \tracinglostchars=2.


Here is an adaptation of the Context code for missing glyphs: https://gist.github.com/phi-gamma/5812290.

As the character table shipped with luaotfload is currently experimental, it doesn’t contain the necessary metadata. Thus the code requires the full version of char-def.lua from a Context distribution (installing the Context packages from TL should suffice).

Usage: \startreportmissingglyphs initializes the tracker. Its counterpart, \stopreportmissingglyphs, disables the glyph checker. Example:

  ... some text ...

If invoked with the optional argument [once], \startreportmissingglyphs will report each missing character only once per font. Example output:

missing font terminal output

Note that due to the nature of the Luatex callbacks involved, the glyph checker works on a per-paragraph basis, and \stopreportmissingglyphs will force a paragraph end.

For reference, I include the full example including the definitions of interface macros from the gist:


%% 1) initialize the tracker code (could go to separate file)
\directlua{dofile "track-missing-glyphs.lua"}
%% 2) Environment start: the optional argument “once”, in square
%%    brackets, requests that the missing glyph message be printed
%%    only once per character and font.
%% 3) Environment stop: we need to force a \par here to
%%    have the callback apply to the current paragraph.
  \endgraf %% paragraph-based callback!
%% Usage examples.
  %% Latin modern lacks glyphs for the Greek script so we use that for
  %% testing.
    Program the μC, please.
    %% Works in math mode (different font model) as well.
    $f = ma$

  lorem schmipsum

    %% With the “once” flag, no message is emitted for repetitions of
    %% missing chars.
    Θάλαττα, θάλαττα.
  • Thanks! It's very close. I'm hitting some errors, though: add the text $f(x)$ and it will crash with error: track-missing-glyphs.lua:43: attempt to index field '?' (a nil value)
    – Jim Paris
    Jun 19 '13 at 16:19
  • 1
    @jim-paris please check the updated code. Jun 20 '13 at 8:55
  • Perfect. A million upvotes if I could.
    – Jim Paris
    Jun 21 '13 at 2:21
  • @jim-paris I’ve updated the code again: with the bleeding edge luaotfload installing Context is not required anymore. Jun 22 '13 at 11:19
  • 1
    Ah, now I see. It should be fixed now. Btw. if you want those math Greek characters to be logged correctly you will have to load unicode-math as well. Jul 3 '13 at 19:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.