2

The original Computer Modern Math Italic font has a modest amount of kerning listed in its TFM metrics (largely for punctuation, but also for some exceptions like lower case d).

enter image description here

But when I use Latin Modern Math as a replacement using unicode-math in either of xelatex or lualatex, those kerns seem to be AWOL.

enter image description here

The GPOS table in all of the unicode math fonts I've looked at has no kern tables. Is it really the case that OpenType math fonts don't have pair-based kerns? There's italic correction information in the MATH tables, of course, but I didn't see anything in the MATH table that corresponds to the kerns that seem to be missing.

3
  • Welcome to TeX.SX! Please help us help you and add a minimal working example (MWE) that illustrates your problem. Reproducing the problem and finding out what the issue is will be much easier when we see compilable code, starting with \documentclass{...} and ending with \end{document}
    – DG'
    Aug 5, 2023 at 15:29
  • 1
    It seems that the question is about fonts. There is no common with LaTeX. For example, the same issue can be tested by other TeX formats. So, asking for a LaTeX minimal example is irrelevant here.
    – wipet
    Aug 5, 2023 at 20:54
  • You can try \mathitalicsmode=2 in luatex, and see if you are just a bit happier with the result. (You might get other unwanted side effects...)
    – mickep
    Aug 7, 2023 at 14:37

1 Answer 1

4

Is it really the case that OpenType math fonts don't have pair-based kerns?

Yes. If you read the spec, you will first find

Layout of math formulas is quite different from regular text layout that is done using tables such as GSUB and GPOS. Regular text layout mainly deals with a line of text, often formatted with a single font. In this situation, actions such as contextual substitution or kerning can be done with access to the complete context of the line of text, and the rules can be expressed in terms of known glyph sequences. Math layout is quite different from this.

that indicates that OpenType math is not kerned. But scrolling further down, you find a long section on kerning, but that happens to be about staircase kerning (for each corner of a glyph, one can have kerns that control where sub- super- and prescripts are placed). Kerns between pairs of letters are not mentioned.

If we turn to your example, I am not convinced that the very tight kerned df you show looks good. But maybe a little would be good.

The rest of the answer might or might not be interesting to you. It might be interesting to others, so I add it anyways.

I am sure that luatex supports pairwise kerning (I hope some LaTeX user will show you how), but I don't know how it is done. In ConTeXt lmtx, it is supported, and the correct way of adding it is in a goodie file. First a look at how it looks here without that tweak:

df-nottweaked

With the tweak it looks like this:

df-tweaked

The tweak, placed in modern-math.lfg, is a small lua snippet:

{
    tweak = "kernpairs",
    list = {
        [0x1D451] = { -- italic d
            [0x1D453] = -.2, -- italic f
        },
    },
},

Of course, the user input was $df$ in both cases.

As a final comment: When looking at the staircase kerns (a few fonts have them) they often look a bit odd, even in Cambria. Maybe that was a cool thing they added that was not too useful. In ConTeXt lmtx, these are converted to the corner kerns (just one value), and that seems to be working well. They are for example enabled for large parentheses, making powers automatically move a bit closer (see the orange boxes).

A power of 2

6
  • Yep, I'd spent some time with the spec and I didn't see anything there that plainly says math fonts don't also support kerns via GPOS. The opening blurb is at best an implicit statement and the staircase kerns are orthogonal. I had had the impression that Latin Modern Math was a drop in replacement for cmmi etc, but if there are no kerns then that's not quite true. Knuth's choice to tightly kern the d is debatable. On the other hand, the comma is hard to disagree with and it seems odd that that's not just a built-in thing anymore, that the march of progress seems to have lost a good thing.
    – dmaxwell
    Aug 5, 2023 at 18:36
  • 1
    The "tightly kerned d" is a difference of opinion. Knuth uses an italic d for differential notation; the creators of Latin Modern apparently believe that a roman d should be used instead, meaning that the d can be treated like all other variables. This isn't likely to be resolved easily, but Knuth would not approve of the LM choice. The tradition I was raised in agrees with Knuth. Aug 5, 2023 at 19:36
  • It would be pretty easy to run over the kerning pairs from cmmi and add all of them as I did in my answer. I don't know, though, if the other metrics are the same for latin modern and computer modern, so maybe something else would then be messed up.
    – mickep
    Aug 5, 2023 at 19:45
  • It's starting to look like this wasn't even an option that the creators of LM were given. If kerns are possible with an OpenType math font, then they didn't have the possibility of adding in the few kerns that Knuth had for d (Y, Z, j, f), motivated I understand by differential notation. All you can do is specify the advance width. It's odd that this wasn't mentioned in their presentation gust.org.pl/projects/e-foundry/math/lmm-compat-prez.pdf on some minor differences between CM and LM.
    – dmaxwell
    Aug 5, 2023 at 20:00
  • "aren't possible"
    – dmaxwell
    Aug 5, 2023 at 20:14

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .