Incorrect math kerning
![](https://secure.gravatar.com/avatar/c5ae4f9aa0d3a9bd5376e92b322c3e50.jpg?s=120&d=mm&r=g)
Hi, This is based on a question about latex on tex.stackexchange: http://tex.stackexchange.com/q/312098/323 but context shows the same behaviour. The subscript "i" in the following example is kerned incorrectly (it is too far away from W). Is this a bug in the font, or with the fontloader? \setupbodyfont[cambria] \starttext \startTEXpage[offset=2mm] $W_i^i$ \stopTEXpage \stoptext Thanks, Aditya
![](https://secure.gravatar.com/avatar/49e63acb01f2ca80efce7eed08310ce8.jpg?s=120&d=mm&r=g)
On 5/30/2016 5:50 AM, Aditya Mahajan wrote:
Hi,
This is based on a question about latex on tex.stackexchange: http://tex.stackexchange.com/q/312098/323
but context shows the same behaviour.
The subscript "i" in the following example is kerned incorrectly (it is too far away from W). Is this a bug in the font, or with the fontloader?
\setupbodyfont[cambria]
\starttext
\startTEXpage[offset=2mm] $W_i^i$ \stopTEXpage
\stoptext
In traditional TeX fonts italic correction is used as a kind of kerning. This happens in combination with cheating with the width of glyphs. This is somewhat reflected in the lm fonts (with some inconsistencies between for instance V and W ... we're currently discussing this). So, a way to force a subscript towards the shape is to use less width, and then use italic correction to move the superscript the other way. Of course this kind of kerning is a bit of a cheat and not related to italic shape (some upright characters also have italic corrections). In cambria staircase kerns are used for this but they are not defined for all (base) characters. The gyre fonts don't cheat on the width. \starttext \startTEXpage[offset=2mm] \startcombination[2*2] {\hbox to 40pt{\hss\showboxes\switchtobodyfont [modern]$W_i^i$\hss}} {\infofont modern} {\hbox to 40pt{\hss\showboxes\switchtobodyfont [cambria]$W_i^i$\hss}} {\infofont cambria} {\hbox to 40pt{\hss\showboxes\switchtobodyfont[lucidaot]$W_i^i$\hss}} {\infofont lucida} {\hbox to 40pt{\hss\showboxes\switchtobodyfont [pagella]$W_i^i$\hss}} {\infofont pagella} \stopcombination \stopTEXpage \stoptext Once the math fonts are stable and frozen I'll come up with a solution (in ConTeXt) for this. Luatex < 0.85 had a mixed code path for dealing with italics (adding them always and removing them selectively) but as the standard is not more explicit about where to apply italic correction these code paths have been separated. In ConTeXt we had some italic correction juggling (basically i disabled passing them to the engine and applied them selectively) but because lm / rest of ot is not consistent it never was satisfying. Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
![](https://secure.gravatar.com/avatar/d4bd34a45c928e8356f38323ff84763e.jpg?s=120&d=mm&r=g)
Am Mon, 30 May 2016 09:35:25 +0200 schrieb Hans Hagen:
In cambria staircase kerns are used for this but they are not defined for all (base) characters.
Are this these values: ["math"]={ ["kerns"]={ ["bottomright"]=36, ["topright"]=17, }, }, ? If yes, how could one change them to check if other values gives a better result? -- Ulrike Fischer http://www.troubleshooting-tex.de/
![](https://secure.gravatar.com/avatar/49e63acb01f2ca80efce7eed08310ce8.jpg?s=120&d=mm&r=g)
On 5/30/2016 4:56 PM, Ulrike Fischer wrote:
Am Mon, 30 May 2016 09:35:25 +0200 schrieb Hans Hagen:
In cambria staircase kerns are used for this but they are not defined for all (base) characters.
Are this these values:
["math"]={ ["kerns"]={ ["bottomright"]=36, ["topright"]=17, }, },
? If yes, how could one change them to check if other values gives a better result?
I looked into it a bit and found a few issues. (1) i forgot to adapt the scaler to the new fontloader so i fixed that (no beta yet) (2) the old (ff) loader makes up some values which is probably a side effect of the at that time missing spec; it's harmless and ok but results in different tables between old and new loader (3) you're right about the spot to patch or add but keep in mind that you look at the packed font table, so in the end you end up with something: kerns = { [0x1D449] = { bottomright = { { kern = -200 } } }, -- it V [0x1D44A] = { bottomright = { { kern = -100 } } }, -- it W } the amount of kerning is subjected to personal preferences e.g. lucida has way less bottom kerning than cambria for instance attached a sample for italic V and W - native lucida ot kerning - native cambria kerning - specified for other fonts Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
![](https://secure.gravatar.com/avatar/49e63acb01f2ca80efce7eed08310ce8.jpg?s=120&d=mm&r=g)
Hi Aditya,
This is based on a question about latex on tex.stackexchange: http://tex.stackexchange.com/q/312098/323
but context shows the same behaviour.
The subscript "i" in the following example is kerned incorrectly (it is too far away from W). Is this a bug in the font, or with the fontloader?
\setupbodyfont[cambria]
\starttext
\startTEXpage[offset=2mm] $W_i^i$ \stopTEXpage
\stoptext
The next beta fixes the scaler but of course that leaves fonts untouched. However, as a test I added some more lfg files that implement the V and W cutins for some fonts. Beware: the lm / gyre fonts are in the process of being updated which means that kerning will change (and therefore also the rendering) later this year. After that we can still decide to ship variants. For now it's directive driven. \enabledirectives[fontgoodies.mathkerning] \startTEXpage[offset=2mm] \startcombination[4*2] {\hbox to 50pt{\hss\showboxes\switchtobodyfont [modern]$V_i^i = W_i^i$\hss}} {\infofont modern} {\hbox to 50pt{\hss\showboxes\switchtobodyfont [cambria]$V_i^i = W_i^i$\hss}} {\infofont cambria} {\hbox to 50pt{\hss\showboxes\switchtobodyfont[lucidaot]$V_i^i = W_i^i$\hss}} {\infofont lucida} {\hbox to 50pt{\hss\showboxes\switchtobodyfont [dejavu]$V_i^i = W_i^i$\hss}} {\infofont dejavu} {\hbox to 50pt{\hss\showboxes\switchtobodyfont [pagella]$V_i^i = W_i^i$\hss}} {\infofont pagella} {\hbox to 50pt{\hss\showboxes\switchtobodyfont [termes]$V_i^i = W_i^i$\hss}} {\infofont termes} {\hbox to 50pt{\hss\showboxes\switchtobodyfont [bonum]$V_i^i = W_i^i$\hss}} {\infofont bonum} {\hbox to 50pt{\hss\showboxes\switchtobodyfont [schola]$V_i^i = W_i^i$\hss}} {\infofont schola} \stopcombination \stopTEXpage A bit of a playground for deciding om where to draw the limit. Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
participants (3)
-
Aditya Mahajan
-
Hans Hagen
-
Ulrike Fischer