问题详情:
我遇到了一个问题,即Internet Explorer 10(在Windows 7-64位下)不会加载嵌入在CSS中的@font-face
字体。相反,它显示类似"Arial"或者其他字体。我在多台设备上测试了这个问题:
- 带Internet Explorer 11的Windows 8(64位)
- 带Internet Explorer 10的Windows 8(64位)
- 带Internet Explorer 10的Windows 7(64位)
但是对于我来说,这个问题从未出现过。但奇怪的是,客户PC上的Internet Explorer 10和Windows 7出现了这个问题。
另一个奇怪的事情是,在Internet Explorer的"网络"选项卡中显示所有资源,但IE不会显示任何字体。 幸运的是,我有一个客户PC来调试这个问题。我还不能确定问题所在。
我已经采取的解决方法:
I have ensured that the path and
font-family
name is correct. I also ensured that the@font-face
command is inside the CSS file I have embeddedI tried to add the doctype from:
<!DOCTYPE html> to <!DOCTYPE html SYSTEM "about:legacy-compat">
I updated the meta tags, e.g.:
<meta http-equiv="X-UA-Compatible" content="IE=edge">
I also tried to change the order of the font-face
url
commandsI removed the
'
from the name of thefont-family
, so from:font-family: 'My font'; to font-family: My font;
I also tried to force the correct MIME of the font with a
.htaccess
file like:AddType application/vnd.ms-fontobject .eot AddType application/x-font-opentype .otf AddType image/svg+xml .svg AddType application/x-font-ttf .ttf AddType application/x-woff .woff
I also installed the website on another server to be sure this is not a server problem
I ensured that the chekboxes in Internet Explorer 10 under "Internet options" -> "Accessibility" are not checked
技术内容:
我正在使用以下方式嵌入我的CSS:
<link rel="stylesheet" type="text/css" href="assets/css/base.css">
我的@font-face
命令如下:
@font-face {
font-family: MyFont;
src: url('myPath/MyFont.eot');
src: url('myPath/MyFont.eot?#iefix') format('embedded-opentype'),
url('myPath/MyFont.woff') format('woff'),
url('myPath/MyFont.ttf') format('truetype'),
url('myPath/MyFont.svg#myfont') format('svg');
font-style: normal;
font-weight : normal;
}
// 编辑: 我想指出CSS字体通常是有效的。但不幸的是,在这个网站上无效。
@font-face
都被禁用了。但事实并非如此。因此,我认为这并不能解决问题。 - dude