JavaScript/CSS Font Detector

Open-source JavaScript routine to test whether any given font is present on the viewer’s web browser:

We try to create a string with a specified font-face. If the font-face is not available, it takes up the font-face of the parent element. We then compare the width of the string with the specified font-face and width of the string with the font-face of the parent element, if they are different, then the font exists, otherwise not.

Clever!

Wednesday, 21 March 2007