Open fred-wang opened 4 years ago
The procedure described for the MathJax feature is almost identical to the existing font-size-adjust CSS property already defined in css-text-4, except that - instead of adjusting all fonts in the font-family list to have the same x-height, you're adjusting all fonts in the font-family list to have the same x-height as the parent element's font.
The sizing changes for font-family: monospace
are an awful legacy bodge. They also only apply for named font sizes. font: medium monospace
is 13px, but font: medium monospace, serif
is 16px. It's not a model to emulate.
However, I think you could probably make a reasonable case for something like font-size-adjust: parent
, which would adjust the x-height for the fonts used in an element, to match the x-height of the first-available-font of the parent element. I'm sure this could be applied beyond MathML as well.
However, I think you could probably make a reasonable case for something like
font-size-adjust: parent
, which would adjust the x-height for the fonts used in an element, to match the x-height of the first-available-font of the parent element. I'm sure this could be applied beyond MathML as well.
That sounds a good idea. Probably something for @bkardell to check with the CSS people.
Or do we want to add some special adjustment for "font-family: math"
Nope. Font families should not affect font sizes. You found the case where they do, but @faceless2 is right that it's terrible and we shouldn't replicate it.
font-size-adjust: parent
There's one tricky piece here which is: Which of the used fonts in the parent should be matched? The primary font's metrics? But what if none of the primary font's glyphs are actually used anywhere in the document? That seems like it would be wrong.
Another option that could work is to recommend that content which use math set font-size-adjust
on the containing paragraph. It's inherited, which means the math and its surrounding text will all use the same apparent x-height.
There's one tricky piece here which is: Which of the used fonts in the parent should be matched?
I think it has to be the "first available font" - we're already using this for metrics for ex/capheight etc., even if the font isn't actually used. So it would be entirely consistent to use the first-avilable font here (for anyone coming to this cold, it's defined as the the first font-face that includes U+0020 in the unicode-range).
Setting it on the parent and relying on inheritance is a bit weird. In parficular, if you just want the x-height to be whatever the normal x-height for that font is, you'd have to do font-size-adjust: calc(1ex / 1em)
. FIrst, that's awful, second it's taking the metric from the first-available-font again, so we're back where we started.
Just something to remember: we now have a font-size: math;
on all MathML elements to say "take into account script level change". So that may conflict or not with the solutions proposed here.
I'm not sure what's the status of this. For the record, this is on "Other tasks" of https://mathml.igalia.com/project/ but it's not clear whether this will be in the initial implementation.
@faceless2 what's the status of the discussion on the CSS WG side?
This is a follow-up of https://github.com/mathml-refresh/mathml/issues/37
With the rule
math { font-family: math; }
, the default behavior is to use a math font instead of inheriting the font from the parent that (likely) is not designed for math layout and would result in poor rendering.The font-size is inherited, but since the surrounded text and the math formula uses two different font families, the actual size of glyphs is different.
MathJax has a configuration option to try and workaround this: https://docs.mathjax.org/en/latest/options/output/index.html#output-matchfontheight
Do we want to enhance font-size with a property value that automatically perform this kind of font-size adjustment when changing the font-family?
Or do we want to add some special adjustment for "font-family: math" (when I checked WebKit and Chromium code, it seems they do something for
font-family: monospace
but not sure whether that's specified by CSS).Or is it something that should be performed by a polyfill?
Or do we just don't care, and we should let people setup their CSS themselves?
(Note: of course, the ideal situation is when one uses a text font with its math companion, like STIX Two for the text and STIX Two Math for the math, see https://fred-wang.github.io/MathFonts/ ; this issue is about what we should do for the default)