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.
public sealed class FontFaceSet : EventTarget, IEnumerable<FontFace>, IReadOnlyCollection<FontFace>, IEnumerableRemarks
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
EventTargetFontFaceSet- Implements
Properties
| Name | Description |
|---|---|
| Count | Gets the number of font faces in the set. |
| OnLoading | Gets or sets the event handler of the loading event. |
| OnLoadingDone | Gets or sets the event handler of the loadingdone event. |
| OnLoadingError | Gets or sets the event handler of the loadingerror event. |
| Ready | 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). |
| Status | Gets the load status of the set. |
Count
FontFaceSet.csOnLoading
FontFaceSet.csGets or sets the event handler of the loading event.
Property value
See also
OnLoadingDone
FontFaceSet.csGets or sets the event handler of the loadingdone event.
Property value
See also
OnLoadingError
FontFaceSet.csGets or sets the event handler of the loadingerror event.
Property value
See also
Ready
FontFaceSet.csGets 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; }Property value
See also
Status
FontFaceSet.csMethods
| Name | Description |
|---|---|
| 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.csAdds 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.csReturns 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.
Parameters
Returns
See also
Clear()
FontFaceSet.csRemoves the font faces that are not CSS-connected (https://drafts.csswg.org/css-font-loading/#dom-fontfaceset-clear).
public void Clear()Delete(FontFace)
FontFaceSet.csRemoves a font face that is not CSS-connected (https://drafts.csswg.org/css-font-loading/#dom-fontfaceset-delete).
GetEnumerator()
FontFaceSet.csEnumerates the font faces: the CSS-connected font faces, then the font faces added by FontFaceSet.Add.
public IEnumerator<FontFace> GetEnumerator()Returns
Has(FontFace)
FontFaceSet.csLoad(string, string)
FontFaceSet.csLoads 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 = " ")