From 35ca30ef4c53e73a7f0ecb4056a4f773e56cbbb9 Mon Sep 17 00:00:00 2001 From: "Davide P. Cervone" Date: Tue, 3 May 2016 21:15:55 -0400 Subject: [PATCH 1/2] Make sure 0 remains 0 when rounding to pixels (plus a bit). Resolves issue #1452. --- unpacked/jax/output/HTML-CSS/jax.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/unpacked/jax/output/HTML-CSS/jax.js b/unpacked/jax/output/HTML-CSS/jax.js index eeb1db78c..45f1ad8ef 100644 --- a/unpacked/jax/output/HTML-CSS/jax.js +++ b/unpacked/jax/output/HTML-CSS/jax.js @@ -1007,8 +1007,8 @@ return m.toFixed(3).replace(/\.?0+$/,"") + "em"; }, EmRounded: function (m) { - m = (Math.round(m*HTMLCSS.em)+.05)/HTMLCSS.em; if (Math.abs(m) < .0006) {return "0em"} + m = (Math.round(m*HTMLCSS.em)+.05)/HTMLCSS.em; return m.toFixed(3).replace(/\.?0+$/,"") + "em"; }, unEm: function (m) { @@ -2937,7 +2937,9 @@ // 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.max(0,Math.round(math.bbox.w*this.em)+.25)/HTMLCSS.outerEm); + var W = math.bbox.w; + if (Math.abs(W) < .006) W = 0; else W = Math.max(0,Math.round(W*this.em)+.25); + span.style.width = HTMLCSS.EmRounded(W/HTMLCSS.outerEm); span.style.display = "inline-block"; // // Adjust bbox to match outer em-size From 19b813a4a7cc8d93b3837f7e8de934a62988c890 Mon Sep 17 00:00:00 2001 From: "Davide P. Cervone" Date: Wed, 11 May 2016 20:48:29 -0400 Subject: [PATCH 2/2] Make Volker's suggested change. Issue #1452. --- unpacked/jax/output/HTML-CSS/jax.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/unpacked/jax/output/HTML-CSS/jax.js b/unpacked/jax/output/HTML-CSS/jax.js index 45f1ad8ef..10f38fb54 100644 --- a/unpacked/jax/output/HTML-CSS/jax.js +++ b/unpacked/jax/output/HTML-CSS/jax.js @@ -2938,7 +2938,7 @@ // which makes it work even when minimum font size is in effect). // var W = math.bbox.w; - if (Math.abs(W) < .006) W = 0; else W = Math.max(0,Math.round(W*this.em)+.25); + W = Math.abs(W) < .006 ? 0 : Math.max(0,Math.round(W*this.em)+.25); span.style.width = HTMLCSS.EmRounded(W/HTMLCSS.outerEm); span.style.display = "inline-block"; //