gpt4 book ai didi

css - Ruby on Rails webfont 不在本地显示

转载 作者:行者123 更新时间:2023-11-28 02:37:30 25 4
gpt4 key购买 nike

我使用的是 Rails 3.2.22,并使用 .woff 和 .woff2 文件安装了新字体。但是字体似乎无法仅在本地显示。在 Assets 被预编译和捆绑后,当我部署到我们的暂存环境时,字体显示正常。我还可以按照我的本地编译 CSS 用于尝试显示字体的 url,然后该链接下载正确的文件。

字体文件包含在“app/assets/fonts”文件夹中,我在我的 application.rb 中有这个

config.assets.paths << Rails.root.join("app", "assets", "fonts")

然后我像这样将字体拉入 Sass:

// Custom Font Faces
@font-face {
font-family: 'Museo Sans Rounded';
src: font-url('MuseoSansRounded-500-webfont.woff2') format('woff2'),
font-url('MuseoSansRounded-500-webfont.woff') format('woff');
font-weight: 500;
font-style: normal;
}

@font-face {
font-family: 'Museo Sans Rounded';
src: font-url('MuseoSansRounded-700-webfont.woff2') format('woff2'),
font-url('MuseoSansRounded-700-webfont.woff') format('woff');
font-weight: 700;
font-style: normal;
}

知道为什么这不在本地显示吗?

最佳答案

尝试在本地编译 Assets 。按照以下步骤操作:

配置/环境/production.rb

config.assets.compile = true

然后运行命令:

RAILS_ENV=production rake assets:precompile

并测试它。

关于css - Ruby on Rails webfont 不在本地显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47342945/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com