Make final math size be in relative units so that it prints even if print media has a different font size. Resolves issue #386.

This commit is contained in:
Davide P. Cervone 2013-04-17 17:21:09 -04:00
parent c4da088220
commit debc24047f
4 changed files with 20 additions and 4 deletions

View File

@ -24,7 +24,7 @@
MathJax.OutputJax["HTML-CSS"] = MathJax.OutputJax({
id: "HTML-CSS",
version: "2.1.1",
version: "2.1.2",
directory: MathJax.OutputJax.directory + "/HTML-CSS",
extensionDir: MathJax.OutputJax.extensionDir + "/HTML-CSS",
autoloadDir: MathJax.OutputJax.directory + "/HTML-CSS/autoload",

View File

@ -2621,7 +2621,14 @@
math = HTMLCSS.Measured(html,box);
}
HTMLCSS.placeBox(box,0,0);
stack.style.width = Math.round(HTMLCSS.unEm(stack.style.width)*this.em)+"px"; // get width right if minimum font size is set
//
// Get width right if minimum font size is set:
// Round to nearest pixel (plus a small amount), and convert back to outer-em's.
// Add the width to the span (outside the MathJax class, so uses outer em size,
// which makes it work even when minimum font size is in effect).
//
span.style.width = HTMLCSS.Em((Math.round(math.bbox.w*this.em)+.25)/HTMLCSS.outerEm);
span.style.display = "inline-block"; stack.style.width = "";
//
// Adjust bbox to match outer em-size
//

View File

@ -24,7 +24,7 @@
MathJax.OutputJax.NativeMML = MathJax.OutputJax({
id: "NativeMML",
version: "2.1",
version: "2.1.1",
directory: MathJax.OutputJax.directory + "/NativeMML",
extensionDir: MathJax.OutputJax.extensionDir + "/NativeMML",

View File

@ -69,6 +69,7 @@
}
},
settings: HUB.config.menuSettings,
ex: 1, // filled in later
Config: function () {
this.SUPER(arguments).Config.call(this);
@ -205,6 +206,7 @@
if (ex === 0 || ex === "NaN") {ex = this.defaultEx; mex = this.defaultMEx}
scale = (mex > 1 ? ex/mex : 1) * this.config.scale;
scale = Math.floor(Math.max(this.config.minScaleAdjust/100,scale));
jax.NativeMML.ex = ex;
} else {scale = 100}
jax.NativeMML.fontSize = scale+"%";
}
@ -232,6 +234,7 @@
var span = document.getElementById(jax.inputID+"-Frame"),
container = span.firstChild, mspan = container.firstChild;
span.style.fontSize = jax.NativeMML.fontSize;
this.ex = jax.NativeMML.ex || this.defaultEx;
//
// Convert to MathML (if restarted, remove any partial math)
//
@ -615,7 +618,13 @@
// parent element to match. Even if we set the <math> width properly,
// it doesn't seem to propagate up to the <span> correctly.
//
if (nMML.widthBug) {parent.style.width = math.firstChild.scrollWidth+"px"}
if (nMML.widthBug) {
//
// Convert size to ex's so that it scales properly if the print media
// has a different font size.
//
parent.style.width = (math.firstChild.scrollWidth/nMML.ex).toFixed(3) + "ex";
}
}
});