Fix problems with linebreaks in fractions (scaling of lineleading, proper detection of auto indentalign, etc.)

This commit is contained in:
Davide P. Cervone 2014-04-21 18:16:31 -04:00
parent 521e6c9fda
commit cb04ee618c
3 changed files with 20 additions and 16 deletions

View File

@ -90,6 +90,7 @@ MathJax.Hub.Register.StartupHook("HTML-CSS Jax Ready",function () {
//
this.HTMLremoveColor(span);
var stack = HTMLCSS.createStack(span);
this.HTMLgetScale();
var state = {
n: 0, Y: 0,
scale: this.scale || 1,
@ -219,7 +220,7 @@ MathJax.Hub.Register.StartupHook("HTML-CSS Jax Ready",function () {
//
if (state.n > 0) {
var LHD = HTMLCSS.FONTDATA.baselineskip * state.scale;
var leading = (state.values.lineleading == null ? state.VALUES : state.values).lineleading;
var leading = (state.values.lineleading == null ? state.VALUES : state.values).lineleading * state.scale;
state.Y -= Math.max(LHD,state.d + line.bbox.h + leading);
}
//
@ -252,7 +253,7 @@ MathJax.Hub.Register.StartupHook("HTML-CSS Jax Ready",function () {
else if (state.isLast) {shift = prev.indentshiftlast || def.indentshiftlast}
else {shift = prev.indentshift || def.indentshift}
if (shift === MML.INDENTSHIFT.INDENTSHIFT) {shift = prev.indentshift || def.indentshift}
if (shift === MML.INDENTSHIFT.AUTO || shift === "") {shift = (state.isTSop ? this.displayIndent : "0")}
if (shift === "auto" || shift === "") {shift = (state.isTSop ? this.displayIndent : "0")}
return HTMLCSS.length2em(shift,0);
},

View File

@ -222,7 +222,7 @@ MathJax.Hub.Register.StartupHook("SVG Jax Ready",function () {
//
if (state.n > 0) {
var LHD = SVG.FONTDATA.baselineskip * state.scale;
var leading = (state.values.lineleading == null ? state.VALUES : state.values).lineleading;
var leading = (state.values.lineleading == null ? state.VALUES : state.values).lineleading * state.scale;
state.Y -= Math.max(LHD,state.d + line.h + leading);
}
//
@ -255,7 +255,7 @@ MathJax.Hub.Register.StartupHook("SVG Jax Ready",function () {
else if (state.isLast) {shift = prev.indentshiftlast || def.indentshiftlast}
else {shift = prev.indentshift || def.indentshift}
if (shift === MML.INDENTSHIFT.INDENTSHIFT) {shift = prev.indentshift || def.indentshift}
if (shift === MML.INDENTSHIFT.AUTO || shift === "") {shift = (state.isTSop ? this.displayIndent : "0")}
if (shift === "auto" || shift === "") {shift = (state.isTSop ? this.displayIndent : "0")}
return SVG.length2em(shift,0);
},

View File

@ -1286,18 +1286,21 @@
},
SVGgetScale: function (svg) {
if (this.mscale) {return this.scale * this.mscale}
var scale = 1,
values = this.getValues("mathsize","scriptlevel","fontsize");
if ((this.styles||{}).fontSize && !values.fontsize) {values.fontsize = this.styles.fontSize}
if (values.fontsize && !this.mathsize) {values.mathsize = values.fontsize}
if (values.scriptlevel !== 0) {
if (values.scriptlevel > 2) {values.scriptlevel = 2}
scale = Math.pow(this.Get("scriptsizemultiplier"),values.scriptlevel);
values.scriptminsize = SVG.length2em(this.Get("scriptminsize"))/1000;
if (scale < values.scriptminsize) {scale = values.scriptminsize}
}
this.scale = scale; this.mscale = SVG.length2em(values.mathsize)/1000;
var scale = 1;
if (this.mscale) {
scale = this.scale;
} else {
var values = this.getValues("mathsize","scriptlevel","fontsize");
if ((this.styles||{}).fontSize && !values.fontsize) {values.fontsize = this.styles.fontSize}
if (values.fontsize && !this.mathsize) {values.mathsize = values.fontsize}
if (values.scriptlevel !== 0) {
if (values.scriptlevel > 2) {values.scriptlevel = 2}
scale = Math.pow(this.Get("scriptsizemultiplier"),values.scriptlevel);
values.scriptminsize = SVG.length2em(this.Get("scriptminsize"))/1000;
if (scale < values.scriptminsize) {scale = values.scriptminsize}
}
this.scale = scale; this.mscale = SVG.length2em(values.mathsize)/1000;
}
if (svg) {svg.scale = scale; if (this.isToken) {svg.scale *= this.mscale}}
return scale * this.mscale;
},