# Math alphabet ignores fontspec options on LuaLaTeX

I am trying to create a new math alphabet on LuaLaTeX, based on the code of mathspec. I set up a font family with some options via fontspec and declare it as an alphabet. Although it seems to work, LuaLaTex ignores the options.

Specifically, I borrowed the following lines from mathspec:

\usepackage[no-math]{fontspec}

\makeatletter
\zf@fontspec{Style = Swash}{Arno Pro Italic}
\let\eu@mathcal\zf@family
\DeclareMathAlphabet{\mymathcal}{EU2}{\eu@mathcal}{m}{n}
\makeatother


When I use $\mymathcal{N}$, for example, LuaLaTeX prints a standard italic N instead of its swash version. On the other hand, XeLaTeX works fine (after changing the encoding scheme).

Do you know how I could fix this issue?

You have to use Renderer=Basic. There are also far better ways to define the font, with the newer versions of fontspec

\documentclass{article}
\usepackage[no-math]{fontspec}

\newfontfamily{\myswashfont}{Cochineal}[
Style=Swash,NFSSFamily=myswash,Renderer=Basic
]
\newfontfamily{\mynonswashfont}{Cochineal}[] % just for testing

\DeclareMathAlphabet{\mymathcal}{\encodingdefault}{myswash}{m}{it}

\begin{document}

{\mynonswashfont\itshape ABCDEFHIJKLMNOPQRSTUVWXYZ}

{\myswashfont\itshape ABCDEFHIJKLMNOPQRSTUVWXYZ}

$\mymathcal{Q}$

{\mynonswashfont\itshape Q}

{\myswashfont\itshape Q}

\end{document}


You can see that the third line (with \mymathcal) has the same output as the last one.

• Thank you! It's perfect. Thanks for fixing the question too! – Luca B. May 15 '16 at 14:45