标签:font-face
@font-face语法规则
@font-face {
   font-family: <YourWebFontName>;
   src: <source> [<format>][,<source> [<format>]]*;
   [font-weight: <weight>];
   [font-style: <style>];
 }
说明:
YourWebFontName:此值指的就是你自定义的字体名称,最好是使用你下载的默认字体,他将被引用到你的Web元素中的font-family。如“font-family:"YourWebFontName";”
source:此值指的是你自定义的字体的存放路径,可以是相对路径也可以是绝路径;
format:此值指的是你自定义的字体的格式,主要用来帮助浏览器识别,其值主要有以下几种类型:truetype,opentype,truetype-aat,embedded-opentype,avg等;weight和style:这两个值大家一定很熟悉,weight定义字体是否为粗体,style主要定义字体样式,如斜体。
实例:(以SingleMaltaRegular为例)
下载所需要的字体。
获得@font-face所需的.eot,.woff,.ttf,.svg字体格式字体。可以在这个网站上搞定。点击进入 (fontsquirrel)
Font Squirrel下载文件到本地的电脑上了,解压。即可得到字体。
在项目中新建文件夹fonts,讲下载字体放进去。
样式书写格式:
@font-face {
   font-family: 'SingleMaltaRegular';   
   src: url('../fonts/singlemalta-webfont.eot');  
   src: url('../fonts/singlemalta-webfont.eot?#iefix') format('embedded-opentype'),      
   url('../fonts/singlemalta-webfont.woff') format('woff'),   
   url('../fonts/singlemalta-webfont.ttf') format('truetype'),    
   url('../fonts/singlemaltawebfont.svg#SingleMaltaRegular') format('svg');   font-weight: normal;   font-style: normal;}?
最后即可引用的字体:
body{
  font-family: 'SingleMaltaRegular'
}
@font-face(css3属性)实现在网页中嵌入任意字体
标签:font-face
原文地址:http://blog.csdn.net/helpzp2008/article/details/41249127