But – in five minutes, I’ll try to simplify the process of working with custom fonts as much as I possibly can. Services like Font Squirrel help to make the task a cinch!
Final CSS
- @font-face {
- font-family: 'blok-regular';
- src: url('type/Blokletters-Potlood.eot');
- src: local('Blokletters Potlood Potlood'),
- local('Blokletters-Potlood'),
- url('type/Blokletters-Potlood.ttf') format('truetype');
- }
- @font-face {
- font-family: 'blok-italic';
- src: url('type/Blokletters-Balpen.eot');
- src: local('Blokletters Balpen Balpen'),
- local('Blokletters-Balpen'),
- url('type/Blokletters-Balpen.ttf') format('truetype');
- }
- @font-face {
- font-family: 'blok-heavy';
- src: url('type/Blokletters-Viltstift.eot');
- src: local('Blokletters Viltstift Viltstift'),
- local('Blokletters-Viltstift'),
- url('type/Blokletters-Viltstift.ttf') format('truetype');
- }
- h1 { font-family: blok-heavy, helvetica, arial; }
Next, we search for the font on the user’s computer by using the “local” attribute. If it’s unfound, only then do we pass a url that will load the font.
Why Doesn’t IE Try to Load the TTF Fonts?
This was definitely a concern. If Explorer can’t work with the truetype format, we don’t want to waste time trying to download the font. Luckily, because of all those local attributes, and the commas, IE won’t understand any of it. As such, it will simply skip the line all together, thus, only utilizing the .eot version.- Follow us on Twitter, or subscribe to the Nettuts+ RSS Feed for the best web development tutorials on the web.
No comments:
Post a Comment