aliftype / xits

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

Too much spacing above glyphs in the denominator when fractions are scaled #91

Closed matteocoder closed 4 years ago

matteocoder commented 4 years ago

After seeing this question from stackexchange I wanted to see the issue for myself and it seems indeed that there is a bit too much spacing above trigonometric functions when they are in the denominator, so things like these can happen: xits cramped cases 2 The denominator and the numerator from the expression below are very close, while with Latin Modern the spacing seems to be tighter: latinmodern cases

Here is the code that causes the issue:

\documentclass[a4paper,12pt]{article}
\usepackage{amsmath}
\usepackage{unicode-math}
\setmainfont{TeX Gyre Termes}
\setmathfont{XITS Math}
\begin{document}
\[
f(x) =
\begin{cases}
\frac{\cos x}{\sin x} \\
\frac{\cos x}{\cos x} \\
\frac{\cos x}{\tan x} \\
\frac{\cos x}{\tan x}
\end{cases}
\]
\end{document}

The code has been compiled using TeXLive 2019 at papeeria.com with both XeLaTeX and LuaLaTeX. If there is something else I can do to help you solve this issue, please let me know. Thank you for your attention and for developing this awesome font.

edit: as shown in this issue, the problem seems to happen only when fractions are downscaled.

Update: I have tried to reproduce the issue on an up-to-date (as of the 24th of december 2019) TeX Live 2019 distribution and, after further investigation, here is what I have found: 1) there is too much spacing when compiling with pdfLaTeX and using the stix package (though this might not be relevant here); 2) it seems that many other OpenType math fonts have this issue, like Cambria Math and GFS Neohellenic math, and that the only ones that produce correct spacing are the TeX Gyre math fonts, Latin Modern Math and Garamond Math.

However there is a workaround: expanding upon the answer given by David Carlisle in the StackExchange question linked above, you could augment the \baselinestretch inside the specific math environment where fractions are downscaled, instead of the full document, like this:

\[
\renewcommand\baselinestretch{1.3}
\selectfont
f(x) =
\begin{cases}
\frac{\cos x}{\sin x} \\
\frac{\cos x}{\cos x} \\
\frac{\cos x}{\tan x} \\
\frac{\cos x}{\tan x}
\end{cases}
\]

I've chosen a 1.3 factor because to my eyes it produces a good amount of space, but it might be too much.

Thank you again for your attention and happy holidays!

khaledhosny commented 4 years ago

Suggestions on how to fix this in the font are welcomed, otherwise I'm completely at loss here.

matteocoder commented 4 years ago

@khaledhosny Thank you for your reply. Unfortunately I don't know anything about digital font design, so what I can suggest is to imitate what the font 'TeX Gyre Termes Math' does to generate the appropriate spacing between the fraction bar and the denominator when a fraction is scaled.

matteocoder commented 4 years ago

@khaledhosny I've found another way to augment the spacing between equations inside a cases environment, which seems to work better than the previous workaround: append a typographic quantity inside square brackets after the double slashes; 1ex seems to be fine for XITS and Cambria. I am closing this issue, and thank you again for your attention.

khaledhosny commented 4 years ago

Great!