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

Missing fonts with luahblatex #536

Closed callegar closed 4 years ago

callegar commented 4 years ago

Description

TeXLive makes it possible to test the forthcoming version by invoking -dev versions of the latex engines. For instance, in place of lualatex one can run lualatex-dev. The latter relies on luahbtex (Version 1.11.2) and the forthcoming version of the latex2e format (now LaTeX2e <2020-02-01> pre-release-3 (develop 2020-1-14 branch) ). Conversely, lualatex gets you luatex (Version 1.10.0) and the current stable version of the latex2e format (LaTeX2e <2019-10-01> patch level 3).

The unicode-math package triggers font substitution warnings with the -dev combination. For instance:

LaTeX Font Warning: Font shape `TU/XITSMath(1)/m/up' undefined
(Font)              using `TU/XITSMath(1)/m/n' instead on input line 21.

LaTeX Font Warning: Font shape `TU/XITSMath(2)/m/up' undefined
(Font)              using `TU/XITSMath(2)/m/n' instead on input line 21.

LaTeX Font Warning: Font shape `TU/XITSMath(3)/m/up' undefined
(Font)              using `TU/XITSMath(3)/m/n' instead on input line 21.

and

 LaTeX Font Warning: Font shape `TU/SourceSansPro(1)/m/up' undefined
(Font)              using `TU/SourceSansPro(1)/m/n' instead on input line 62.

LaTeX Font Warning: Font shape `TU/SourceCodePro(1)/m/up' undefined
(Font)              using `TU/SourceCodePro(1)/m/n' instead on input line 62.

(./testo.incl.tex

LaTeX Font Warning: Font shape `TU/SourceSerifPro(1)/m/up' undefined
(Font)              using `TU/SourceSerifPro(1)/m/n' instead on input line 18.

The warnings appear to be always related to seeking up fonts, not finding them and substituting n fonts for them.

It is unclear to me whether the problem is in unicode-math being in need to catch up with newer engines/formats or real problems in the latex format or in luahblatex.

Add info or delete as appropriate:

Minimal example demonstrating the issue

The preconfigured test document is actually sufficient to show the issue, no need to invent anything new ;-) :

\documentclass{article}
\usepackage{unicode-math}
\setmathfont{texgyrepagella-math.otf}% filename only please!
\begin{document}
\[
  a = b
\]
\end{document}
FrankMittelbach commented 4 years ago

looks like Will overlooked that he also has to adjust unicode-math: that is still using \updefault to set up the symbol fonts, but should use either explicitly "n" or \shapedefault.

It should be harmless, but, if you want to avoid the warning messages during testing, try

\let\updefault\shapedefault
\setmathfont{texgyrepagella-math.otf}% filename only please!
\def\updefault{up}
callegar commented 4 years ago

The trick works! Looks like I need to use the \let\updefault\shapedefault before setting the main, mono and sans font, otherwise I get the warning with those fonts too. Thanks!

u-fischer commented 4 years ago

If you get the warnings with text fonts too, it could indicated that your fontspec version is not up-to-date.

callegar commented 4 years ago

Should be since I have run tlmgr update --all as of today. Interestingly, the warning with the text fonts appear to only occur if I load unicode-math. I'll try to test more as soon as I have some time for it. The \let\updefault\shapedefault seems to break compilation with regular lualatex (hangs with high CPU usage after showing /usr/local/texlive/2019/texmf-dist/tex/latex/unicode-math/unicode-math-table.tex).

FrankMittelbach commented 4 years ago

Use \def\updefault{n} instead not sure if the \let could produce a loop if some files are old and others new method, looks like it.

callegar commented 4 years ago

Weird enough, the latest trick still fixes the behavior with lualatex-dev and lets lualatex work without hanging, but creates the missing font issue with lualatex. In other words, with

\usepackage[mathup=sym]{unicode-math}
\def\updefault{n}
\setsansfont{Source Sans Pro}
\setmainfont{Source Serif Pro}
\setmonofont{Source Code Pro}[Scale=MatchLowercase]
\setmathfont{XITS Math}
\def\updefault{up}

everything is fine with lualatex-dev, but stable lualatex now gives me:

LaTeX Font Warning: Font shape `TU/SourceSerifPro(0)/m/up' undefined
(Font)              using `TU/SourceSerifPro(0)/m/n' instead on input line 64.

and

LaTeX Font Warning: Font shape `TU/SourceSansPro(0)/m/up' undefined
(Font)              using `TU/SourceSansPro(0)/m/n' instead on input line 65.

The other way round, without the first \updefault redefinition, I get the errors with lualatex-dev but not with lualatex.

Removing the final \def\updefault{up} seems to make both happy.

FrankMittelbach commented 4 years ago

Removing the final \def\updefault{up} seems to make both happy.

yes and no. I think you slightly misunderstand the situation.

So once unicode-math is corrected the file will work (without any \def or \let) correctly in the old and the new LaTeX. But with the workaround it will not work in an old installation because there \updefault should be "n" all the time --- which is why you see warnings if you add \def\updefault{up} and then run it through the old LaTeX.

callegar commented 4 years ago

Clear now! Sorry for having made you type such a long explanation, but definitely thanks for it!

FrankMittelbach commented 4 years ago

Well obviously my writing in ltnews31 wasn't clear enough (so my fault really:-)) if you have any suggestion on what could be improved in the explanation there please suggest it.

callegar commented 4 years ago

Thanks for the fix!