Fix font extension handling of extra variants, and handle those variants in enrichment. #1033
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR fixes several problems with font extensions that define new font variants, and allows non-standard variants to round-trip through SRE without causing verification errors (now that we are checking
mathvariant
values inMmlNode
).Currently, the
ignore-variant
property is used to determine whether a node's non-standardmathvariant
should produce an error message when used in MathML input, and non-standard variants can be specified using thedata-mjx-variant
attribute. The presence of that attribute sets theignore-variant
properly when a MathML element is created by the MathML input jax, and the serialization of the node viaMmlVisitor
and its subclasses would add thedata-mjx-variant
attribute whenignore-variant
is set.In this PR, the
MmlVisitor
is modified to remove themathvariant
whenignore-variant
is set (anddata-mjx-variant
is added as before), since the variant is non-standard and should not be included in actual serialized MathML.In the past, when a non-standard variant is needed in TeX output, the
ignore-variant
property would need to be added by hand. If the parser'sstack.env.font
is a non-standard variant, this was not being done, and so if a non-standard variant is needed in a font extension (as with the IEEE Euler fonts), this would lead to an error during parsing of the MathML generated during SRE enrichment. To fix this, theTexParser
is modified to set theignore-variant
when any token node is created with a non-standardmathvariant
.The
mergeOptions()
function in the commonFontData.ts
, which is used to merge font-extension information into an existing font, was not working properly, so this PR fixes how the merge is handled: it now modifies a named property of the font instance rather than using arrays, which never worked, and I don't know what I was thinking, as that makes no sense. The uses ofmergeOptions
are updated accordingly.Finally, the SVG version of
FontData.ts
is modified to add acacheIds
property to the data for font extensions in SVG fonts, as these are needed to name the font caches for any new variants that the extension adds.All this will allow a custom IEEE Euler font extension that stores the needed characters in separate variants, like in their v2 extension.