[Tex/LaTex] Difficulty finding/selecting CM Bright using `fontspec`

fontsfontspecunicode-mathxetex

I'm trying to modify the fonts in my document so that normal text comes up in Calluna, and maths comes up in Computer Modern Bright.

My preamble goes something like this:

\documentclass{article}

\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}

\usepackage{ifxetex}

\ifxetex
    \usepackage{fontspec}
    \usepackage{unicode-math}

    \setmainfont{Calluna}
    \setmathfont{Asana Math}  
    %\setmathfont[range=\mathup]{CMU Bright Medium}
    %\setmathfont[range=\mathbfup]{CMU Bright SemiBold}
    %\setmathfont[range=\mathbfit]{CMU Bright SemiBold}
    %\setmathfont[range=\mathit]{CMU Bright Medium Oblique}
\else
    \usepackage[T1]{fontenc}
    \usepackage{cmbright}
\fi

I've gotten to this stage after looking at other examples on this site that appeared to work for other people.

All the \setmathfont commands are commented out because they gave me an error "font-not-found". Currently, Asana Math is working (for some reason). Other fonts like Latin Modern Math do not.

Calluna is one of my system fonts and comes up fine.

How should I proceed in order to set the maths font to CM Bright? Also, what exactly does the package unicode-math do?

Best Answer

If you inspect your font files in Windows Explorer, you will indeed see that the fonts are called CMU Bright Medium and CMU Bright Medium Oblique.

enter image description here

Since fontspec can't find those fonts, it means that those names are wrong. If you look at the font name in FontForge, for example, you can see that the actual font name of CMU Bright Medium is CMU Bright Roman.

enter image description here

I don't know why Windows thinks differently. Now, if you use the real font names, fontspec finds them and loads them.

\documentclass{article}
\usepackage{fontspec}
\usepackage{unicode-math}
    \setmainfont{Linux Libertine O}
    \setmathfont[range=\mathup]{CMU Bright Roman}
    \setmathfont[range=\mathbfup]{CMU Bright SemiBold}
    \setmathfont[range=\mathbfit]{CMU Bright SemiBold}
    \setmathfont[range=\mathit]{CMU Bright Oblique}
\begin{document}
1234567890
\end{document}

This solves your problem, which is that fontspec couldn't find the CMU Bright fonts. Now, you will notice if you compile the MWE above that fontspec throws a few warnings at you, of the following kind:

*************************************************
* fontspec warning: "script-not-exist-latn"
* 
* Font 'CMU Bright Roman' does not contain script 'Math'.
* 'Latin' script used instead.
*************************************************

These are warnings, not errors. As I understand it, fontspec is simply telling you that the fonts you're loading aren't set up for math use. So you shouldn't use them for math as you're doing here.