Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
markdown_preview: Independent code font family (#56744)
Lee Nussbaum003e8211770e
diff --git a/crates/markdown/src/markdown.rs b/crates/markdown/src/markdown.rsindex 9386092ef6f..69feee416da 100644--- a/crates/markdown/src/markdown.rs+++ b/crates/markdown/src/markdown.rs@@ -179,6 +179,11 @@ impl MarkdownStyle {} else {theme_settings.ui_font.family.clone()};+ let code_font_family = if is_preview {+ theme_settings.markdown_preview_code_font_family().clone()+ } else {+ theme_settings.buffer_font.family.clone()+ };let text_color = colors.text;@@ -235,7 +240,7 @@ impl MarkdownStyle {border_color: Some(colors.border_variant),background: Some(colors.editor_background.into()),text: TextStyleRefinement {- font_family: Some(theme_settings.buffer_font.family.clone()),+ font_family: Some(code_font_family.clone()),font_fallbacks: theme_settings.buffer_font.fallbacks.clone(),font_features: Some(theme_settings.buffer_font.features.clone()),font_size: Some(buffer_font_size.into()),@@ -245,7 +250,7 @@ impl MarkdownStyle {..Default::default()},inline_code: TextStyleRefinement {- font_family: Some(theme_settings.buffer_font.family.clone()),+ font_family: Some(code_font_family),font_fallbacks: theme_settings.buffer_font.fallbacks.clone(),font_features: Some(theme_settings.buffer_font.features.clone()),font_size: Some(buffer_font_size.into()),diff --git a/crates/settings/src/vscode_import.rs b/crates/settings/src/vscode_import.rsindex 003923fdb90..62fe79683d2 100644--- a/crates/settings/src/vscode_import.rs+++ b/crates/settings/src/vscode_import.rs@@ -978,6 +978,7 @@ impl VsCodeSettings {agent_ui_font_size: None,agent_buffer_font_size: None,markdown_preview_font_family: None,+ markdown_preview_code_font_family: None,markdown_preview_theme: None,theme: None,icon_theme: None,diff --git a/crates/settings_content/src/theme.rs b/crates/settings_content/src/theme.rsindex 43cf3b36e98..4d33d0d9b9d 100644--- a/crates/settings_content/src/theme.rs+++ b/crates/settings_content/src/theme.rs@@ -152,6 +152,9 @@ pub struct ThemeSettingsContent {/// The name of a font to use for rendering in the markdown preview./// Falls back to the UI font if unset.pub markdown_preview_font_family: Option<FontFamilyName>,+ /// The name of a font to use for code (code blocks and inline code) in the+ /// markdown preview. Falls back to the buffer font if unset.+ pub markdown_preview_code_font_family: Option<FontFamilyName>,/// The theme to use for the markdown preview./// Falls back to the main editor theme if unset.pub markdown_preview_theme: Option<ThemeSelection>,diff --git a/crates/theme_settings/src/settings.rs b/crates/theme_settings/src/settings.rsindex 86432cf7b5e..c9f220a923c 100644--- a/crates/theme_settings/src/settings.rs+++ b/crates/theme_settings/src/settings.rs@@ -59,6 +59,9 @@ pub struct ThemeSettings {/// The font family to use for rendering in the markdown preview./// Falls back to the UI font family if unset.markdown_preview_font_family: Option<SharedString>,+ /// The font family to use for code in the markdown preview.+ /// Falls back to the buffer font family if unset.+ markdown_preview_code_font_family: Option<SharedString>,/// The theme to use for the markdown preview./// Falls back to the main editor theme if unset.pub markdown_preview_theme: Option<ThemeSelection>,@@ -415,6 +418,14 @@ impl ThemeSettings {.unwrap_or(&self.ui_font.family)}+ /// Returns the font family to use for code in the markdown preview,+ /// falling back to the buffer font family when unset.+ pub fn markdown_preview_code_font_family(&self) -> &SharedString {+ self.markdown_preview_code_font_family+ .as_ref()+ .unwrap_or(&self.buffer_font.family)+ }+/// Returns the buffer font size, read from the settings.////// The real buffer font size is stored in-memory, to support temporary font size changes.@@ -651,6 +662,10 @@ impl settings::Settings for ThemeSettings {.markdown_preview_font_family.as_ref().map(|f| f.0.clone().into()),+ markdown_preview_code_font_family: content+ .markdown_preview_code_font_family+ .as_ref()+ .map(|f| f.0.clone().into()),markdown_preview_theme: content.markdown_preview_theme.clone()