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.
Constructors
FontFaceSet()
public FontFaceSet()
Properties
Onloading
[Value("onloading")]
public EventHandlerNonNull Onloading { get; set; }
Property Value
Onloadingdone
[Value("onloadingdone")]
public EventHandlerNonNull Onloadingdone { get; set; }
Property Value
Onloadingerror
[Value("onloadingerror")]
public EventHandlerNonNull Onloadingerror { get; set; }
Property Value
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.
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
fontFontFace
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
Returns
- bool
A Boolean value that is
trueif rendering text with the given font specification will not attempt to use any fonts in thisFontFaceSetthat are not yet fully loaded.This means that all fonts in thisFontFaceSetthat are matched by the given font specification have astatusproperty set to"loaded".Otherwise, this function returnsfalse.
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 returnstrueif 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't available or fully loaded, the method may still returntrue. This behavior helps avoid the visual issues associated with font swapping but may be counterintuitive if you're trying to confirm the availability of a specific font.
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
Remarks
Delete(FontFace)
The delete() method of the FontFaceSet interface removes a font from the set.
[Value("delete")]
public bool Delete(FontFace font)
Parameters
fontFontFace
Returns
- bool
A boolean value which is
trueif the deletion was successful, andfalseotherwise.
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.
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
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.