Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Collapsed font heights #3127

Open
paeifbnaeufbpae opened this issue Oct 7, 2023 · 3 comments
Open

Collapsed font heights #3127

paeifbnaeufbpae opened this issue Oct 7, 2023 · 3 comments

Comments

@paeifbnaeufbpae
Copy link

When playing around with the MathJax fonts found in ts/output/chtml/fonts/tex-woff-v2, I noticed that the height of the text that this font produces is collapsed, i.e. it doesn't have the full height.

Example:
Screenshot 2023-10-07 at 16 50 35

These are just two <div>s with the texts "01234567890" and "xyz" and MathJax_Main-Regular.woff and MathJax_Main-Italic.woff, with no further modifications other than their font-size scaled up.

Was this a conscious decision? If so, what's the motivation behind it?

@dpvc
Copy link
Member

dpvc commented Oct 8, 2023

Yes, this is by design. The MathJax fonts are intended for use within MathJax for laying out mathematics, and are not designed for use as text fonts. The reason for this unusual ascent/descent setup is so that when used with line-height equal to 0 (as in MathJax's layout), the fonts align on their baselines. This is achieved by having their ascent and descent being equal. Ideally, both would have been zero, but some browsers had trouble with that, so they have a small ascent and descent. This makes it easier to place the characters in a two-dimensional layout, for things like superscripts and subscript, accents, limits on summations, fractions, etc. MathJax also needs to make each character have its correct height and depth rather than the height and depth of the font as a whole, and so CSS padding is used to set the height and depth (and width) from the baseline, which is easiest to do when the ascent and decent are zero, as is the case with line-height of zero when the ascent and decent are equal.

The fonts in v4 handle this in a different way, but in v3 the fonts were set to have equal ascent and decent.

@dpvc dpvc added the Question label Oct 8, 2023
@paeifbnaeufbpae
Copy link
Author

How specifically will this change in v4? I already read about the switch to Latin Modern in mathjax/MathJax-src#973.

@dpvc
Copy link
Member

dpvc commented Oct 8, 2023

The fonts all have their natural ascent and descent values, except for one that is used to force the ascent/descent to be equal when it is used as the first font in a list of fonts in font-family CSS declarations.

@dpvc dpvc transferred this issue from mathjax/MathJax-src Nov 11, 2023
@dpvc dpvc added the v3 label Nov 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants