Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make tex font packages work with \require #1075

Merged
merged 2 commits into from
Mar 18, 2024
Merged

Make tex font packages work with \require #1075

merged 2 commits into from
Mar 18, 2024

Conversation

dpvc
Copy link
Member

@dpvc dpvc commented Mar 14, 2024

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 dpvc requested a review from zorkow March 14, 2024 16:57
@dpvc dpvc added this to the v4.0 milestone Mar 14, 2024
@dpvc
Copy link
Member Author

dpvc commented Mar 14, 2024

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.

Copy link
Member

@zorkow zorkow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One cosmetic rewrite of an if condition.
Otherwise looks good.

ts/output/chtml/FontData.ts Outdated Show resolved Hide resolved
@dpvc dpvc merged commit 5ed20c7 into develop Mar 18, 2024
@dpvc dpvc deleted the require-font branch March 18, 2024 20:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants