6

I am looking to replace the TeX command \iffontchar with Lua code. Reason I am printing some tables with Lua code and want to replace the notdef(tofu) with something else.

\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}

enter image description here

yannisl
  • 117,160

0 Answers0