# Arithmetic overflow with fontspec and LuaTeX

I have the following code using this font:

\documentclass{minimal}

\usepackage{lettrine}
\usepackage{fontspec,xunicode}

\newfontfamily\EBLettrineFont{EBGaramondInitialsF2}
\renewcommand{\LettrineFontHook}{\EBLettrineFont}

\begin{document}

\lettrine{T}{his} is a test

\end{document}


It works fine with xelatex, but crashes with lualatex:

! Arithmetic overflow.
\LettrineFont ...\divide \@tempcnta by \@tempcntb
l.11 \lettrine{T}{his}
is a test
?


What is wrong?

-
is this font free available for download? –  Herbert Aug 23 '11 at 11:27
When I try to compile your example with lualatex (beta-0.65.0-2011041019 (rev 4033) from Ubuntu's TL2009) I get another error, I get XeTeX is required to compile this document.. –  N.N. Aug 23 '11 at 11:28
@Herbert: the link is in the question (where it says "this font"). –  ℝaphink Aug 23 '11 at 11:30
@N.N. Up-to-date TL2011 has LuaTeX beta-0.70.1-2011061410 (rev 4277) –  ℝaphink Aug 23 '11 at 11:31

The lettrine package depends on the font having the character X in order to perform its calculations; and this font, it seems, does not have the character. The lettrine macro in question is \LettrineFont. It constructs a box containing the X in a given font and then measures its height. For this font and this character, LuaTeX reports a box height of 0 pt. A following integer division then fails.

Strictly speaking, the lettrine assumption is fair and the font is at fault for not providing even a minimal set of characters. If you still want to use this font, the easiest way is to modify \LettrineFont to use a character that exists in this font, such as O:

\documentclass{minimal}

\usepackage{lettrine}
\usepackage{fontspec,xunicode}
\usepackage{etoolbox}

\newfontfamily\EBLettrineFont{EBGaramondInitialsF2}
\renewcommand{\LettrineFontHook}{\EBLettrineFont}

\patchcmd{\LettrineFont}{\selectfont X}{\selectfont O}{}{%
\GenericWarning{}{Patching \protect\LettrineFont\space failed}}

\begin{document}

\lettrine{T}{his} is a test

\end{document}


XeTeX, unlike LuaTeX, returns the height of nonexistent X as 8.10722 pt with this example code, and therefore division by zero does not occur.

-
Thank you very much! –  ℝaphink Aug 23 '11 at 11:48