5

This is a follow up question to a previous reported font problem. Compiling the following MWE with LuaLaTeX

\documentclass{article}

\usepackage{unicode-math}
\setmathfont{LibertinusMath-Regular.otf}[Kerning=On]
\showoutput
\begin{document}
$w_j q^j$
\end{document}

results into a strangely spaced subscript "j".

Original result with strangely spaced j

After some discussion with the font maintainer, with the LuaTeX maintainers on their mailing list and after I had read the OpenType specs, I came to the conclusion to fix the broken font metrics myself as suggested by Ulrike Fischer in her comment on my previous post and I followed the approach as decsribed in this answer.

Step 1

I changed the font such that the right bearings of "w" and "j" are positive and removed the italic corretions.

Step 2

I introduced staircase (aka MATH) kerning for the "w" in the lower right corner and for the "j" in the upper left corner like this:

staircase-kerning-w-graphical staircase-kerning-w-textual

staircase-kerning-j-graphical staircase-kerning-j-textual

After compiling the MWE with the new font, the result looks like this:

Result with full staircase kerning

It is better, but not as good as expected. The log output is

....\mathon
....\TU/LibertinusMath-Regular.otf(1)/m/n/10 𝑤
....\kern-1.2 (font)                            <--- This is it
....\hbox(4.944+1.568)x3.78995, shifted 2.09978, direction TLT
.....\TU/LibertinusMath-Regular.otf(1)/m/n/8 𝑗
....\TU/LibertinusMath-Regular.otf(1)/m/n/10 𝑞
....\kern0.36 (italic)
....\hbox(4.944+1.568)x3.78995, shifted -3.7496, direction TLT
.....\TU/LibertinusMath-Regular.otf(1)/m/n/8 𝑗
....\mathoff

LuaLaTeX introduced a small negative kern but not as much as expected.

Step 3

By luck and accident, I compiled the MWE with the upper left staircase kerning of "j" being removed, e.g. I tried the MWE with a lower right kerning for "w" only. Et viola, the result is

Result with base staircase kerning

The log output is

....\mathon
....\TU/LibertinusMath-Regular.otf(1)/m/n/10 𝑤
....\kern-2.1 (font)                       <--- That's even better
....\hbox(4.944+1.568)x3.78995, shifted 2.09978, direction TLT
.....\TU/LibertinusMath-Regular.otf(1)/m/n/8 𝑗
....\TU/LibertinusMath-Regular.otf(1)/m/n/10 𝑞
....\kern0.36 (italic)
....\hbox(4.944+1.568)x3.78995, shifted -3.7496, direction TLT
.....\TU/LibertinusMath-Regular.otf(1)/m/n/8 𝑗
....\mathoff

Of course I wondered why.

Step 4

After playing around with the upper left staircase kerning of "j", I found out the following:

  • The closer the kerning points get to the outline of the j, the less effective the kerning gets, i.e. the visible white space becomes wider
  • The closer the kerning points get to the left bearing of the j (i.e. the bounding box), the more effective the kerning gets, i.e. the visible with space becomes less

It seems that the upper left staircase kerning has an "inverted sign issue". If I only add staircase kerning points to the "w" and leave the "j" as is, the kerning seems to be as expected by the specs. However, if I add kerning points to the "j", too, the kerning is diminished. This gets worse the more accurate the kerning points follow the outline of the "j".

Question:

Is this a bug in LuaTeX, because it makes a wrong calculation, or does FontForge exports a broken font with wrong coordinates for the kerning points? At some point the sign gets wrong, but I do not know which is the component I should blame.

PS: Sorry, for the long post for such a simple question. Moreover, I gladly share my font files if someone wants to compile the MWE her- or himself. I would have posted and linked them here, too, if I had known how.

2
  • I couldn't check what's actually written into the font files, but the values reported by fontforge look suspecious: For top left they report positive kern values, and positive kerning is always adding more space instead of reducing it. Mar 11, 2020 at 20:16
  • @MarcelKrüger You are right, I designed the kerning points with the help of the graphical editor, i.e. such that the points look correct in the drawing. However, this illustration uses a wrong orientation. See [github.com/fontforge/fontforge/issues/1375] which is an unresolved issue since 2014. One has to think of the left kerning points as being mirrored at the left bearing, i.e. the reported numbers in the textual dialog are the one that are exported into the font file. :-(
    – nagmat84
    Mar 11, 2020 at 20:40

0

You must log in to answer this question.

Browse other questions tagged .