Fontspec not allowing to specify italic font in XeLaTeX

fontsfontspecxetex

MWE

\documentclass[]{article}
\usepackage{amsthm,amsmath,amsfonts}

\usepackage[]{fontspec}
\setmainfont{Old Standard}[
FakeBold=2,
%SmallCapsFont=PlayfairDisplaySC-Black.otf,
%BoldFont=ModernMTStd-Bold.otf,
ItalicFont=ModernMT-ExtendedItalic.otf,
%BoldItalicFont=ModernMT-ExtendedItalic.otf,
]

\title{Test}
\author{Me}

\begin{document}
 \maketitle
 Just testing if the sum operator works.
        \begin{align*}
            F(n)
                & = \sum_{d\mid n}f(d)\\
            f\ast g
                & = \sum_{d\mid n}f(d)g(n/d)
        \end{align*}
\end{document}

Error shown: enter image description here

But font is located in the same directory. enter image description here

But if I comment out the italic font, it works properly.

\documentclass[]{article}
\usepackage{amsthm,amsmath,amsfonts}

\usepackage[]{fontspec}
\setmainfont{Old Standard}[
FakeBold=2,
%SmallCapsFont=PlayfairDisplaySC-Black.otf,
%BoldFont=ModernMTStd-Bold.otf,
%ItalicFont=ModernMT-ExtendedItalic.otf,
%BoldItalicFont=ModernMT-ExtendedItalic.otf,
]

\title{Test}
\author{Me}

\begin{document}
\maketitle
Just testing if the sum operator works.
        \begin{align*}
            F(n)
                & = \sum_{d\mid n}f(d)\\
            f\ast g
                & = \sum_{d\mid n}f(d)g(n/d)
        \end{align*}
\end{document}

Output:
enter image description here

Best Answer

fontspec looks in the system font folder for system fonts (installed fonts)*.

Otherwise, tell fontspec which folder the uninstalled fonts are in by using the Path= option.

For example, the following uses AvrileSerif-Bold.ttf as the upright font, and ModernMT-ExtendedItalic.otf as the italic font, both font files are in the local folder, so therefore the Path= option is set to Path=./,:

path option

This is an exaggerated example. I do not recommend random mixing of fonts for actual typesetting.

Note that text mode fonts (upright in blue, italics in red) are independent of math mode fonts). MWE

\documentclass{article}
\usepackage{xcolor}
\usepackage{amsthm,amsmath,amsfonts}

\usepackage{fontspec}
\setmainfont{AvrileSerif}[
FakeBold=2,
%SmallCapsFont=PlayfairDisplaySC-Black.otf,
%BoldFont=ModernMTStd-Bold.otf,
Path=./,
UprightFont=*-Bold.ttf,
UprightFeatures={Colour=blue},
ItalicFont=ModernMT-ExtendedItalic.otf,
ItalicFeatures={Colour=red},
%BoldItalicFont=ModernMT-ExtendedItalic.otf,
]

\title{Test}
\author{Me}

\begin{document}
 \maketitle
 Just testing if the \textit{sum operator} works.
        \begin{align*}
            F(n)
                & = \sum_{d\mid n}f(d)\\
            f\ast g
                & = \sum_{d\mid n}f(d)g(n/d)
        \end{align*}
\end{document}

*On Windows, fonts installed as user are not visible; instead, install them as admin.

Related Question