在开发模式下,自定义字体(Raleway)存在,但在暂存环境中没有反映。我将我的应用部署到了Heroku。
在application.rb中添加了以下命令。
我使用命令
config.assets.paths << Rails.root.join('app', 'assets', 'fonts')
在application.bootstrap.scss中添加了font-family。
@font-face {
font-family: 'raleway-regular';
font-style: normal;
font-weight: 400;
src: font-url('raleway-regular.ttf') format('truetype');
}
@font-face {
font-family: 'raleway-semibold';
src: font-url('raleway-semibold.ttf') format('truetype');
}
@font-face {
font-family: 'raleway-medium';
src: font-url('raleway-Medium.ttf') format('truetype');
}
my_app/app/assets/fonts
目录下提供字体文件。我使用命令
rails new my_app --javascript esbuild --css bootstrap --database postgresql
创建了我的 Rails 应用程序。
Rails 版本为 7。