
On Mon, Feb 10, 2025 at 02:07:17PM +0100, Petr Olsak wrote:
Hello
I suppose that the luatex binary is fixed for TeXlive 2025, so I can open an additional problem and I won't disturb you while finalizing the binaries:).
Use this test file:
-------------------
\input luaotfload.sty \font\f=[latinmodern-math]:mode=base;script=math; \textfont0=\f \Umathcode `f= 0 0 "1D453 % italic f from Unicode math font
$f!$, $f$!, $f\/$!
\showboxbreadth=100 \batchmode \showlists \bye
---------------------
When luatex processes it, we get italic correction only in the first case:
\mathon .\f 𝑓 .\kern0.9 (italic) .\f ! .\mathoff .\tenrm , .\glue(\spaceskip) 3.33333 plus 2.08331 minus 0.88889 .\mathon .\f 𝑓 .\mathoff .\tenrm ! .\tenrm , .\glue(\spaceskip) 3.33333 plus 2.08331 minus 0.88889 .\mathon .\f 𝑓 .\kern0.0 (font) .\mathoff .\tenrm !
Yes, fontforge shows that latinmodern-math italic f has italic correction 90, i.e. 0.9pt for the font at 10pt. And the italic correction is inserted in the first case according to rule 17 of appendix G of TeXbook, where we only need to add: "if the symbol is not a text symbol or if \fontdimen2 is zero **or if script=math fontfeature is used** then insert italic correction". It sounds OK, it is natural extension of the original Knuth's idea: his math scripts were in fonts cmmi10 and cmsy10 where \fontdimen2=0pt.
But:
A) why the italic correction isn't inserted in case 2? The rule 17 in appendix G of TeXbook says that "if the single-char atom isn't a text symbol (i.e. it isn't followed by a next specific atom) then the italic correction is inserted". The condition is obviously true for the last single-char atom of the math list. But luatex with Unicode math font doesn't respect this rule. Why?
B) why there is \kern0.0 in the third case where we want to insert explicit italic correction (which is 0.9pt as fontforge says)?
When we comment out the third line in our example (\textfont0=...), i.e. the classical plain TeX setting with 7bit tfm fonts is used, then luatex inserts italic correction in all three cases. It means that explicit \/ works and rule 17 from appendix G is respected.
OK, maybe it is a decision of somebody who implemented Unicode math because missing italic corrections at the end of math list looks better, for example at the end of a sentence (ef-dot): $f$. I.e. the rule 17 from TeXbook will be not respected. But if our sentence ends by $f$! or by $f$? then the result looks very bad and user is unable to do local corrections by explicit \/.
The problem is not due to simplification of the example here. If you try lualatex with unicode-math macros or OpTeX, you get the same results.
Note that xetex puts correctly italic corrections in all three cases even though a Unicode math font is loaded.
Can someone explain me this confusing behavior?
Thanks
Petr Olsak
Hi Petr. Sorry for replying to the thread from two months ago. Very informative.. You're definitely more versed than me here. But from reading the luatex documetation, and Hans' writing, , or I may be wrong, or the way I interpreted it is that there would be no need to obey \mathsurround when \mathsurroundskip is 0pt. It never was. Hence the \kern0.9 folllowed by \mathoff whenever you called upon \Umathcode `f= "0 "0 "1D453 %italic f from Unicode… .\hbox(0.0+0.0)x20.0, direction TLT .\mathon .\f 𝑓 .\kern0.9 (italic) .\f ! .\mathoff .\tenrm , .\glue(\spaceskip) 3.33333 plus 2.08331 minus 0.88889 .\mathon .\f 𝑓 .\mathoff .\tenrm ! .\tenrm , .\glue(\spaceskip) 3.33333 plus 2.08331 minus 0.88889 .\mathon .\f 𝑓 .\kern0.0 (font) Of course, this is coming directly from Knuth himself that every math-on and math-off that contribute and quote «Math-on and math-off items act essentially as kerns that contribute the spacing specified by \mathsurround; such spacing will disappear into the line break if a formula comes at the very end or the very beginning of a line, because of the way the rules have been formulated above. » If on the other hand, you were to say, heck, let's ignore the skip setting and obey \mathsurround. The question is now. What \mathsurround is to obey, when you're already ignoring the skip to begin with? If you were to say \Umathcode `f= "4 "0 "1D453 it thus returns \hbox(0.0+0.0)x20.0, direction TLT .\mathon .\f 𝑓 .\f ! .\mathoff .\tenrm , .\glue(\spaceskip) 3.33333 plus 2.08331 minus 0.88889 .\mathon .\f 𝑓 .\mathoff .\tenrm ! .\tenrm , .\glue(\spaceskip) 3.33333 plus 2.08331 minus 0.88889 .\mathon .\f 𝑓 .\kern0.0 (font) .\mathoff .\tenrm ! absorbing it or in Knuth's words, incorporating it or «surrounded by “math-on” and “math-off” items, and the space factor is set to 1000». I disagree with you in that while trying to interpret Knuth he ever said «\/. If the last item on the current list is a character or ligature, an explicit kern for its italic correction is appended.» as a matter of enclosing it in math. At no point did he said that the \/ is within math mode at all. But I agree with you in that the manual may be edited further to correct some typos here and there. e.g., what the heck are noads? on chapter 7.5.5 the word sounds like nodes, but I'm not sure if he meant modes and the m was mistakenly replaced by n. His writing may be convoluted at times, but he's very thorough nonetheless. And as you know, The new primitives as he calls them come right out from the originaaal knuth's \mathcode and \delcode in addition with the unmodified primitives. Thanks for the post. Very informative.