LuaLaTeX: Remapping \mathcal letters for Asana Math
Here, I restore \mathcal
to a more traditional look, saving the undesired revision as \svmathcal
.
\documentclass{article}
\usepackage{amsmath,bm}
\usepackage{fontspec}
\usepackage{unicode-math}
\setmathfont{Asana Math}
\let\svmathcal\mathcal
\DeclareSymbolFontAlphabet{\mathcal} {symbols}
\DeclareMathAlphabet{\mathcal}{OMS}{cmsy}{m}{n}
\SetMathAlphabet{\mathcal}{bold}{OMS}{cmsy}{b}{n}
\begin{document}
$\mathcal{H}$ vs $\svmathcal{H}$
Also in bold:
$\bm{\mathcal{H}}$
\end{document}
I got the idea from egreg at Mathcal in fouriernc package
Asana Math includes these as Stylistic Alternates, so you can request them by adding Style=Alternate
to \setmathfont
.
\documentclass{article}
\usepackage{amsmath}
\usepackage{fontspec}
\usepackage{unicode-math}
\setmathfont[Style=Alternate]{Asana Math}
\begin{document}
$\mathcal{ABCDEFGHIJKLMNOPQRSTUVWXYZ}$
$\mathbfcal{ABCDEFGHIJKLMNOPQRSTUVWXYZ}$
\end{document}
You might be wondering about \mathcal{R}
. I think this is a font bug, because the replacement glyph does exists, it just isn't set up to be a stylistig alternate...
You can patch the font in LuaTeX to fix this, but that's a bit complicated because the fontloader discard the glyphname, so the glyph is a bit complicated to find:
\documentclass{article}
\usepackage{amsmath}
\usepackage{fontspec}
\usepackage{unicode-math}
\directlua{
% We want to stop the fontloader from discarding names it considers useless, so enable keepnames
fonts.privateoffsets.keepnames = true
% That's not quite enough because the font is most likely already cached without the names, so disable the cache
% WARNING: This affects all fonts you load in this documet from here on. This will make your document significantly slower.
fonts.handlers.otf.cache.enabled = false
fonts.handlers.otf.addfeature {
name = "asana-salt-r",
type = "substitution",
data = {
[0x211B] = "uni211B.salt"
},
}
}
\setmathfont[RawFeature=asana-salt-r,Style=Alternate]{Asana Math}
\begin{document}
\[\mathcal{ABCDEFGHIJKLMNOPQRSTUVWXYZ}\]
\[\mathbfcal{ABCDEFGHIJKLMNOPQRSTUVWXYZ}\]
\end{document}