Closed bgvoisin closed 6 years ago
After more testing, it seems the hooks into fontspec are simply not working: \mathrm does pick the font selected by \setmainfont, but none of the other \mathbf, \mathit, \mathsf or \mathtt seems to take \setmainfont, \setsansfont and \setmonofont into account. On the other hand, setting those explicitly with \setmathfontface solves the matter. I looked at the implementation part of the doc (G.3 Hooks into fontspec), to try to understand what was going on; but unfortunately, owing to my lack of knowledge of LaTeX 3, I could not figure out what was going wrong hence cannot propose a fix.
@bgvoisin — thanks much, as always, Bruno. I'll try to fix this up sooner rather than later — it sounds like I've missed something here and it's been too long since I looked into an update for unicode-math.
Ah, and I can see exactly where the problem is :( This did in fact work once upon a time. But then I renamed some internal fontspec commands that unicode-math was trying to override! I should have been more careful there...
Update to come. (I hope this week.)
I noticed that loading unicode-math
after using \setsansfont
/\setmathsf
etc. will also reset the traditional-style math-font commands to Computer Modern. Is that behavior the same as this issue, intended behavior or a separate issue?
I don't know whether that's connected. This arises because of something mentioned casually in section 4.4.1 of the doc, "Default 'text math' fonts" : "When selecting document fonts using fontspec commands such as \setmainfont, unicode-math inserts some additional that keeps the current default fonts ‘in sync’ with their corresponding \mathrm commands, etc.". An implicit consequence is that unicode-math must be loaded before using \setmainfont etc., so that it can modify the definition of \setmainfont before the latter is actually used (the modification being to have \setmainfont influence \mathrm, and so forth).
Needless to say, I had never noticed this in the doc, before writing one or two years ago, in essence,
\usepackage{fontspec}
\setmainfont{LucidaBrightOT.otf}
\setsansfont{LucidaSansOT.otf}
\setmonofont{LucidaSansTypewriterOT.otf}
\usepackage{unicode-math}
\setmathfont{LucidaBrightMathOT.otf}
and finding out something wasn't right. It's only after some time testing that I realized the order mattered, and you need to write instead
\usepackage{fontspec}
\usepackage{unicode-math}
\setmainfont{LucidaBrightOT.otf}
\setsansfont{LucidaSansOT.otf}
\setmonofont{LucidaSansTypewriterOT.otf}
\setmathfont{LucidaBrightMathOT.otf}
then finally found the above section in the doc, providing a likely explanation.
Otherwise, if \setmainfont is used before calling unicode-math, the unicode-math default prevails, which is to use Latin Modern for \mathrm etc.
@bgvoisin I didn’t really expect that loading unicode-math
would retroactively make \setsansfont
have an effect on \mathsf
. What was surprising to me, however, was that loading unicode-math
undoes the effect of \setmathsf
on \mathsf
.
Sorry, I had forgotten fontspec used \setmainfont to redefine \mathrm already, and similarly for \setsansfont and \setmonofont, even without loading unicode-math.
Going back to your original question, this (ie unicode-math's undoing of fontspec's doing) must be related then.
Le 1 oct. 2017 à 15:50, tkalliom notifications@github.com a écrit :
@bgvoisin https://github.com/bgvoisin I didn’t really expect that loading unicode-math would retroactively make \setsansfont have an effect on \mathsf. What was surprising to me, however, was that loading unicode-math undoes the effect of \setmathsf on \mathsf.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/wspr/unicode-math/issues/404#issuecomment-333377972, or mute the thread https://github.com/notifications/unsubscribe-auth/AWAQD-L_5pN8glefqN4pixDtMkigHXJEks5sn5i2gaJpZM4PRuXy.
@tkalliom — the behaviour you describe is (I think) unrelated to this issue. I'm going to have to dig into this a little deeper; I'm not 100% why it's happening.
This issue should now be fixed in the latest upload to CTAN (v0.8g, just sent through now). Thanks again Bruno!
See the attached example: \symit and \textit yield the fonts set by fontspec and unicode-math, but \mathit and \mathtextit default to Computer Modern. I do not know whether that is intended behaviour, or something I'm doing wrong, or a bug, as I don't fully understand the difference between \symXYZ, \textXYZ and \mathXYZ.
umtest.zip