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
mathvariantvalues inMmlNode).Currently, the
ignore-variantproperty is used to determine whether a node's non-standardmathvariantshould produce an error message when used in MathML input, and non-standard variants can be specified using thedata-mjx-variantattribute. The presence of that attribute sets theignore-variantproperly when a MathML element is created by the MathML input jax, and the serialization of the node viaMmlVisitorand its subclasses would add thedata-mjx-variantattribute whenignore-variantis set.In this PR, the
MmlVisitoris modified to remove themathvariantwhenignore-variantis set (anddata-mjx-variantis 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-variantproperty would need to be added by hand. If the parser'sstack.env.fontis 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, theTexParseris modified to set theignore-variantwhen 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 ofmergeOptionsare updated accordingly.Finally, the SVG version of
FontData.tsis modified to add acacheIdsproperty 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.