Skip to content
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

MathJax does not support Unicode 14 mathematical script variants #3045

Open
JeppeKlitgaard opened this issue May 9, 2023 · 6 comments
Open
Labels
Accepted Issue has been reproduced by MathJax team Feature Request v4

Comments

@JeppeKlitgaard
Copy link

I much prefer writing the majority of my source math using Unicode, which generally works really well with MathJax.

I have noticed, however, when I want to display calligraphic math, I find that they render using an unexpected font in MathJax.

My suggestion is thus that the Unicode range starting at 1D49C render similar to \mathcal{…}

As an example, the insert the following on https://www.mathjax.org/#demo:

$$
\mathcal{O} \quad\quad 𝒪
$$

Which renders as
image

I would expect them to have the same rendering

@pkra
Copy link
Contributor

pkra commented May 10, 2023

𝒪 matches \mathscr{O}, not \mathcal{O}

image

(There's a unicode proposal for distinguishing the calligraphic/chancery alphabet
from the fancy-script/roundhand alphabet using variation selectors though I'm not sure where that's at.)

@JeppeKlitgaard
Copy link
Author

Ah, now that makes a lot of sense! Thanks a ton @pkra.

I think with that in mind I will close this issue.

From w3c/mathml#61 and https://w3c.github.io/xml-entities/script.html it appears that the Unicode variant has been added as part of Unicode 14!

@JeppeKlitgaard
Copy link
Author

JeppeKlitgaard commented May 10, 2023

It appears that the Unicode variant selectors are not supported by MathJax just yet :(

Here is a demo that can be used on https://www.mathjax.org/#demo:

Calligraphic Variants: 𝒪︀ (text), $𝒪︀$ (MathJax, Unicode), $\mathcal{O}$ (MathJax, LaTeX)
<br>
Script Variants: 𝒪︁ (text), $𝒪︁$ (MathJax, Unicode), $\mathscr{O}$ (MathJax, LaTeX)
<br>
No Variant Selected: 𝒪 (text), $𝒪$ (MathJax, Unicode)

Which renders as:

image

The variants are not rendered correctly when given as Unicode. Note that the browser also does not correctly render the variants, presumably because of a lack of font support. Since MathJax has access to glyphs for both variants, it should be able to render the variants correctly.

Expected:

  • U+1D4AA U+FE00 should render as $\mathcal{O}$
  • U+1D4AA U+FE01 should render as $\mathscr{O}$

@JeppeKlitgaard JeppeKlitgaard changed the title Should unicode mathematical script characters display as calligraphic math? MathJax does not support Unicode 14 mathematical script variants May 10, 2023
@dpvc dpvc added Accepted Issue has been reproduced by MathJax team Feature Request v4 labels May 29, 2023
@xworld21
Copy link

I'd like to add that other symbols have variation sequences. The one I noticed is the symbol for the empty set U+2205, which the Unicode spec renders like \varnothing, but with an extra 0+FE00 makes it like \emptyset. (By the way MathJax 3 renders U+2205 like \emptyset.)

@xworld21
Copy link

I have jerry-rigged partial support for some variation sequences by adding some filters after initialisation but before typesetting:
https://github.com/vlmantova/bookml/blob/694457da6c22b530b24c488a6bca89112bcb0a7f/XSLT/bookml-html5.xsl#L101-L169
The code modifies the MathML nodes before they get loaded so that MathJax uses the desired variant. It understands script variants and make U+2205 behave as per Unicode 15.1 (so render like \varnothing by default, switch \emptyset if followed by U+FE00). The main limitation is that it only works for identifiers and operators consisting of a single character only.

The full list of standardized variation sequences is at https://www.unicode.org/Public/15.1.0/ucd/StandardizedVariants.txt

If I understand correctly, variation sequences should really be implemented in the fonts and enabled via font-feature-settings: "cv01", "cv02" in CSS (not sure if MathJax needs code changes, maybe around font metrics?).

@xworld21
Copy link

I repackaged my code: https://codepen.io/xworld21/pen/oNmbeVR contains a MathJax 3 config that recognises the variation sequences in MathML input (not in TeX input I am afraid).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Accepted Issue has been reproduced by MathJax team Feature Request v4
Projects
None yet
Development

No branches or pull requests

4 participants