On Sat, Jan 30, 2021 at 11:13 PM Hans Hagen
On 1/30/2021 2:33 PM, Marcel Fabian Krüger wrote:
Hi,
take the following document:
\font\extend ntxexx at 10pt \textfont3=\extend
\showboxdepth\maxdimen \showboxbreadth\maxdimen
\setbox0=\hbox{$ \big) $} \showbox0 \bye
It writes to the log:
\box0= \hbox(8.5+3.1125)x4.72997, direction TLT .\mathon .\hbox(8.5+3.1125)x4.72997, direction TLT ..\mathon ..\hbox(8.5+3.1125)x4.72997, direction TLT ...\hbox(0.56+10.665)x4.72997, shifted -7.55249, direction TLT ....\extend ^A ...\vbox(8.5+0.0)x0.0, direction TLT ...\hbox(0.0+0.0)x0.0, direction TLT ..\mathoff .\mathoff
Particularly note the width 4.72997 of the hbox with the delimiter. If we look at the relevant part of the tfm file (in pl format), we find the dimensions of the glyph as
(CHARACTER O 1 (CHARWD R 0.313) (CHARHT R 0.056) (CHARDP R 1.0665) (CHARIC R 0.08) (NEXTLARGER O 21) )
We would expect the width of the box to be 10pt*(CHARWD+CHARIC)=10pt*(0.313+0.08)=3.93pt. Instead we get 10pt*(CHARWD+2*CHARIC)=10pt*(0.313+2*0.08)=4.73pt~4.72997.
The cause of this is in mlist.c, do_delimiter (around line 1652):
b = char_box(f, c, att); if (!do_new_math(f)) { /*tex Italic gets added to width. */ width(b) += char_italic(f, c); }
The char_box function already adds the italic correction to the box width if new math isn't used, therefore the additionally added char_italic leads to the duplicated value.
This can be fixed by removing the if block:
diff --git a/source/texk/web2c/luatexdir/tex/mlist.c b/source/texk/web2c/luatexdir/tex/mlist.c index c34dee488..e9df7b13f 100644 --- a/source/texk/web2c/luatexdir/tex/mlist.c +++ b/source/texk/web2c/luatexdir/tex/mlist.c @@ -1649,11 +1649,8 @@ static pointer do_delimiter(pointer q, pointer d, int s, scaled v, boolean flat, if (same != NULL && x == c) { *same = emas; } + /*tex italic gets added to width */ b = char_box(f, c, att); - if (!do_new_math(f)) { - /*tex Italic gets added to width. */ - width(b) += char_italic(f, c); - } if (delta != NULL) { /*tex This used to be (f, x). */ *delta = char_italic(f, c); -- In the luametatex source (which is a bit different) I have a comment:
/*tex Italic gets added to width. Isn't this already done in char_box ... check it!*/
so given your test file I assume that we can indeed remove that addition for. One reason I kept it even in luametatex is that I wanted to check if later on there are no other assumptions because juggling with italic correction happens in several places. Adding twice and subtracting once later would nto surprise me, but I have no traditional tex fonts set up.
In traditional tex mode fonts, italic corrections are always added to boxes because those fonts have that correction subtracted from the natural width, so that's why I was puzzled in the comment but I'm always reluctant to change something in math (in luatex).
I've never heard of ntxexx but it looks like a font to test this. We don't use traditional math setups in context so I assume that you tested all this with some more cases (and combinations).
committed rev. 7401 -- luigi