latex3 / unicode-math

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

Incompatibility between math accents and old-style math alphabets like \mathbf with XeLaTeX #400

Open bgvoisin opened 7 years ago

bgvoisin commented 7 years ago

Math accents seem to now give errors when applied to old-style math alphabet commands like \mathbf, and to be just fine when applied to new-style commands like \symbf. Maybe this is known, but I don't remember seeing it mentioned in the unicode-math doc.

I realized that while answering a question to the lucida list, about adapting lucida-amsmath.tex to use the Lucida OpenType fonts. The matter, however, is not specific to Lucida. It is triggered by line 171 of lucida-amsmath.tex

\wh{\mathbf{K}}(i|i),\qquad i=1,\dots,n.

where \wh = \widehat (credit to John Lienhard for identifying this line as the culprit). Any math accent gives the same result. Possible test code:

`\documentclass{article}

\usepackage{kantlipsum}

\usepackage{fontspec} \usepackage{unicode-math} \setmainfont{lmroman10-regular.otf} \setmathfont{latinmodern-math.otf}

\begin{document}

\kant[1-5]

\begin{equation} \widehat{\mathbf{K}}(i|i),\qquad i=1,\dots,n. \end{equation}

\end{document} `

Remove \kant[1-5] so the faulty equation occurs before a page break, the console output with XeLaTeX is

! Internal error: bad native font flag in `map_char_to_glyph'

and XeLaTeX hangs forever. Leave \kant[1-5] so the faulty equation occurs after a page break, output is

! Internal error: bad native font flag in `map_char_to_glyph'

xdvipdfmx:fatal: File ended prematurely

Output file removed.

and the run is terminated. With LuaLaTeX, everything's just fine.

wspr commented 7 years ago

I agree this is not good. In the short term I’m sure you know that you can fix this by loading the package with a kind of backwards compatibility:

\usepackage[mathbf=sym]{unicode-math}

I haven’t been able to trim this down to a minimal example yet… even if I do I’m not sure if XeTeX is being actively maintained at the moment, so it’s good to know it currently works in LuaTeX.