Allow tex packages that load font extensions to work better with \require and renderer changes. #1080
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 is for beta.6.
The addition of the new TeX packages that load various double-struck fonts has broken the previous separation of input and output jax. There are some assumptions that relied on this separation, so these new TeX packages complicate things somewhat. In particular, switching renderers when one of these packages has been loaded via
\require
would not necessarily retain the font in the new renderer. Furthermore, because of the way the extensions hooked into the renderer changes, leading a second font extension would interfere with the loading of the first one when a renderer change occurred.The component packages for these extensions tried to set things up overcome some of these complications, but were not completely successful. So this PR includes changes to properly handle switching renderers and fonts, both in regular pages and in the v4-lab. In addition, it implements generic font extensions that are not tied to a particular base font, so that the extensions like
mathjax-dsfont
can be applied to any font.One of the important changes is to move the code that adds an extension to a font from the TeX component file (where it currently is) into the font extension's component file instead. So all the code controlling the extension being added to a font is now in the extension itself, rather than in the TeX package. The TeX package file now simply has to set up the loading of the extension and that is it. This is done via the changes to the
components/mjs/input/tex/extension.js
file.To facilitate this, and to overcome the problem with multiple font extensions, the loader has been extended to include a new function
addPackageData()
that can be used to update the loader package information (like thecheckReady()
function), and that data can now include a list of additional packages to load after the initial one is loaded. So we can now set up several font extensions to be loaded when the output jax is changed, for example.There is also an array of extensions that need to be installed when the renderer changes that is set when one of the font extensions is loaded by
\require
(in case the new renderer has already been loaded, and so the file-based hooks will not be triggered). This is referenced by the changes in the\require
macro, which sets a corresponding array in the document'sMenu
object, and that is used by the menu code to install the needed extensions when the output jax changes.Because of the
extraLoads
array, thePackage
object gets a new methodloadPromise()
that returns a promise that is resolved when all the extra files are loaded, and thecheckReady()
method (if any) resolves. This is also used in thecomponents/mjs/output/util.js
file to make sure these files are loaded when a new output jax component is loaded.Some other cleanup is also performed. The
addExtension()
functions in the common and chtml output jax files now have the optionalprefix
argument that theFontData
version has (though it is not currently used), and the instance versions of these functions now take aFontExtensionData
object rather than an extension name, so that we don't have to store that data in the dynamic extension data. (Since theseaddExtension()
calls have been moved to the font extension components themselves, and those have access to the font data, that means we don't need to keep that data in the saved dynamic extension object any longer). The dynamic extension data now uses a default value for theprefix
, rather than requiring it to be set in the font extension component, as in the past.Finally, some of the config files have been updated to remove
exclude
arrays that are no longer needed.This branch requires changes in the font components, as well as the font tools, and also the v4-lab. You will need to check out the
generic-extensions
branches in the font-tools and fonts repositories, then compile the font-tools, and rebuild the extension fonts (all three). Then check out thelab-extension-update
in the MathJax-dev repository. Finally, link the newly built fonts into MathJax-dev'snode_modules
directory next to the other fonts.