Jak*_*Jak 5 routing ruby-on-rails rails-routing embedded-fonts
在我的rails(2.x)应用程序中.我想在我的视图中使用自定义字体.所以我在fonts文件夹下的public中添加了字体文件.当我尝试在url中或通过应用程序获取字体时,它会通过路由错误.我猜rails路由无法识别格式/文件.如果我错了,请纠正我并给我解决方案
css代码:
@font-face {
font-family: 'Effra';
src: url('/fonts/effra_std_rg-webfont.eot');
src: url('/fonts/effra_std_rg-webfont.eot?#iefix') format('embedded-opentype'),
url('/fonts/effra_std_rg-webfont.woff') format('woff'),
url('/fonts/effra_std_rg-webfont.ttf') format('truetype'),
url('/fonts/effra_std_rg-webfont.svg#EffraRegular') format('svg');
font-weight: normal;
font-style: normal;
}
Run Code Online (Sandbox Code Playgroud)
注意:我可以通过直接键入路径而不是eot文件来获取woff,ttf文件.
Error trace:
Unknown action
No action responded to fonts. Actions: XXXXXXsomeactionsXXXXX and rescue_404
Run Code Online (Sandbox Code Playgroud)
先谢谢,阿伦.
我通过将字体文件夹移动到 public/stylesheets/fonts 下解决了上述问题。并将上面的代码制作如下。
font-face {
font-family: 'Effra';
src: url('fonts/effra_std_rg-webfont.eot');
src: url('fonts/effra_std_rg-webfont.eot?#iefix') format('embedded-opentype'),
url('fonts/effra_std_rg-webfont.woff') format('woff'),
url('fonts/effra_std_rg-webfont.ttf') format('truetype'),
url('fonts/effra_std_rg-webfont.svg#EffraRegular') format('svg');
font-weight: normal;
font-style: normal;
}
Run Code Online (Sandbox Code Playgroud)
希望这对其他人有帮助。
| 归档时间: |
|
| 查看次数: |
647 次 |
| 最近记录: |