Continuing https://chat.stackexchange.com/rooms/97632/discussion-between-marcel-kruger-and-mdayq6, running lualatex on

% \setmathfont{texgyretermes-math.otf}
\setmathfont[Kerning=On]{TeXRygeTermesMath-Regular.otf}%%% same as Tex Gyre Termes Math, with an attempt to improve kerning

where the font is taken from http://filebin.net/36gqo82z5evv2869 (our attempts to improve tex gyre termes math), produces

left kerning

As we see, the kerning is applied in the first case but not in the second. What to do to get the proper kerning also in the second case?

Further, trying to reduce the kerning between f and } ends in nowhere: whichever value I enter into kern offset

no right kerning

, the resulting PDF is unchanged.

Any idea on how to adjust the kerning between f and }?

Last but not least, any idea of how to reduce the kerning in $\sigma_0$ and \[\sigma_0\] using Fontforge? As of now, this kerning is enormously large...

EDIT: Following Marcel's suggestions, I abandoned the search for a good solution for {f} and created a TeX Ryge Termes Math font with new kernings improving the right subscripts for italics \sigma and \tau in math mode. Let's consider the input

%\setmathfont[Ligatures=TeX]{TeX Gyre Termes Math}
\setmathfont[Ligatures=TeX]{TeXRygeTermesMath-Regular.otf} %%% Name changed to comply with the license. The shapes are (hopefully) the same, and the math kernings are new.
\newcommand{\test}[1]{#1_{abc} #1_0^a #1^b_b #1_1^c #1^d_⊀ #1_βŸ‚^e #1_T^f #1_k^g #1_{\mathup{k}}^h #1_{h}^j}

With the original Gyre fonts, the above produces the output

original xelatex output

for xelatex and

original lualatex output

for lualatex.

When using the kerned Ryge fonts, we get

output of xelatex using the Ryge font with kernings

when compiled with xelatex and

output of lualatex using the Ryge font with kernings

when compiled with lulatex.

With the new Ryge font, xelatex does a generally good job on kerning, and lualatex does almost no job on kerning except the subscript "abc". Why so?

Further improvements deem necessary:

  • slightly increase the kerning for subscripts ⊀, 𝑇, and k of both 𝜎 and 𝜏

  • slightly increase the kerning in 𝜏_0 (but not in 𝜎_0)

  • slightly decrease the kerning in 𝜏_βŸ‚ and 𝜎_βŸ‚

such that all the kernings still remain nonpositive.

After that, 𝜎^𝑓, 𝜏^𝑓, 𝜎^𝑗, and 𝜏^𝑗 need small positive kernings.

Is it possible to do so on the font level?

  • Please stop asking multiple questions in every question. That doesn't fit to the format of the site and makes all answers harder to find. Aug 20, 2019 at 19:41

1 Answer 1


For your two problems read my answer to your other question: Normal kerning is not the right tool for Math and will normally not be applied. That LuaTeX sometimes does apply it probably happens because TeX no longer knows that the characters used to be math. After the f italic correction is inserted, so the f and } do not directly follow each other -> no kerning. Also in display math LuaTeX doesn't expect to find something requiring kerning, so kerning is skipped.

Anyway, your last question is more interest:

The kerning between a character and it's subscript is known in OpenType Math as Math kerning. See https://docs.microsoft.com/en-us/typography/opentype/spec/math#mathkerninfo-table for the details. In your case you only need to adjust the sigma.

Open a math font in FontForge. Then you can change math related parameters through Element->Other Info->MATH Info. A windows like this opens: enter image description here

Select "Math Kern" and press to add math kerning for a new glyph. Enter the name of your glyph, in your case "u1D70E" (MATHEMATICAL ITALIC SMALL SIGMA). Then press change to adjust the values.

enter image description here

This brings you to the Math Kerning dialog:

enter image description here To add new points, go to "Textual" and then select "Bottom Right". Press three times to add three points and go back to "Graphical". Here click on the sigma below Bottom Right to select this block. Your kerning point appears and you can drag it to an appropriate location. Roughly, every point means that if a subscript is attached at this height or lower, then it should get this amount of kerning. For example you can set your points like this:

enter image description here

Now confirm with OK, Ok again and generate your font.

If you placed your points in the same way as I did, $\sigma_0$ becomes

enter image description here

Of course, if you do not want to change your font, LuaTeX also allows you to use Lua code to change mathkerns:

  -- First create a table specifying the mathkerns we want to set:
  local mathkerns = {
    ["TeXGyreTermesMath-Regular"] = { -- This should be the PostScript name of the font
      [0x1D70E] = { -- If the character would have a regular name, you could also use the glyphname here
        bottomright = {
  local function initmathkern(tfmdata)
    local values = mathkerns[tfmdata.properties.psname]
    if not values then return end
    for cp, value in next, values do
      local tcp = type(cp)
      if tcp == 'string' then
        cp = tfmdata.resources.unicodes[cp]
      local char = tfmdata.characters[cp]
      if char then
        local mathkern = char.mathkerns
        if not mathkern then
          mathkern = {}
          char.mathkerns = mathkern
        for corner, v in next, value do
          mathkern[corner] = v
    name = 'mathkern',
    description = 'Overwrite mathkern values',
    initializers = {
      base = initmathkern,
  • Wow. What are the images. An editor or software to create the fonts?
    – Sebastiano
    Aug 20, 2019 at 22:34
  • @Sebastiano Yes, the question was how to change this in FontForge, so these are FontForge screenshots Aug 20, 2019 at 23:19
  • I think there was once a question on the context list how to add or change the mathkerns with lua, but it was never answered. Aug 21, 2019 at 6:40
  • @UlrikeFischer mailman.ntg.nl/pipermail/ntg-context/2019/094714.html There is an answer, but it is β€œuse goodiesβ€œ which are not available in generic. Aug 21, 2019 at 9:00
  • @HenriMenke I knew I had forgotten something. I wanted to transfer the issues in lua-fond-pond to luaotfload before moving the repo to latex. I have an issue about goodies there. That is something that should be addressed if possible. Aug 21, 2019 at 9:23

You must log in to answer this question.