首先获取要使用字体的三种文件格式.EOT、.TTF或.OTF、.SVG,确保能在主流浏览器中都能正常显示该字体。
.EOT,适用于Internet Explorer 4.0+
.TTF或.OTF,适用于Firefox 3.五、Safari、Opera
.SVG,适用于Chrome、IPhone
最多见的是.TTF文件,咱们须要经过这种文件格式转换为其他两种文件格式。
http://www.fontsquirrel.com/fontface/generator提供的在线字体转换服务获取字体文件格式的转换。
在css中进行以下声明:css
@font-face { font-family: 'fontNameRegular'; src: url('fontName.eot'); src: local('fontName Regular'), local('fontName'), url('fontName.woff') format('woff'), url('fontName.ttf') format('truetype'), url('fontName.svg#fontName') format('svg'); } /*其中fontName替换为你的字体名称*/
在css中使用这个字体浏览器
h1{font-family: fontNameRegular}