function guessFontAvailability (desiredFont) { // create an element with the desired font family var a = document.createElement ('span'); a.appendChild (document.createTextNode ('AAA')); a.style.fontFamily = desiredFont + ', monospace'; a.style.fontSize = '100px'; a.style.visibility = 'hidden'; // create an element which will use the browser's default monospace font var b = document.createElement ('span'); b.appendChild (document.createTextNode ('AAA')); b.style.fontFamily = 'monospace'; b.style.fontSize = '100px'; b.style.visibility = 'hidden'; // attach the elements to the body document.body.appendChild (a); document.body.appendChild (b); // check if the dimensions of the elements are similar var available = true; if (a.offsetWidth === b.offsetWidth && a.offsetHeight === b.offsetHeight) { available = false; } // remove the elements and return the availability of the font a.parentNode.removeChild (a); b.parentNode.removeChild (b); return available; }