Closed Bug 1788937 Opened 3 years ago Closed 4 months ago

Implement font-family: math

Categories

(Core :: MathML, enhancement)

enhancement

Tracking

()

RESOLVED FIXED
145 Branch
Tracking Status
firefox145 --- fixed

People

(Reporter: fredw, Assigned: eri)

References

(Blocks 1 open bug)

Details

(Keywords: dev-doc-complete)

Attachments

(1 file)

Currently we implement the default math font selection via an internal x-math lang (bug 947654) and it's configurable via the font preference menu.

We could instead use font-family: math
https://drafts.csswg.org/css-fonts/#valdef-font-family-math
https://w3c.github.io/mathml-core/#the-top-level-math-element

Replaces the internal x-math lang for the CSS Fonts Level 4
font-family: math generic font family.

Spec: https://www.w3.org/TR/css-fonts-4/#math-def

Assignee: nobody → eri
Status: NEW → ASSIGNED
Attachment #9500032 - Attachment description: Bug 1788937 - Implement font-family: math. r?fredw → Bug 1788937 - Implement font-family: math. r?fredw,jfkthame

Suppose I understand the logic of this patch and gfxFcPlatformFontList::AddGenericFonts function correctly, does it mean that after this patch is merged, if I want Firefox to use the fonts directly queried from fontconfig for the generic family math. In that case, I need to turn on mathml.font_family_math.enabled (of course this is the default in nightly), and set font.name.serif.x-math (empty by default) and font.name-list.serif.x-math (a series of fonts predefined by Firefox by default) to empty?

(In reply to Celeste Liu [:Coelacanthus] from comment #2)

Suppose I understand the logic of this patch and gfxFcPlatformFontList::AddGenericFonts function correctly, does it mean that after this patch is merged, if I want Firefox to use the fonts directly queried from fontconfig for the generic family math. In that case, I need to turn on mathml.font_family_math.enabled (of course this is the default in nightly), and set font.name.serif.x-math (empty by default) and font.name-list.serif.x-math (a series of fonts predefined by Firefox by default) to empty?

I have just tested this. You only need to set mathml.font_family_math.enabled and font.name.serif.x-math = "math", as name seems to have priority over name-list. With that I was able to change the font with fontconfig preferences.

That's what I would expect, yes. (Thanks for testing it!) The font.name.* pref comes first (if non-empty), and then the list from font.name-list.* is appended to that; and (on Linux) each family-name found is then passed to fontconfig to be resolved. So just setting font.name.serif.x-math = "math" should mean that the first-choice font for math content will be whatever fontconfig returns for math.

Actually, I think we should probably include math at the beginning of the font.name-list.serif.x-math pref on Linux, so that this happens by default. This is what we do for the other generics (serif, sans-serif, etc): we just map them to the same names and let fontconfig resolve them. But that will potentially change behavior quite significantly (suddenly making use of the fontconfig math generic, where previously we used an internal list of common math fonts), so we should do that change in a separate bug.

(In reply to Jonathan Kew [:jfkthame] from comment #4)

That's what I would expect, yes. (Thanks for testing it!) The font.name.* pref comes first (if non-empty), and then the list from font.name-list.* is appended to that; and (on Linux) each family-name found is then passed to fontconfig to be resolved. So just setting font.name.serif.x-math = "math" should mean that the first-choice font for math content will be whatever fontconfig returns for math.

Actually, I think we should probably include math at the beginning of the font.name-list.serif.x-math pref on Linux, so that this happens by default. This is what we do for the other generics (serif, sans-serif, etc): we just map them to the same names and let fontconfig resolve them. But that will potentially change behavior quite significantly (suddenly making use of the fontconfig math generic, where previously we used an internal list of common math fonts), so we should do that change in a separate bug.

That sounds good. But I agree with doing it on a different bug, the behaviour is very different. For example, on my Firefox build container, the default math family order in fontconfig was "XITS Math", then "STIX Two Math", then "Latin Modern Math", so it was quite different than the one currently in Firefox.

Pushed by fwang@igalia.com: https://github.com/mozilla-firefox/firefox/commit/fc0d07c7d94a https://hg.mozilla.org/integration/autoland/rev/edf20ccb2b51 Implement font-family: math. r=jfkthame,emilio,firefox-style-system-reviewers,layout-reviewers
Pushed by agoloman@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/9d4a4e88a42a https://hg.mozilla.org/integration/autoland/rev/bdd95e1cb88e Revert "Bug 1788937 - Implement font-family: math. r=jfkthame,emilio,firefox-style-system-reviewers,layout-reviewers" for causing wpt failures @math-global-event-handlers.tentative.html.

Backed out for causing wpt failures @math-global-event-handlers.tentative.html.

Flags: needinfo?(eri)

(In reply to agoloman from comment #8)

Backed out for causing wpt failures @math-global-event-handlers.tentative.html.

UPDATE: The wpt failures were not caused by this patch, only the WR failure

So sorry about that, I'm still trying to figure out what tests are best to run at each point, so the Wr failures slipped by. I came across the Unicode PUA test before so I have an idea of what I missed. I'll upload a fix for that in a bit.

Flags: needinfo?(eri)
Depends on: 1985548
Pushed by fwang@igalia.com: https://github.com/mozilla-firefox/firefox/commit/0599bccd8474 https://hg.mozilla.org/integration/autoland/rev/25f99d4015d3 Implement font-family: math. r=jfkthame,emilio,firefox-style-system-reviewers,layout-reviewers
Status: ASSIGNED → RESOLVED
Closed: 4 months ago
Resolution: --- → FIXED
Target Milestone: --- → 145 Branch

MDN docs changes can be tracked in the following GitHub issue: https://github.com/mdn/content/issues/41506

Blocks: 2009163
Blocks: 2014703
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: