mirror of
https://github.com/discourse/discourse.git
synced 2025-06-02 16:29:32 +08:00
FEATURE: when rich-editor is enabled use Jetbrains Mono as code font (#32122)
This change forces consistency around code font in Discourse once the new rich-editor is enabled - This means all code blocks in Discourse will render with this font - Additionally the markdown mode composer will render with this font Additionally we make 3 small adjustments: 1. We disable ligatures which conflict with typographer 2. We add support for custom ligature settings 3. We adjust down font size, cause 14px ends up matching visually with a 16px non monospace font, this change is already in place previously on posts Example: 
This commit is contained in:
@ -64,9 +64,31 @@ module Stylesheet
|
||||
|
||||
CSS
|
||||
|
||||
if SiteSetting.rich_editor
|
||||
contents << <<~CSS
|
||||
#{font_css(jetbrains_mono)}
|
||||
#{render_font_special_properties(jetbrains_mono, "body")}
|
||||
:root {
|
||||
--d-font-family--monospace: #{jetbrains_mono[:stack]};
|
||||
}
|
||||
|
||||
CSS
|
||||
else
|
||||
contents << <<~CSS
|
||||
:root {
|
||||
--d-font-family--monospace: ui-monospace, "Cascadia Mono", "Segoe UI Mono", "Liberation Mono", menlo, monaco, consolas, monospace;
|
||||
}
|
||||
|
||||
CSS
|
||||
end
|
||||
|
||||
contents
|
||||
end
|
||||
|
||||
def jetbrains_mono
|
||||
@@jetbrains_mono ||= DiscourseFonts.fonts.find { |f| f[:key] == "jet_brains_mono" }
|
||||
end
|
||||
|
||||
def wizard_fonts
|
||||
contents = +""
|
||||
|
||||
@ -262,6 +284,12 @@ module Stylesheet
|
||||
else
|
||||
contents << "#{" " * indent}font-feature-settings: normal;\n"
|
||||
end
|
||||
|
||||
# avoiding adding normal to the CSS cause it is not needed in this case
|
||||
if font[:font_variant_ligatures].present?
|
||||
contents << "#{" " * indent}font-variant-ligatures: #{font[:font_variant_ligatures]};\n"
|
||||
end
|
||||
|
||||
contents
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user