I have a document:
\documentclass{article}
\usepackage{fontspec}
\begin{document}
Program the μC, please.
\end{document}
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
.
Best Answer
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:If invoked with the optional argument
[once]
,\startreportmissingglyphs
will report each missing character only once per font. Example 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: