Fix vertical stretchy characters to use multiple extenders rather than CSS transform. Issue #1326
This commit is contained in:
parent
3cdcd73b01
commit
49003fe4ac
|
@ -34,6 +34,7 @@
|
||||||
var EVENT, TOUCH, HOVER; // filled in later
|
var EVENT, TOUCH, HOVER; // filled in later
|
||||||
|
|
||||||
var STRUTHEIGHT = 1,
|
var STRUTHEIGHT = 1,
|
||||||
|
EFUZZ = .1, // overlap needed for stretchy delimiters
|
||||||
HFUZZ = .025, DFUZZ = .025; // adjustments to bounding box of character boxes
|
HFUZZ = .025, DFUZZ = .025; // adjustments to bounding box of character boxes
|
||||||
|
|
||||||
var STYLES = {
|
var STYLES = {
|
||||||
|
@ -665,6 +666,9 @@
|
||||||
pxPerInch: 96,
|
pxPerInch: 96,
|
||||||
em: 16,
|
em: 16,
|
||||||
|
|
||||||
|
maxStretchyParts: 1000, // limit the number of parts allowed for
|
||||||
|
// stretchy operators. See issue 366.
|
||||||
|
|
||||||
FONTDEF: {},
|
FONTDEF: {},
|
||||||
TEXDEF: {
|
TEXDEF: {
|
||||||
x_height: .442,
|
x_height: .442,
|
||||||
|
@ -1009,11 +1013,11 @@
|
||||||
},
|
},
|
||||||
extendDelimiterV: function (node,H,delim,BBOX,font) {
|
extendDelimiterV: function (node,H,delim,BBOX,font) {
|
||||||
node = CHTML.addElement(node,"mjx-delim-v"); var tmp = CHTML.Element("span");
|
node = CHTML.addElement(node,"mjx-delim-v"); var tmp = CHTML.Element("span");
|
||||||
var top, bot, mid, ext, tbox, bbox, mbox, ebox, k = 1;
|
var top, bot, mid, ext, tbox, bbox, mbox, ebox, k = 1, c;
|
||||||
tbox = this.createChar(tmp,(delim.top||delim.ext),1,font); top = tmp.removeChild(tmp.firstChild);
|
tbox = this.createChar(tmp,(delim.top||delim.ext),1,font); top = tmp.removeChild(tmp.firstChild);
|
||||||
bbox = this.createChar(tmp,(delim.bot||delim.ext),1,font); bot = tmp.removeChild(tmp.firstChild);
|
bbox = this.createChar(tmp,(delim.bot||delim.ext),1,font); bot = tmp.removeChild(tmp.firstChild);
|
||||||
mbox = ebox = CHTML.BBOX.zero();
|
mbox = ebox = CHTML.BBOX.zero();
|
||||||
var h = tbox.h + tbox.d + bbox.h + bbox.d;
|
var h = tbox.h + tbox.d + bbox.h + bbox.d - EFUZZ;
|
||||||
node.appendChild(top);
|
node.appendChild(top);
|
||||||
if (delim.mid) {
|
if (delim.mid) {
|
||||||
mbox = this.createChar(tmp,delim.mid,1,font); mid = tmp.removeChild(tmp.firstChild);
|
mbox = this.createChar(tmp,delim.mid,1,font); mid = tmp.removeChild(tmp.firstChild);
|
||||||
|
@ -1022,30 +1026,27 @@
|
||||||
if (delim.min && H < h*delim.min) H = h*delim.min;
|
if (delim.min && H < h*delim.min) H = h*delim.min;
|
||||||
if (H > h) {
|
if (H > h) {
|
||||||
ebox = this.createChar(tmp,delim.ext,1,font); ext = tmp.removeChild(tmp.firstChild);
|
ebox = this.createChar(tmp,delim.ext,1,font); ext = tmp.removeChild(tmp.firstChild);
|
||||||
if (delim.fullExtenders) {
|
var eH = ebox.h + ebox.d, eh = eH - EFUZZ, n, N;
|
||||||
var n = Math.ceil((H-h)/(k*(ebox.h+ebox.d)*.9));
|
N = n = Math.min(Math.ceil((H-h)/(k*eh)),this.maxStretchyParts);
|
||||||
H = .9*n*k*(ebox.h+ebox.d) + h;
|
if (delim.fullExtenders) H = n*k*eh + h; else eh = (H-h)/(k*n);
|
||||||
}
|
c = ebox.d+ebox.a-eH/2; // for centering of extenders
|
||||||
var s = 1.1*(H - h)/k + .3; // space to cover by extender
|
ext.style.margin = ext.style.padding = "";
|
||||||
s /= (ebox.h+ebox.d); // scale factor;
|
ext.style.lineHeight = CHTML.Em(eh);
|
||||||
this.Transform(ext,
|
ext.style.marginBottom = CHTML.Em(c-EFUZZ/2/k);
|
||||||
"translateY("+CHTML.Em(-ebox.d+.25-s*ebox.a)+") scaleY("+s.toFixed(3).replace(/0+$/,"")+")",
|
ext.style.marginTop = CHTML.Em(-c-EFUZZ/2/k);
|
||||||
"left "+CHTML.Em(ebox.d)
|
var TEXT = ext.textContent, text = "\n"+TEXT;
|
||||||
);
|
while (--n > 0) TEXT += text;
|
||||||
ext.style.paddingTop=ext.style.paddingBottom = 0;
|
ext.firstChild.textContent = TEXT;
|
||||||
top.style.marginBottom = CHTML.Em((H-h)/k);
|
|
||||||
node.appendChild(ext);
|
node.appendChild(ext);
|
||||||
if (delim.mid) {
|
if (delim.mid) {
|
||||||
node.appendChild(mid);
|
node.appendChild(mid);
|
||||||
mid.style.marginBottom = top.style.marginBottom;
|
|
||||||
node.appendChild(ext.cloneNode(true));
|
node.appendChild(ext.cloneNode(true));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
H = h - .25; top.style.marginBottom = "-.25em";
|
c = (H-h-EFUZZ) / k;
|
||||||
if (delim.mid) {
|
top.style.marginBottom = CHTML.Em(c+parseFloat(top.style.marginBottom||"0"));
|
||||||
node.appendChild(mid);
|
if (delim.mid) node.appendChild(mid);
|
||||||
mid.style.marginBottom = "-.3em"; H -= .1;
|
bot.style.marginTop = CHTML.Em(c+parseFloat(bot.style.marginTop||"0"));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
node.appendChild(bot);
|
node.appendChild(bot);
|
||||||
var vbox = CHTML.BBOX({
|
var vbox = CHTML.BBOX({
|
||||||
|
|
Loading…
Reference in New Issue
Block a user