10

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,

enter image description here

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,

enter image description here

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.

  1. use crappy free fonts. Those Pagella, Termes, etc., really have pretty bad designs.
  2. use a good font like Minion math (my go to font) I bear with the keening issues for now. Use \! when necessary
  3. 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.

  • Are you sure it is "wrong" to not kern the lower i? I can also see an aesthetic advantage in having sub and superscript aligned. – MaxNoe May 29 '16 at 15:46
  • @MaxNoe It is definitely wrong not to kern the subscript. – egreg May 29 '16 at 15:58
  • 1
    »I would like to reproduce TeX82 always.« That is so cute. – Henri Menke May 29 '16 at 16:43
  • 2
    May I say that the claim that all free fonts are crap demonstrates a rather surprising ignorance for somebody who uses TeX. Coming to this site and saying it demonstrates an astonishing level of social ignorance. The claim is all the more remarkable given the fact that you cannot yet provide a single example of a free maths font which demonstrates the behaviour you are complaining of. Apparently crap fonts are doing something right, though you seem not to have noticed it. – cfr May 30 '16 at 3:13
  • 1
    In that case, you have stated a false trichotomy: the three options you list do not exhaust your choices. If those are your only choices, then you must mean the claim about free fonts generally. Otherwise you have other choices you don't list. Not liking a font isn't the same as thinking it is crappy. I think Pagella is OK for text, although I don't think it is great. Termes doesn't seem worse to me than Times, but I don't like Times a lot, so that's not saying much. And I don't use either for maths. Actually, I almost always use LM. EB Garamond or Venturis or something else for a change. – cfr May 30 '16 at 3:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.