【发布时间】:2019-04-03 18:39:52
【问题描述】:
我正在尝试让Playlist font 在我的 Rails 应用程序上工作。它显示在本地主机上,但不在 Heroku 上。
我在我的assets 文件夹中添加了一个fonts 文件夹,将PlaylistCaps.otf 和PlaylistScript.otf 文件放入其中,并将这一行添加到我的config/application.rb:
config.assets.paths << Rails.root.join("app","assets","fonts")
我的application.scss 文件中有这个:
@font-face {
font-family: "PlaylistScript";
src: url(/assets/fonts/PlaylistScript.otf) format("opentype");
}
@font-face {
font-family: "PlaylistCaps";
src: url(/assets/fonts/PlaylistCaps.otf) format("opentype");
}
我也尝试过将源文件放在 S3 上并将其链接到 src: url() 但无济于事......
我检查以确保 Heroku 在部署时预编译了我的资产(我不单独进行)。
谁能帮我解决这个问题?我的现场网站目前正在显示那个糟糕的样板草书。我查阅了许多 SO 帖子(here、here、here)和一些要点(如this),但找不到可行的解决方案。
如果你想四处逛逛,直播网站是here。
更新
我在scss 中添加了一个谷歌字体备份选项以避免草书默认值。它仍然没有显示正确的字体,但至少它不会在页面加载时因为丑陋而让你眼花缭乱:
$font-script: 'PlaylistScript', 'Arizonia', cursive;
【问题讨论】:
-
你在用git吗?我假设 heroku 是这样,所以从 Rails 根目录运行
git ls-files --error-unmatch app/assets/fonts/PlaylistCaps.otf。只是想确保它已被添加到您的 git 存储库中。 -
@NathanKontny 它回来了
app/assets/fonts/PlaylistCaps.otf。
标签: ruby-on-rails heroku