Skip to content

Fix problem with Plane1 not being mapped to the MathJax fonts properly #1457

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 11, 2016

Conversation

dpvc
Copy link
Member

@dpvc dpvc commented May 3, 2016

This makes sure the Math Alphabetical characters are mapped down to the ASCII range so that they display properly in the MathJax fonts (which are only Plane0). Resolves issue #1451.

if (n > 0xFFFF && this.FONTDATA.RemapPlane1) {
var nv = this.FONTDATA.RemapPlane1(n,variant);
n = nv.n; variant = nv.variant;
}
Copy link
Member

Choose a reason for hiding this comment

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

I still don't like double parked assignments.

Copy link
Member Author

Choose a reason for hiding this comment

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

Of course, this would be

let [n,variant] = this.FONTDATA.RemapPlane1(n,variant);

Putting the two assignments on the same line is my way of imitating this. The purpose of those two lines is to decompose the object obtained from the previous command. It has always bothered me that JavaScript didn't have a way to do that directly, so I'm glad to see it in ES6.

@zorkow
Copy link
Member

zorkow commented May 11, 2016

LGTM (I don't quite understand the context, though.)

@dpvc
Copy link
Member Author

dpvc commented May 11, 2016

The context is that the MathJax TeX fonts only have glyphs in Unicode plane 0. At the time they were created, there was not very good support for Plane1, and so we could not rely on it. Also, because we were sending these over the network, we wanted to keep them as small as possible, and so didn't want to have duplicate characters in Plane1 when we would have to use Plane0 for some browsers anyway. To further help make the fonts small, we broke up the characters into a number of separate fonts (26 as I recall) so that only small sets of characters needed to be downloaded rather than the whole set. The STIX fonts, for example, include nearly 9000 glyphs, and are prohibitively large to download as a web font.

The Math Alphabet characters (like the double-struck characters, and the Fraktur set) are in Plane1; e.g., double-struck are (mostly) at U-1D538 to U-1D56B. But MathJax's fonts handle them by putting them at the usual ASCII positions, but in a separate font for the double-struck versions. The same for Fraktur, script, sans-serif, etc.

In MathML these characters can be specified in two different ways: Either directly as their Plane1 versions, e.g., <mi>&#x1D538;</mi> or via the mathvariant, e.g., <mi mathvariant="double-struck">A</mi>. Having the double-struck characters in the ASCII positions makes it easy to handle the second of these (by having a style that selects the font with the double-struck characters). Indeed, the Firefox MathML did not support mathvariants other than normal, italic, bold, and bold-italic (I'm not sure if it does even yet), so MathJax added styles to map double-struck, Fraktur, etc. to its own fonts when NativeMML output was used.

For the direct Unicode values, since the MathJax fonts don't include the glyphs at the Plane1 locations, MathJax must convert them to their ASCII positions and apply the correct font for the alphabet in use. That is what the code above does. The original issue had someone using <mi mathvariant="double-struck">&#x1D538;</mi>, which is redundant, but MathJax should handle it anyway. It does in HTML-CSS and SVG output, but didn't in CommonHTML. The RemapPlane1() code was included, but I forgot to call it. The patch above adds the missing call.

@dpvc dpvc merged commit a091415 into mathjax:develop May 11, 2016
@dpvc dpvc deleted the issue1451 branch May 11, 2016 21:12
@pkra pkra added this to the MathJax v2.x.x milestone May 17, 2016
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.

3 participants