views:

16673

answers:

21

Is there any way to add some custom font on website without using images, flash or some other graphics. For example, I was working on some wedding website, and I was found a lot of nice fonts for that subject, but I can't find the right way to add that font on the server, and how to include that font with css into the html. Is this possible to do without graphics?

A: 

I'm afraid graphics is your only option in this case.

Ed Brown
With JavaScript, CSS3, and the way the internet is going, There are several other options. TypeKit works all the way to back IE6
Zack
+6  A: 

Or you could try sIFR (http://http://www.mikeindustries.com/blog/sifr)

Edit: I know it uses flash, but only if available. If flash isn't available, it displays the original text in it's original (css) font.

Casper
+1  A: 

FOund an interesting link here:

http://www.spoono.com/html/tutorials/tutorial.php?url=embeddingfonts

mattlant
Yeah. I found that too. It won't work in Firefox ( and in fact produces HORIBILE results )
Kent Fredric
Nice! Works fine in IE, and no browser was specified. This could have been an intranet site for a large corporation standardized on IE! Thanks.
mattlant
+14  A: 

I've found that the easiest way to have non-standard fonts on a website is to use sIFR

It does involve the use of a Flash object that contains the font, but it degrades nicely to standard text / font if Flash is not installed.

The style is set in your CSS and Javascript set's up the flash replacement for your text.

Edit: (I still recommend using images for non-standard fonts as sIFR adds time to a project and can require maintenance).

Matt
What a terrible idea ! I have flash in my browser but flashblock too. On that website, my browser display an horrible defaced page. Flash should stay something that you use for big animations or movies. Too much flash is wery anoying and visualy, my my...
e-satis
@e-satis: How so? Personally, I never notice the difference between a page that uses sIFR and one that doesn't, aside from the subtle text rendering differences. I think it's a great idea, honestly, although `@font-face` is much better where supported.
musicfreak
"Edit: (I still recommend using images for non-standard fonts as sIFR adds time to a project and can require maintenance)." very well said. sIFR is a really cool technique but it seems to require a lot to get the EXACT look you want. If you have the time to learn and master this technique I'd highly recommend it. But if you are looking for a quick and easy font-replacement technique I'd use image replacement or even the @font-face css property
Derek Adair
+25  A: 

This could be done via CSS 2.0 and should work in WebKit based browser. It is not really widely supported, though, I think.

<style type="text/css">
@font-face {
    font-family: "My Custom Font";
    src: url(http://www.example.org/mycustomfont.ttf) format("truetype");
}
p.customfont { 
    font-family: "My Custom Font", Verdana, Tahoma;
}
</style>
<p class="customfont">Hello world!</p>
hangy
Note: Looks like the font-face tag also is a part of CSS3 and not just CSS2. See http://www.css3.info/webkit-has-web-fonts-support/ for more information.
hangy
Both Internet Explorer and Firefox re NOT based on Webkit, so it's quite a useless solution in my opinion.
Casper
It's not useless since it's standard : the more you implement it, the more it will likely be implemented by browsers. That does not mean you should not find another way to compensate, but using this as a complement seems good to me.
e-satis
Firefox 3.1 does support @font-face, though.
Ms2ger
It does work in IE, but just not with a TrueType font.See my answer below.http://brendanjerwin.github.com/2009/03/03/embedding-fonts.html
brendanjerwin
Make sure you have the right to distribute the font!
Viet
@brendanjerwin: updated version of your link - http://brendanjerwin.com/development/web/2009/03/03/embedding-fonts.html
Matt Ball
+1  A: 

It looks like it only works in Internet Explorer, but a quick Google search for "html embed fonts" yields http://www.spoono.com/html/tutorials/tutorial.php?id=19

If you want to stay platform-agnostic (and you should!) you'll have to use images, or else just use a standard font.

James Muscat
+2  A: 

The technique that the W3C has recommended for do this is called "embedding" and is well described by the three articles here: Embedding Fonts. In my limited experiments, I have found this process error-prone and have had limited success in making it function in a multi-browser environment.

Steve Moyer
+2  A: 

"Is there any way to add some custom font on website, without using ... flash"

Sure, use Silverlight.

:P

TraumaPony
only problem with this is distribution rights, as you would need that to use the font :(
mattlant
+3  A: 

Safari and Internet Explorer both support the CSS @font-face rule, however they support two different embedded font types. Firefox is planning to support the same type as Apple some time soon. SVG can embed fonts but isn't that widely supported yet (without a plugin).

I think the most portable solution I've seen is to use a JavaScript function to replace headings etc. with an image generated and cached on the server with your font of choice -- that way you simply update the text and don't have to stuff around in Photoshop.

zobier
This does not have to be done with JavaScript. I know that a lot of people like to use JavaScript for quite a few stuff nowadays, but a standard CSS technique may be more appropriate here. See http://www.sitepoint.com/article/header-images-css-xhtml/
hangy
I'm sorry if there's confusion, the technique refers not to the method of image replacement which, as you say, can be CSS. It is about generating graphics representing a given string in a particular font/style, on the fly, at the server -- obviating the need to create these manually.
zobier
+3  A: 

If you use ASP.NET its really easy to generate image based fonts without actually having to install (as in adding to the installed font base) fonts on the server by using:

  PrivateFontCollection pfont = new PrivateFontCollection();
  pfont.AddFontFile(filename);
  FontFamily ff = pfont.Families[0];

and then drawing with that font onto a Graphics

mattlant
well, yes... And you user can forget about copying and pasting. And zooming too, in old browsers. I don't even talk about bandwidth issues !
e-satis
Yeah, ok, and the question specified that it was going to be using it for content text? No it didnt, it was a general question, and this was a general answer. Small snippets of text, headers, etc, dont take up lots of bandwidth. Sheesh, get a grip!
mattlant
+2  A: 

Did a bit of research and dug up this:

http://www.alistapart.com/articles/dynatext/

This technique uses images, but it appears to be "hands free". You write your text, and you let a few automated scripts do automated find-and-replace on the page for you on the fly.

Has some limitations, but probably one of the easier choises ( and more browser compatible ) than all the rest I've seen.

Kent Fredric
+7  A: 

This article says it works with all 3 major browsers:

http://jontangerine.com/log/2008/10/font-face-in-ie-making-web-fonts-work

Here is a sample I got working:

http://brendanjerwin.com/test_font.html

More discussion: http://brendanjerwin.com/development/web/2009/03/03/embedding-fonts.html

brendanjerwin
+5  A: 

Typeface.js and Cufon are two other interesting options. They are Javascript components that render special font data in JSON format (which you can convert from Truetype or OpenType formats on their web sites) via the new element in all newer browsers except IE and via VML in IE.

The main problem with both (as of now) is that selecting text does not work or at least works only quite awkwardly.

Still, very nice for headlines. Body text... I don't know.

And it's surprisingly fast.

Thomas
Another interesting option is typekit.com Similar concept.
Zack
+1  A: 

See the following article for alternative methods:

http://www.smashingmagazine.com/2009/01/27/css-typographic-tools-and-techniques/

I have only used Cufon. I have found it reliable and very easy to use so I've stuck with it.

idea
A: 

thanks, Can I add Unicode font using font face. my Unicode have a extension .eot and It's not working is there any other way to add unicode.

Ashraful88
A: 

I've tried it! wont work in IE, works in FF, Chrome and Safari.

andsien
This is a comment, not an answer.
TheMagician
A: 

Typeface.js JavaScript Way:

With typeface.js you can embed custom fonts in your web pages so you don't have to render text to images

Instead of creating images or using flash just to show your site's graphic text in the font you want, you can use typeface.js and write in plain HTML and CSS, just as if your visitors had the font installed locally.

http://typeface.neocracy.org/

Bakkal
A: 

nice post , this code works awesome :)

ashok
This should be a comment, not an answer.
True Soft
A: 

Monotype recently released a lot of their fonts along with a new system for using them on your web pages: http://www.webfonts.fonts.com/

Cogwheel - Matthew Orlando
+3  A: 

Some fonts You can add via Google Web Fonts.

Technically, the fonts are hosted at Google and You link them in the HTML header. Then, You can use them freely in CSS with @font-face (read about it).

For example:

In HTML header

 <link href=' http://fonts.googleapis.com/css?family=Droid+Sans' rel='stylesheet' type='text/css'>

Then in CSS

h1 { font-family: 'Droid Sans', arial, serif; }

The solution seems quite reliable (even Smashing Magazine uses it for an article title.). There are, however, not so many fonts available so far in Google Font Directory.

Michał Pękała
A: 

It totally worked. Very big thanks from me. And if someone knows that how to change the cursor on your webpages please contact me guys. The Article was nice and totally worked. Email me my answer at [email protected]

Jashrun