FontFaceSet Class

The font faces of a document (https://drafts.csswg.org/css-font-loading/#fontfaceset): the CSS-connected font faces of the @font-face rules of the style sheets of the document, in document order, followed by the font faces added by FontFaceSet.Add, in insertion order. The set of a worker (WorkerGlobalScope.Fonts) only has the font faces added by FontFaceSet.Add: it is never pending on the environment, and its tasks run on the event loop of the worker.

Remarks

The font faces are loaded by FontFace.Load and FontFaceSet.Load, and by the user agent when the text of the document uses them: the font matching of the layout requests the font faces it needs (the first available font of the font-relative units and of the line boxes, the font of each character, the next family when a font face fails to load), and, for the documents that are not rendered, the font faces of the first family of the texts are loaded (FontFaceSet.LoadUsedFontFaces). The set is pending on the environment while the document is loading, has pending style sheets, or has "pending layout operations which might cause the user agent to request a font, or which depend on recently-loaded fonts": FontFaceSet.Ready is fulfilled once the document is loaded, its layout is up to date and no font face is loading (FontFaceSet.UpdateLayoutForFonts).

See also

Inheritance
EventTarget FontFaceSet
Implements

Properties

NameDescription
CountGets the number of font faces in the set.
OnLoadingGets or sets the event handler of the loading event.
OnLoadingDoneGets or sets the event handler of the loadingdone event.
OnLoadingErrorGets or sets the event handler of the loadingerror event.
ReadyGets the promise resolved when the set is loaded. The font faces used by the text of the document that is not rendered yet are loaded first: the set is pending on the environment while the document has pending layout operations (https://drafts.csswg.org/css-font-loading/#fontfaceset-pending-on-the-environment).
StatusGets the load status of the set.

Gets the number of font faces in the set.

public int Count { get; }

Property value

int

Gets or sets the event handler of the loading event.

public Action<Event>? OnLoading { get; set; }

OnLoadingDone

FontFaceSet.cs

Gets or sets the event handler of the loadingdone event.

public Action<Event>? OnLoadingDone { get; set; }

OnLoadingError

FontFaceSet.cs

Gets or sets the event handler of the loadingerror event.

public Action<Event>? OnLoadingError { get; set; }

Gets the promise resolved when the set is loaded. The font faces used by the text of the document that is not rendered yet are loaded first: the set is pending on the environment while the document has pending layout operations (https://drafts.csswg.org/css-font-loading/#fontfaceset-pending-on-the-environment).

public Task<FontFaceSet> Ready { get; }

Gets the load status of the set.

public FontFaceSetLoadStatus Status { get; }

Methods

NameDescription
Add(FontFace)Adds a font face that is not CSS-connected (https://drafts.csswg.org/css-font-loading/#dom-fontfaceset-add).
Check(string, string)Returns whether the text can be rendered with the font without loading a font face (https://drafts.csswg.org/css-font-loading/#font-face-set-check): all the matching font faces are loaded.
Clear()Removes the font faces that are not CSS-connected (https://drafts.csswg.org/css-font-loading/#dom-fontfaceset-clear).
Delete(FontFace)Removes a font face that is not CSS-connected (https://drafts.csswg.org/css-font-loading/#dom-fontfaceset-delete).
GetEnumerator()Enumerates the font faces: the CSS-connected font faces, then the font faces added by FontFaceSet.Add.
Has(FontFace)Returns whether the font face is in the set.
Load(string, string)Loads the font faces that match a font (a value of the font shorthand, e.g. 12px MyFont) and a text (https://drafts.csswg.org/css-font-loading/#font-face-set-load). The task completes with the matching font faces, once they are loaded, or fails when one of them cannot be loaded or when the font is invalid.
System.Collections.IEnumerable.GetEnumerator()

Add(FontFace)

FontFaceSet.cs

Adds a font face that is not CSS-connected (https://drafts.csswg.org/css-font-loading/#dom-fontfaceset-add).

public FontFaceSet Add(FontFace font)

Check(string, string)

FontFaceSet.cs

Returns whether the text can be rendered with the font without loading a font face (https://drafts.csswg.org/css-font-loading/#font-face-set-check): all the matching font faces are loaded.

public bool Check(string font, string text = " ")

Removes the font faces that are not CSS-connected (https://drafts.csswg.org/css-font-loading/#dom-fontfaceset-clear).

public void Clear()

Delete(FontFace)

FontFaceSet.cs

Removes a font face that is not CSS-connected (https://drafts.csswg.org/css-font-loading/#dom-fontfaceset-delete).

public bool Delete(FontFace font)

GetEnumerator()

FontFaceSet.cs

Enumerates the font faces: the CSS-connected font faces, then the font faces added by FontFaceSet.Add.

public IEnumerator<FontFace> GetEnumerator()

Has(FontFace)

FontFaceSet.cs

Returns whether the font face is in the set.

public bool Has(FontFace font)

Parameters

font FontFace

Returns

bool

Load(string, string)

FontFaceSet.cs

Loads the font faces that match a font (a value of the font shorthand, e.g. 12px MyFont) and a text (https://drafts.csswg.org/css-font-loading/#font-face-set-load). The task completes with the matching font faces, once they are loaded, or fails when one of them cannot be loaded or when the font is invalid.

public Task<IReadOnlyList<FontFace>> Load(string font, string text = " ")

System.Collections.IEnumerable.GetEnumerator()

FontFaceSet.cs
IEnumerator IEnumerable.GetEnumerator()

No documentation is available.