I've been spending a few evenings investigating the best way to implement @font-face with todays modern browsers. I am a full time web/system developer with a background as a graphic designer I find the opportunities and possibilites with web design becoming more and more interesting. So, I made some testing and would like to hear if anyone has advices, any better ideas or inputs on this. My testing scenario looks like this.
I tested with ALOT of different online tools and applications but in the end I boiled this down to one online service and one application.
- FontSquirrel, online tool - free. http://www.fontsquirrel.com/fontface/generator
- FontXChange, application for mac/win - 99$. http://fontgear.net/fontxchange.html
I used a font that was shipped with my Mac, Tamil Sangam MN and Tamil Sangam MN Bold, both came as open type, .otf.
- TamilSangamMN.otf - 290 KB
- TamilSangamMNBold.otf - 271 KB
Investigating conversion sizes
FontSquirrel
This is a good online tool, it's very good. There are a few different modes and I've used the Basic and Optimal. The output of my .otf file was svg, ttf, eot and woff.
Basic
Regular
- TamilSangamMN.svg 233 KB
- TamilSangamMN.ttf 71 KB
- TamilSangamMN.eot 25 KB
- TamilSangamMN.woff 30 KB
- Total: 359 KB
Bold
- TamilSangamMNbold.svg 225 KB
- TamilSangamMNbold.ttf 69 KB
- TamilSangamMNbold.eot 25 KB
- TamilSangamMNbold.woff 30 KB
- Total: 349 KB
Optimal
First thing I noticed with the optimal fonts are that they are considerably much smaller than the basic variants ~ 260 KB!
Regular
- TamilSangamMN.svg 33 KB
- TamilSangamMN.ttf 25 KB
- TamilSangamMN.eot 15 KB
- TamilSangamMN.woff 17 KB
- Total: 90 KB
Bold
- TamilSangamMNbold.svg 33 KB
- TamilSangamMNbold.ttf 25 KB
- TamilSangamMNbold.eot 15 KB
- TamilSangamMNbold.woff 17 KB
- Total: 90 KB
FontXChange
This tool can do so much more than just juggling fonts for the web. It can convert several formats between each other; like opentype, true type, web fonts, post script and so on. The result is overall very high quality the files are so large, almost twice the size of FontSquirrels Basic versions and over 7 times bigger than FontSquirrels Optimal version.
Regular
- TamilSangamMN.svg 480 KB
- TamilSangamMN.ttf 72 KB
- TamilSangamMN.eot 72 KB
- TamilSangamMN.woff 80 KB
- Total: 704 KB
Bold
- TamilSangamMNbold.svg 463 KB
- TamilSangamMNbold.ttf 69 KB
- TamilSangamMNbold.eot 70 KB
- TamilSangamMNbold.woff 80 KB
- Total: 682 KB
Setting up the CSS
It puzzled me a bit in the start that the actual order in the font list mattered. Then I discovered that some takes the first format that it finds compatible rather than sticking with the format that is optimal - and it sucks. After some laborations I found that this is the optimal way to format your css (note the order of the file types | important!).
@font-face {
font-family: 'TamilSangam';
src: url('.eot');
src: url('.svg') format('svg'),
url('.eot?#iefix') format('embedded-opentype'),
url('.woff') format('woff'),
url('.ttf') format('truetype');
font-weight: normal;
font-style: normal;
}
My test results
Regular fonts
I did mark the best version with a *
Firefox MAC (15.0.1)
- FontSquirrel Optimal: Renders a bit to fat
- FontSquirrel Basic: Renders a bit to fat
- FontXChange 4.0: Renders a bit to fat, but the kerning is better than the FontSquirrel version *
Firefox Windows (15.0.1)
- FontSquirrel Optimal: Renders very nice
- FontSquirrel Basic: Font gets jagged/choppy
- FontXChange 4.0: Renders very nice *
Safari Mac (6.0)
- FontSquirrel Optimal: Perfect render
- FontSquirrel Basic: Perfect render
- FontXChange 4.0: Perfect render *
Chrome Mac (21.0)
- FontSquirrel Optimal: A bit fat
- FontSquirrel Basic: A bit fat
- FontXChange 4.0: Perfect render *
Chrome Windows (21.0)
- FontSquirrel Optimal: Perfect render
- FontSquirrel Basic: Perfect render
- FontXChange 4.0: Perfect render *
Internet Explorer (9.0)
- FontSquirrel Optimal: Perfect render *
- FontSquirrel Basic: Perfect render
- FontXChange 4.0: Font gets jagged/choppy
Bold fonts
Firefox MAC (15.0.1)
- FontSquirrel Optimal: Renders very fat *
- FontSquirrel Basic: Renders very fat
- FontXChange 4.0: Renders very fat, but better kerning (I would like to select this one for the mac but since the windows version of firefox isn't compatible here it has to go)
Firefox Windows (15.0.1)
- FontSquirrel Optimal: Renders ok, not very antialiased *
- FontSquirrel Basic: Font gets jagged/choppy
- FontXChange 4.0: Font gets a bit distorted/jagged
Safari Mac (6.0)
- FontSquirrel Optimal: Perfect render *
- FontSquirrel Basic: Perfect render
- FontXChange 4.0: Renders fat
Chrome Mac (21.0)
- FontSquirrel Optimal: Perfect render *
- FontSquirrel Basic: Good render, a few percent to fat
- FontXChange 4.0: Renders fat
Chrome Windows (21.0)
- FontSquirrel Optimal: Perfect render *
- FontSquirrel Basic: Perfect render
- FontXChange 4.0: Renders very fat
Internet Explorer (9.0)
- FontSquirrel Optimal: Perfect render *
- FontSquirrel Basic: Perfect render
- FontXChange 4.0: Font gets jagged/choppy
The final implementation
I usually organize my webfonts in the following pattern, <webfonts> / <conversion source> / <conversion method> / <fonts>
/* Regular */
@font-face {
font-family: 'TamilSangam';
src: url('webfonts/fontsquirrel/optimal/tamil_sangam_mn.eot');
src: url('webfonts/fontxchange/TamilSangamMN.svg#TamilSangamMN') format('svg'),
url('webfonts/fontsquirrel/optimal/tamil_sangam_mn.eot?#iefix') format('embedded-opentype'),
url('webfonts/fontxchange/TamilSangamMN.woff') format('woff'),
url('webfonts/fontxchange/TamilSangamMN.ttf') format('truetype');
font-weight: normal;
font-style: normal;
}
/* Bold */
@font-face {
font-family: 'TamilSangam';
src: url('webfonts/fontsquirrel/optimal/tamil_sangam_mn_bold.eot');
src: url('webfonts/fontsquirrel/optimal/tamil_sangam_mn_bold.svg#tamil_sangam_mnbold') format('svg'),
url('webfonts/fontsquirrel/optimal/tamil_sangam_mn_bold.eot?#iefix') format('embedded-opentype'),
url('webfonts/fontsquirrel/optimal/tamil_sangam_mn_bold.woff') format('woff'),
url('webfonts/fontsquirrel/optimal/tamil_sangam_mn_bold.ttf') format('truetype');
font-weight: bold;
font-style: normal;
}
Graphical overview of the result (fullsize at http://i.stack.imgur.com/atb98.png)
Conclusions and quests
There isn't one single tool out there that will deliver fonts that render nice on the Mac and Windows in all browsers. You must experiment and test on each font. The methodology posted above is just a simple way and suggestion how to test and experiment with @font-face's.
Is there anything you think I could change in my methods or implementation, is there any application or service that I missed?
All the best / T