Skip to content
Permalink
Browse files

Add \texttt and \textsf macros, and make them work with mtextFontInhe…

…rit. Resolves issue mathjax#459.
  • Loading branch information...
dpvc committed Feb 9, 2014
1 parent 2afb801 commit bcceb085909ba22f35d18ccfd919cb508617751d
@@ -935,6 +935,8 @@
textrm: ['Macro','\\mathord{\\rm\\text{#1}}',1],
textit: ['Macro','\\mathord{\\it{\\text{#1}}}',1],
textbf: ['Macro','\\mathord{\\bf{\\text{#1}}}',1],
textsf: ['Macro','\\mathord{\\sf{\\text{#1}}}',1],
texttt: ['Macro','\\mathord{\\tt{\\text{#1}}}',1],
pmb: ['Macro','\\rlap{#1}\\kern1px{#1}',1],
TeX: ['Macro','T\\kern-.14em\\lower.5ex{E}\\kern-.115em X'],
LaTeX: ['Macro','L\\kern-.325em\\raise.21em{\\scriptstyle{A}}\\kern-.17em\\TeX'],
@@ -75,6 +75,20 @@ MathJax.OutputJax["HTML-CSS"] = MathJax.OutputJax({
"font-size": "90%"
},

//
// For mtextFontInherit version of \texttt{}
//
".MathJax .MJX-monospace": {
"font-family": "monospace"
},

//
// For mtextFontInherit version of \textsf{}
//
".MathJax .MJX-sans-serif": {
"font-family": "sans-serif"
},

"#MathJax_Tooltip": {
"background-color": "InfoBackground", color: "InfoText",
border: "1px solid black",
@@ -2170,8 +2170,12 @@
span = this.HTMLhandleSize(this.HTMLcreateSpan(span));
var variant = this.HTMLgetVariant();
// Avoid setting the font style for error text or if mtextFontInherit is set
if (HTMLCSS.config.mtextFontInherit || this.Parent().type === "merror")
{variant = {bold:variant.bold, italic:variant.italic, fontInherit: true}}
if (HTMLCSS.config.mtextFontInherit || this.Parent().type === "merror") {
var vname = this.Get("mathvariant");
if (vname === "monospace") {span.className += " MJX-monospace"}
else if (vname.match(/sans-serif/)) {span.className += " MJX-sans-serif"}
variant = {bold:variant.bold, italic:variant.italic, fontInherit: true};
}
for (var i = 0, m = this.data.length; i < m; i++)
{if (this.data[i]) {this.data[i].toHTML(span,variant)}}
if (!span.bbox) {span.bbox = this.HTMLzeroBBox()}
@@ -64,6 +64,19 @@ MathJax.OutputJax.SVG = MathJax.OutputJax({
margin: "1em 0em"
},

//
// For mtextFontInherit version of \texttt{}
//
".MathJax_SVG .MJX-monospace": {
"font-family": "monospace"
},

//
// For mtextFontInherit version of \textsf{}
//
".MathJax_SVG .MJX-sans-serif": {
"font-family": "sans-serif"
},
"#MathJax_SVG_Tooltip": {
"background-color": "InfoBackground", color: "InfoText",
border: "1px solid black",
@@ -1483,6 +1483,9 @@
var variant = this.SVGgetVariant(), def = {direction:this.Get("dir")};
if (variant.bold) {def["font-weight"] = "bold"}
if (variant.italic) {def["font-style"] = "italic"}
variant = this.Get("mathvariant");
if (variant === "monospace") {def["class"] = "MJX-monospace"}
else if (variant.match(/sans-serif/)) {def["class"] = " MJX-sans-serif"}
svg.Add(BBOX.TEXT(scale,this.data.join(""),def)); svg.Clean();
this.SVGhandleColor(svg);
this.SVGsaveData(svg);

0 comments on commit bcceb08

Please sign in to comment.
You can’t perform that action at this time.