IE很奇怪。我查看了 MIME 类型,添加了一个.htaccess
文件
<FilesMatch "\.(ttf|otf|eot|woff)$">
<IfModule mod_headers.c>
Header set Access-Control-Allow-Origin "*"
</IfModule>
</FilesMatch>
AddType application/vnd.ms-fontobject .eot
AddType application/octet-stream .otf .ttf
而 IE9 开发者工具似乎已经注意到它已经到位但又没有任何变化。该网站目前处于离线状态(仅在硬盘驱动器上查看)-尽管当它上传到不同的服务器时它仍然无法正常工作-所有 Javascript 和样式表都从head
标签内链接。都好。
字体根本没有正确导入。
我在开发者控制台中收到一条错误消息:
CSS3117: @font-face failed cross-origin request. Resource access is restricted.
vitesse-bold.eot?#iefix
CSS3117: @font-face failed cross-origin request. Resource access is restricted.
vitesse-bold.woff
CSS3117: @font-face failed cross-origin request. Resource access is restricted.
vitesse-bold.ttf
我已经对此进行了大量研究,并且我了解文档类型可能会阻碍这一点。我正在使用 UTF-8,其中 css 以开头,@charset "UTF-8";
而我的 HTML 文件也以:
<!DOCTYPE HTML>
<html lang="en">
<head>
<meta charset="UTF-8">
我认为这与字体转换有关,但如果是这样的话,当您从托管服务器直接查看网站时,字体首先在 IE 中不起作用。
关于如何解决这个问题的任何想法?
同样在 IE 7 和 8 中,他们只使用 EOT 文件,我得到一个不同的错误:
CSS3111: @font-face encountered unknown error.
vitesse-bold.eot
字体目录.htaccess:
<FilesMatch "\.(ttf|otf|eot|woff)$">
<IfModule mod_headers.c>
Header set Access-Control-Allow-Origin "*"
</IfModule>
</FilesMatch>
AddType application/vnd.ms-fontobject .eot
AddType application/octet-stream .otf .ttf
主网站.htaccess:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
CSS字体导入:
@font-face {
font-family:'Vitesse-Bold';
src:url('../includes/fonts/vitesse-bold.eot');
src:url('../includes/fonts/vitesse-bold.eot?#iefix') format('embedded-opentype'),
url('../includes/fonts/vitesse-bold.woff') format('woff'),
url('../includes/fonts/vitesse-bold.ttf') format('truetype'),
url('../includes/fonts/vitesse-bold.svg#vitesse-bold') format('svg');
font-weight:normal;
font-style:normal;
}
@font-face {
font-family:'Flama-Bold';
src:url('../includes/fonts/flama-bold.eot');
src:url('../includes/fonts/flama-bold.eot?#iefix') format('embedded-opentype'),
url('../includes/fonts/flama-bold.woff') format('woff'),
url('../includes/fonts/flama-bold.ttf') format('truetype'),
url('../includes/fonts/flama-bold.svg#flama-bold') format('svg');
font-weight:normal;
font-style:normal;
}
截图:
http://www.titaniumwebdesigns.com/forums/screenshot-a.jpg
字体导入src:url('../includes/fonts/font.eot');
http://www.titaniumwebdesigns.com/forums/screenshot-b.jpg
字体导入src:url('http://sub-domain.domain.com/includes/fonts/font.eot');
http://www.titaniumwebdesigns.com/forums/screenshot-c.jpg
字体导入src:url('http://www.sub-domain.domain.com/includes/fonts/font.eot');
不确定 IE 用这两种字体创建两种字体发生了什么http://www.
,http://
但它现在似乎已经停止工作。