How to add some non-standard font to a website?

后端 未结 19 1365
时光说笑
时光说笑 2020-11-22 02:17

Is there a way to add some custom font on a website without using images, Flash or some other graphics?

For example, I was working on a wedding website, and I found

相关标签:
19条回答
  • 2020-11-22 02:41

    If by non standard font, you mean custom font of a standard format, here's how I do it, and it works for all browsers I've checked so far:

    @font-face {
        font-family: TempestaSevenCondensed;
        src: url("../fonts/pf_tempesta_seven_condensed.eot") /* EOT file for IE */
    }
    @font-face {
        font-family: TempestaSevenCondensed;
        src: url("../fonts/pf_tempesta_seven_condensed.ttf") /* TTF file for CSS3 browsers */
    }
    

    so you'll just need both the ttf and eot fonts. Some tools available online can make the conversion.

    But if you want to attach font in a non standard format (bitmaps etc), I can't help you.

    0 讨论(0)
  • 2020-11-22 02:42

    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.

    0 讨论(0)
  • 2020-11-22 02:43

    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.

    0 讨论(0)
  • 2020-11-22 02:44

    If you use ASP.NET, it's 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.

    0 讨论(0)
  • 2020-11-22 02:45

    See the article 50 Useful Design Tools For Beautiful Web Typography for alternative methods.

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

    0 讨论(0)
  • 2020-11-22 02:47

    It is also possible to use WOFF fonts - example here

    @font-face {
    font-family: 'Plakat Fraktur';
    src: url('/resources/fonts/plakat-fraktur-black-modified.woff') format('woff');
    font-weight: bold;
    font-style: normal;
     }
    
    0 讨论(0)
提交回复
热议问题