@@ -215,7 +215,7 @@ CommonOutputJax<N, T, D, CHTMLWrapper<N, T, D>, CHTMLWrapperFactory<N, T, D>, CH
215215 /**
216216 * @override
217217 */
218- public unknownText ( text : string , variant : string ) {
218+ public unknownText ( text : string , variant : string , width : number = null ) {
219219 const styles : StyleList = { } ;
220220 const scale = 100 / this . math . metrics . scale ;
221221 if ( scale !== 100 ) {
@@ -228,6 +228,16 @@ CommonOutputJax<N, T, D, CHTMLWrapper<N, T, D>, CHTMLWrapperFactory<N, T, D>, CH
228228 this . cssFontStyles ( this . font . getCssFont ( variant ) , styles ) ;
229229 }
230230 }
231+ //
232+ // Work around Safari bug with the MJXZERO font by forcing the width.
233+ // (If MJXZERO can be made to work with Safari, then remove width parameter
234+ // and call to getBBox().w in TextNode.ts)
235+ //
236+ if ( width !== null ) {
237+ const metrics = this . math . metrics ;
238+ styles . width = Math . round ( width * metrics . em * metrics . scale ) + 'px' ;
239+ }
240+ //
231241 return this . html ( 'mjx-utext' , { variant : variant , style : styles } , [ this . text ( text ) ] ) ;
232242 }
233243
@@ -238,11 +248,16 @@ CommonOutputJax<N, T, D, CHTMLWrapper<N, T, D>, CHTMLWrapperFactory<N, T, D>, CH
238248 * @override
239249 */
240250
241- public measureTextNode ( text : N ) {
251+ public measureTextNode ( textNode : N ) {
242252 const adaptor = this . adaptor ;
243- text = adaptor . clone ( text ) ;
253+ const text = adaptor . clone ( textNode ) ;
254+ //
255+ // Work arround Safari bug with the MJXZERO font.
256+ //
257+ adaptor . setStyle ( text , 'font-family' , adaptor . getStyle ( text , 'font-family' ) . replace ( / M J X Z E R O , / g, '' ) ) ;
258+ //
244259 const style = { position : 'absolute' , 'white-space' : 'nowrap' } ;
245- const node = this . html ( 'mjx-measure-text' , { style} , [ text ] ) ;
260+ const node = this . html ( 'mjx-measure-text' , { style} , [ text ] ) ;
246261 adaptor . append ( adaptor . parent ( this . math . start . node ) , this . container ) ;
247262 adaptor . append ( this . container , node ) ;
248263 let w = adaptor . nodeSize ( text , this . math . metrics . em ) [ 0 ] / this . math . metrics . scale ;
0 commit comments