@@ -208,7 +208,7 @@ CommonOutputJax<N, T, D, CHTMLWrapper<N, T, D>, CHTMLWrapperFactory<N, T, D>, CH
208208 /**
209209 * @override
210210 */
211- public unknownText ( text : string , variant : string ) {
211+ public unknownText ( text : string , variant : string , width : number = null ) {
212212 const styles : StyleList = { } ;
213213 const scale = 100 / this . math . metrics . scale ;
214214 if ( scale !== 100 ) {
@@ -221,6 +221,16 @@ CommonOutputJax<N, T, D, CHTMLWrapper<N, T, D>, CHTMLWrapperFactory<N, T, D>, CH
221221 this . cssFontStyles ( this . font . getCssFont ( variant ) , styles ) ;
222222 }
223223 }
224+ //
225+ // Work around Safari bug with the MJXZERO font by forcing the width.
226+ // (If MJXZERO can be made to work with Safari, then remove width parameter
227+ // and call to getBBox().w in TextNode.ts)
228+ //
229+ if ( width !== null ) {
230+ const metrics = this . math . metrics ;
231+ styles . width = Math . round ( width * metrics . em * metrics . scale ) + 'px' ;
232+ }
233+ //
224234 return this . html ( 'mjx-utext' , { variant : variant , style : styles } , [ this . text ( text ) ] ) ;
225235 }
226236
@@ -231,11 +241,16 @@ CommonOutputJax<N, T, D, CHTMLWrapper<N, T, D>, CHTMLWrapperFactory<N, T, D>, CH
231241 * @override
232242 */
233243
234- public measureTextNode ( text : N ) {
244+ public measureTextNode ( textNode : N ) {
235245 const adaptor = this . adaptor ;
236- text = adaptor . clone ( text ) ;
246+ const text = adaptor . clone ( textNode ) ;
247+ //
248+ // Work arround Safari bug with the MJXZERO font.
249+ //
250+ adaptor . setStyle ( text , 'font-family' , adaptor . getStyle ( text , 'font-family' ) . replace ( / M J X Z E R O , / g, '' ) ) ;
251+ //
237252 const style = { position : 'absolute' , 'white-space' : 'nowrap' } ;
238- const node = this . html ( 'mjx-measure-text' , { style} , [ text ] ) ;
253+ const node = this . html ( 'mjx-measure-text' , { style} , [ text ] ) ;
239254 adaptor . append ( adaptor . parent ( this . math . start . node ) , this . container ) ;
240255 adaptor . append ( this . container , node ) ;
241256 let w = adaptor . nodeSize ( text , this . math . metrics . em ) [ 0 ] / this . math . metrics . scale ;
0 commit comments