aliftype / xits

XITS - OpenType implementation of STIX fonts with math support
SIL Open Font License 1.1
351 stars 35 forks source link

Display variants of big operators have wrong “depth” #90

Closed OlivierNicole closed 5 years ago

OlivierNicole commented 5 years ago

While implementing a math layout algorithm, I noticed some strange disparities between my output (top) and LuaLaTeX's (bottom) with big operators in display style:

Capture d’écran_2019-10-06_00-18-18

In the first equation, the product operator has no “depth”, i.e. is entirely above the baseline, which is strange. The depth of the display integral sign is too small, too.

According to what I can see in Fontforge, the display-style product (glyph uni220F.display) indeed has no depth. Is this a problem in the font design, or am I missing something?

(Edit.: use better screenshot)

OlivierNicole commented 5 years ago

Here is a screenshot with debug boxes on, which make the problem more visible:

Capture d’écran_2019-10-06_00-02-24

khaledhosny commented 5 years ago

I don’t remember the exact details, but some glyphs are centered around the math base line (using the glyph height from its bounding box). I think big operators belong to this group.

OlivierNicole commented 5 years ago

Is there a marker in the font that indicates this fact, or is it an external convention?

khaledhosny commented 5 years ago

External logic.

OlivierNicole commented 5 years ago

It is a bit unfortunate because it requires specific code for things that could be handled entirely by the generic glyph drawing functions. Is there a particular reason for this state of things?

khaledhosny commented 5 years ago

No idea, but I think it is because these rules are not fixed, the same glyph can be used as operator and as something else and it is up to the layout engine to detect and handle that. For the exact rules, you probably need to check The TeX Book (Appendix G), Appendix G illuminated, and OpenType Math Illuminated.

OlivierNicole commented 5 years ago

I will look it up. Thank you for your help!