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

Closed
opened this issue May 6, 2013 · 6 comments

Projects
None yet
3 participants

### nageh 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.
Author

### nageh 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]
Member

### pkra commented May 6, 2013

 Thanks for reporting it here, too.
Member

### dpvc commented Feb 9, 2014

 When mtextFontInherit is in effect, this asks that the font of the surrounding text should be used for all  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

 Add \texttt and \textsf macros, and make them work with mtextFontInhe… 
…rit. Resolves issue mathjax#459.
 bcceb08 
Member

### dpvc 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

 Merge branch 'issue459' into develop. Issue mathjax#459. 
 ed624f3 

Member

### dpvc commented Feb 10, 2014

 => Merged.

Closed

Member

### dpvc commented Apr 21, 2014

 => In Test Suite. LaTeXToMathML/mathvariant/textsf-1.html LaTeXToMathML/mathvariant/texttt-1.html