latex3 / unicode-math

XeLaTeX/LuaLaTeX package for using unicode/OpenType maths fonts
http://ctan.org/pkg/unicode-math
LaTeX Project Public License v1.3c
239 stars 28 forks source link

Allow multiple extra fonts to be defined for missing characters. #513

Open beojan opened 5 years ago

beojan commented 5 years ago

Description

As stated here, there is no way to request an additional font to be used as fallback if glyphs are missing in the main math font.

The best that can be done is setting the main font for the latin,Latin,greek,Greek,num ranges, but the fallback now needs all glyphs, including, e.g., the decimal point and comma. This prevents using a symbol only font like MdSymbol.

Check/indicate

Minimal example demonstrating the issue

\documentclass{article}
\usepackage{unicode-math}
\setmathfont{mdsymbol}
\setmathfont[ranges={up/{latin,Latin,greek,Greek,num}}]{Fira Math Light}
\begin{document}
\[
  \sum_{a \in b} f_{a}(1,3) = 4.5
\]
\end{document}
wspr commented 5 years ago

Can you please update the example to use explicit filenames? This makes it much easier for me to replicate. Presumably MdSymbol-Regular.otf is the font you are referring to?

beojan commented 5 years ago

Here, and tested this time so I haven't misspelled range.

\documentclass{article}
\usepackage{unicode-math}
\setmathfont{MdSymbol-Light.otf}
\setmathfont[range=up/{latin,Latin,greek,Greek,num}]{FiraMath-Light.otf}
\setmathfont[range=it/{latin,Latin,greek,Greek,num}]{FiraMath-Light.otf}
\begin{document}
\[
  \sum_{a \in b} f_{a}(1,3) = 4.5
\]
\end{document}
wspr commented 5 years ago

(As a side note, if you're changing every alphabet range you should be able to just write range=up...)

beojan commented 5 years ago

Wouldn't that change everything?

wspr commented 5 years ago

I don't really see how. Maybe I am missing something, or maybe this feature doesn't quite work as I expect.

Actually in the next release of unicode-math this example won't work. Maybe I need to rethink the interface a little, but the idea is going to be that the first maths font chosen must be an OpenType math font to act as the fallback font and the font from which various dimensions are used.

I could then add a "slow" loading option which checked dynamically at load time which character slots have glyphs actually present in the font.

beojan commented 5 years ago

I don't really see how. Maybe I am missing something, or maybe this feature doesn't quite work as I expect.

No, it looks like I was mistaken, and range=up indeed only changes the alphabet ranges.

the idea is going to be that the first maths font chosen must be an OpenType math font to act as the fallback font and the font from which various dimensions are used.

I could then add a "slow" loading option which checked dynamically at load time which character slots have glyphs actually present in the font.

That's exactly what I was hoping for. Though perhaps it could be the other way around, with metrics taken from one font and a separate one being the fallback. For instance here, Fira Math is a proper math font with many symbols, it's just missing a few that I was trying to take from MdSymbol. Not being able to do this, I gave up and instead tried to use MdSymbol as the main math font with Fira Math as the fallback, but I would prefer to be able to use Fira Math symbols wherever they actually exist.