Allow the no-font components to still have a default font, just not a packed one. #1327
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.
This PR fixes an issue that occurs when you load the
output/chtmloroutput/svgcomponents by hand (usingstartup.js) rather than using a combined component. Currently, these output components are built with no font (so they can be used with any of the fonts without incurring the cost of downloading the default font), and they are the basis of the-nofontcombined components. Unfortunately, being built with no font means that you have to specify or load a font explicitly if you load the output component by hand.This PR fixes this problem by configuring the font to load the default font (
mathjax-newcm) whenoutput/chtmloroutput/svgis loaded without specifying another font while still not having to include the font data for the default font.The old approach worked by having webpack replace the reference to
DefaultFont.jsby anofont.jsfile in the output directory. This PR changes that to instead replace the font'sdefault.jsfile (which is loaded byDefault.jsto instead call a newnofont.jsfile in the font directory itself. This new file returns the font name and a null font class object, and thecomponents/mjs/output/util.jsfile uses the null font class to cause the default font to load if another font wasn't specified.I will need to rebuild the fonts to include the new
nofont.jsfiles, but for testing, you can just addnode_modules/@mathjax/mathjax-newcm-font/mjs/nofont.jscontaining:and that should allow you to pack the output components and the combined components. Note that this only affects the packed components, not loading components or modules from source.
This is not critical in the sense that you can get around the problem by specifying
mathjax-newcmexplicitly in the configuration, but it will make things easier for people.