views:

224

answers:

5

I'm developing a website for someone but they want (insist) that the title be in a non-standard font. (The customer is always right.) I have the TrueType (.ttf) font but how do I bundle this with the website so that it uses it?

I tried putting it in the Images folder and tried to access it with the style sheet:

font-family:URL(Images/Arial_Rounded_MT_Bold.ttf)

But that didn't work. How do I include a non-standard font in a way which will render?

In case it's useful, this is an ASP.NET 2.0 site.

+3  A: 

You have two options:

  1. Create an image instead of using text
  2. Use sifr to convert your text to the .ttf font
Dave Swersky
Dave, I already have the .ttf font file!!
flavour404
Yes, but you won't be able to get it to the user's system over the web. Look up sifr to see what it does.
Dave Swersky
sIFR is ridiculously cool.
John Rudy
flavour404, you're not understanding him. The font has to be installed on the server and you would use sifr to render the text in that font, in the place of the original.The only other possibility is if you are okay only serving the font to a select group of firefox 3.5-3.6(?) users who can comply with html5/css3.
thismat
Yep, these are the only two methods I have seen "in the wild".
ctford
thismat, no I understood Dave perfectly.
flavour404
+4  A: 

There is currently no standard way to do this. You could use @font-face, but it's not supported in all browsers. As Lance mentioned, this is a great place to find a support reference for the major browsers.

There is an effort to standardize this type of thing. The Web Open Font Format (WOFF) is such an effort. It looks like this may even be adopted by the major browsers in the future. We will have to wait and see.

For now, the best you can do is to reference your font like you normally would, but add a default (standard) font after that.

font-family: "Arial Rounded MT Bold", "Times New Roman", Serif
EndangeredMassa
Here's a good link regarding browser support for @font-face: http://webfonts.info/wiki/index.php?title=@font-face_browser_support
Lance McNearney
+2  A: 

You have lots of options, none of them perfect. Smashing Magazine has a great article about rich fonts - most of them involve flash / image replacement.

http://www.smashingmagazine.com/2009/10/22/rich-typography-on-the-web-techniques-and-tools/

Mike Robinson
+1  A: 

There is a fair amount of activity on the subject of distributing fonts along with websites, but it's generally in the experimental stage, and won't work for the vast majority of browsers in use. In a few years you may be able to do this, but for the moment you would have to use an image or sIFR.

qid
+1  A: 

Convert your TrueType font into an Embedded OpenType font (it's easy!) so that you have two font files:

  • Arial_Rounded_MT_Bold.ttf
  • Arial_Rounded_MT_Bold.eot

Then make your CSS look like this:

@font-face {
  font-family: 'Arial Rounded Bold';
  src: url('Arial_Rounded_MT_Bold.eot');
}
@font-face {
  font-family: 'Arial Rounded Bold';
  src: url('Arial_Rounded_MT_Bold.ttf') format('truetype');
}
h1.title {
  font-family: 'Arial Rounded Bold', serif;
}

Thanks to Internet Explorer, the EOT specification needs to be first, in a separate @font-face block and without the format attribute. More info here.

Enjoy!

a paid nerd
This looks pretty good and I will give it a try :)
flavour404