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.

Yan Zhou
  • 9,032
  • 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
  • @MaxNoe -- not kerning the lower i is not wrong, but it is in many publishing houses not traditional. – barbara beeton May 29 '16 at 15:59
  • If I remove unicode-math so that LuaLaTeX uses the legacy CM fonts, the kern is used, so I guess it's a problem with luaotfload. – egreg May 29 '16 at 16:02
  • @MaxNoe - Having the subscript i slightly to the left of the upperscript i is definitely "standard" practice in pdfLaTeX. – Mico May 29 '16 at 16:02
  • I don't have the math font Lucida Bright Math OT on my system, so I can't investigate what may be going on with this font. With TeX Gyre Termes Math, TeX Gyre Termes Math, XITS Math, and Asana 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 or luaotfload are the cause of the issue. – Mico May 29 '16 at 16:08
  • @Mico Isn't it a problem with the font if the font lacks the kerning information completely? Seems odd it worked before, but perhaps LuaTeX was not using font-specific kerning information in maths mode? – cfr May 29 '16 at 16:37
  • 1
    »I would like to reproduce TeX82 always.« That is so cute. – Henri Menke May 29 '16 at 16:43
  • I don't have the lucida font but latin modern math has kerning, but cambria math not. 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
  • @HenriMenke Of course I don't mean everything in TeX82. But basical stuff like these should not break backward compatibility – Yan Zhou May 29 '16 at 16:46
  • @YanZhou Problem is font handling is essentially a complete re-write and works from a different starting point, plus maths isn't the top priority for the LuaTeX people – Joseph Wright May 29 '16 at 16:54
  • @JosephWright So there is no workaround at the moment? – Yan Zhou May 29 '16 at 17:09
  • As some fonts do kern but other not it is quite probably a problem with some tables/values in the fonts and these can be manipulated with lua. That's why I suggested the context list (or the luatex list). – Ulrike Fischer May 29 '16 at 17:23
  • Is there a free font that shows the same bad behaviour. If so, I can check the context output to see if it is a bug in the engine or the macro package – Aditya May 30 '16 at 01:38
  • @aditya according to the comments Cambria Math also shows the problem. However I don't have Windows or office, so I don't have that font. I think it has something to do with missing math kern table. I also tried Minion math, in which case the same problem exists. – Yan Zhou May 30 '16 at 02:22
  • 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 03:13
  • Have you asked Adobe or MS to add the missing table to the fonts? If not, I wonder why not? – cfr May 30 '16 at 03:15
  • @cfr I did not say they are all crappy. The few I mentioned are indeed crappy. Termes, Pagella are poor imitations to their commercial counter parts. There are indeed good free fonts out there. Computer modern and Latin modern which derives from it are very solid, to name just one. I don't use them only because I like humanist designs better. You may have a different taste for fonts. That's fine. Calling someone ignorance only because he shows a different taste, that is true ignorance. – Yan Zhou May 30 '16 at 03:24
  • 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 03:35
  • Not a bug on the engine --- see https://mailman.ntg.nl/pipermail/ntg-context/2016/085765.html and following threads. – Luigi Scarso May 31 '16 at 08:01
  • @LuigiScarso I agree it is not a bug of engine. It's more like the engine handle things differently. It is correct in the sense that it follows exactly the kerning (or lack of it) in the font. I am looking for a way to patch the font to add that kerning infomation – Yan Zhou May 31 '16 at 14:28
  • Testing Minion Math, the kerning is completely wrong and has the wrong height. Integrals look especially awful. Any progress finding the error? – Gaussler Jun 19 '16 at 15:08
  • @Gaussler I haven't seen any of the issues you described – Yan Zhou Jun 19 '16 at 18:07
  • @YanZhou Sorry, I realized I had set up Minion Math wrongly. Anyway, I think the lower limit in integrals looks completely wrong, way too far from the integral sign. – Gaussler Jun 23 '16 at 19:07
  • @Gaussler I haven't seen that either. Looks like you have faulty fonts. This usually happens with pirated ones. – Yan Zhou Jun 24 '16 at 10:50
  • No, what I am talking about now is what happens wirh free fonts as well, like CM and XITS. – Gaussler Jun 24 '16 at 10:52
  • @Gaussler In that case I have no clue. I have seen it with XeTeX, but not with LuaTeX – Yan Zhou Jun 24 '16 at 10:55

0 Answers0