@@ -3327,9 +3327,10 @@ describe('web font loading', () => {
33273327 } ) ;
33283328
33293329 // Each test adds a new family, so that no earlier measurement can be in the bBox cache
3330- const addFace = ( ) => {
3331- face = new FontFace ( `PlotlyTestFont ${ ++ faceCount } ` , `url(${ fontUrl } )` ) ;
3330+ const addFace = ( name = `PlotlyTestFont ${ ++ faceCount } ` ) => {
3331+ face = new FontFace ( name , `url(${ fontUrl } )` ) ;
33323332 document . fonts . add ( face ) ;
3333+ // The family comes back as CSS, with quotes when the name needs them
33333334 return face . family ;
33343335 } ;
33353336
@@ -3364,6 +3365,23 @@ describe('web font loading', () => {
33643365 . then ( done , done . fail ) ;
33653366 } ) ;
33663367
3368+ it ( 'should redraw a plot whose quoted font family contains a comma' , ( done ) => {
3369+ const fig = makeFigure ( addFace ( `PlotlyTest, Font${ ++ faceCount } ` ) ) ;
3370+ let widthBeforeLoad ;
3371+
3372+ Plotly . newPlot ( gd , fig . data , fig . layout )
3373+ . then ( ( ) => {
3374+ expect ( face . status ) . not . toBe ( 'loaded' ) ;
3375+ widthBeforeLoad = legendWidth ( gd ) ;
3376+ return new Promise ( ( resolve ) => gd . once ( 'plotly_afterplot' , resolve ) ) ;
3377+ } )
3378+ . then ( ( ) => {
3379+ expect ( face . status ) . toBe ( 'loaded' ) ;
3380+ expect ( legendWidth ( gd ) ) . not . toBe ( widthBeforeLoad ) ;
3381+ } )
3382+ . then ( done , done . fail ) ;
3383+ } ) ;
3384+
33673385 it ( 'should not redraw a plot that does not use the loaded font' , ( done ) => {
33683386 addFace ( ) ;
33693387 const fig = makeFigure ( 'Arial' ) ;
@@ -3373,7 +3391,7 @@ describe('web font loading', () => {
33733391 spyOn ( plotApi , '_doPlot' ) . and . callThrough ( ) ;
33743392 return face . load ( ) ;
33753393 } )
3376- // The `loadingdone` event can fire after the load promise resolves
3394+ // `document.fonts.ready` can resolve after the load promise
33773395 . then ( ( ) => new Promise ( ( resolve ) => setTimeout ( resolve , 100 ) ) )
33783396 . then ( ( ) => {
33793397 expect ( plotApi . _doPlot ) . not . toHaveBeenCalled ( ) ;
@@ -3392,7 +3410,7 @@ describe('web font loading', () => {
33923410 spyOn ( plotApi , '_doPlot' ) . and . callThrough ( ) ;
33933411 return face . loaded ;
33943412 } )
3395- // The `loadingdone` event can fire after the load promise resolves
3413+ // `document.fonts.ready` can resolve after the load promise
33963414 . then ( ( ) => new Promise ( ( resolve ) => setTimeout ( resolve , 100 ) ) )
33973415 . then ( ( ) => {
33983416 expect ( plotApi . _doPlot ) . toHaveBeenCalledTimes ( 1 ) ;
@@ -3406,15 +3424,15 @@ describe('web font loading', () => {
34063424 Plotly . newPlot ( gd , fig . data , fig . layout )
34073425 . then ( ( ) => {
34083426 expect ( face . status ) . not . toBe ( 'loaded' ) ;
3409- expect ( gd . _clearFontListener ) . toEqual ( jasmine . any ( Function ) ) ;
3427+ expect ( gd . _fontLoadToken ) . toBeDefined ( ) ;
34103428
34113429 Plotly . purge ( gd ) ;
3412- expect ( gd . _clearFontListener ) . toBeUndefined ( ) ;
3430+ expect ( gd . _fontLoadToken ) . toBeUndefined ( ) ;
34133431
34143432 spyOn ( plotApi , '_doPlot' ) . and . callThrough ( ) ;
34153433 return face . loaded ;
34163434 } )
3417- // The `loadingdone` event can fire after the load promise resolves
3435+ // `document.fonts.ready` can resolve after the load promise
34183436 . then ( ( ) => new Promise ( ( resolve ) => setTimeout ( resolve , 100 ) ) )
34193437 . then ( ( ) => {
34203438 expect ( plotApi . _doPlot ) . not . toHaveBeenCalled ( ) ;
0 commit comments