Custom font is loaded after first interaction with diagram

I have a problem with custom fonts on goJS diagrams. When app is loaded and I open diagram fonts are not loaded to diagram util first interaction with diagram. For example:


but when I have any interaction with diagram (I selected node) fonts are changing to ones that were intended here:

It is also working separately for diagram and palette. When palette node is touched it’s font gets loaded but diagram stays with default.
Screenshot from 2021-08-16 11-38-33
Screenshot from 2021-08-16 11-38-49

What may be the reason for this behaviour? How can I fix it or debug?

Could you only load your diagram after the custom fonts are loaded? You would need to use something like fontfaceobserver - npm to detect when a font has been loaded.

This helped, thanks

Browsers now provide an API for this: CSS Font Loading API - Web APIs | MDN

Examples: CSS Font Loading API - Web APIs | MDN

A GoJS sample: Waiting for font to load