commit debc24047f25cf546876cf8baffe914736d5af38
parent c4da088220929b63af5e36915f1225d24706df14
Author: Davide P. Cervone <dpvc@union.edu>
Date: Wed, 17 Apr 2013 17:21:09 -0400
Make final math size be in relative units so that it prints even if print media has a different font size. Resolves issue #386.
Diffstat:
4 files changed, 20 insertions(+), 4 deletions(-)
diff --git a/unpacked/jax/output/HTML-CSS/config.js b/unpacked/jax/output/HTML-CSS/config.js
@@ -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",
diff --git a/unpacked/jax/output/HTML-CSS/jax.js b/unpacked/jax/output/HTML-CSS/jax.js
@@ -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
//
diff --git a/unpacked/jax/output/NativeMML/config.js b/unpacked/jax/output/NativeMML/config.js
@@ -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",
diff --git a/unpacked/jax/output/NativeMML/jax.js b/unpacked/jax/output/NativeMML/jax.js
@@ -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";
+ }
}
});