Closed
Description
Issue Summary
There is a rendering bug when Chinese chars in \text block. The affected version is 4.0.0-beta.6. And the 3.2.2 version is fine.
Steps to Reproduce:
- Open the following html, as you can see, Chinese \text block is rendered wrong.
<!DOCTYPE html>
<html>
<head>
<title>Mathjax tex-mml-svg bug</title>
<script src="https://cdn.jsdelivr.net/npm/mathjax@4.0.0-beta.6/tex-mml-svg.js" id="MathJax-script"></script>
</head>
<body>
<p>Rendering bug when Chinese chars in \text block: $$\text{中文 bug}$$</p>
<p>Latin chars is fine: $$\text{adwaw da ai dawd,}$$</p>
<p>Version 3.2.2 is also fine</p>
</body>
</html>
Technical details:
- MathJax Version: 4.0.0-beta.6
- Client OS: Windows 11
- Browser: Chrome 124.0.6367.63
I am using the default MathJax configuration:
and loading MathJax via
<script src="https://cdn.jsdelivr.net/npm/mathjax@4.0.0-beta.6/tex-mml-svg.js" id="MathJax-script"></script>
Supporting information:
<!DOCTYPE html>
<html>
<head>
<title>Mathjax tex-mml-svg bug</title>
<script src="https://cdn.jsdelivr.net/npm/mathjax@4.0.0-beta.6/tex-mml-svg.js" id="MathJax-script"></script>
</head>
<body>
<p>Rendering bug when Chinese chars in \text block: $$\text{中文 bug}$$</p>
<p>Latin chars is fine: $$\text{adwaw da ai dawd,}$$</p>
<p>Version 3.2.2 is also fine</p>
</body>
</html>
Metadata
Metadata
Assignees
Labels
Type
Projects
Milestone
Relationships
Development
No branches or pull requests
Activity
dpvc commentedon May 2, 2024
Thanks for the report.
The easiest solution is to set the
mtextInheritFont
option totrue
in theoutput
block of your configuration:If you want the non-Chinese text to be in the default MathJax font, then you can use the following patch instead:
The problem was that the
placeChar()
function wasn't handling characters that are not in the MathJax font properly (it did not process their widths correctly) in SVG output. This corrected routine should do the job.I will make a PR to fix the problem in the next release.
dpvc commentedon May 2, 2024
Sorry, I had mistyped
mtextInheritFont
in the first code block above. I have fixed it, so make sure you have the correct version if you use that.Fix handling of unknown characters in SVG output. (mathjax/MathJax#3224)
Merge pull request #1089 from mathjax/issue3224