FontFaceSet.check()
The check()
method of the FontFaceSet
returns whether all
fonts in the given font list have been loaded and are available.
Syntax
check(font)
check(font, text)
Parameters
font
-
a font specification using the CSS value syntax, for example
"italic bold 16px Roboto"
text
-
limit the font faces to those whose Unicode range contains at least one of the characters in text. This does not check for individual glyph coverage.
Return value
A Boolean
value that is true
if the font list is available.
Examples
In the following example, the first line will print true
if the Courier font is available at 12px
. The second line will print true
if the font MyFont
contains the "ß" character.
console.log(document.fonts.check("12px courier"));
console.log(document.fonts.check("12px MyFont", "ß"));
Specifications
Specification |
---|
CSS Font Loading Module Level 3 # dom-fontfaceset-check |
Browser compatibility
BCD tables only load in the browser