Asset pipeline, compass font-face and eot?iefix call to the font

非 Y 不嫁゛ 提交于 2019-11-29 09:59:30

问题


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.


回答1:


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



回答2:


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.




回答3:


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



来源:https://stackoverflow.com/questions/7699663/asset-pipeline-compass-font-face-and-eotiefix-call-to-the-font

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!