@@ -29,7 +29,10 @@ import {MmlNode} from '../core/MmlTree/MmlNode.js';
2929import { HTMLNodes } from '../util/HTMLNodes.js' ;
3030import { CHTMLWrapper } from './chtml/Wrapper.js' ;
3131import { CHTMLWrapperFactory } from './chtml/WrapperFactory.js' ;
32+ import { FontData } from './chtml/FontData.js' ;
33+ import { TeXFont } from './chtml/fonts/tex.js' ;
3234import { percent } from '../util/lengths.js' ;
35+ import { BBox } from './chtml/BBox.js' ;
3336
3437/*****************************************************************/
3538/*
@@ -43,14 +46,16 @@ export class CHTML extends AbstractOutputJax {
4346 ...AbstractOutputJax . OPTIONS ,
4447 scale : 1 , // Global scaling factor for all expressions
4548 skipAttributes : { } , // RFDa and other attributes NOT to copy to CHTML output
46- CHTMLWrapperFactory : null // The CHTMLWrapper factory to use
49+ CHTMLWrapperFactory : null , // The CHTMLWrapper factory to use
50+ font : null // The FontData object to use
4751 } ;
4852
4953 /*
50- * Used to store the HTMLNodes factory and the CHTMLWraper factory.
54+ * Used to store the HTMLNodes factory, the CHTMLWraper factory, and FontData object .
5155 */
5256 public nodes : HTMLNodes ;
5357 public factory : CHTMLWrapperFactory ;
58+ public font : FontData ;
5459
5560 /*
5661 * The MathDocument for the math we find
@@ -78,6 +83,7 @@ export class CHTML extends AbstractOutputJax {
7883 this . factory = this . options . CHTMLWrapperFactory || new CHTMLWrapperFactory ( ) ;
7984 this . factory . chtml = this ;
8085 this . nodes = new HTMLNodes ( ) ;
86+ this . font = this . options . font || new TeXFont ( ) ;
8187 }
8288
8389 /*
@@ -105,6 +111,21 @@ export class CHTML extends AbstractOutputJax {
105111 return node ;
106112 }
107113
114+ /*
115+ * @param {MathItem } math The MathItem to get the bounding box for
116+ * @param {MathDocument } html The MathDocument for the math
117+ */
118+ public getBBox ( math : MathItem , html : MathDocument ) {
119+ this . document = html ;
120+ this . math = math ;
121+ this . nodes . document = html . document ;
122+ math . root . setTeXclass ( null ) ;
123+ this . nodeMap = new Map < MmlNode , CHTMLWrapper > ( ) ;
124+ let bbox = this . factory . wrap ( math . root ) . getBBox ( ) ;
125+ this . nodeMap = null ;
126+ return bbox ;
127+ }
128+
108129 /*
109130 * @override
110131 */
0 commit comments