Monday, 04 October 2010 07:37

CSS3 @Font-Face Embedding

Written by Miguel

css3The web is predominantly presented by and viewed in a spectrum of a few fonts, most notably Arial, Times New Roman, Verdana and Courier. These fonts are considered web-safe, purely because every computer has them installed.

 

For years, developers have tried to come up with ways to embed other fonts into websites. The most common of setbacks, is cross-browser compatibility. One such method (and probably the cleanest) of embedding fonts into websites is a technique called @font-face.

 

Even though Internet Explorer supports font embedding since version 4, the font has to be in the proprietary EOT format, and declared specifically for IE.

Here is a useful tool to convert TTF fonts to EOT:

http://ttf2eot.sebastiankippe.com/

 

The method

First, we copy the TTF and EOT fonts to your website directory. Next, add the following code to your CSS file (or style to your html file header):

body {

font-family: MY_FONT_NAME, Verdana, Arial, sans-serif;

}

@font-face {

font-family: MY_FONT_NAME;

src: url("MY_FONT_NAME.eot") /* EOT file for IE */

}

@font-face {

font-family: MY_FONT_NAME;

src: url("MY_FONT_NAME.TTF") /* TTF file for CSS3 browsers */

}

 

NB: replace MY_FONT_NAME with the desired font name.

Miguel

Miguel

E-mail: This e-mail address is being protected from spambots. You need JavaScript enabled to view it

Add comment



Call Us: +27 11 612 7460