From 9ed49e85e4108f729553c860465dc6a58085f319 Mon Sep 17 00:00:00 2001 From: "Davide P. Cervone" Date: Tue, 10 Mar 2015 13:38:23 -0400 Subject: [PATCH 1/7] Alter fonts to make ascent=descent so that line-height:0 makes its axis along the baseline. That should simplify things (though it may make unknown characters harder to handle -- we'll see). --- .../output/CommonHTML/fonts/TeX/fontdata.js | 18 ------------------ unpacked/jax/output/CommonHTML/jax.js | 13 +++---------- 2 files changed, 3 insertions(+), 28 deletions(-) diff --git a/unpacked/jax/output/CommonHTML/fonts/TeX/fontdata.js b/unpacked/jax/output/CommonHTML/fonts/TeX/fontdata.js index c253ea12f..59261b9c9 100644 --- a/unpacked/jax/output/CommonHTML/fonts/TeX/fontdata.js +++ b/unpacked/jax/output/CommonHTML/fonts/TeX/fontdata.js @@ -586,8 +586,6 @@ CHTML.FONTDATA.FONTS['MathJax_Caligraphic'] = { directory: 'Caligraphic/Regular', - ascent: .789, - descent: .216, skew: { 0x41: 0.194, 0x42: 0.139, @@ -659,8 +657,6 @@ CHTML.FONTDATA.FONTS['MathJax_Main-bold'] = { directory: 'Main/Bold', weight: 'bold', - ascent: .951, - descent: .267, skew: { 0x131: 0.0319, 0x237: 0.0958, @@ -797,8 +793,6 @@ CHTML.FONTDATA.FONTS['MathJax_Main-italic'] = { directory: 'Main/Italic', style: 'italic', - ascent: .750, - descent: .250, Ranges: [ [0xA0,0xFF,"Latin1Supplement"], [0x300,0x36F,"CombDiacritMarks"], @@ -910,8 +904,6 @@ CHTML.FONTDATA.FONTS['MathJax_Main'] = { directory: 'Main/Regular', - ascent: .900, - descent: .272, skew: { 0x131: 0.0278, 0x237: 0.0833, @@ -1192,8 +1184,6 @@ CHTML.FONTDATA.FONTS['MathJax_Math-italic'] = { directory: 'Math/Italic', style: 'italic', - ascent: .717, - descent: .218, skew: { 0x41: 0.139, 0x42: 0.0833, @@ -1372,8 +1362,6 @@ CHTML.FONTDATA.FONTS['MathJax_Size1'] = { directory: 'Size1/Regular', - ascent: .850, - descent: .350, 0x20: [0,0,250,0,0], // SPACE 0x28: [850,349,458,152,422], // LEFT PARENTHESIS 0x29: [850,349,458,35,305], // RIGHT PARENTHESIS @@ -1423,8 +1411,6 @@ CHTML.FONTDATA.FONTS['MathJax_Size2'] = { directory: 'Size2/Regular', - ascent: 1.360, - descent: .862, 0x20: [0,0,250,0,0], // SPACE 0x28: [1150,649,597,180,561], // LEFT PARENTHESIS 0x29: [1150,649,597,35,416], // RIGHT PARENTHESIS @@ -1466,8 +1452,6 @@ CHTML.FONTDATA.FONTS['MathJax_Size3'] = { directory: 'Size3/Regular', - ascent: 1.450, - descent: .950, 0x20: [0,0,250,0,0], // SPACE 0x28: [1450,949,736,209,701], // LEFT PARENTHESIS 0x29: [1450,949,736,34,526], // RIGHT PARENTHESIS @@ -1493,8 +1477,6 @@ CHTML.FONTDATA.FONTS['MathJax_Size4'] = { directory: 'Size4/Regular', - ascent: 1.750, - descent: 1.250, 0x20: [0,0,250,0,0], // SPACE 0x28: [1750,1249,792,237,758], // LEFT PARENTHESIS 0x29: [1750,1249,792,33,554], // RIGHT PARENTHESIS diff --git a/unpacked/jax/output/CommonHTML/jax.js b/unpacked/jax/output/CommonHTML/jax.js index 98bc81540..b128efc5f 100644 --- a/unpacked/jax/output/CommonHTML/jax.js +++ b/unpacked/jax/output/CommonHTML/jax.js @@ -34,8 +34,7 @@ var EVENT, TOUCH, HOVER; // filled in later var SCRIPTFACTOR = Math.sqrt(1/2), - AXISHEIGHT = .25, - HFUZZ = .05, DFUZZ = 0; // adjustments to bounding box of character boxes + AXISHEIGHT = .25; var STYLES = { ".MathJax_CHTML_Display": { @@ -558,14 +557,8 @@ } this.addCharList(node.firstChild,list,bbox); this.cleanBBox(bbox); - bbox.h += HFUZZ; bbox.d += DFUZZ; - bbox.t += HFUZZ; bbox.b += DFUZZ; - var a = (bbox.H-bbox.D)/2; // center of font (line-height:0) - if (a < bbox.h) {node.firstChild.style.paddingTop = this.Em(bbox.h-a)} - else {node.firstChild.style.marginTop = this.Em(bbox.h-a)} - // ### FIXME: Safari doesn't center, so clip bbox.d at 0 and adjust later? - if (bbox.d+1 > 0) {node.firstChild.style.paddingBottom = this.Em(bbox.d+a)} - else {node.firstChild.style.marginBottom = this.Em(bbox.d+a)} + node.firstChild.style.paddingTop = this.Em(bbox.h); + node.firstChild.style.paddingBottom = this.Em(bbox.d); return bbox; }, From d878d3add209b10790e3de7c4c3f0603d53bdaa7 Mon Sep 17 00:00:00 2001 From: "Davide P. Cervone" Date: Tue, 10 Mar 2015 16:00:42 -0400 Subject: [PATCH 2/7] Don't need bbox.H and bbox.D now that ascent and descent are equal (so center is baseline). --- unpacked/jax/output/CommonHTML/jax.js | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/unpacked/jax/output/CommonHTML/jax.js b/unpacked/jax/output/CommonHTML/jax.js index b128efc5f..31a098fbc 100644 --- a/unpacked/jax/output/CommonHTML/jax.js +++ b/unpacked/jax/output/CommonHTML/jax.js @@ -529,8 +529,6 @@ if (bbox.l > bbox.w+C[3]) bbox.l = bbox.w+C[3]; if (bbox.r < bbox.w+C[4]) bbox.r = bbox.w+C[4]; bbox.w += C[2]; - if (bbox.H < font.ascent) bbox.H = font.ascent; - if (bbox.D < font.descent) bbox.D = font.descent; if (m == 1 && font.skew && font.skew[item.n]) bbox.skew = font.skew[item.n]; } } @@ -613,10 +611,9 @@ } var s = 1.1*(H - h)/k + .2*k; // space to cover by extender s /= (ebox.h+ebox.d); // scale factor; - var a = (ebox.H-ebox.D)/2; // center of font this.Transform(ext, - "translateY("+CHTML.Em(-(a+ebox.d)+.05)+") scaleY("+s.toFixed(3).replace(/0+$/,"")+")", - "left "+CHTML.Em(a+ebox.d) + "translateY("+CHTML.Em(-ebox.d+.05)+") scaleY("+s.toFixed(3).replace(/0+$/,"")+")", + "left "+CHTML.Em(ebox.d) ); ext.style.paddingTop=ext.style.paddingBottom = 0; top.style.marginBottom = CHTML.Em((H-h)/k); @@ -663,12 +660,11 @@ } if (delim.min && W < w*delim.min) W = w*delim.min; right.style.marginLeft = CHTML.Em((W-w-rbox.l)/k); - BBOX.w = BBOX.r = W; BBOX.H = lbox.H; BBOX.D = lbox.D; + BBOX.w = BBOX.r = W; if (W > w) { ebox = this.createChar(tmp,delim.rep,scale,font); ext = tmp.removeChild(tmp.firstChild); if (ebox.h > BBOX.h) BBOX.h = ebox.h; if (ebox.d < BBOX.d) BBOX.d = ebox.d; - BBOX.H = ebox.H; BBOX.D = ebox.D; var s = (W - w)/k + .2; // space to cover by extender s /= (ebox.r - ebox.l); // scale factor this.Transform(ext, @@ -792,11 +788,11 @@ /********************************************************/ zeroBBox: function () { - return {h:0, d:0, w:0, l:0, r:0, D:0, H:0, t:0, b:0}; + return {h:0, d:0, w:0, l:0, r:0, t:0, b:0}; }, emptyBBox: function () { return {h:-BIGDIMEN, d:-BIGDIMEN, w:0, l:BIGDIMEN, r:-BIGDIMEN, - D:-BIGDIMEN, H:-BIGDIMEN, t:-BIGDIMEN, b:-BIGDIMEN}; + t:-BIGDIMEN, b:-BIGDIMEN}; }, cleanBBox: function (bbox) { if (bbox.h === -BIGDIMEN) bbox.h = 0; @@ -805,8 +801,6 @@ if (bbox.r === -BIGDIMEN) bbox.r = 0; if (bbox.t === -BIGDIMEN) bbox.t = 0; if (bbox.b === -BIGDIMEN) bbox.b = 0; - if (bbox.H === -BIGDIMEN) bbox.H = .8; - if (bbox.D === -BIGDIMEN) bbox.D = .2; }, scaleBBox: function (bbox,level,dlevel) { var scale = Math.pow(SCRIPTFACTOR,Math.min(2,level)-(dlevel||0)); From a6f9e65af3c6aa4db2da09720cf397774c4153da Mon Sep 17 00:00:00 2001 From: "Davide P. Cervone" Date: Tue, 10 Mar 2015 19:08:32 -0400 Subject: [PATCH 3/7] Simplify mfrac layout. (Don't try to force the division line to be on the baseline so that it is always raised to the correct place by a vertical align of .25em; instead, just shift the whole stack appropriately. This may cause misalignment if we can't measure the parts exactly, however, but should speed things up a bit.) --- unpacked/jax/output/CommonHTML/jax.js | 50 +++++++++++---------------- 1 file changed, 20 insertions(+), 30 deletions(-) diff --git a/unpacked/jax/output/CommonHTML/jax.js b/unpacked/jax/output/CommonHTML/jax.js index 31a098fbc..dface4c11 100644 --- a/unpacked/jax/output/CommonHTML/jax.js +++ b/unpacked/jax/output/CommonHTML/jax.js @@ -34,7 +34,8 @@ var EVENT, TOUCH, HOVER; // filled in later var SCRIPTFACTOR = Math.sqrt(1/2), - AXISHEIGHT = .25; + AXISHEIGHT = .25, + HFUZZ = .05, DFUZZ = 0; // adjustments to bounding box of character boxes var STYLES = { ".MathJax_CHTML_Display": { @@ -52,11 +53,8 @@ }, "mjx-math *": {display:"inline-block", "text-align":"left"}, - "mjx-mfrac": {"vertical-align":".25em"}, - "mjx-fbox": {width:"100%"}, - "mjx-ftable": {display:"table", width:"100%"}, - "mjx-numerator": {display:"table-cell", "text-align":"center"}, - "mjx-denominator": {display:"table-cell", "text-align":"center"}, + "mjx-numerator": {display:"block", "text-align":"center"}, + "mjx-denominator": {display:"block", "text-align":"center"}, ".MJXc-fpad": {"padding-left":".1em", "padding-right":".1em"}, "mjx-stack": {display:"inline-block"}, @@ -555,8 +553,9 @@ } this.addCharList(node.firstChild,list,bbox); this.cleanBBox(bbox); - node.firstChild.style.paddingTop = this.Em(bbox.h); - node.firstChild.style.paddingBottom = this.Em(bbox.d); + bbox.h += HFUZZ; bbox.d += DFUZZ; bbox.t += HFUZZ; bbox.b += DFUZZ; + node.firstChild.style[bbox.h < 0 ? "marginTop" : "paddingTop"] = this.Em(bbox.h); + node.firstChild.style[bbox.d < 0 ? "marginBottom": "paddingBottom"] = this.Em(bbox.d); return bbox; }, @@ -911,7 +910,7 @@ if (this.inferred) return node; if (!this.CHTMLnodeID) {this.CHTMLnodeID = CHTML.GetID()}; var id = (this.id || "MJXc-Node-"+this.CHTMLnodeID); - return HTML.addElement(node,"mjx-"+this.type,{className:"MJXc-"+this.type, id:id}); + return HTML.addElement(node,"mjx-"+this.type,{id:id}); }, CHTMLnodeElement: function () { if (!this.CHTMLnodeID) {return null} @@ -1580,7 +1579,7 @@ toCommonHTML: function (node) { node = this.CHTMLdefaultNode(node,{ childNodes:["mjx-numerator","mjx-denominator"], - forceChild:true, noBBox:true + forceChild:true, noBBox:true, childCount:2 }); var values = this.getValues("linethickness","displaystyle","scriptlevel", "numalign","denomalign","bevelled"); @@ -1597,15 +1596,11 @@ // // Create the table for the fraction and set the alignment // - var frac = HTML.addElement(node,"mjx-itable",{},[ - ["mjx-row",{},[["mjx-fbox",{},[["mjx-ftable",{},[["mjx-row"]]]]]]], - ["mjx-row"] - ]); - var num = frac.firstChild.firstChild.firstChild.firstChild, denom = frac.lastChild; - num.appendChild(node.firstChild); - denom.appendChild(node.firstChild); - if (values.numalign !== "center") num.firstChild.style.textAlign = values.numalign; - if (values.denomalign !== "center") denom.firstChild.style.textAlign = values.denomalign; + var num = node.firstChild, denom = node.lastChild; + var frac = HTML.addElement(node,"mjx-box"); + frac.appendChild(num); frac.appendChild(denom); node.appendChild(frac); + if (values.numalign !== "center") num.style.textAlign = values.numalign; + if (values.denomalign !== "center") denom.style.textAlign = values.denomalign; // // Get the bounding boxes for the parts, and determine the placement // of the numerator and denominator @@ -1625,15 +1620,10 @@ t = Math.max(t,mt); q = (u - nbox.d*sscale) - (a + t/2); if (q < p) u += (p - q); q = (a - t/2) - (dbox.h*sscale - v); if (q < p) v += (p - q); - node.style.verticalAlign = CHTML.Em(a-t/2); - // - // Add the rule to the table - // - var rule = HTML.Element("mjx-row",{},[["mjx-cell",{},[["mjx-line"]]]]); - num.parentNode.appendChild(rule); rule = rule.firstChild.firstChild; - rule.style.borderTop = CHTML.Em(t)+" solid"; - num.firstChild.className += " MJXc-fpad"; nbox.L = nbox.R = .1; - denom.firstChild.className += " MJXc-fpad"; dbox.L = dbox.R = .1; + frac.style.verticalAlign = CHTML.Em(t/2-v); + num.style.borderBottom = CHTML.Em(t)+" solid"; + num.className += " MJXc-fpad"; nbox.L = nbox.R = .1; + denom.className += " MJXc-fpad"; dbox.L = dbox.R = .1; } // // Determine the new bounding box and place the parts @@ -1643,8 +1633,8 @@ CHTML.combineBBoxes(this.CHTML,dbox,0,-v,sscale); CHTML.cleanBBox(this.CHTML); u -= sscale*nbox.d + a + t/2; v -= sscale*dbox.h - a + t/2; - if (u > 0) num.firstChild.style.paddingBottom = CHTML.Em(u); - if (v > 0) denom.firstChild.style.paddingTop = CHTML.Em(v); + if (u > 0) num.style.paddingBottom = CHTML.Em(u); + if (v > 0) denom.style.paddingTop = CHTML.Em(v); // // Add nulldelimiterspace around the fraction // (TeXBook pg 150 and Appendix G rule 15e) From fdb10e64c4fb9c08934ff675d690983485839df6 Mon Sep 17 00:00:00 2001 From: "Davide P. Cervone" Date: Tue, 10 Mar 2015 19:39:09 -0400 Subject: [PATCH 4/7] Rework radicals to match TeX results better for nested radicals (spacing is critical, since the stretchy parts are designed to add up properly with the algorithm). --- unpacked/jax/output/CommonHTML/jax.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/unpacked/jax/output/CommonHTML/jax.js b/unpacked/jax/output/CommonHTML/jax.js index dface4c11..8d1738f1c 100644 --- a/unpacked/jax/output/CommonHTML/jax.js +++ b/unpacked/jax/output/CommonHTML/jax.js @@ -73,7 +73,7 @@ "vertical-align":"top" }, - "mjx-surd": {"vertical-align":"top!important"}, + "mjx-surd": {"vertical-align":"top"}, "mjx-mphantom": {visibility:"hidden"}, @@ -1659,19 +1659,18 @@ var base = node.firstChild; var sqrt = HTML.addElement(node,"mjx-box"); sqrt.appendChild(base); var bbox = this.CHTMLbboxFor(0), BBOX = this.CHTML = CHTML.emptyBBox(); - var t = CHTML.TEX.surd_height, p = CHTML.TEX.rule_thickness, q, H; + var t = CHTML.TEX.rule_thickness, T = CHTML.TEX.surd_height, p = t, q, H; if (this.Get("displaystyle")) p = CHTML.TEX.x_height; q = t + p/4; H = bbox.h + bbox.d + q + t; var surd = HTML.Element("mjx-surd"); sqrt.insertBefore(surd,base); - var sbox = CHTML.createDelimiter(surd,0x221A,H,1); + var sbox = CHTML.createDelimiter(surd,0x221A,[H-.04,H],1); if (sbox.h + sbox.d > H) q = ((sbox.h+sbox.d) - (H-t))/2; H = bbox.h + q + t; var x = this.CHTMLaddRoot(node,sbox,sbox.h+sbox.d-H); - surd.style.verticalAlign = CHTML.Em(H-sbox.h); base.style.paddingTop = CHTML.Em(q); - base.style.borderTop = CHTML.Em(t)+" solid"; - sqrt.style.paddingTop = CHTML.Em(t); + base.style.borderTop = CHTML.Em(T)+" solid"; + sqrt.style.paddingTop = CHTML.Em(2*t-T); // use wider line, but don't affect height bbox.h += q + 2*t; CHTML.combineBBoxes(BBOX,sbox,x,H-sbox.h,1); CHTML.combineBBoxes(BBOX,bbox,x+sbox.w,0,1); From 1968831dd026683c4d282d0dc091da1873b62580 Mon Sep 17 00:00:00 2001 From: "Davide P. Cervone" Date: Tue, 10 Mar 2015 19:47:27 -0400 Subject: [PATCH 5/7] Use correct offset for \atop and friends --- unpacked/jax/output/CommonHTML/jax.js | 1 + 1 file changed, 1 insertion(+) diff --git a/unpacked/jax/output/CommonHTML/jax.js b/unpacked/jax/output/CommonHTML/jax.js index 8d1738f1c..e04896bfd 100644 --- a/unpacked/jax/output/CommonHTML/jax.js +++ b/unpacked/jax/output/CommonHTML/jax.js @@ -1615,6 +1615,7 @@ p = Math.max((isDisplay ? 7 : 3) * CHTML.TEX.rule_thickness, 2*mt); // force to at least 2 px q = (u - nbox.d*sscale) - (dbox.h*sscale - v); if (q < p) {u += (p - q)/2; v += (p - q)/2} + frac.style.verticalAlign = CHTML.Em(-v); } else { // \over p = Math.max((isDisplay ? 3 : 0) * t, mt); // force to be at least 1px t = Math.max(t,mt); From 117f29096df30b4195db4d6f8d5dc62965e4aa7b Mon Sep 17 00:00:00 2001 From: "Davide P. Cervone" Date: Tue, 10 Mar 2015 19:54:28 -0400 Subject: [PATCH 6/7] Fix wrong property name --- unpacked/jax/output/CommonHTML/jax.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/unpacked/jax/output/CommonHTML/jax.js b/unpacked/jax/output/CommonHTML/jax.js index e04896bfd..16cedaac9 100644 --- a/unpacked/jax/output/CommonHTML/jax.js +++ b/unpacked/jax/output/CommonHTML/jax.js @@ -1579,7 +1579,7 @@ toCommonHTML: function (node) { node = this.CHTMLdefaultNode(node,{ childNodes:["mjx-numerator","mjx-denominator"], - forceChild:true, noBBox:true, childCount:2 + forceChild:true, noBBox:true, minChildren:2 }); var values = this.getValues("linethickness","displaystyle","scriptlevel", "numalign","denomalign","bevelled"); From 59c9f45592c8e53e3354e9037c0f3bf2408de5f5 Mon Sep 17 00:00:00 2001 From: "Davide P. Cervone" Date: Tue, 10 Mar 2015 20:17:33 -0400 Subject: [PATCH 7/7] Fix some spacing, and a few minor formatting issues. --- unpacked/jax/output/CommonHTML/jax.js | 66 ++++++++++++--------------- 1 file changed, 30 insertions(+), 36 deletions(-) diff --git a/unpacked/jax/output/CommonHTML/jax.js b/unpacked/jax/output/CommonHTML/jax.js index 16cedaac9..60ba91c8f 100644 --- a/unpacked/jax/output/CommonHTML/jax.js +++ b/unpacked/jax/output/CommonHTML/jax.js @@ -1150,29 +1150,29 @@ if (H != values.minsize) {H = [Math.max(H*CHTML.TEX.delimiterfactor/1000,H-CHTML.TEX.delimitershortfall),H]} while (node.firstChild) node.removeChild(node.firstChild); - this.CHTML = bbox = CHTML.createDelimiter(node,this.data.join("").charCodeAt(0),H,1); + this.CHTML = bbox = CHTML.createDelimiter(node,this.data.join("").charCodeAt(0),H,1); bbox.sH = (H instanceof Array ? H[1] : H); // // Reposition as needed // - if (values.symmetric) {H = (bbox.h + bbox.d)/2 + a} - else {H = (bbox.h + bbox.d) * h/(h + d)} - H -= bbox.h; - if (Math.abs(H) > .05) { - node.style.verticalAlign = CHTML.Em(H); - bbox.h += H; bbox.d -= H; bbox.t += H; bbox.b -= H; - } + if (values.symmetric) {H = (bbox.h + bbox.d)/2 + a} + else {H = (bbox.h + bbox.d) * h/(h + d)} + H -= bbox.h; + if (Math.abs(H) > .05) { + node.style.verticalAlign = CHTML.Em(H); + bbox.h += H; bbox.d -= H; bbox.t += H; bbox.b -= H; + } } }, CHTMLstretchH: function (node,W) { var bbox = this.CHTML; - var values = this.getValues("maxsize","minsize","mathvariant","fontweight"); + var values = this.getValues("maxsize","minsize","mathvariant","fontweight"); // FIXME: should take style="font-weight:bold" into account as well - if ((values.fontweight === "bold" || parseInt(values.fontweight) >= 600) && + if ((values.fontweight === "bold" || parseInt(values.fontweight) >= 600) && !this.Get("mathvariant",true)) values.mathvariant = MML.VARIANT.BOLD; - values.maxsize = CHTML.length2em(values.maxsize,bbox.w); - values.minsize = CHTML.length2em(values.minsize,bbox.w); - W = Math.max(values.minsize,Math.min(values.maxsize,W)); + values.maxsize = CHTML.length2em(values.maxsize,bbox.w); + values.minsize = CHTML.length2em(values.minsize,bbox.w); + W = Math.max(values.minsize,Math.min(values.maxsize,W)); if (W !== bbox.sW) { while (node.firstChild) node.removeChild(node.firstChild); this.CHTML = bbox = CHTML.createDelimiter(node,this.data.join("").charCodeAt(0),W,1,values.mathvariant); @@ -1298,14 +1298,9 @@ // var stack = base, delta = 0; if (bbox.ic) {delta = 1.3*bbox.ic + .05} // make faked IC be closer to expeted results - if (this.data[this.over]) { - stack = this.CHTMLaddOverscript(over,boxes,values,delta,base); - } - if (this.data[this.under]) { - this.CHTMLaddUnderscript(under,boxes,values,delta,node,stack); - } else { - node.appendChild(stack); - } + if (this.data[this.over]) stack = this.CHTMLaddOverscript(over,boxes,values,delta,base); + if (this.data[this.under]) this.CHTMLaddUnderscript(under,boxes,values,delta,node,stack); + else node.appendChild(stack); // // Handle horizontal positions // @@ -1373,7 +1368,7 @@ // var stack = HTML.Element("mjx-stack"); stack.appendChild(over); stack.appendChild(base); - if (obox.d < 0 || obox.h < .25) { + if (obox.d < 0) { // // For negative depths, set the height and align to top // in order to avoid extra baseline space @@ -1421,7 +1416,7 @@ ]); node.firstChild.firstChild.firstChild.appendChild(stack); node.firstChild.lastChild.appendChild(under); - if (ubox.d < 0 || ubox.h < .25) { + if (ubox.d < 0) { // // For negative depths, set the height and align to top // in order to avoid extra baseline space @@ -1448,7 +1443,6 @@ }, // // Center boxes horizontally, taking offsets into account - // ### FIXME: handle BBOX.l and BBOX.r // CHTMLplaceBoxes: function (base,under,over,values,boxes) { var W = this.CHTML.w, i, m = boxes.length; @@ -1660,14 +1654,14 @@ var base = node.firstChild; var sqrt = HTML.addElement(node,"mjx-box"); sqrt.appendChild(base); var bbox = this.CHTMLbboxFor(0), BBOX = this.CHTML = CHTML.emptyBBox(); - var t = CHTML.TEX.rule_thickness, T = CHTML.TEX.surd_height, p = t, q, H; - if (this.Get("displaystyle")) p = CHTML.TEX.x_height; + var t = CHTML.TEX.rule_thickness, T = CHTML.TEX.surd_height, p = t, q, H; + if (this.Get("displaystyle")) p = CHTML.TEX.x_height; q = t + p/4; - H = bbox.h + bbox.d + q + t; + H = bbox.h + bbox.d + q + t; var surd = HTML.Element("mjx-surd"); sqrt.insertBefore(surd,base); var sbox = CHTML.createDelimiter(surd,0x221A,[H-.04,H],1); - if (sbox.h + sbox.d > H) q = ((sbox.h+sbox.d) - (H-t))/2; - H = bbox.h + q + t; + if (sbox.h + sbox.d > H) q = ((sbox.h+sbox.d) - (H-t))/2; + H = bbox.h + q + t; var x = this.CHTMLaddRoot(node,sbox,sbox.h+sbox.d-H); base.style.paddingTop = CHTML.Em(q); base.style.borderTop = CHTML.Em(T)+" solid"; @@ -1675,7 +1669,7 @@ bbox.h += q + 2*t; CHTML.combineBBoxes(BBOX,sbox,x,H-sbox.h,1); CHTML.combineBBoxes(BBOX,bbox,x+sbox.w,0,1); - return node; + return node; }, CHTMLaddRoot: function () {return 0} }); @@ -1686,24 +1680,24 @@ toCommonHTML: MML.msqrt.prototype.toCommonHTML, CHTMLaddRoot: function (sqrt,sbox,d) { if (!this.data[1]) return; - var BBOX = this.CHTML, bbox = this.data[1].CHTML, + var BBOX = this.CHTML, bbox = this.data[1].CHTML, root = sqrt.firstChild; var dlevel = Math.min(2,this.Get("scriptlevel")), level = Math.min(2,this.data[1].Get("scriptlevel")); scale = Math.pow(SCRIPTFACTOR,level-dlevel); if (scale !== 1) this.data[1].CHTMLhandleScriptlevel(root,dlevel); - var h = this.CHTMLrootHeight(bbox,sbox,scale)-d; - var w = Math.min(bbox.w,bbox.r); // remove extra right-hand padding, if any - var dx = Math.max(w,sbox.offset/scale); + var h = this.CHTMLrootHeight(bbox,sbox,scale)-d; + var w = Math.min(bbox.w,bbox.r); // remove extra right-hand padding, if any + var dx = Math.max(w,sbox.offset/scale); if (h) root.style.verticalAlign = CHTML.Em(h/scale); if (dx > w) root.firstChild.style.paddingLeft = CHTML.Em(dx-w); dx -= sbox.offset/scale; root.style.width = CHTML.Em(dx); CHTML.combineBBoxes(BBOX,bbox,0,h,scale); - return dx*scale; + return dx*scale; }, CHTMLrootHeight: function (bbox,sbox,scale) { - return .45*(sbox.h+sbox.d-.9)+sbox.offset + Math.max(0,bbox.d-.075); + return .45*(sbox.h+sbox.d-.9)+sbox.offset + Math.max(0,bbox.d-.075); } });