mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FEATURE: Add site setting and wizard step to set base font (#10250)
Co-authored-by: Neil Lalonde <neillalonde@gmail.com>
This commit is contained in:
@@ -53,6 +53,8 @@ end
|
||||
|
||||
require 'pry-rails' if Rails.env.development?
|
||||
|
||||
require 'discourse_fonts'
|
||||
|
||||
if defined?(Bundler)
|
||||
bundler_groups = [:default]
|
||||
|
||||
@@ -307,6 +309,32 @@ module Discourse
|
||||
config.assets.precompile << "#{file}.js"
|
||||
end
|
||||
|
||||
# Use discourse-fonts gem to symlink fonts and generate .scss file
|
||||
fonts_path = File.join(config.root, 'public/fonts')
|
||||
Discourse::Utils.atomic_ln_s(DiscourseFonts.path_for_fonts, fonts_path)
|
||||
File.open(File.join(config.root, 'app/assets/stylesheets/common/fonts.scss'), 'w') do |file|
|
||||
DiscourseFonts.fonts.each do |font|
|
||||
file.write <<~EOF
|
||||
.font-#{font[:key].tr("_", "-")} {
|
||||
--font-family: #{font[:name]};
|
||||
font-family: #{font[:name]};
|
||||
}
|
||||
EOF
|
||||
|
||||
if font[:variants].present?
|
||||
font[:variants].each do |variant|
|
||||
file.write <<~EOF
|
||||
@font-face {
|
||||
font-family: #{font[:name]};
|
||||
src: asset-url("/fonts/#{variant[:filename]}") format("#{variant[:format]}");
|
||||
font-weight: #{variant[:weight]};
|
||||
}
|
||||
EOF
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
require_dependency 'stylesheet/manager'
|
||||
require_dependency 'svg_sprite/svg_sprite'
|
||||
|
||||
|
||||
Reference in New Issue
Block a user