mathjax/MathJax-demos-node

MathML symbols are not converted correctly

j-komma opened this issue · 3 comments

We use MathJax to convert MathML to SVG. Unfortunately, some symbols are not converted correctly. The following symbols are not converted correctly:

Volume Integral U+2230
Surface Integral U+222F
Circled division sign U+2A38

The following steps are necessary to reproduce the problem:

  1. Unzip the provided Folder
    MathJax.zip

  2. change into the Direcotry

  3. run "npm i"

  4. run "node convert.js"

Now the imported XML strings with the MathML and the SVG elements generated for them should be outputed.

"https://www.svgviewer.dev/" can be used to check the SVG.

I am happy to answer any additional questions.

dpvc commented

The characters you cite are not available in MathJax's font set, and so it does not have the bounding box information for them. It inserts a text node in hopes that some system font will have the character, but there is no guarantee of that, and if it does, MathJax doesn't know the size of the character it obtains. In the browser, it can ask the browser to measure the width (roughly), but in a node application, where these is not a real DOM to work with, MathJax has to make a guess as to the size. That is not a very sophisticated guess, and so it may get it wrong. It also doesn't have large and small sizes, so can't handle display-vs-inline style size changes, and it doesn't thane any italic correction data, so can't offset the limits on the integrals.

In order to do better with the width in node, you would need to use something like puppeteer to get access to a real browser DOM where the measurements can take place, but it will still have the other issues mentioned above. There is a puppeteer example in the puppeteer directory of this repository.

The next release will have a larger font selection, with wider character coverage.

@dpvc If it is currently already possible to install a font on the operating system, so that these are rendered correctly. Are there fonts that are recommended here where also possibly the boxes fit (more than less)? Which fonts have you used here for the calculation of the boxes?

I think for the most users it would be good to know what fonts should be used here.

Thanks!!

dpvc commented

Which fonts have you used here for the calculation of the boxes?

If you mean for the characters that aren't in MathJax's fonts, MathJax doesn't have any bounding box information for these characters, and it's approach to these is very basic: it just assumes they are all the same size (governed by the unknownCharWidth option), which is .6em by default.

Are there fonts that are recommended here where also possibly the boxes fit (more than less)?

No, node-based handing of characters that are outside the fonts is of limited utility. But the next release of MathJax will have new fonts with wider coverage, so that should improve the situation.