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

Mathvariant fixes #2292

Merged
merged 10 commits into from
Jan 5, 2024
Merged

Mathvariant fixes #2292

merged 10 commits into from
Jan 5, 2024

Conversation

brucemiller
Copy link
Owner

@brucemiller brucemiller commented Dec 31, 2023

First step, clean up erroneous, missing and/or redundant font declarations which lead to erroneous or redundant mathvariant declarations in the MathML. Typically happens when the appropriate font is not propagated while synthesizing symbols.

Then add classes, like ltx_mathvariant_italic, for cases where the mathvariant cannot be handled by remapping the Unicode.

Fixes #2021
Fixes #2051

@brucemiller brucemiller changed the title [WiP] Mathvariant fixes Mathvariant fixes Jan 3, 2024
@brucemiller brucemiller requested a review from dginev January 3, 2024 02:47
@@ -729,15 +731,18 @@ sub stylizeContent {
$class = ($class ? $class . ' ' : '') . 'ltx_font_oldstyle'; }
elsif ($font =~ /smallcaps/) {
$class = ($class ? $class . ' ' : '') . 'ltx_font_smallcaps'; }
elsif ($variant) { # Any left-over mathvariant? Punt to CSS
$class = ($class ? $class . ' ' : '') . 'ltx_mathvariant_' . $variant; }
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should this check also unset $variant = undef; after it is moved to a class value?

As it is, I see that one of the tests has both a class and mathvariant attribute, as in:

<mtext class="ltx_mathvariant_italic" mathvariant="italic">

But in MathML Core the only prescribed use of mathvariant is for the normal value. So the class addition should suffice. That was my suggestion in #2051 (comment)

Copy link
Owner Author

Choose a reason for hiding this comment

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

Right, well as I understood the original issue, and the implications of the (eventually) linked mozilla issue, it was that Core will ignore (most) mathvariants, and that Full may ignore it, and that CSS could be used as a fallback. Moreover, that browsers should be able to cope with there being both CSS and mathvariant.

Keeping the mathvariant at least records for MathML-Full agents which don't support CSS that the token was (apparently) intended to belong to a certain semantic class. Removing it seems somehow wrong, even though in the current scheme of things it is likely always to be ignored (but harmless?)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Since it is ignored in practice, keeping it until there is some actual issue caused by it is likely harmless, as you say. And indeed it is a MathML Full use.

I've heard rumors of hypothetical MathML Full agents without CSS support, but I wonder if/when we'll have some to test with...

Linking the current MathML Core text on mathvariant just in case:

The mathvariant attribute, if present, must be an ASCII case-insensitive match of normal.


No further comments on the PR, looks good to merge.

@brucemiller
Copy link
Owner Author

Following offline discussions, simplified the m:mtext (gets CSS, but not mathvariant), and avoid visual styling of formatting codepoints such as invisible-times. @dginev please take another peak if all looks OK.

if ((defined $u_text) && ($u_text ne '')) { # didn't remap the text ? Keep text & variant
$text = $u_text;
$variant = ($plane1hack && ($variant ne $u_variant) && ($variant =~ /^bold/)
? 'bold' : undef); } # Possibly keep variant bold
# Use class (css) to patchup some weak translations
if (!$font) { }
if ($text =~ /^\p{Format}*$/) { # Formatting (eg. InvisibleTImes)
Copy link
Collaborator

Choose a reason for hiding this comment

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

this regex is a little odd - does it mean starting with \p{Format} or empty? If so, you can replace the *$ with ?

Copy link
Owner Author

Choose a reason for hiding this comment

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

I clarified the comment; should mean that the text contains only formatting characters, or is empty.

Copy link
Collaborator

@dginev dginev left a comment

Choose a reason for hiding this comment

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

Cool! Good to merge.

Tiny regex quibble, but it's just a minor performance-related note.

@brucemiller brucemiller merged commit 3b56185 into master Jan 5, 2024
26 checks passed
@brucemiller brucemiller deleted the mathvariant-fixes branch January 5, 2024 20:08
@dginev dginev mentioned this pull request Feb 23, 2024
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.

[MathML] remove reliance on mathvariant Unneeded mathsize in munder for large operators?
2 participants