From 12073e10f8dea478a58a4d166d720ca363bd162a Mon Sep 17 00:00:00 2001 From: Dino Date: Fri, 12 Dec 2025 09:55:06 +0000 Subject: [PATCH] Fix missing buffer font features in Blame UI, Hover Popover and Markdown Preview (#44657) - Fix missing font features in `git_ui::blame_ui::GitBlameRenderer.render_blame_entry` - Fix missing buffer font features in `markdown_preview::markdown_renderer` - Update the way that the markdown style is built for hover popovers so that, for code blocks, the buffer font features are used. - Introduce `gpui::Styled.font_features` to allow callers to also set the font's features, similar to how `gpui::Styled.font_family` already exists. Relates to #44209 Release Notes: - Fixed wrong font features in Blame UI, Hover Popover and Markdown Preview --- crates/editor/src/hover_popover.rs | 5 ++++- crates/git_ui/src/blame_ui.rs | 2 +- crates/gpui/src/styled.rs | 15 ++++++++++++--- crates/markdown_preview/src/markdown_renderer.rs | 10 +++++++++- 4 files changed, 26 insertions(+), 6 deletions(-) diff --git a/crates/editor/src/hover_popover.rs b/crates/editor/src/hover_popover.rs index 9ef54139d39ece6e9414d8fee3c7a75c9a89036d..edf10671b9e4c63e2918f6e144ba1b553e44daca 100644 --- a/crates/editor/src/hover_popover.rs +++ b/crates/editor/src/hover_popover.rs @@ -623,7 +623,10 @@ pub fn hover_markdown_style(window: &Window, cx: &App) -> MarkdownStyle { }); MarkdownStyle { base_text_style, - code_block: StyleRefinement::default().my(rems(1.)).font_buffer(cx), + code_block: StyleRefinement::default() + .my(rems(1.)) + .font_buffer(cx) + .font_features(buffer_font_features.clone()), inline_code: TextStyleRefinement { background_color: Some(cx.theme().colors().background), font_family: Some(buffer_font_family), diff --git a/crates/git_ui/src/blame_ui.rs b/crates/git_ui/src/blame_ui.rs index fe9af196021e01edd406c9ced86e0465b7e70984..f67d426ff3bf23df7e32af7aae109ad78642a674 100644 --- a/crates/git_ui/src/blame_ui.rs +++ b/crates/git_ui/src/blame_ui.rs @@ -65,7 +65,7 @@ impl BlameRenderer for GitBlameRenderer { .w_full() .gap_2() .justify_between() - .font_family(style.font().family) + .font(style.font()) .line_height(style.line_height) .text_color(cx.theme().status().hint) .child( diff --git a/crates/gpui/src/styled.rs b/crates/gpui/src/styled.rs index b50432d332f7e26fdd4528c1644be3c9761b6ad0..752038c1ed63a1d0d5960bf0a74a1c2fdbc43392 100644 --- a/crates/gpui/src/styled.rs +++ b/crates/gpui/src/styled.rs @@ -1,8 +1,9 @@ use crate::{ self as gpui, AbsoluteLength, AlignContent, AlignItems, BorderStyle, CursorStyle, - DefiniteLength, Display, Fill, FlexDirection, FlexWrap, Font, FontStyle, FontWeight, - GridPlacement, Hsla, JustifyContent, Length, SharedString, StrikethroughStyle, StyleRefinement, - TextAlign, TextOverflow, TextStyleRefinement, UnderlineStyle, WhiteSpace, px, relative, rems, + DefiniteLength, Display, Fill, FlexDirection, FlexWrap, Font, FontFeatures, FontStyle, + FontWeight, GridPlacement, Hsla, JustifyContent, Length, SharedString, StrikethroughStyle, + StyleRefinement, TextAlign, TextOverflow, TextStyleRefinement, UnderlineStyle, WhiteSpace, px, + relative, rems, }; pub use gpui_macros::{ border_style_methods, box_shadow_style_methods, cursor_style_methods, margin_style_methods, @@ -630,6 +631,14 @@ pub trait Styled: Sized { self } + /// Sets the font features of this element and its children. + fn font_features(mut self, features: FontFeatures) -> Self { + self.text_style() + .get_or_insert_with(Default::default) + .font_features = Some(features); + self + } + /// Sets the font of this element and its children. fn font(mut self, font: Font) -> Self { let Font { diff --git a/crates/markdown_preview/src/markdown_renderer.rs b/crates/markdown_preview/src/markdown_renderer.rs index d9997b54274d53e4897b3a3810629054e5458275..336f1cacfd2e3d7c25e19aeaf328b1c10db10b30 100644 --- a/crates/markdown_preview/src/markdown_renderer.rs +++ b/crates/markdown_preview/src/markdown_renderer.rs @@ -75,8 +75,10 @@ impl RenderContext { let settings = ThemeSettings::get_global(cx); let buffer_font_family = settings.buffer_font.family.clone(); + let buffer_font_features = settings.buffer_font.features.clone(); let mut buffer_text_style = window.text_style(); buffer_text_style.font_family = buffer_font_family.clone(); + buffer_text_style.font_features = buffer_font_features; buffer_text_style.font_size = AbsoluteLength::from(settings.buffer_font_size(cx)); RenderContext { @@ -631,8 +633,14 @@ fn render_markdown_code_block( .tooltip(Tooltip::text("Copy code block")) .visible_on_hover("markdown-block"); + let font = gpui::Font { + family: cx.buffer_font_family.clone(), + features: cx.buffer_text_style.font_features.clone(), + ..Default::default() + }; + cx.with_common_p(div()) - .font_family(cx.buffer_font_family.clone()) + .font(font) .px_3() .py_3() .bg(cx.code_block_background_color)