mathjax / MathJax-node

MathJax for Node
Apache License 2.0
616 stars 97 forks source link

[SVG output] improve string-width detection for text elements #368

Closed pkra closed 1 year ago

pkra commented 7 years ago

358 introduced detection for full-width forms. A more advanced approach might use string-width which handles more cases such as (some) combining characters.

Note it's not perfect and won't help with all combining characters, in part due to natural ambiguities ("can we assume the user's system will combine the characters?", see also https://github.com/sindresorhus/string-width/issues/2, https://github.com/sindresorhus/string-width/issues/4).

However, we're currently split up strings in text elements anyway, so we would need to make sure all characters end up in the same text element.

wrvc3000 commented 6 years ago

Hi!

I'm not sure if this has to do with this issue, so I'd prefer to ask instead of creating a new one.

For an asciimath text like this: los números 'NN' naturales

We are getting the N cropped, like this:

screen shot 2018-06-07 at 12 40 55

What could be happening?

Thanks!

Tech details: mathjax-node 2.1.1 nodejs 8 SVG output Neo-Euler font Chrome Browser macOS High Sierra

dpvc commented 6 years ago

This is an unrelated issue, and should have been filed separately. Your other recent issue is the same one, however, so no need to open a new one now.

The problem is that the Neo-Euler is the smallest font available in MathJax (meaning it has the fewest glyphs), and it does not include any of the double-struck letters. In particular, the double-struck N is not in that font. When mathjax-node encounters a character that isn't in the font it is using, it falls back on using a Unicode reference to the desired character in hopes that your reader will have some font that contains it. But since mathjax-node doesn't have any bounding box information about the character, it has to make a guess about its width, height, and depth. In this case, it has underestimated the width slightly, and you are seeing the result.

There is no provision for working around that in mathjax-node with AsciiMath input. You might get away with `NN\ ` to add some space afterward, but you don't have a lot of options in AsciiMath for the size of that space, and so the spacing may not be great. But at least the full letter would be visible.

pkra commented 1 year ago

Cleaning up my old issues.