Useful Hints

EMBEDDING FONTS

Recently I was doing a bit more research on how to embed custom fonts into my websites and I came across several intersting links.

The first one was an article written by a freelance web developer, John Raasch. He lists and describes all the pros and cons regarding various methods of embedding custom fonts: http://jonraasch.com/blog/embedding-custom-fonts. At the end he sums up his prefered method of embedding and gives the reasons for his choice.

The second article I came across is similar to the one above, detailing the various embedding methods: http://pcandweb.com/tutorials/how-to-embed-custom-fonts-on-webpage.html

And thirdly, I found this site: http://typekit.com/. They provide a service whereby you pay a monthly subscription to use their library of fonts, and by inserting specific coding supplied by Typekit your custom font will apprear on your website. However, when I browsed through their font library I noticed that the custom fonts took a moment or 2 to load before they appeared.

Personally, I decided to give the @font-face class a try, which is detailed in the first 2 links. I found it to be pretty easy to implement and it worked across the following browsers: Firefox, IE, Safari and Chrome. The following tutorial was very useful in detailing the @font-face implementation step by step: http://blog.themeforest.net/tutorials/how-to-achieve-cross-browser-font-face-support/

Below is how you can make use of the @font-face class to embed your custom font:

STEP 1: SELECT YOUR FONT
Due to licensing concerns, it is best to use a free font. A site that I make use of often is: http://www.dafont.com.

STEP 2: CONVERTING YOUR FONT
Different browsers support different font formats, therefore you will need create different font files in order to get cross browser support. Below is a list of the font formats supported by different web browsers.

Source: Wikipedia

The tutuoral I mentioned above makes use of the Font Squirrel @font-face Kit Generator. It allows you to upload your font file, select your output formats and download a folder with all of your converted font files. A demo page will also be downloaded to your computer once Font Squirrel has finished converting your fonts.

STEP 3: INSERTING THE CSS

@font-face {
	font-family: 'YourFontName';
	src: url('YourFontName-webfont.eot');
	src: local('YourFontName'), 
	url('YourFontName-webfont.woff') format('woff'), 
	url('YourFontName-webfont.ttf') format('truetype'), 
	url('YourFontName-webfont.svg#webfontFsOvWXlB') format('svg');
	font-weight: normal;
	font-style: normal;
}

h1 {
	font-family: 'YourFontName', Helvetica, Arial, sans-serif;
}

                    

If you decide to try the @font-face class for your website, please read through the above links carefully as they detail the pros and cons and potential font licensing issues regarding this method.

to top