FontFamily for TextBlock in AdvancedDynamicTexture

In total… all is simpliest )

We can use FontFaceSet API FontFaceSet - Web APIs | MDN
for:

  • force loading font: document.fonts.load
  • checking font state: document.fonts.load or document.fonts.ready promise
    then, we can just update textBlock.fontFamily property or create and apply AdvancedTexture style, when we need.

If we have many fonts and need choisen one - we can use FontFaceSet.check method

All it in doc, and only one small hints:

  1. We can use just text-element with font style in html page for browser start font loading. Because before FotnFaceSet.load or page naven’t that block font loading not invoked.
    <span style="font-family:‘MyFont’> 

Probably it can save some time )

4 Likes