我想\iffontchar
用 Lua 代码替换 TeX 命令。原因是我要用 Lua 代码打印一些表格,并想用其他代码替换 notdef(tofu)。
\documentclass{article}
\usepackage{fontspec}
% Font at https://github.com/unicode-org/last-resort-font
\newfontfamily\lastresort{lastResort}
\newfontfamily\symbolfont{Symbola}
\providecommand\graybox{{\symbolfont \char"2591}}
\usepackage{luacode}
\begin{document}
\raggedright
\language-1
\begin{luacode}
for codepoint=0x0061,0x007A,1 do
if codepoint then tex.sprint(utf8.char(codepoint)) end
end
\end{luacode}
% TeX from here on
\bgroup
% INVALID CHARS
\iffontchar\font"0x0 \else \graybox\fi
\luadirect{tex.print(utf8.char(0x16B02))}
\lastresort
\luadirect{tex.sprint(utf8.char(0x16B02))}
%\luadirect{tex.sprint(utf8.char(0x2407))} <controls in pictures block
\egroup
\end{document}