Bugfix: MathJax fonts - #574
Open
Daria-E wants to merge 3 commits into
Open
Conversation
The HTML-CSS output jax prefers fonts installed on the machine over MathJax's own, and its default availableFonts list names STIX. macOS ships STIX 1.x as system-reserved faces that WebKit resolves by name, so the preview selects them and typesets digits and operators in STIXGeneral-Regular, a Times-metric face indistinguishable from body text while identifiers still read as math italic. Browsers that do not enumerate those faces, such as Firefox, load MathJax's TeX fonts and render the same document correctly. An empty availableFonts list declines local fonts. preferredFont is nulled alongside it because MathJax tests the preferred font even when it is absent from availableFonts, so the list alone still takes the local path on a machine carrying MathJax's own TeX fonts. MathJax resolves its configuration, jax and fonts against the script element's own src, so script-src and font-src both derive their source expression from that URL rather than repeating the origin. Without the font-src entry the faces are blocked, and the output jax stalls for its web-font timeout before falling back to bitmap image fonts.
The HTML-CSS output jax renders in vector web fonts, but with the fonts fetched from the CDN at render time the preview falls back to bitmap image fonts — pixelated on zoom — whenever that fetch times out. The 22 TeX woff faces now ship in Resources/MathJax/fonts/HTML-CSS/TeX/woff/, and the preview's resource-load delegate serves any bundled MathJax resource from file: (the loader was already served this way; the fonts join it). Fonts load synchronously, so the web-font timeout that triggers the image fallback never fires. Resources that are not bundled — config, jax.js, fontdata.js — still load from the CDN. kMPMathJaxCDN gains external linkage so the delegate can scope the redirect to the loader's origin. MPMathJaxLocalFontsTests pins the redirect (woff to the bundle without a query, un-bundled resources passing through, the loader keeping its config query) and the presence of the full TeX woff set.
Remove font binaries from repo.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The HTML-CSS output jax prefers fonts installed on the machine over MathJax's own, and its default availableFonts list names STIX. macOS ships STIX 1.x as system-reserved faces that WebKit resolves by name, so the preview selects them and typesets digits and operators in STIXGeneral-Regular, a Times-metric face indistinguishable from body text while identifiers still read as math italic. Browsers that do not enumerate those faces, such as Firefox, load MathJax's TeX fonts and render the same document correctly.
An empty availableFonts list declines local fonts. preferredFont is nulled alongside it because MathJax tests the preferred font even when it is absent from availableFonts, so the list alone still takes the local path on a machine carrying MathJax's own TeX fonts.
MathJax resolves its configuration, jax and fonts against the script element's own src, so script-src and font-src both derive their source expression from that URL rather than repeating the origin. Without the font-src entry the faces are blocked, and the output jax stalls for its web-font timeout before falling back to bitmap image fonts.