Allow mtext to be typeset in the surrounding text font rather than MathJax fonts, provided the mtextFontInherit flag is set to true in the HTML-CSS block of the configuration (resolves issue #21, and should improve issues #19 and #40)

This commit is contained in:
Davide P. Cervone 2011-09-22 00:14:19 -04:00
parent 030b1fc294
commit d15a820a0e
6 changed files with 35 additions and 24 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -505,7 +505,7 @@
// Set the font metrics // Set the font metrics
// //
this.em = MML.mbase.prototype.em = jax.HTMLCSS.em * jax.HTMLCSS.scale; this.em = MML.mbase.prototype.em = jax.HTMLCSS.em * jax.HTMLCSS.scale;
this.outerEm = jax.HTMLCSS.em; this.outerEm = jax.HTMLCSS.em; this.scale = jax.HTMLCSS.scale;
span.style.fontSize = jax.HTMLCSS.fontSize; span.style.fontSize = jax.HTMLCSS.fontSize;
this.getLinebreakWidth(div); this.getLinebreakWidth(div);
// //
@ -1759,12 +1759,28 @@
MML.chars.Augment({ MML.chars.Augment({
toHTML: function (span,variant) { toHTML: function (span,variant) {
this.HTMLhandleVariant(span,variant,this.data.join("").replace(/[\u2061-\u2064]/g,"")); // remove invisibles var text = this.data.join("").replace(/[\u2061-\u2064]/g,""); // remove invisibles
if (!variant) {
var scale = Math.floor(100/HTMLCSS.scale+.5) + "%";
HTMLCSS.addElement(span,"span",{style:{"font-size":scale}},[text]);
var HD = HTMLCSS.getHD(span), W = HTMLCSS.getW(span);
span.bbox = {h:HD.h, d:HD.d, w:W, lw:0, rw:W, exactW: true};
} else {
this.HTMLhandleVariant(span,variant,text);
}
} }
}); });
MML.entity.Augment({ MML.entity.Augment({
toHTML: function (span,variant) { toHTML: function (span,variant) {
this.HTMLhandleVariant(span,variant,this.toString().replace(/[\u2061-\u2064]/g,"")); // remove invisibles var text = this.toString().replace(/[\u2061-\u2064]/g,""); // remove invisibles
if (!variant) {
var scale = Math.floor(100/HTMLCSS.scale+.5) + "%";
HTMLCSS.addElement(span,"span",{style:{"font-size":scale}},[text]);
var HD = HTMLCSS.getHD(span), W = HTMLCSS.getW(span);
span.bbox = {h:HD.h, d:HD.d, w:W, lw:0, rw:W, exactW: true};
} else {
this.HTMLhandleVariant(span,variant,text);
}
} }
}); });
@ -1880,22 +1896,17 @@
MML.mtext.Augment({ MML.mtext.Augment({
toHTML: function (span) { toHTML: function (span) {
span = this.HTMLhandleSize(this.HTMLcreateSpan(span)); span.bbox = null; span = this.HTMLhandleSize(this.HTMLcreateSpan(span));
if (this.Parent().type === "merror") { var variant = this.HTMLgetVariant();
// Avoid setting the font style for error text // Avoid setting the font style for error text or if mtextFontInherit is set
HTMLCSS.addText(span,this.data.join("")); if (HTMLCSS.config.mtextFontInherit || this.Parent().type === "merror") {variant = null}
var HD = HTMLCSS.getHD(span), W = HTMLCSS.getW(span); for (var i = 0, m = this.data.length; i < m; i++)
span.bbox = {h: HD.h, d: HD.d, w: W, lw: 0, rw: W}; {if (this.data[i]) {this.data[i].toHTML(span,variant)}}
} else { if (!span.bbox) {span.bbox = {w:0, h:0, d:0, rw:0, lw:0}}
var variant = this.HTMLgetVariant(); if (this.data.join("").length !== 1) {delete span.bbox.skew}
for (var i = 0, m = this.data.length; i < m; i++) this.HTMLhandleSpace(span);
{if (this.data[i]) {this.data[i].toHTML(span,variant)}} this.HTMLhandleColor(span);
if (!span.bbox) {span.bbox = {w:0, h:0, d:0, rw:0, lw:0}} return span;
if (this.data.join("").length !== 1) {delete span.bbox.skew}
}
this.HTMLhandleSpace(span);
this.HTMLhandleColor(span);
return span;
} }
}); });