I am trying out the new luatex 0.95 in TeXLive 2016 pretest. There's a problem with math kernel. Below is a MWE
\documentclass{article}
\usepackage{unicode-math}
\setmathfont{Lucida Bright Math OT}
\begin{document}
\selectfont$W_i^i$
\end{document}
When compiled with the new version (0.95), I get the following,
As one can see, the subscript i is not kerned at all. When compiled with older version (TeXLive 2015, version 0.80), I got the correct one,
I did some digging, it seems to have something to do with how the new version handle the mathkern table. It now has to code path, one for TeX82 behavior, and one for OpenType math. Is there anyway to have the new version to fall back to the old behavior? In fact, I would like it to reproduce TeX82 always.
Update 1
@egreg
I don't think the problem is with luaotfload. I tried Asana-math and it is kerned. I also tried Minion Math, it is not kerned. So I did a little bit more inspecting. For those fonts that were kerned, there is a mathkern table for the glyphs in question. And for those that weren't, the mathkern table is nil. In the case of Lucida, there is no mathkern table at all. I also tried to use the old Type 1 Lucida math fonts. And it works correctly. The metric of the new open type Lucida Math is perhaps different than the original one, considering they were released decades apart, but they are similar at least.
It looks to me that luatex 0.9 is taking two different code path for TFM fonts and OT fonts. It has always been doing so to handle OT. However, the final results were usually consistent. Now it seems they handle math kerning differently now. I recall read something along this line somewhere but cannot recall exactly where.
Update 2
I found an old post Weird font/spacing issue with LuaTeX & Asana Math It is somehow related though entirely different issues than what is here. But based on the answer in that post, I tried to patch the font, with something similar to the following,
function patch(font)
if font.psname then
if string.find(font.psname, 'LucidaMath') then
char = font.characters[119882]
char.mathkern = char.mathkern or {}
char.mathkern.bottom_right = char.mathkern.bottom_right or {}
char.mathkern.bottom_right.height = { }
char.mathkern.bottom_right.kern = { -1000 }
end
end
end
After adding the above function to the luaotfload call back, it appears there's no effect at all. I tried to se the kerning to more extreme values just to see if there is any effects. That old post was from a few years ago. So I guess maybe the font table structure has somehow changed. Can anyone point me to the right direction of where should I add/modify the mathkern table in the font data? I looked into the luatex manual, the structure of mathkern table is pretty clear. But it is not clear at all where is is position within the big font data table.
I inspected the font table after patching. The mathkern table is indeed inserted into the character subtable. But is has no effect. I obtained the code point for W by inspecting the output PDF (I think the code point that should be used in the above function should in the math section, not the usual W.)
Update 3
I tried a few more fonts. It appears that commercial fonts like Minion Math, Licida are not handled properly. Fonts like TeX gyre termes math are OK. So I am now left with three choices.
- use crappy free fonts. Those Pagella, Termes, etc., really have pretty bad designs.
- use a good font like Minion math (my go to font) I bear with the keening issues for now. Use
\!when necessary - go back to Math time pro, etc., old PS math font.
None are ideal solution. The best would be if someone point me to the right direction of how to patch the math keening table in Lua. I tried xetex, which has a lot more issues when handling open type math. If some one knows any good reference on how to patch the font, that will be very helpful. Don't point me to the luatex reference manual. It's the worst document of any software I have ever seen.


i? I can also see an aesthetic advantage in having sub and superscript aligned. – MaxNoe May 29 '16 at 15:46iis not wrong, but it is in many publishing houses not traditional. – barbara beeton May 29 '16 at 15:59unicode-mathso that LuaLaTeX uses the legacy CM fonts, the kern is used, so I guess it's a problem withluaotfload. – egreg May 29 '16 at 16:02Lucida Bright Math OTon my system, so I can't investigate what may be going on with this font. WithTeX Gyre Termes Math,TeX Gyre Termes Math,XITS Math, andAsana Math, though, the problem you've described doesn't occur with LuaTeX 0.95 or, for that matter, LuaTeX 0.8. Not sure if LuaTeX orluaotfloadare the cause of the issue. – Mico May 29 '16 at 16:08cambria mathnot. In context there is no kerning with cambria either, so you could ask on the context list. – Ulrike Fischer May 29 '16 at 16:43