我正在使用指南针'font-face
与inline-font-files
and font-files
为了创造一些沿着新的 Bulletproof @Font-Face 语法 http://www.fontspring.com/blog/the-new-bulletproof-font-face-syntax using 数据 URI http://en.wikipedia.org/wiki/Data_URI_scheme适用于 woff、ttf 和 otf 文件。
我对 eot 使用相对 URL(由于 IE 缺乏对数据 URI 的支持)和 svg 文件(由于我猜是 #FontName 哈希)。 eot 文件不会造成任何问题,因为有一个参数,但是因为font-face
在 Compass 中,svg 与其他格式没有什么不同,我根本无法使用inline-font-files
包含字体数据,因为这也会使 svg 版本内联。
有没有办法制作font-face
返回如下内容:
@font-face {
font-family: 'PTSans';
src: url('pts55fwebfont.eot');
src: url('pts55fwebfont.eot?#iefix') format('embedded-opentype'),
url('data:WOFF_DATA') format('woff'),
url('data:TTF_DATA') format('truetype'),
url('pts55fwebfont.svg#PTSansRegular') format('svg');
font-weight: normal;
font-style: normal;
}
问题是我不知道如何使 woff、otf 和 ttf 版本使用数据 URI,同时仍然允许 svg 版本使用标准 URL。我想出的最好的办法是:
@include font-face('PTSans', inline-font-files('ptsans/pts55fwebfont.woff', woff, 'ptsans/pts55fwebfont.ttf', truetype), 'ptsans/pts55fwebfont.eot', normal, normal);
@include font-face('PTSans', font-files('ptsans/pts55fwebfont.svg#PTSansRegular'), $weight: normal, $style: normal);
这会将 svg 分解成它自己的@font-face。同一帐户上的 CSS 是否有效,我可以使用不同的粗细和样式创建具有相同姓氏的多个 @font-face 规则?如果是这样的话,它会像上面的 CSS 示例一样有效吗(看起来是这样)?当然,在 Compass/sass 中是否有更好的方法来实现这一点?