On 4/28/2025 12:43 AM, Carlos wrote:
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.
Just for the record (i don't want to start an italic discussion here;
we're basically done with that):
- italic correction in traditional tex math is not like italic
correction in text: it is added to the width but also also indicates the
shifts in e.g. subscripts; it's just a practical way to encode that in
the limited possibilities in a (definitely at that time, to be as
compact as possible) tfm font
- if you want to mess with it, there are callbacks in luatex that can be
of help
- in a similar fashion sometimes height and depth communicate something,
e.g. with some delimiters; again, you can mess with that in lua
- when math is read (from the input) a node list is made but some nodes
are of a temporary nature: they are called noads; these can transform
into each other (same mem size cq. field overlap) and eventually become
h/vlists, kerns and rules
- so, after the second pass over the math list (we're talking
traditional tex math rendering here), the one that builds the final math
representation including spacing, noads are gone
- in a similar fashion the more abstract muglue becomes exact regular glue
- the math node (begin/end) are used in the par builder to determine how
to handle glue in there (esp line breaks); luatex also has the option to
use glue instead of kerns encoded in these nodes (maybe we should remove
that feature)
- much in the math engine is hard coded and that proved to work quite
ok, after all tex became a standard for a reason (luametatex opens that up)
- the opentype model is somewhat different as it on the one hand took
from tex but uses italic correction differently as it has staircase kerns
- however, in the end fonts kept using the traditional model i.e.
combining italic correction but sometimes also introduced these kerns
(which introduce problems themselves); we have to accept / live with that
- for tl luatex 2026 we removed some control over rendering and now
assume fonts using italics in the traditional way; this should work ok
for plain and latex
- (context is another matter but irrelevant for this discussion as we do
things different; its users moved on to luametatex where we also have
more control over various mechanisms and extended math rendering; we
have published plenty about this over time)
That's all there is to say: the next tex live luatex will have math done
more traditionally. We won't extend control and capabilities because
after all it's supposed to be stable.
Hans
-----------------------------------------------------------------
Hans Hagen | PRAGMA ADE
Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
-----------------------------------------------------------------
_______________________________________________
dev-luatex mailing list -- [email protected]
To unsubscribe send an email to [email protected]