gabriel / font-detect-js

Font detection using Javascript and Flash

This URL has Read+Write access

gabriel (author)
Wed Jan 28 11:44:12 -0800 2009
commit  64bc075e3f720704f88b24be7ba8bb26a8d2d67d
tree    ceff6b540efbb67ec610caa1e83bd2f5c0363aa9
parent  512a3a78f71dec95bd21ce9cdf88fa3dcc2b8035
name age message
file README.md Loading commit data...
file amp.html
file edit.html
directory flash/
file index.html
file index.prototype.html
directory javascripts/
directory stylesheets/ Thu Jun 26 14:23:49 -0700 2008 importing [gabriel]
README.md

This code uses flash to detect system fonts and then detects via javascript in the browser which fonts will actually render.

View a demo at: http://font-detect.s3.amazonaws.com/index.html

font-detect.png

<!-- element for SWF to load into -->
<div id="font-detect-swf"></div>

<script src="javascripts/jquery-1.2.6.pack.js"></script>
<script src="javascripts/swfobject.js"></script>
<script src="javascripts/font-detect.js"></script>  
<script>
  $(document).ready(function() {

    var fontDetect = newFontDetect("font-detect-swf", "flash/FontList.swf", function(fd) {        
      var fonts = fd.fonts();

      // Do something with fonts, which look like: [ { fontName:'Arial', fontStyle:'regular' fontType:'device' }, .... ]
      // for(var i = 0, length = fonts.length; i < length; i++) {
      //   var name = fonts[i].fontName;
      // }
    };

  });
</script>

There is also a Prototype version at font-detect.prototype.js