JavaScript/CSS Font Detector This code works on the simple principle that each character appears differently in different fonts. So different fonts will take different width and height for the same string of characters of same font-size.
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. The string which we will use to generate the widths can be anything. But I guess we use 'm' or 'w' because these two characters take up the maximum width. And we use a trailing 'l' so that the same width fonts-faces can get separated based on the width of l character. I have tested it on Firefox 2 and IE 6.0. Please report bugs and suggestions here. Working Demo You can test any Font here: Fonts on your computer This table below shows which fonts are present on your system. (I have listed some of the most common and some uncommon fonts.) Johan Sundström has presented this data in a more interesting and cool layout here: http://exhibit.ecmanaut.googlepages.com/installed-fonts.html. Thanks Johan.
|
|||||
| lalit.org › blog | inspiration | lab | synapsys | who? | bio | email | |||||