资产管道、指南针字体和 eot?iefix 对字体的调用

发布于 2024-12-09 00:11:43 字数 255 浏览 6 评论 0原文

我正在尝试使用 Compass 字体混合,其中包含
*.eot?iefix

我的应用程序/资产/字体包含所需的所有字体类型,包括 .eot。

当我尝试运行 asset:precompile 时,任务失败,并显示如下内容: webfont.eot?iefix 未预编译

您知道此问题的可能解决方案吗?

如果我有 config.assets.compile = true,它运行不会出现错误,但据我了解,最好不要在生产中使用它。

I am trying to use a Compass font-face mixin, which contains the inclusion of
*.eot?iefix

My app/assets/fonts contains all the font types needed, including .eot.

When I try to run assets:precompile the task fails saying something like:
webfont.eot?iefix isn't precompiled

Do you know the possible solution for this problem?

It runs with no error in case I have config.assets.compile = true, but as I've understood it's better not to use it on production.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

蓬勃野心 2024-12-16 00:11:43

您也可以使用纯 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;
}

You can do it with pure Scss too:

@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;
}
忘羡 2024-12-16 00:11:43

我刚刚通过一些(支持的)技巧解决了这个问题。

我创建了一个新的 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;
}

请注意资产路径的使用以及特殊文件结尾的串联。

I've just solved this problem with a little (supported) hack.

I've created a new css file font.css.erb and place @import "font" in the place of the @font-face declaration.

@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;
}

Note the use of the asset path, and the concatenation of the special file endings.

不打扰别人 2024-12-16 00:11:43

Seems to be a known issue https://github.com/rails/rails/issues/3045
Using config.assets.compile = true for now.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文