5

我正在尝试使用 Compass font-face mixin,其中包含
*.eot?iefix

我的 app/assets/fonts 包含所有需要的字体类型,包括 .eot。

当我尝试运行 assets:precompile 任务失败时说: webfont.eot?iefix is not precompiled

你知道这个问题的可能解决方案吗?

如果我有 config.assets.compile = true,它运行没有错误,但据我所知,最好不要在生产中使用它。

4

3 回答 3

10

你也可以用纯Scss做到这一点:

@font-face {
  font-family: 'DroidSans';
  src: url(font-path('DroidSans-webfont.eot'));
  src: url(font-path('DroidSans-webfont.eot') + '?#iefix') format('embedded-opentype'),
       url(font-path('DroidSans-webfont.woff')) format('woff'),
       url(font-path('DroidSans-webfont.ttf')) format('truetype'),
       url(font-path('DroidSans-webfont.svg') + '#DroidSansRegular') format('svg');
  font-weight: normal;
  font-style: normal;
}
于 2011-11-23T14:58:28.463 回答
4

我刚刚用一点(受支持的)hack 解决了这个问题。

我创建了一个新的 css 文件font.css.erb并放置@import "font"@font-face声明的位置。

@font-face {
    font-family: 'SketchBlockBold';
    src: font_url('font/sketch_block-webfont.eot');
    src: url('<%= asset_path('font/sketch_block-webfont.eot')+"?#iefix" %>') format('embedded-opentype'),
         font_url('font/sketch_block-webfont.woff') format('woff'),
         font_url('font/sketch_block-webfont.ttf') format('truetype'),
         url('<%= asset_path('font/sketch_block-webfont.svg')+"#SketchBlockBold" %>') format('svg');
    font-weight: normal;
    font-style: normal;
}

注意资产路径的使用,以及特殊文件结尾的连接。

于 2011-10-12T13:04:22.663 回答
1

似乎是一个已知问题https://github.com/rails/rails/issues/3045 目前使用 config.assets.compile = true。

于 2011-10-10T11:37:13.767 回答