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

missing support for \textsf and \texttt when mtextInheritFont is being used #459

Closed
nageh opened this issue May 6, 2013 · 6 comments

Comments

Projects
None yet
3 participants
@nageh
Copy link

commented May 6, 2013

As per my comment at https://bugzilla.wikimedia.org/show_bug.cgi?id=35186:

"As for \textsf and \texttt, these commands are correctly being defined but are missing styling support in the HTML/CSS output jax when mtextFontInherit is being enabled.

This is fixed by amending the source with matches for "monospace" and
"sans-serif" font variants. In explanation, you'll find code statements like

if(!j.weight&&j.mathvariant.match(/bold/)){j.weight="bold"}

Replicate these for the other font variants."

I assume these changes should go to the official MathJax sources as well rather than just to my WP script.

@nageh

This comment has been minimized.

Copy link
Author

commented May 6, 2013

PS: \textsf and \textt are being defined as
textsf: ['Macro','\mathord{\sf{\text{#1}}}',1],
texttt: ['Macro','\mathord{\tt{\text{#1}}}',1]

@pkra

This comment has been minimized.

Copy link
Member

commented May 6, 2013

Thanks for reporting it here, too.

@dpvc

This comment has been minimized.

Copy link
Member

commented Feb 9, 2014

When mtextFontInherit is in effect, this asks that the font of the surrounding text should be used for all <mtext> elements. Since bold and italics are weights and styles for a given font, it makes sense to apply those to the inherited font; but I'm not sure what it means to apply "sans-serif" or "monospace" to the surrounding font. These are usually considered separate fonts, and so it would not be inheriting the surrounding font.

It would be possible to apply font-family:sans-serif and font-family:monospace I suppose, but these may not fit the surrounding font well. I guess the page author could use CSS to style .MathJax span[font-family="sans-serif"] and .MathJax span[font-family="monospace"] to provide control over the fonts used, at least for HTML output. SVG would have to be handled separately.

In any case, the position in the code where you suggest the change is not the correct place. The variant returned by HTMLgetVariant() is not used when mtextFontInherit is true (except to determine the bold and italic properties).

dpvc pushed a commit to dpvc/MathJax that referenced this issue Feb 9, 2014

@dpvc

This comment has been minimized.

Copy link
Member

commented Feb 9, 2014

It looks like the CSS selectors give above don't work, since the [attr=value] selectors are for element attributes, not style properties. So I reworked the approach to apply a class to the mtext when mathvariant is monospace or one of the sans-serif forms. This class is styled with font-family: monospace or font-family:sans-serif, but that can be overridden by the page author by setting

"HTML-CSS": {
  styles: {
    ".MathJax .MJX-monospace": {"font-family": "(some-font-name)"}
  }
}
SVG: {
  styles: {
    ".MathJax_SVG .MJX-monospace": {"font-family": "(some-font-name)"}
  }
}

in the MathJax configuration. Similarly for .MJX-sans-serif.

dpvc pushed a commit to dpvc/MathJax that referenced this issue Feb 10, 2014

@dpvc dpvc added Merged and removed Ready for Review labels Feb 10, 2014

@dpvc

This comment has been minimized.

Copy link
Member

commented Feb 10, 2014

=> Merged.

@dpvc

This comment has been minimized.

Copy link
Member

commented Apr 21, 2014

=> In Test Suite.

LaTeXToMathML/mathvariant/textsf-1.html
LaTeXToMathML/mathvariant/texttt-1.html

@dpvc dpvc added v2.4 and removed Merged labels Jun 30, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.