display uninstalled font on a webpage [duplicate]

2020-07-18 04:10发布

问题:

This question already has answers here:
Closed 7 years ago.

Possible Duplicate:
Non-Standard fonts in web?

I have created a Unicode font and I would like to use it on my webpage. I want people to see and read the font. Can they do it without installing the font? Something like run the font from server?

If I remember correctly, I have seen this long time back.

回答1:

You may do this using CSS3's @font-face feature. But you have to provide the necessary font formats.

FontSquirrel's @font-face Generator is a nice web tool that does all the dirty work for you. It is very easy to use and creates all the necessary files, including CSS stylesheets and a HTML example file.

What's really valuable is that it includes all formats and hacks needed to display the font in all major browsers, something which is not so easy to get right.



回答2:

You can use @font-face

In your css you the font would be declared using the @font-face rule.You can specify the font family, specify the links to the fonts in the different formats.

@font-face {
font-family: 'MyWebFont';
src: url('webfont.eot'); /* IE9 Compat Modes */
src: url('webfont.eot?#iefix') format('embedded-opentype'), 
     url('webfont.woff') format('woff'), 
     url('webfont.ttf')  format('truetype'),
     url('webfont.svg#svgFontName') format('svg'); 
}

In your html you then call it using font-family

body 
{
   font-family: 'MyWebFont', Fallback, sans-serif;
}