5

I wanted to use \matcal{H} with my math font Asana Math in LuaLaTeX (with the help of unicode-math). Unfortunately, the assigned calligraphic characters for Asana Math are not the ones I want to use:

From my earlier uses of this font with Microsoft Word I know that there comes a more standard-ish design with Asana Math for calligraphic letters:

Is there any way to add this (extended) unicode character in a formula? I tried the following workaround: \textrm{\fontspec{Asana Math}{\char"10FEA9}}

This led to the following:

I assume that this character couldn't be detected somehow. What can I do or is there even a better approach?

2 Answers 2

9

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}

enter image description here

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}
0
5

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}

enter image description here

I got the idea from egreg at Mathcal in fouriernc package

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .