# Are the widths of 𝐿, 𝑌, and 𝑍 in TeX Gyre Termes Math really equal?

It was a surprise to me when feeding lualatex with

\documentclass{standalone}
\usepackage{unicode-math}
\setmathfont{TeX Gyre Termes Math}% or \setmathfont{texgyretermes-math.otf}
\begin{document}
Width of $L$: \setbox0\hbox{$L$}\the\wd0. \text{Width of}\ $Y$:\ \setbox0\hbox{$Y$}\the\wd0. \text{Width of}\ $Z$:\ \setbox0\hbox{$Z$}\the\wd0.
\end{document}


yielded

Are the widths of the three symbols REALLY equal? I find it hard to believe because these numbers look way too nice, occupying only 3 decimal digits each. I might imagine that really different lengths (given in sp or some other unit) were rounded up to the same number while converting to pt. Is it really so? If so, is it possible to distinguish between the widths of math-mode 𝐿, 𝑌, and 𝑍 from inside LuaLaTeX? If so, how? (After all, running xelatex on the same input provides us with three different numbers. Also, running pdflatex (with \usepacakge{amsmath} instead of \usepackage{unicode-math}+\setmathfont{…}) yields three different numbers.)

• What is your question? Character widths are not physical lengths that can be measured, we are not using hot metal. They are simply a length valued property set by the font designer. Oct 17, 2022 at 13:58
• @DavidCarlisle Got it; question reformulated. Oct 17, 2022 at 14:01
• I don't see any real difference in the formulation. Why do you expect the font designer to have set values that differ by small fractions of a pt?????? Oct 17, 2022 at 14:03
• classically in tfm fonts you can only have 18 different widths in the whole font Oct 17, 2022 at 14:22
• actualy 16, Knuth writes in the metafont sources: The actual width of a character is \\{width}|[width_index]|, in design-size units; this is a device for compressing information, since many characters have the same width. Since it is quite common for many characters to have the same height, depth, or italic correction, the \.{TFM} format imposes a limit of 16 different heights, 16 different depths, and 64 different italic corrections. Oct 17, 2022 at 16:16

character lengths are not measured properties that depend on some accuracy of measurement, they are properties set by the font designer.

\documentclass{article}
\usepackage{unicode-math}
\setmathfont{TeX Gyre Termes Math}% or \setmathfont{texgyretermes-math.otf}
\begin{document}
Width of $L$: \setbox0\hbox{$L$}\the\wd0. \text{Width of}\ $Y$:\ \setbox0\hbox{$Y$}\the\wd0. \text{Width of}\ $Z$:\ \setbox0\hbox{$Z$}\the\wd0.

L
\the\fontcharwd\textfont0 119871,
\the\fontcharic\textfont0 119871,

Y
\the\fontcharwd\textfont0 119884,
\the\fontcharic\textfont0 119884,

Z
\the\fontcharwd\textfont0 119885,
\the\fontcharic\textfont0 119885,

\end{document}


You get

with luatex, and

With xetex.

So the three characters have the same width but different italic correction.

luatex, in contrast to xetex, does not add italic correction at the end of the math which explains why you get different box widths with xetex.

• Curious, does pdflatex or classic latex add the italic correction? Oct 17, 2022 at 14:35
• yes but there is a long and painful history about italic correction in opentype math luatex has "comments" about that and parameters to control when it is used @dedded Oct 17, 2022 at 14:38
• Is no italic correction the desired behaviour? Oct 17, 2022 at 15:35
• @Gaussler texdoc luatex section 7.5.5 Oct 17, 2022 at 15:45
• @Gaussler yes, although latex doesn't really have a good interface to setting the extra parameters based on font choice. classic TeX math fonts do not use "italic correction" to correct italic. the advance width of the character is always "width+ic" and "width" is used for subscript position. Some OTF math fonts follow this, but some use "width" as the advance width and use the separate subscript cutin parameter to kern subscripts closer and use italic correction just as would be used in text fonts. Basically the system can not tell what the font params mean Oct 18, 2022 at 10:06

Yes and no. The three characters have the same advance width 556. If we only look at that, the orange boxes below, we see (here the characters are squeezed together to make it more clear that the orange boxes have the same width):

We notice that the L and Z stick out to the left while Y and Z stick out to the right (in fact L also sticks out to the right, but very very little, see below). If we look at the font data, we see the following:

  [119871]={ -- L
["boundingbox"]={ -8, 0, 559, 653 },
["index"]=454,
["math"]={
["accent"]=267,
["italic"]=31,
},
["unicode"]=119871,
["width"]=556,
[119884]={ -- Y
["boundingbox"]={ 78, 0, 633, 653 },
["index"]=467,
["math"]={
["accent"]=362,
["italic"]=105,
},
["unicode"]=119884,
["width"]=556,
},
[119885]={ -- Z
["boundingbox"]={ -6, 0, 606, 653 },
["index"]=468,
["math"]={
["accent"]=362,
["italic"]=78,
},

• The (advance) widths are indeed equal.
• The bounding boxes shown are {xbottomleft, ybottomleft, xtopright, ytopright}. The negative values in the first slot for L and Z indicate that they stick out to the left. The values in the third slot indicates that they do in fact all stick out to the right (the L very little).
• We notice that the characters have different amounts of italic correction.

Here I would consider the answer to be complete, but since the other answers wrote about luatex and xetex doing things differently, let me add something about the italic correction in math. In luatex you have the possibility to add italic correction as well (by setting \mathitalicsmode to 1 or 2, I think). I think that the reason it is not added by default is that if one reads the vague specifications it seems that it should not always be added. The situation today is that there are some math fonts, like cambria, garamond-math and lucida (and probably some more) that somehow follow the spec and do not rely on italic corrections (but on kerns), and then there are the rest (like Termes) that relies on the old TeX way with italic correction.

In the last few weeks I have discussed these issues with Hans Hagen a lot, in the context (pun intended) of the newer luametatex engine. Our aim has been to have a spacing model that works both with the old TeX-like fonts and with the newer ones. If we use italic corrections, a formula can look like this (italic corrections marked in blue):

As can be seen, the italic correction is always added, and in case of a subscript, removed. Since italic correction in opentype math is not really italic correction, we thought that maybe we could get rid of it alltogether, and replace it by corner kerns. Then it can look like this:

The output is (hopefully) the same. Notice that the width of the orange box with the Z is changed, and that there are two corner kerns added (one bottom right for the subscript, and one top left for the prescript).

The reason that the orange box is enlarged to the left in order to have a method that also works for difficult characters, like lower case italic f that in some fonts sticks out a lot to the left and right from the orange box. Compare the following to examples, and you will understand why.

• Thx!!! \mathitalicsmode can be 0 or 1 according to my texdoc luatex, not 1 or 2. Oct 17, 2022 at 16:15
• I'm quite perplexed about the choice of the bounding box for Y. Oct 17, 2022 at 16:16
• @egreg So should we change it in the .otf font? I'd be eager to do that with fontforge at least locally if it results in better typesetting and if I know what to do exactly. Oct 17, 2022 at 16:18
• @AlbertNash I think the value 2 is new. Oct 17, 2022 at 16:35
• @egreg Why? The tighter box fits well with traditional TeX. The subscript is placed tight to it. Oct 17, 2022 at 16:37

You're not measuring the width of the characters, but of some math formulas. And math formulas are treated differently by LuaLaTeX and XeLaTeX, as the former doesn't add a trailing italic correction.

If you compile the following with XeLaTeX, you get that, indeed, the characters have the same width, namely 5.56pt.

\documentclass{article}
\usepackage{unicode-math}

\setmathfont{TeX Gyre Termes Math}

\frenchspacing

\begin{document}

$x$

\the\fontcharwd\textfont0 𝐿

\the\fontcharwd\textfont0 𝑌

\the\fontcharwd\textfont0 𝑍

Width of $L$: \sbox0{$L$}\the\wd0.

Width of $Y$: \sbox0{$Y$}\the\wd0.

Width of $Z$: \sbox0{$Z$}\the\wd0.

\end{document}


• Thanks! I guess, adding $x$ is a workaround against a zero-producing kludge of XeLaTeX , isn't it? Oct 17, 2022 at 14:54
• @AlbertNash That's in order that math fonts are assigned before inquiring \textfont2`. Oct 17, 2022 at 14:56
• @egreg sorry yes, comment deleted Oct 17, 2022 at 15:06