-
Notifications
You must be signed in to change notification settings - Fork 100
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
Unicode variation sequences #2244
base: master
Are you sure you want to change the base?
Conversation
Oh, I should have added a demo:
|
b51b78a
to
5486852
Compare
I have rebased against the new refactor. However, the OMS font metrics do not have |
Oh, probably not. In my overly rushed tests, |
I'm very impressed how well you navigated through LaTeXML's Unicode maze! It looks spot-on, as far as it goes; The "big picture" still has a few mysteries to be sorted out, however.
|
I have some answers!
The crux of the matter is that the calligraphic distinction used to be treated as a stylistic choice, so the few fonts that offer options use different, non-standardised strategies. For instance, STIX uses stylistic sets, which require STIX-specific CSS rules to trigger the glyph switch. Since the rules are font specific, you need to use the latest Variation sequences are instead semantic and meant to work the same way regardless of the font, and are very poorly supported at the moment. However, at least STIX (stipub/stixfonts#218) and MathJax (mathjax/MathJax#3045) claim they will understand them in the future. Cambria Math should already work with them (not tested!).
The lowercase ones are not specified in Unicode (presumably because they don't appear in the wild), so that seems risky, should a future standard give a different meaning to them (extremely unlikely of course). |
Thanks @xworld21 ; The fact that empty set works implies that the Browser & Font are capable of dealing with variation sequences, but are not using it for caligraphic/roundhand. Thanks for the pointer: it looks like STIX 2.2 will support it. I'm a little leery of belt-n-suspenders adding both the variation selectors and classes. You're right that Fred's CSS rules are specific to Stix2, which makes it tempting to add a You're also right about the lowercase; I thought I'd seen that they were included. I suppose we'd still have to use whatever CSS, if it ever comes to that (doubtful). |
I have something more flexible in mind. With modern CSS, you can set font features depending on the actual font being used, so it would be enough to add a rule for 'STIX Two Math' and maybe a few other known fonts. If the browser is using STIX, good, otherwise nothing happens. Not entirely bullet proof (e.g. the font could have been imported with a different name), but it sounds somewhat better than the current |
This is the kind of backward-compatible CSS that would work. It will adjust to which font is actually being used: @font-feature-values "STIX Two Math" {
@styleset {
calligraphic: 0; /* \mathcal 'chancery' */
script: 1; /* \mathscr 'roundhand' */
}
@character-variant {
varnothing: 0; /* \varnothing */
emptyset: 3; /* \emptyset */
}
}
@font-feature-values "XITS Math" {
@styleset {
calligraphic: 1; /* \mathcal 'chancery' */
script: 0; /* \mathscr 'roundhand' */
}
}
math {
font-family: "STIX Two Math", "XITS Math";
/* LaTeXML/Unicode defaults */
font-variant-alternates: character-variant(emptyset) styleset(script);
}
.mathcal {
font-variant-alternates: styleset(calligraphic);
}
.varnothing {
font-variant-alternates: character-variant(varnothing);
} Demo at https://codepen.io/xworld21/pen/XWvaKod It is a simplified version of Fred Wang's MathFonts page with a correction (indeed, roundhand and chancery were swapped for STIX) and extra code for |
Fix #2235, at least when it comes to empty set and (capital) script characters. Unicode specifies a few other sequences but I haven't found which macros or fonts should have that output (see https://www.unicode.org/Public/15.1.0/ucd/StandardizedVariants.txt).
This change is supposed to be fully backwards compatible: if the MathML font recognises the variation sequence, it will use the more correct character; if not, the standard dictates that it must behave as if the variation selector is not there. I have tried to ensure that
--noplane1
and--hackplane1
keep working correctly.Note: the output of
tools/compilemetrics
is not deterministic so I just inspected the the output and applied the (trivial) change toStandardMetrics.pm
by hand. I don't know how to test if the metrics work correctly.