【发布时间】:2019-07-22 18:28:13
【问题描述】:
我想将自定义字体集成到我的 Ruby on Rails 应用程序中。我的文字是西里尔文字。我从谷歌字体下载了一种特殊的西里尔字体。在学习了一些教程之后,我仍然遇到了同样的问题:应用程序正常工作(本地主机加载没有错误),但文字中的字体没有改变。
这是我的文件夹的样子:
-app
--assets
---fonts
----Oswald-Regular.ttf
---stylesheets
----application.css
----styles.scss
这是我的 config/application.rb 的样子:
require_relative 'boot'
require 'rails/all'
# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)
module Signup
class Application < Rails::Application
# Initialize configuration defaults for originally generated Rails version.
config.load_defaults 5.2
config.assets.paths << Rails.root.join('app', 'assets', 'fonts')
# Settings in config/environments/* take precedence over those specified here.
# Application configuration can go into files in config/initializers
# -- all .rb files in that directory are automatically loaded after loading
# the framework and any gems in your application.
end
end
这是我的 application.css 的样子:
h1{
font-family:"Oswald";
}
这是我的 styles.scss 的样子:
@font-face {
font-family: "Oswald";
src: url("assets/fonts/Oswald-Regular.ttf") format("truetype");
}
虽然没有错误消息,但我仍然不明白我可以添加什么来使我的应用正常运行...
【问题讨论】:
标签: css ruby-on-rails fonts ruby-on-rails-5