简体   繁体   English

@ font-face无法在客户端站点上运行?

[英]@font-face not working on a client site?

This is CSS code 这是CSS代码

@font-face {
    font-family: 'FuturaStdBook';
    src: url('site/font-face/futurastd-medium-webfont.eot');
    src: local('☺'), url('site/font-face/futurastd-medium-webfont.woff') format('woff'), url('site/font-face/futurastd-medium-webfont.ttf') format('truetype'), url('site/font-face/futurastd-medium-webfont.svg#webfont') format('svg');
    font-weight: normal;
    font-style: normal;
}

h2 {font-family:'FuturaStdBook', sans-serif}

Can it be related to mime type? 它可以与哑剧类型有关吗?

How can i ensure my path is right? 我怎样才能确保自己的道路正确?

If you're using IIS, you'll need to register a MIME type for the .eot extension. 如果您使用的是IIS,则需要为.eot扩展名注册MIME类型。

  1. In IIS Manager, in the IIS section, open the MIME Types configuration 在IIS管理器的IIS部分中,打开MIME类型配置
  2. Under "Actions", click "Add..." 在“操作”下,点击“添加...”
  3. Enter .otf in the extension box, and application/octet-stream in the MIME type box. 在扩展名框中输入.otf ,在MIME类型框中输入application/octet-stream
  4. Click OK 单击确定

You'll need to do this for each non-standard extension you use ( .ttf is already registered, .woff is not), but that should do it! 您需要为您使用的每个非标准扩展( .ttf已经注册, .woff不是)执行此操作,但是应该这样做!

尝试使用Font Squirrel为您的自定义字体获取防弹CSS声明。

The problem are the definitions of font-weight and font-style in your font-face declaration. 问题是font-face声明中font-weightfont-style的定义。 Since h2 elements are defined in a bold face by default, the font-face declaration is not taken into account for these elements (because the browser thinks, the font file is for normal weighted weight only, which is most probably true). 由于h2元素默认以粗体定义,因此不考虑这些元素的font-face声明(因为浏览器认为,字体文件仅用于正常加权权重,这很可能是真的)。

Solution: You need a second font-face declaration with font-weight: bold in it or you set h2 elements to have font-weight:normal and font-style: normal . 解决方案:您需要使用font-weight: bold的第二个font-face声明, 或者将h2元素设置为font-weight:normalfont-style: normal

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM