At work we use a couple of custom truetype fonts. Traditionally, to get these fonts rendered on our website our graphic designer would create images and deploy them to our web server - as you could imagine this is both inflexible and expensive. Today I set off on a voyage to try and find a better solution. I have evaluated three javascript frameworks that take an appropriately licensed (truetype) font file and munges it into a javascript file that gets sent to the client that renders the font directly in the browser window (using some SVG magic). Each implementation seems to have strengths and weaknesses, including:
- The size of the generated javascript file (processed from the ttf file)
- The size of the base javascript library
- The ease of integrating into your CSS
- The ability to copy and paste the generated text
- How well the font renders on different platforms (it seems that Windows handles font rendering very differently to other platforms).
- The quality of the sample code and sample font pages (generated)
Anyways, here is an example of the three different implementations:
http://www.lesmills.com.au/presentations/font_test In a nutshell:
- typeface.js (http://typeface.neocracy.org/) - renders well cross-platform, largish javascript (unable to pick individual unicode characters to export), generated text can be copied
- fontsquirrel (hhttp://www.fontsquirrel.com/) - really polished implementation, great demo pages, however generated fonts really suck on Windows (on both IE and Firefox)
- cufon** **(http://cufon.shoqolate.com/generate/)- renders well cross-platform, small javascript (ability to select individual unicode characters for export).
Quick sidenote, it's important to keep the size of these generated libraries down (so the client isn't kept waiting while fonts load).
Two strategies are used to achieve this - the first is to only include the individual characters we are going to use, this can easily reduce the file size by at least 50%.
The second trick is to switch on compression for js and css within Apache (this further reduces the size of data transferred by another 50-60%). So for my use, I have decided that Cufon is the best.