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

[math] [css-fonts] Solution to mixing text and math fonts in a document #5534

Open
fred-wang opened this issue Sep 19, 2020 · 7 comments
Open

Comments

@fred-wang
Copy link

fred-wang commented Sep 19, 2020

(Part of #5384 - MathML Core related CSS)

cc @litherum @jfkthame @drott @bkardell

This is an item to discuss for the next CSSWG Math meeting.

Documents containing equations use fonts for the text (e.g. STIX Two Text, Cambria, Latin Modern...) and a companion font for the math (e.g. STIX Two Math, Cambria Math, Latin Modern Math...). Obviously, the former fonts have usual italic/bold variants, glyphs and font features to write "normal" text while the latter has all the specialized features for rendering formulas (math symbols, operator stretching, layout parameters, etc).

In the ideal situation where one has total control on the environment (e.g. TeX systems, Microsoft Word on Windows), it can be ensured that a pair of such fonts is available and used to get beautiful rendering. This is not necessarily the case on the Web : Even if Web fonts can be used, most authors either intentionally want to use non-matching fonts (like their favorite text font + their favorite math font), or even worse don't provide any math font at all.

This has two consequences:

  1. If font-family on the <math> tags is not set to one installed on the user's computer/device or provided via a web font, then the mathematical formula will render with a text font, resulting in poor rendering.

  2. Even if font-family on the <math> tags is set to an available math font, this one may be different from the inherited font-family of the surrounding text, resulting in inconsistent font-size between text and inline math.

In order to solve 1., Firefox implements a mechanism similar to how it selects fonts for different languages (lang attribute), essentially claiming that <math> tags have an 'x-math' language and picking known math fonts from the user preference. WebKit instead just hardcodes some known math fonts in its MathML UA stylesheet. Chromium does not have any mechanism implemented yet.

Browsers have not implemented anything in order to solve 2, although it seems WebKit & Chromium have a similar adjustment mechanism when moving to a "monospace" family for example. MathJax also has a heuristic to perform adjustments via JavaScript measurements.

The MathML CG would like to find a cross-compatible CSS-based solutions to address these use cases:

For 1. it seems implementing font-family: math in browsers is the way to go, although there is some discussion about limiting generic families (see #4910). This would allow to make the default math font configurable by the users.

For 2. @faceless2 proposed extending font-size-adjust to compare the size against the font inherited from the parent could work?

@faceless2
Copy link

@astearns
Copy link
Member

astearns commented Jan 5, 2021

@fred-wang @faceless2 this week’s meeting is at the bad time for Europeans. Shall we plan on taking this up on January 13?

@faceless2
Copy link

13th certainly works better for me

@astearns astearns added this to the VF2F-2021-02-09 EUR milestone Feb 2, 2021
@litherum
Copy link
Contributor

litherum commented Feb 8, 2021

Possibly related: #5539

@astearns astearns modified the milestones: VF2F-2021-02-09 EUR, VF2F-2021-04-06 EUR Mar 22, 2021
@astearns
Copy link
Member

OK, another attempt at getting to this in one of our long-form meetings. @fred-wang could you commit to discussing this on April 6th? @faceless2 @bkardell

@faceless2
Copy link

I have a meeting I can't skip at 1600-1700CEST and one I can if necessary at 1800-1900CEST (UTC+2). But I'm only on the periphery of this one, so please don't postpone on my account.

@astearns
Copy link
Member

Looking at https://github.com/mathml-refresh/mathml/issues/225 I am not yet seeing consensus.

@astearns astearns removed the Agenda+ label Apr 13, 2021
@astearns astearns removed this from the EUR VF2F-2021-04-06 milestone Jul 24, 2021
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

6 participants