Table of Contents

Class FontFaceSet

Namespace
CSharpToJavaScript.APIs.JS
Assembly
CSharpToJavaScript.dll

The FontFaceSet interface of the CSS Font Loading API manages the loading of font-faces and querying of their download status.

[Value("FontFaceSet")]
public class FontFaceSet : EventTarget
Inheritance
FontFaceSet
Inherited Members

Remarks

A FontFaceSet instance is a Set-like object that can hold an ordered set of FontFace objects.

This property is available as Document.Fonts, or self.fonts in web workers.

See also on MDN

Constructors

FontFaceSet()

public FontFaceSet()

Properties

Onloading

[Value("onloading")]
public EventHandlerNonNull Onloading { get; set; }

Property Value

EventHandlerNonNull

Onloadingdone

[Value("onloadingdone")]
public EventHandlerNonNull Onloadingdone { get; set; }

Property Value

EventHandlerNonNull

Onloadingerror

[Value("onloadingerror")]
public EventHandlerNonNull Onloadingerror { get; set; }

Property Value

EventHandlerNonNull

Ready

The ready read-only property of the FontFaceSet interface returns a {{jsxref("Promise")}} that resolves to the given FontFaceSet.

[Value("ready")]
public Task<FontFaceSet> Ready { get; }

Property Value

Task<FontFaceSet>

A {{jsxref("Promise")}} that resolves to the given FontFaceSet.

Remarks

The promise will only resolve once the document has completed loading fonts, layout operations are completed, and no further font loads are needed.

See also on MDN

Status

The status read-only property of the FontFaceSet interface returns the loading state of the fonts in the set.

[Value("status")]
public FontFaceSetLoadStatus Status { get; }

Property Value

FontFaceSetLoadStatus

One of:

Remarks

Methods

Add(FontFace)

The add() method of the FontFaceSet interface adds a new font to the set.

[Value("add")]
public FontFaceSet Add(FontFace font)

Parameters

font FontFace

Returns

FontFaceSet

A new FontFaceSet.

Remarks

Check(string, string)

The check() method of the FontFaceSet returns true if you can render some text using the given font specification without attempting to use any fonts in this FontFaceSet that are not yet fully loaded. This means you can use the font specification without causing a font swap.

[Value("check")]
public bool Check(string font, string text = null)

Parameters

font string
text string

Returns

bool

A Boolean value that is true if rendering text with the given font specification will not attempt to use any fonts in this FontFaceSet that are not yet fully loaded.This means that all fonts in this FontFaceSet that are matched by the given font specification have a status property set to &quot;loaded&quot;.Otherwise, this function returns false.

Remarks

NOTE

The check() method is not designed to verify whether a specific font style can be rendered or if a particular font is fully loaded. Instead, it returns true if the specified text can be rendered using the given font specification without causing a font swap. This means that even if the requested font isn&apos;t available or fully loaded, the method may still return true. This behavior helps avoid the visual issues associated with font swapping but may be counterintuitive if you&apos;re trying to confirm the availability of a specific font.

See also on MDN

Clear()

The clear() method of the FontFaceSet interface removes all fonts added via this interface. Fonts added with the {{cssxref("@font-face")}} rule are not removed.

[Value("clear")]
public GlobalObject.Undefined Clear()

Returns

GlobalObject.Undefined

None (GlobalObject.Undefined).

Remarks

Delete(FontFace)

The delete() method of the FontFaceSet interface removes a font from the set.

[Value("delete")]
public bool Delete(FontFace font)

Parameters

font FontFace

Returns

bool

A boolean value which is true if the deletion was successful, and false otherwise.

Remarks

Font faces that were added to the set using the CSS @font-face rule remain connected to the corresponding CSS, and cannot be deleted.

See also on MDN

Load(string, string)

The load() method of the FontFaceSet forces all the fonts given in parameters to be loaded.

[Value("load")]
public Task<List<FontFace>> Load(string font, string text = null)

Parameters

font string
text string

Returns

Task<List<FontFace>>

A {{jsxref("Promise")}} fulfilled with an {{jsxref("Array")}} of loaded FontFace objects. The
promise is fulfilled when all the fonts are loaded; it is rejected if one of the fonts
failed to load.

Remarks