我在我的Scss文件中配置了一些字体,如下所示:
@font-face {
font-family: 'Icomoon';
src: asset-url('icoMoon.eot?#iefix', font) format('embedded-opentype'),
asset-url('icoMoon.woff', font) format('woff'),
asset-url('icoMoon.ttf', font) format('truetype'),
asset-url('icoMoon.svg#Icomoon', font) format('svg');
}
Run Code Online (Sandbox Code Playgroud)
实际的字体文件存储在/ app/assets/fonts /中
我已经添加config.assets.paths << Rails.root.join("app", "assets", "fonts")
到我的application.rb文件中
编译CSS源代码如下:
@font-face {
font-family: 'Icomoon';
src: url(/assets/icoMoon.eot?#iefix) format("embedded-opentype"), url(/assets/icoMoon.woff) format("woff"), url(/assets/icoMoon.ttf) format("truetype"), url(/assets/icoMoon.svg#Icomoon) format("svg");
}
Run Code Online (Sandbox Code Playgroud)
但是当我运行应用程序时,找不到字体文件.日志:
开始获取"/assets/icoMoon.ttf"为127.0.0.1在2012-06-05 23:21:17 +0100服务资产/icoMoon.ttf - 404未找到(13ms)
为什么资产管道没有将字体文件缩小为just/assets?
人们有什么想法?
亲切的问候,尼尔
额外信息:
在检查rails控制台的资产路径和assetprecompile时,我得到以下内容:
1.9.2p320 :001 > y Rails.application.config.assets.precompile
---
- !ruby/object:Proc {}
- !ruby/regexp /(?:\/|\\|\A)application\.(css|js)$/
- .svg
- .eot
- .woff
- .ttf
=> nil
1.9.2p320 :002 > …
Run Code Online (Sandbox Code Playgroud) 我想在我的rails 4 app中使用bootstrap 3.按照本教程使用此 github页面中的bootstrap saas设置bootstrap 3 .
Bootstrap工作正常,但glyphicons没有按预期工作.
某些字形根本没有显示.例如,我厌倦了在application.html.erb中显示其中一些进行测试:
glyphicon glyphicon-floppy-disk -> <span class="glyphicon glyphicon-floppy-disk"></span>
</br>
glyphicon glyphicon-plus -> <span class="glyphicon glyphicon-plus"></span>
</br>
glyphicon glyphicon-minus -> <span class="glyphicon glyphicon-minus"></span>
Run Code Online (Sandbox Code Playgroud)
图标呈现像这样
软盘图标根本不呈现(显示无效的字符)加号和减号sig不是粗体,比bootstap网站上显示的要小得多.
我也在rails控制台上看到以下消息.
Started GET "/fonts/glyphicons-halflings-regular.woff" for 127.0.0.1 at 2014-02-22 16:29:54 -0800
ActionController::RoutingError (No route matches [GET] "/fonts/glyphicons-halflings-regular.woff"):
Started GET "/fonts/glyphicons-halflings-regular.ttf" for 127.0.0.1 at 2014-02-22 16:29:54 -0800
ActionController::RoutingError (No route matches [GET] "/fonts/glyphicons-halflings-regular.ttf"):
Started GET "/fonts/glyphicons-halflings-regular.svg" for 127.0.0.1 at 2014-02-22 16:29:54 -0800
ActionController::RoutingError (No route matches …
Run Code Online (Sandbox Code Playgroud) 我无法在生产中的Rails 4应用程序中加载字体,它在开发中正常工作.
在部署时,资产在服务器上进行预编译.
我有我的字体
app/assets/fonts
我的app.css:
@font-face {
font-family: 'WalkwayBoldRegular';
src: url('Walkway_Bold-webfont.eot');
src: url('Walkway_Bold-webfont.eot?#iefix') format('embedded-opentype'),
url('Walkway_Bold-webfont.woff') format('woff'),
url('Walkway_Bold-webfont.ttf') format('truetype'),
url('Walkway_Bold-webfont.svg#WalkwayBoldRegular') format('svg');
font-weight: normal;
font-style: normal;
}
Run Code Online (Sandbox Code Playgroud)
在我的production.rb中,我有:
config.assets.precompile << Proc.new { |path|
if path =~ /\.(eot|svg|ttf|woff)\z/
true
end
}
Run Code Online (Sandbox Code Playgroud) 在Rails 3中有一个rake资产:预编译:nodigest任务,它编译资产并在/ public/assets目录中编写没有摘要部分的资源.在Rails 4中,这已被删除,默认情况下,所有资产都只使用摘要进行预编译.由于各种原因,我还需要一些资产的非消化版本.有没有简单的方法来启用旧的行为?