In short: As of now there does not seem to be a good way to solve your problems in LuaLaTeX with Opentype Math fonts.
Read on:
The problem you see is essentially that the handling of italic correction in traditional TeX fonts and Opentype math fonts are different, and that some fonts converted were not really made to follow the new (vague) standard (essentially set by Cambria). If you do not load unicode-math
, you will get the old type1 fonts, and that is why you get what you expect. Let me start by showing the result of your example, set with Cambria:
Here, I'd say that the first example looks OK (except for the space between the f
and the (
, but that could be avoided by not using \left
). I would say that the reason is that Cambria is the "model Opentype math font", the font made by Microsoft at the same time as the rather vague specification was done, and luatex was adapted to that (what else?).
Looking at the specification we find
Italics correction can be used in the following situations:
- When a run of slanted characters is followed by a straight character
(such as an operator or a delimiter), the italics correction of the
last glyph is added to its advance width.
- When positioning limits on
an N-ary operator (e.g., integral sign), the horizontal position of
the upper limit is moved to the right by Β½ of the italics correction,
while the position of the lower limit is moved to the left by the same
distance.
- When positioning superscripts and subscripts, their default
horizontal positions are also different by the amount of the italics
correction of the preceding glyph.
Latin modern math (the font used in your screenshots), was converted from the traditional Computer modern math fonts, and so it inherits some of the behaviors from that as well (one could argue that it was not really made into a real Opentype math font, whatever that would mean). This means that one will see problems like these pop up, and even with quick fixes like \mathitalicsmode2
(added in April 2022) that was added to cure one problem in one situation, what happens is that the problem is just pushed to some other place/construction.
I think that what needs to be done (challenge to the unicode-math
maintainers) to finally get rid of this problem is to use some similar model as we now have in ConTeXt and luametatex, where the italic correction taken care of by altering widths of glyphs and adding corner kerns. This seems to be a model that works OK with most fonts.
Your example (adapted for ConTeXt) looks like:
In case you are curious, the code used to generate this was:
\usebodyfont[modern]
\usebodyfont[cambria]
\setupbodyfont[modern]
\starttext
\startbuffer
\startformula
f(T), f\left( T \right),
\int_{a}^{b} f\left( x \right) \dd x, \frac{1}{T},
\stopformula
\stopbuffer
\getbuffer
\switchtobodyfont[cambria]
\getbuffer
\stoptext
unicode-math
package, everything looks perfect.β: no, in βπ (π)β you have too much space between π and π.