Skip to content

Allow font family, weight, and style CSS to be inherited by token elements - #1574

Merged
dpvc merged 2 commits into
developfrom
fix/font-inherit
Sep 24, 2026
Merged

dpvc merged 2 commits into
developfrom
fix/font-inherit

Conversation

@dpvc

@dpvc dpvc commented Sep 22, 2026

Copy link
Copy Markdown
Member

For an expression like

<mrow style="font-family: arial">
  <mn>1</mn>
  <mo>+</mo>
  <mn>2</mn>
</mrow>

the font family should affect all three elements that it contains. But currently in MathJax, that is not the case.

This PR fixes that issue and propagates the font family, weight, and style CSS styles of a container to its child nodes. For an mstyle element, the fontfamily, fontweight and fontstyle are also propagated. For an mi element with a single character content, the style will be set to italic for the specified font automatically.

This inheritance is accomplished by using the setInheritedAttributes() method. The font-family, font-weight, and font-style, if specified, are moved to the inherited fontfamily, fontweight, and fontstyle attributes (these are inherited values, not explicit attributes, so don't show up in the MathML output directly). The output jax wrapper's getVariant() method then picks these up and uses them when determine the math variant to use (which can be an explicit font). This handling is simplified a bit as well.

@dpvc
dpvc requested a review from zorkow September 22, 2026 00:13
@dpvc dpvc added this to the v4.2 milestone Sep 22, 2026
@codecov

codecov Bot commented Sep 22, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 74.44444% with 23 lines in your changes missing coverage. Please review.
✅ Project coverage is 87.12%. Comparing base (91b8038) to head (341626d).
⚠️ Report is 17 commits behind head on develop.

Files with missing lines Patch % Lines
ts/core/MmlTree/MmlNode.ts 50.00% 23 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1574      +/-   ##
===========================================
- Coverage    87.12%   87.12%   -0.01%     
===========================================
  Files          392      392              
  Lines        89187    89280      +93     
  Branches      5063     3378    -1685     
===========================================
+ Hits         77706    77784      +78     
- Misses       11481    11496      +15     

☔ View full report in Codecov by Harness.
📢 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.

@zorkow zorkow left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

lgtm.

@dpvc
dpvc merged commit 3fcfca2 into develop Sep 24, 2026
1 of 3 checks passed
@dpvc
dpvc deleted the fix/font-inherit branch September 24, 2026 23:43
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