Skip to content

Commit

Permalink
Fix issues with munderover/msubsup when base is scaled via mstyle. (m…
Browse files Browse the repository at this point in the history
  • Loading branch information
dpvc committed Mar 16, 2020
1 parent 2d7045b commit cdf76ed
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 13 deletions.
2 changes: 1 addition & 1 deletion ts/output/chtml/Wrappers/msubsup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ CommonMsubsupMixin<CHTMLWrapper<any, any, any>, Constructor<CHTMLscriptbase<any,
sub.toCHTML(stack);
const corebox = this.baseCore.bbox;
if (corebox.ic) {
this.adaptor.setStyle(sup.chtml, 'marginLeft', this.em(this.coreIC() / sup.bbox.rscale));
this.adaptor.setStyle(sup.chtml, 'marginLeft', this.em(this.coreIC() * base.bbox.rscale / sup.bbox.rscale));
}
}

Expand Down
8 changes: 4 additions & 4 deletions ts/output/common/Wrappers/msubsup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@ export function CommonMsupMixin<W extends AnyWrapper,
* @override
*/
public getOffset(bbox: BBox, sbox: BBox) {
const x = (this.baseCore.bbox.ic ? .2 * this.baseCore.bbox.ic + .05 : 0);
return [x, this.getU(bbox, sbox)];
const x = (this.baseCore.bbox.ic ? .05 * this.baseCore.bbox.ic + .05 : 0);
return [x * bbox.rscale, this.getU(bbox, sbox)];
}

};
Expand Down Expand Up @@ -207,7 +207,7 @@ export function CommonMsubsupMixin<W extends AnyWrapper,
const w = bbox.w;
const [u, v, q] = this.getUVQ(basebox, subbox, supbox);
bbox.combine(subbox, w, v);
bbox.combine(supbox, w + this.coreIC(), u);
bbox.combine(supbox, w + this.coreIC() * basebox.rscale, u);
bbox.w += this.font.params.scriptspace;
bbox.clean();
this.setChildPWidths(recompute);
Expand All @@ -226,7 +226,7 @@ export function CommonMsubsupMixin<W extends AnyWrapper,
const tex = this.font.params;
const t = 3 * tex.rule_thickness;
const subscriptshift = this.length2em(this.node.attributes.get('subscriptshift'), tex.sub2);
const drop = (this.isCharBase() ? 0 : basebox.d + tex.sub_drop * subbox.rscale);
const drop = (this.isCharBase() ? 0 : basebox.d * basebox.rscale + tex.sub_drop * subbox.rscale);
//
// u and v are the veritcal shifts of the scripts, initially set to minimum values and then adjusted
//
Expand Down
11 changes: 6 additions & 5 deletions ts/output/common/Wrappers/scriptbase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -248,15 +248,16 @@ export function CommonScriptbaseMixin<W extends AnyWrapper,
*/
public coreIC() {
const corebox = this.baseCore.getBBox();
return (corebox.ic ? 1.2 * corebox.ic + .05 : 0);
return (corebox.ic ? 1.05 * corebox.ic + .05 : 0);
}

/**
* @return {boolean} True if the base is an mi, mn, or mo (not a largeop) consisting of a single character
*/
public isCharBase() {
let base = this.baseChild;
if ((base.node.isKind('mstyle') || base.node.isKind('mrow')) && base.childNodes.length === 1) {
while ((base.node.isKind('mstyle') || base.node.isKind('mrow')) &&
base.bbox.rscale === 1 && base.childNodes.length === 1) {
base = base.childNodes[0];
}
return ((base.node.isKind('mo') || base.node.isKind('mi') || base.node.isKind('mn')) &&
Expand Down Expand Up @@ -291,7 +292,7 @@ export function CommonScriptbaseMixin<W extends AnyWrapper,
const tex = this.font.params;
const subscriptshift = this.length2em(this.node.attributes.get('subscriptshift'), tex.sub1);
return Math.max(
this.isCharBase() ? 0 : bbox.d + tex.sub_drop * sbox.rscale,
this.isCharBase() ? 0 : bbox.d * bbox.rscale + tex.sub_drop * sbox.rscale,
subscriptshift,
sbox.h * sbox.rscale - (4/5) * tex.x_height
);
Expand All @@ -310,7 +311,7 @@ export function CommonScriptbaseMixin<W extends AnyWrapper,
const p = (attr.displaystyle ? tex.sup1 : attr.texprimestyle ? tex.sup3 : tex.sup2);
const superscriptshift = this.length2em(attr.superscriptshift, p);
return Math.max(
this.isCharBase() ? 0 : bbox.h - tex.sup_drop * sbox.rscale,
this.isCharBase() ? 0 : bbox.h * bbox.rscale - tex.sup_drop * sbox.rscale,
superscriptshift,
sbox.d * sbox.rscale + (1/4) * tex.x_height
);
Expand Down Expand Up @@ -397,7 +398,7 @@ export function CommonScriptbaseMixin<W extends AnyWrapper,
public getDelta(noskew: boolean = false) {
const accent = this.node.attributes.get('accent');
const ddelta = (accent && !noskew ? this.baseChild.coreMO().bbox.sk : 0);
return DELTA * this.baseCore.bbox.ic / 2 + ddelta;
return (DELTA * this.baseCore.bbox.ic / 2 + ddelta) * this.baseChild.bbox.rscale;
}

/**
Expand Down
4 changes: 2 additions & 2 deletions ts/output/svg/Wrappers/msubsup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ CommonMsubsupMixin<SVGWrapper<any, any, any>, Constructor<SVGscriptbase<any, any
sup.toSVG(svg);
sub.toSVG(svg);

sub.place(bbox.w, v);
sup.place(bbox.w + this.coreIC(), u);
sub.place(bbox.w * bbox.rscale, v);
sup.place((bbox.w + this.coreIC()) * bbox.rscale, u);
}

}
2 changes: 1 addition & 1 deletion ts/output/svg/Wrappers/scriptbase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ CommonScriptbaseMixin<SVGWrapper<any, any, any>, SVGConstructor<any, any, any>>(
const [x, v] = this.getOffset(bbox, sbox);
this.baseChild.toSVG(svg);
this.script.toSVG(svg);
this.script.place(bbox.w + x, v);
this.script.place(bbox.w * bbox.rscale + x, v);
}

}

0 comments on commit cdf76ed

Please sign in to comment.