Why do different fonts yield different underline behaviors?

Here is a simple experiment:

#set underline(offset: 2pt, stroke: 0.3pt)

#underline[#super[ab]cd#sub[ef]]

#set text(font: "STIX Two Text")
#underline[#super[ab]cd#sub[ef]]

This yields:

Why is the underline function yielding different results? And how can I avoid this?

And while I’m at it, why do the superscripts and subscripts have different sizes in the second case? Should I redefine #sub() and #super to avoid this?

Here is a hint for us (also for me).

If we insert this, the result changes:

#set sub(typographic: false)
#set super(typographic: false)

All of them change except for the STIX Two Text’s ef which remains as it was.

Then: default font’s ab and ef were typographic, but only STIX’s ab was typographic and ef was synthesized.

  • if we use typographic sub/supscript glyphs, as defined by the font, then the base font size doesn’t change and maybe that helps the underline to stay intact, font baseline doesn’t change?
  • STIX two seems to have typographic supscript glyphs but not subscript ones. Unfortunately this leads to the size mismatch since they are generated differently, then.

3 Likes