# Picking single glyph with setmathfont range modifies other glyphs

How can I change the font used for just one glyph without affecting any other glyph ?

I recently switched from pdfLaTeX to XeLaTeX and fontspec and unicode-math.

I am using TeX Gyre Pagella as my main math font but I do not like the glyph for the empty set so I want to use the glyph from Asana Math for this symbol.

I am trying to achieve this with the range feature of unicode-math as per Section 4.1 of its manual :

\documentclass{article}
\usepackage{fontspec}
\usepackage{unicode-math}
\setmathfont{texgyrepagella-math.otf}
\setmathfont{Asana-Math.otf}[range={\emptyset}]
\begin{document}
$\emptyset\mathbb N\BbbN$
\end{document}


This does not give the result I expected :

The emptyset symbol still comes from Pagella, and the \mathbb alphabet has been changed to the one from Asana.

Changing the range to [range={\varnothing}] does give the correct emptyset symbol (which I find strange, but it works !) but still has unintended consequences :

I tried to change the range to [range=up/{\varnothing}] to indicate that I only want to affect the upshape font, but this does not compile :

! Undefined control sequence.
\l__um_alphabet_tl ->\varnothing

l.5 ...ont{Asana-Math.otf}[range=up/{\varnothing}]


Note : unicode-math if v0.8f and fontspec is v2.6d, from TexLive 2017.

## Edit about a previously accepted solution

The workaround with [range={\int}] causes unwanted space with delimiters :

\documentclass{article}
\usepackage{fontspec}
\usepackage{unicode-math}
\setmathfont{texgyrepagella-math.otf}
\setmathfont{Asana-Math.otf}[range={\varnothing}]
\setmathfont{texgyrepagella-math.otf}[range={\int}]
\begin{document}
$\big||a| - |b|\big|\leq|a-b|$
\end{document}


The empty-range trick described there has the same effect.

• I added an edit regarding the spacing issue. – Ulrike Fischer Aug 23 '17 at 15:11

The range option is a bit buggy and has a tendency to change more than you want. So use it with care. In your case if works, if you reset the font to your main font at the end (but imho the symbol doesn't really fit):

\documentclass{article}
\usepackage{fontspec}
\usepackage{unicode-math}
\setmathfont{texgyrepagella-math.otf}
\setmathfont{Asana-Math.otf}[range={\varnothing}]
\setmathfont{texgyrepagella-math.otf}[range={\int}]
\begin{document}
$\emptyset\mathbb N\BbbN$
\end{document}


The unwanted space is due to a bug in unicode-math regarding the delcode of the period. In this case it only affects xelatex, with lualatex there is no problem. See also https://github.com/wspr/unicode-math/issues/344. A work-around (I wouldn't call it a solution as the number has to be found out) is:

\documentclass{article}

\usepackage{fontspec}
\usepackage{unicode-math}
\setmathfont{texgyrepagella-math.otf}

\setmathfont{Asana-Math.otf}[range={\varnothing}]
\setmathfont{texgyrepagella-math.otf}[range={\int}]

\Udelcodenum.=1073741824
\begin{document}
$\big||a| - |b|\big|\leq|a-b|$
\end{document}
`
• That's the "experimental" side of unicode-math ! Regarding the glyph: the one from Pagella looks like a stroked-through zero (like the glyph in Computer Modern) which I always found strange because in handwriting, the empty set symbol really has a circular shape, not oval like a zero (at least in France). – ysalmon Aug 17 '17 at 20:09