MathJax-src icon indicating copy to clipboard operation
MathJax-src copied to clipboard

Make tex font packages work with \require

Open dpvc opened this issue 1 year ago • 1 comments

This PR makes the changes needed to the font extension infrastructure to allow a TeX font package to be loaded via \require (e.g., \require{dsfont}) and have it load the needed font.

The components/mjs/input/tex/extension.js file exports a function that does the work of loading and adding a font extension, simplifying the dsfont, bbm and bboldx component files. This sets up the needed path for the extension, and the load hook that loads the font extension and adds it into the output jax when it is loaded.

To do this, the common output jax gets a new addExtension() function that looks up the font extension and adds it to the current font for that output jax. The chtml output jax overrides this so that it can add the needed CSS rules to load the fonts needed for the extension, if any. These come from a modified addExtension() in the ChtmlFontData object, which produces the needed @fontface rules and passes them back so that the output jax's addExtension() can insert the rules into the chtml stylesheet.

The common FontData object now saves the complete FontExtensionData object so that it can be used in the common output jax's addExtension() to add the extension to its existing font.

Finally, the bboldx extension is modified to configure the textmacros packages in its config() method rather than via its options setting. This is because when you use \require{bboldx}, this forces the textmacros package to be loaded and configured before bboldx is, and so the textmacros packages have already been processed before bboldx adds its package. So this allows bboldx to adds the package after the fact. You need to merge the textcomp-textmacros branch in order for this to work, since it includes changes to textmacros that are needed for the config() method to work (the textConf object).

I'm sorry to be adding yet another PR for beta.5, but since we are including the font extensions, it is probably best to have them work with \require.

dpvc avatar Mar 14 '24 16:03 dpvc

PS, \require{dsfont}, etc. still won't work with the v4-lab due to the way that the packages are handled for the check boxes (the component files are not actually processed, and that is what loads and adds the font extension). I will see if I can get that to work as well, but for now, you have to test this in a stand-alone file.

dpvc avatar Mar 14 '24 17:03 dpvc