gpui: Impl Default for TextRun (#41084)

Release Notes:

- N/A

When I was implementing Input, I often used `TextRun`, but `background`,
`underline` and `strikethrough` were often not used.

So make change to simplify it.
This commit is contained in:
Jason Lee
2025-11-06 01:50:23 +00:00
committed by GitHub
parent 622d626a29
commit 64c8c19e1b
5 changed files with 27 additions and 62 deletions
+7 -1
View File
@@ -739,7 +739,7 @@ impl Display for FontStyle {
}
/// A styled run of text, for use in [`crate::TextLayout`].
#[derive(Clone, Debug, PartialEq, Eq)]
#[derive(Clone, Debug, PartialEq, Eq, Default)]
pub struct TextRun {
/// A number of utf8 bytes
pub len: usize,
@@ -813,6 +813,12 @@ pub struct Font {
pub style: FontStyle,
}
impl Default for Font {
fn default() -> Self {
font(".SystemUIFont")
}
}
/// Get a [`Font`] for a given name.
pub fn font(family: impl Into<SharedString>) -> Font {
Font {