JavaScript document.fonts Property
JavaScript document.fonts Property
The document.fonts
property of the Document interface returns the FontFaceSet interface of the document.
The FontFaceSet interface is useful for loading new fonts, checking the status of previously loaded fonts etc.
Example
HTML Online Editor
<!DOCTYPE html>
<html>
<body>
<p id="point"></p>
<script>
var x = document.getElementById("point");
x.innerHTML = document.fonts.status;
</script>
</body>
</html>
Syntax
document.fonts
Return Values
Value | Explanation |
---|---|
Object | Returns the FontFaceSet interface of the document. |
Using Callback Function
You can use a callback function to execute after all fontSets of the current document is loaded.
Example
HTML Online Editor
<!DOCTYPE html>
<html>
<body>
<p id="point"></p>
<script>
var x = document.getElementById("point");
document.fonts.ready.then(function() {
//Run after all FontFaceSets are loaded
x.innerHTML = "FontFaceSet of this document is ready";
});
</script>
</body>
</html>
Reminder
Hi Developers, we almost covered 97% of JavaScript Tutorials with examples for quick and easy learning.
We are working to cover every Single Concept in JavaScript.
Please do google search for:
Join Our Channel
Join our telegram channel to get an instant update on depreciation and new features on HTML, CSS, JavaScript, jQuery, Node.js, PHP and Python.
This channel is primarily useful for Full Stack Web Developer.