olsak / OpTeX

OpTeX - LuaTeX format with extended Plain TeX macros
http://petr.olsak.net/optex/
35 stars 14 forks source link

Phantom larger than real in subscript #25

Closed cao- closed 3 years ago

cao- commented 3 years ago
\fontfam[garamond]

$$
\eqalign{
    &s_a(x) \cr
    &s_{\phantom a}(x)}
$$

\bye

You can see that there is more space in the second line, before the parenthesis. Maybe the phantom disables some math kerning, so this is not even possible to solve, but since I noticed it I wanted to post this "problem" anyway. It is font specific: for instance when no font is loaded or when the lm fonts are used I don't see any difference.

olsak commented 3 years ago

When we write

\fontfam[garamond]
$s_a$\showlists
\bye

then we can read in log file:

\mathon
\_mF 𝑠
\kern-0.58 (font)
\hbox(2.996+0.098)x4.014, shifted 2.5, direction TLT
.\_mF 𝑎

The \kern-.58pt (from font) is inserted here, but it is not inserted when \phantom follows (instead of a natural letter). Each character of Unicode math font can have four kerns: top-left, top-right, bottom-left, bottom-right and they are ususaly zero. But the character 𝑠 has nonzero bottom-right kern. What should be happen is not defined in classical TeX and LuaTeX inserts this kern when subscript with a letter of the same font follows. But this kern is not inserted when subscript-phantom follows. This problem is out of the scope of macro level, it should be solved at engine level, IMHO.

You can correct this alligment by ... &s_{\phantom a\kern-.58pt}(x)... but I understand that this is not a generic solution:).

cao- commented 3 years ago

Yes, I imagined that it was something similar to issue #174 or issue #173 of luaotfload, so something related to the luatex engine. Anyhow, I just wanted to be sure, by making you aware of it. Thanks for the answer :)