commit 3b8ab2e5c1da0758bae110a9d783a7d6c35e1d32
parent 0c77e8c880ad141914d8e7508573d6ab59849efa
Author: Davide P. Cervone <dpvc@union.edu>
Date: Sun, 11 Oct 2015 18:57:38 -0400
Round em's to nearest pixel to avoid WebKit alignment issues. Resolves issue #1283.
Diffstat:
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/unpacked/jax/output/CommonHTML/jax.js b/unpacked/jax/output/CommonHTML/jax.js
@@ -972,8 +972,8 @@
if (list.length) this.addCharList(node.firstChild,list,bbox);
bbox.clean();
if (bbox.d < 0) {bbox.D = bbox.d; bbox.d = 0}
- if (bbox.h - bbox.a) node.firstChild.style[bbox.h - bbox.a < 0 ? "marginTop" : "paddingTop"] = this.Em(bbox.h-bbox.a);
- if (bbox.d > -bbox.b) node.firstChild.style.paddingBottom = this.Em(bbox.d+bbox.b);
+ if (bbox.h - bbox.a) node.firstChild.style[bbox.h - bbox.a < 0 ? "marginTop" : "paddingTop"] = this.EmRounded(bbox.h-bbox.a);
+ if (bbox.d > -bbox.b) node.firstChild.style.paddingBottom = this.EmRounded(bbox.d+bbox.b);
return bbox;
},
@@ -1196,6 +1196,11 @@
if (Math.abs(m) < .001) return "0";
return (m.toFixed(3).replace(/\.?0+$/,""))+"em";
},
+ EmRounded: function (m) {
+ m = (Math.round(m*CHTML.em)+.05)/CHTML.em;
+ if (Math.abs(m) < .0006) {return "0em"}
+ return m.toFixed(3).replace(/\.?0+$/,"") + "em";
+ },
unEm: function (m) {
return parseFloat(m);
},