Enumeration FontLoaderInterfaceSignal

The FontLoaderInterfaceSignal lists all the signals that may be sent by the FontLoaderInterface.

These signals are emitted by the FontLoaderInterface has finished loading.

The FontLoaderInterface may fire the following signals :

/** 
* Sample to illustrate the loading of fonts.
*/
import { FontLoaderInterface, InfiniteFactory, FontLoaderInterfaceSignal, InfiniteEvent, FontLoadingStatus, FontInterface } from 'generated_files/documentation/appinfiniteapi';

// font loading is used wheen loading annotations

// what to do when fonts are loaded
let lFontLoaded : (pEvent : InfiniteEvent) => void;
// get the font loader, no need to create it, all the time available (singleton)
const lFontLoader : FontLoaderInterface = InfiniteFactory.GetInfiniteApiController().getFontLoader();
// register font Open Sans normal (no bold, no italic) by its url
const lFontRegistered : boolean = lFontLoader.registerFont('Open Sans', false, false, 'resources/fonts/OpenSans-Regular.otf');
console.assert(lFontRegistered, 'font should be registered');

// what to do when fonts is loaded ?
lFontLoader.addEventListener(FontLoaderInterfaceSignal.FontsLoaded, lFontLoaded);
// load explicitly font, if not, font will be loaded if required when loading annotations
const lLoadStatus : FontLoadingStatus = lFontLoader.loadFont('Open Sans', false, false);
console.assert(lLoadStatus === FontLoadingStatus.FLS_LoadingStarted, 'Font loading should be started');

// when fonts are loaded => what do we do ?
// perhaps some gui code ?
lFontLoaded = (_pEvent : InfiniteEvent) : void =>
{
// get all registered fonts and their status
const lFonts : Array<FontInterface> = [];
lFontLoader.getRegisteredFonts(lFonts);
let i : number;
let lErrorCount : number = 0;
for (i = 0; i < lFonts.length; i += 1)
{
if (lFonts[i].error !== undefined)
{
lErrorCount += 1;
}
}
console.assert(lErrorCount === 0, 'There should be no font in error');
// when font is loaded, we unload it, but perhaps we should make some gui code ? :)
lFontLoader.unregisterFont('Open Sans', false, false);
};

Please refer to the FontLoaderInterface for more information.
Events

Enumeration Members

Enumeration Members

FontsLoaded: "fontsLoaded"

Signal sent by the FontLoaderInterface when the FontLoaderInterface has finished loading the fonts. This does not tell if the loading was successful.

No attachment for events of this type.