diff --git a/ts/output/chtml/Wrappers/mroot.ts b/ts/output/chtml/Wrappers/mroot.ts
index 864743360..4325e280c 100644
--- a/ts/output/chtml/Wrappers/mroot.ts
+++ b/ts/output/chtml/Wrappers/mroot.ts
@@ -42,9 +42,9 @@ export class CHTMLmroot extends CommonMrootMixin(CHTM
/**
* @override
*/
- protected addRoot(ROOT: N, root: CHTMLWrapper, sbox: BBox) {
+ protected addRoot(ROOT: N, root: CHTMLWrapper, sbox: BBox, H: number) {
root.toCHTML(ROOT);
- const [x, h, dx] = this.getRootDimens(sbox);
+ const [x, h, dx] = this.getRootDimens(sbox, H);
const bbox = root.getBBox();
this.adaptor.setStyle(ROOT, 'verticalAlign', this.em(h));
this.adaptor.setStyle(ROOT, 'width', this.em(x));
diff --git a/ts/output/chtml/Wrappers/msqrt.ts b/ts/output/chtml/Wrappers/msqrt.ts
index 5c079383d..acf6b7f5b 100644
--- a/ts/output/chtml/Wrappers/msqrt.ts
+++ b/ts/output/chtml/Wrappers/msqrt.ts
@@ -74,6 +74,8 @@ export class CHTMLmsqrt extends CommonMsqrtMixin extends CommonMsqrtMixin extends CommonMsqrtMixin, sbox: BBox) {
+ protected addRoot(ROOT: N, root: CHTMLWrapper, sbox: BBox, H: number) {
}
}
diff --git a/ts/output/common/Wrappers/mroot.ts b/ts/output/common/Wrappers/mroot.ts
index 321bf7956..2befeae32 100644
--- a/ts/output/common/Wrappers/mroot.ts
+++ b/ts/output/common/Wrappers/mroot.ts
@@ -66,23 +66,23 @@ export function CommonMrootMixin(Base: T): MrootCons
/**
* @override
*/
- public combineRootBBox(BBOX: BBox, sbox: BBox) {
+ public combineRootBBox(BBOX: BBox, sbox: BBox, H: number) {
const bbox = this.childNodes[this.root].getBBox();
- const [x, h] = this.getRootDimens(sbox);
+ const [x, h] = this.getRootDimens(sbox, H);
BBOX.combine(bbox, 0, h);
}
/**
* @override
*/
- public getRootDimens(sbox: BBox) {
+ public getRootDimens(sbox: BBox, H: number) {
const surd = this.childNodes[this.surd] as CommonMo;
const bbox = this.childNodes[this.root].getBBox();
const offset = (surd.size < 0 ? .5 : .6) * sbox.w;
const {w, rscale} = bbox;
const W = Math.max(w, offset / rscale);
const dx = Math.max(0, W - w);
- const h = this.rootHeight(bbox, sbox, surd.size);
+ const h = this.rootHeight(bbox, sbox, surd.size, H);
const x = W * rscale - offset;
return [x, h, dx];
}
@@ -91,11 +91,12 @@ export function CommonMrootMixin(Base: T): MrootCons
* @param {BBox} rbox The bbox of the root
* @param {BBox} sbox The bbox of the surd
* @param {number} size The size of the surd
+ * @param {number} H The height of the root as a whole
* @return {number} The height of the root within the surd
*/
- public rootHeight(rbox: BBox, sbox: BBox, size: number) {
- const H = sbox.h + sbox.d;
- const b = (size < 0 ? 2 + .3 * (H - 4) : .55 * H) - sbox.d;
+ public rootHeight(rbox: BBox, sbox: BBox, size: number, H: number) {
+ const h = sbox.h + sbox.d;
+ const b = (size < 0 ? 1.9 : .55 * h) - (h - H);
return b + Math.max(0, rbox.d * rbox.rscale);
}
diff --git a/ts/output/common/Wrappers/msqrt.ts b/ts/output/common/Wrappers/msqrt.ts
index 17d33faad..84d31aea2 100644
--- a/ts/output/common/Wrappers/msqrt.ts
+++ b/ts/output/common/Wrappers/msqrt.ts
@@ -56,8 +56,9 @@ export interface CommonMsqrt extends AnyWrapper {
*
* @param {BBox} bbox The bounding box so far
* @param {BBox} sbox The bounding box of the surd
+ * @param {number} H The height of the root as a whole
*/
- combineRootBBox(bbox: BBox, sbox: BBox): void;
+ combineRootBBox(bbox: BBox, sbox: BBox, H: number): void;
/**
* @param {BBox} sbox The bounding box for the surd character
@@ -67,9 +68,10 @@ export interface CommonMsqrt extends AnyWrapper {
/**
* @param {BBox} sbox The bounding box of the surd
+ * @param {number} H The height of the root as a whole
* @return {number[]} The x offset of the surd, and the height, x offset, and scale of the root
*/
- getRootDimens(sbox: BBox): number[];
+ getRootDimens(sbox: BBox, H: Number): number[];
}
@@ -145,11 +147,11 @@ export function CommonMsqrtMixin(Base: T): MsqrtCo
const surdbox = this.childNodes[this.surd].getBBox();
const basebox = new BBox(this.childNodes[this.base].getBBox());
const [p, q] = this.getPQ(surdbox);
- const [x] = this.getRootDimens(surdbox);
const t = this.font.params.rule_thickness;
const H = basebox.h + q + t;
+ const [x] = this.getRootDimens(surdbox, H);
bbox.h = H + t;
- this.combineRootBBox(bbox, surdbox);
+ this.combineRootBBox(bbox, surdbox, H);
bbox.combine(surdbox, x, H - surdbox.h);
bbox.combine(basebox, x + surdbox.w, 0);
bbox.clean();
@@ -161,8 +163,9 @@ export function CommonMsqrtMixin(Base: T): MsqrtCo
*
* @param {BBox} bbox The bounding box so far
* @param {BBox} sbox The bounding box of the surd
+ * @param {number} H The height of the root as a whole
*/
- public combineRootBBox(bbox: BBox, sbox: BBox) {
+ public combineRootBBox(bbox: BBox, sbox: BBox, H: number) {
}
/**
@@ -172,15 +175,18 @@ export function CommonMsqrtMixin(Base: T): MsqrtCo
public getPQ(sbox: BBox) {
const t = this.font.params.rule_thickness;
const p = (this.node.attributes.get('displaystyle') ? this.font.params.x_height : t);
- const q = (sbox.h + sbox.d > this.surdH ? ((sbox.h + sbox.d) - (this.surdH - 2 * t - p / 2)) / 2 : t + p / 4);
+ const q = (sbox.h + sbox.d > this.surdH ?
+ ((sbox.h + sbox.d) - (this.surdH - 2 * t - p / 2)) / 2 :
+ t + p / 4);
return [p, q];
}
/**
* @param {BBox} sbox The bounding box of the surd
+ * @param {number} H The height of the root as a whole
* @return {number[]} The x offset of the surd, and the height, x offset, and scale of the root
*/
- public getRootDimens(sbox: BBox) {
+ public getRootDimens(sbox: BBox, H: number) {
return [0, 0, 0, 0];
}
diff --git a/ts/output/svg/Wrappers/mroot.ts b/ts/output/svg/Wrappers/mroot.ts
index 8201775d3..cd1a79ad7 100644
--- a/ts/output/svg/Wrappers/mroot.ts
+++ b/ts/output/svg/Wrappers/mroot.ts
@@ -42,9 +42,9 @@ export class SVGmroot extends CommonMrootMixin, sbox: BBox) {
+ protected addRoot(ROOT: N, root: SVGWrapper, sbox: BBox, H: number) {
root.toSVG(ROOT);
- const [x, h, dx] = this.getRootDimens(sbox);
+ const [x, h, dx] = this.getRootDimens(sbox, H);
const bbox = root.getBBox();
root.place(dx * bbox.rscale, h);
this.dx = x;
diff --git a/ts/output/svg/Wrappers/msqrt.ts b/ts/output/svg/Wrappers/msqrt.ts
index 6e692e959..4a9e64a62 100644
--- a/ts/output/svg/Wrappers/msqrt.ts
+++ b/ts/output/svg/Wrappers/msqrt.ts
@@ -55,7 +55,9 @@ export class SVGmsqrt extends CommonMsqrtMixin extends CommonMsqrtMixin extends CommonMsqrtMixin, sbox: BBox) {
+ protected addRoot(ROOT: N, root: SVGWrapper, sbox: BBox, H: number) {
}
}