Home Reference Source
public class | source

Font

A class used to load fonts

Static Method Summary

Static Public Methods
public static

create(font: String, styles: Object): Font

Returns a new instance of Font

Constructor Summary

Public Constructor
public

constructor(font: String, styles: Object)

Creates a new instance of Font

Method Summary

Public Methods
public

Destroy font related tags

public

get(srcs: Array): Font

Loads the font into the html document

public

load(attempts: Number, interval: Number): Promise

A method to check if a font has been loaded

Static Public Methods

public static create(font: String, styles: Object): Font source

Returns a new instance of Font

Params:

NameTypeAttributeDescription
font String

Holds the font name

styles Object

Holds the font styles as object properties

Return:

Font

The newly created Font instance

Public Constructors

public constructor(font: String, styles: Object) source

Creates a new instance of Font

Params:

NameTypeAttributeDescription
font String

Holds the font name

styles Object

Holds the font styles as object properties

Public Methods

public destroy() source

Destroy font related tags

public get(srcs: Array): Font source

Loads the font into the html document

Params:

NameTypeAttributeDescription
srcs Array

An array of sources pointing to the font file ( ttf, otf, etc )

Return:

Font

Returns the current instance of the class

public load(attempts: Number, interval: Number): Promise source

A method to check if a font has been loaded

Params:

NameTypeAttributeDescription
attempts Number
  • optional
  • default: -1

The number of attempts before the promise is rejected. Default is infinite.

interval Number
  • optional
  • default: 100

The time in milliseconds it takes to retry the load

Return:

Promise

A promise that is resolved when the font is loaded