Skip to content

Commit 53f681a

Browse files
authored
Merge pull request #98 from mathjax/better-bbox
Scale bboox in drawBBox if the element is scaled.
2 parents 0f857a3 + 94a3a74 commit 53f681a

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

mathjax3-ts/output/chtml/Wrapper.ts

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -653,24 +653,32 @@ export class CHTMLWrapper<N, T, D> extends AbstractWrapper<MmlNode, CHTMLWrapper
653653
*/
654654

655655
public drawBBox() {
656-
const bbox = this.getBBox();
656+
let {w, h, d, R} = this.getBBox();
657657
const box = this.html('mjx-box', {style: {
658-
opacity: .25, 'margin-left': this.em(-bbox.w - bbox.R)
658+
opacity: .25, 'margin-left': this.em(-w - R)
659659
}}, [
660660
this.html('mjx-box', {style: {
661-
height: this.em(bbox.h),
662-
width: this.em(bbox.w),
661+
height: this.em(h),
662+
width: this.em(w),
663663
'background-color': 'red'
664664
}}),
665665
this.html('mjx-box', {style: {
666-
height: this.em(bbox.d),
667-
width: this.em(bbox.w),
668-
'margin-left': this.em(-bbox.w),
669-
'vertical-align': this.em(-bbox.d),
666+
height: this.em(d),
667+
width: this.em(w),
668+
'margin-left': this.em(-w),
669+
'vertical-align': this.em(-d),
670670
'background-color': 'green'
671671
}})
672672
] as N[]);
673673
const node = this.chtml || this.parent.chtml;
674+
const size = this.adaptor.getAttribute(node, 'size');
675+
if (size) {
676+
this.adaptor.setAttribute(box, 'size', size);
677+
}
678+
const fontsize = this.adaptor.getStyle(node, 'fontSize');
679+
if (fontsize) {
680+
this.adaptor.setStyle(box, 'fontSize', fontsize);
681+
}
674682
this.adaptor.append(this.adaptor.parent(node), box);
675683
this.adaptor.setStyle(node, 'backgroundColor', '#FFEE00');
676684
}

0 commit comments

Comments
 (0)