[Tex/LaTex] Specifying the font for only one character with unicode-math

fontsfontspecunicode-mathxetex

I'm using XeTeX and the fontspec and unicode-math packages. In order to use a different math font for Greek letters, I do something like this, using the range option of \setmathfont:

\setmathfont[Path=/usr/share/texmf/fonts/opentype/public/tex-gyre-math/]{texgyretermes-math.otf} 
\setmathfont[range=\mathit/{greek,Greek},Path=/usr/share/texmf/fonts/opentype/public/tex-gyre/]{texgyretermes-regular.otf} 

Now, how could I change the font for only one Greek letter (say \phi) ?

Update

Based on @egreg's answer (which is deleted now), I tried the following code. The $\phi$ does not appear in the output. If I replace this line by the commented line, then $\phi$ appears in the output but it is not in regular font.

% !TeX program = XeLaTeX
% !Mode:: "TeX:UTF-8"
\documentclass[fontsize=12pt]{scrartcl}
\usepackage{amsmath,amssymb,amsfonts,amsthm}
\usepackage{unicode-math}
\usepackage{fontspec}
\setmonofont[Path=/usr/share/fonts/truetype/freefont/,Scale = 1.05]{FreeMonoBold.ttf} 
\setmainfont
[        Scale = 1.1,
     Extension = .otf,
   UprightFont = *-regular,
      BoldFont = *-bold,
    ItalicFont = *-italic,
BoldItalicFont = *-bolditalic,
]{xits}

\setmathfont[Path=/usr/share/texmf/fonts/opentype/public/tex-gyre-math/]{texgyretermes-math.otf} 
\setmathfont[range={\mitvarphi,\mitphi},Path=/usr/share/texmf/fonts/opentype/public/tex-gyre/]{texgyretermes-regular.otf}
% \setmathfont[range=\mathit/{varphi,phi},Path=/usr/share/texmf/fonts/opentype/public/tex-gyre/]{texgyretermes-regular.otf}
\setmathfont[range=\int,Path=/usr/share/texmf/fonts/opentype/public/tex-gyre-math/]{texgyretermes-math.otf}

\begin{document}

$\phi = \psi+1$. 

\end{document}

Second update

Since I use only three greek letters in my document, phi, mu and lambda, the following code works :

\setmathfont[Path=/usr/share/texmf/fonts/opentype/public/tex-gyre-math/]{texgyretermes-math.otf} 
\setmathfont[range=\mathit/{greek,Greek},Path=/usr/share/texmf/fonts/opentype/public/tex-gyre/]{texgyretermes-regular.otf} 
\setmathfont[range={\mitmu,\mitlambda},Path=/usr/share/texmf/fonts/opentype/public/tex-gyre-math/]{texgyretermes-math.otf} 

Best Answer

In normal text, phi is only one glyph, and the font makes it upright, bold, italic, bold-italic. In math text, there are a dozen phi glyphs, and the boldness, italic is part of the glyph itself:

phi math

To have upright lower case Greek, use \setmathfont{Asana Math}[math-style=french], for example, and use \mitphi for italic phi.

\documentclass[12pt]{article}
\usepackage{xcolor}
\usepackage{unicode-math}
\setmathfont{Asana Math}[math-style=french,Colour=blue]
\setmathfont{Asana Math}[range={\mitphi},Colour=red]
\setmainfont{Noto Serif}

\begin{document}
abc xyz 
$𝛗𝜙𝝋𝞍𝞿
\mupphi
\mupvarphi
\mbfphi
\mbfvarphi
\mitvarphi
\mitphi
\mbfitvarphi
\mbfitphi
\mbfsansvarphi
\mbfsansphi
\mbfitsansvarphi
\mbfitsansphi
$

$\phi \mu \lambda$
\end{document}

Use \AtBeginDocument{\renewcommand\mupphi{\mitphi}} to redefine upright phi as italic phi.

mupphi redefined

\documentclass[12pt]{article}
\usepackage{xcolor}
\usepackage{unicode-math}
\setmathfont{Asana Math}[math-style=french,Colour=blue]
\setmathfont{Asana Math}[range={\mitphi},Colour=red]
\setmainfont{Noto Serif}
\AtBeginDocument{\renewcommand\mupphi{\mitphi}}

\begin{document}
phi $\phi$, upright phi (now italic) $ \mupphi$, and the rest $ \mu \lambda$
\end{document}

To do the converse, italic lower case Greek with italic phi redefined as upright phi:

phi 2

\documentclass[12pt]{article}
\usepackage{xcolor}
\usepackage{unicode-math}
\setmathfont{Asana Math}[Colour=blue]
\setmathfont{Asana Math}[range={\mupphi},Colour=red]
\setmainfont{Noto Serif}
\AtBeginDocument{\renewcommand\mitphi{\mupphi}}

\begin{document}
phi $\phi$, italic phi (now upright) $ \mitphi$, and the rest $ \mu \lambda$
\end{document}

Or maybe even just use \mupphi wherever needed.