Skip to content

Conversation

dpvc
Copy link
Member

@dpvc dpvc commented Aug 16, 2025

This PR adds a fontExtensions configuration that makes it easier to specify a font extension to load (e.g., mathjax-euler). It sets up the extraLoads package data to make sure the extension loads after the font itself. The current method of including the extension in the loader.load array doesn't work properly as it can be loaded before the font arrives. That can be handled by setting up dependencies and paths in the loader configuration, but it is harder than it should be, so this makes it easy.

Resolves issue mathjax/MathJax#3410.

The original section that was used to configure a font has been moved to a configFont() function, and a new configExtensions() function uses it to set up the font extensions.

@dpvc dpvc requested a review from zorkow August 16, 2025 19:10
@dpvc dpvc added this to the v4.0.1 milestone Aug 16, 2025
Copy link

codecov bot commented Aug 21, 2025

Codecov Report

❌ Patch coverage is 76.08696% with 11 lines in your changes missing coverage. Please review.
✅ Project coverage is 86.71%. Comparing base (efcdd46) to head (e504edc).

Files with missing lines Patch % Lines
components/mjs/output/util.js 79.31% 6 Missing ⚠️
ts/output/common.ts 70.58% 5 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1337      +/-   ##
===========================================
- Coverage    86.72%   86.71%   -0.01%     
===========================================
  Files          337      337              
  Lines        84145    84182      +37     
  Branches      4769     4773       +4     
===========================================
+ Hits         72971    72997      +26     
- Misses       11151    11162      +11     
  Partials        23       23              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@dpvc
Copy link
Member Author

dpvc commented Aug 21, 2025

I added a commit that includes support for generic font extensions that have dynamic font ranges, like mathjax-euler. It turns out that they reference the generic font, which was only meant as a placeholder for the actual font, but that wasn't being replaced. This commit fixes that, but unfortunately, it requires a static property on the output jax because the dynamic files don't have access to the output jax instance. So the typeset() method sets up that static value, so that any dynamic loads during the typesetting will go to the right font. We do it here in case there are several output jax instances with different fonts. We also set it during the output jax constructor, in case the dynamic files are loaded up front (like some of the documentation examples illustrate).

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.

lgtm.

@dpvc
Copy link
Member Author

dpvc commented Aug 28, 2025

I just realized there is a potential problem, here. If there is a retry during the toDOM() call (for loading dynamic font ranges), then the genericFont will not be reset. So I need to made another commit to handle that.

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