# How to use luatex with large unicode codepoint?

I am trying to use the Material Design Icon Font with lualatex.

The Material Design icon set is made available as a webfont, including a ttf version at https://materialdesignicons.com/ (use the download button to get version 5.4.55). The downloaded file materialdesignicons-webfont.ttf declares the font name "Material Design Icons" and when saved at a system accessible place seems to work with regular applications like Libreoffice. Specifically, the icons at https://pictogrammers.github.io/@mdi/font/5.4.55/ appear to be usable.

However, if I try to use that with luatex as:

\documentclass{article}
\usepackage{fontspec}
\newfontface\MDI{Material Design Icons}[]

\begin{document}
Look at this character {\MDI \char"F1372}!
\end{document}


then I cannot seem to get the correct characters. For instance F1372 should be mdi-account-details-outline character according to the table in https://pictogrammers.github.io/@mdi/font/5.4.55/ but it turns out as a different character.

Any idea?

• It works with XeLaTeX, so I guess it's a luaotfload issue. If I ask \showoutput, the shown code point is F1372. – egreg May 11 at 11:34

The code works as expected with XeLaTeX. With LuaLaTeX it seems that there is an offset by 14.

\documentclass{article}
\usepackage{fontspec,iftex}

\newfontface\MDI{materialdesignicons-webfont.ttf}
\newcommand{\mdiicon}[1]{%
{\MDI\symbol{\numexpr"#1\ifluatex-14\fi}}%
}

\pagestyle{empty}

\begin{document}

Look at this character \mdiicon{F1372}!

Look at this character \mdiicon{F1380}!

\end{document}


The output is the same for both engines.

• the offset depends sadly on the actual char. There are some duplicates and luaotfload removes them, so the offset increases. F0001 e.g. is okay – Ulrike Fischer May 11 at 12:20

The values are a bit off because of duplicates. But you can make yourself a table:

\documentclass{article}
\usepackage{fontspec,xfp}
\newfontface\MDI{Material Design Icons}[]

\begin{document}

\ExplSyntaxOn\raggedright
{\MDI \int_step_inline:nnn{983041}{983041+5940}{\makebox[6em][l]{{\ttfamily \int_to_Hex:n{#1}:}\hfill\char\int_eval:n{#1},}~}}
\ExplSyntaxOff

\end{document}

• Seems a bug of luaotfload to me. Breaks compatibility with xelatex and cut and paste too. Reported as github.com/latex3/luaotfload/issues/185 – Callegar May 11 at 13:00
• @Callegar - your bug report over there, and response to the maintainer's comment too, seem right to me (though I am no TeX expert. And since the entire raison d'être of TeX and derivatives is predictable output - the pushback is surprising to me. – davidbak May 12 at 0:33