improv: switch to Open Sans and Noto Sans Mono, with tweaked text styles

This commit is contained in:
Michael Aaron Murphy 2025-02-18 22:25:40 +01:00 committed by Michael Murphy
parent 3f25af87a3
commit 7d84d21129
18 changed files with 206 additions and 72 deletions

View file

@ -1019,11 +1019,13 @@ fn single_instance_subscription<App: ApplicationExt>() -> Subscription<Message<A
}
const EMBEDDED_FONTS: &[&[u8]] = &[
include_bytes!("../../res/Fira/FiraSans-Light.otf"),
include_bytes!("../../res/Fira/FiraSans-Regular.otf"),
include_bytes!("../../res/Fira/FiraSans-SemiBold.otf"),
include_bytes!("../../res/Fira/FiraSans-Bold.otf"),
include_bytes!("../../res/Fira/FiraMono-Regular.otf"),
include_bytes!("../../res/open-sans/OpenSans-Light.ttf"),
include_bytes!("../../res/open-sans/OpenSans-Regular.ttf"),
include_bytes!("../../res/open-sans/OpenSans-Semibold.ttf"),
include_bytes!("../../res/open-sans/OpenSans-Bold.ttf"),
include_bytes!("../../res/open-sans/OpenSans-ExtraBold.ttf"),
include_bytes!("../../res/noto/NotoSansMono-Regular.ttf"),
include_bytes!("../../res/noto/NotoSansMono-Bold.ttf"),
];
fn preload_fonts() {

View file

@ -13,8 +13,8 @@ use std::sync::{LazyLock, Mutex, RwLock};
/// ID for the `CosmicTk` config.
pub const ID: &str = "com.system76.CosmicTk";
const MONO_FAMILY_DEFAULT: &str = "Fira Mono";
const SANS_FAMILY_DEFAULT: &str = "Fira Sans";
const MONO_FAMILY_DEFAULT: &str = "Noto Sans Mono";
const SANS_FAMILY_DEFAULT: &str = "Open Sans";
/// Stores static strings of the family names for `iced::Font` compatibility.
pub static FAMILY_MAP: LazyLock<Mutex<BTreeSet<&'static str>>> = LazyLock::new(|| Mutex::default());

View file

@ -27,48 +27,48 @@ pub enum Typography {
/// [`Text`] widget with the Title 1 typography preset.
pub fn title1<'a>(text: impl Into<Cow<'a, str>> + 'a) -> Text<'a, crate::Theme, Renderer> {
Text::new(text.into())
.size(32.0)
.line_height(LineHeight::Absolute(44.0.into()))
.font(crate::font::light())
.size(35.0)
.line_height(LineHeight::Absolute(52.0.into()))
.font(crate::font::semibold())
}
/// [`Text`] widget with the Title 2 typography preset.
pub fn title2<'a>(text: impl Into<Cow<'a, str>> + 'a) -> Text<'a, crate::Theme, Renderer> {
Text::new(text.into())
.size(28.0)
.line_height(LineHeight::Absolute(36.0.into()))
.font(crate::font::default())
.size(29.0)
.line_height(LineHeight::Absolute(43.0.into()))
.font(crate::font::semibold())
}
/// [`Text`] widget with the Title 3 typography preset.
pub fn title3<'a>(text: impl Into<Cow<'a, str>> + 'a) -> Text<'a, crate::Theme, Renderer> {
Text::new(text.into())
.size(24.0)
.line_height(LineHeight::Absolute(32.0.into()))
.font(crate::font::default())
.line_height(LineHeight::Absolute(36.0.into()))
.font(crate::font::bold())
}
/// [`Text`] widget with the Title 4 typography preset.
pub fn title4<'a>(text: impl Into<Cow<'a, str>> + 'a) -> Text<'a, crate::Theme, Renderer> {
Text::new(text.into())
.size(20.0)
.line_height(LineHeight::Absolute(28.0.into()))
.font(crate::font::default())
.line_height(LineHeight::Absolute(30.0.into()))
.font(crate::font::bold())
}
/// [`Text`] widget with the Heading typography preset.
pub fn heading<'a>(text: impl Into<Cow<'a, str>> + 'a) -> Text<'a, crate::Theme, Renderer> {
Text::new(text.into())
.size(14.0)
.line_height(LineHeight::Absolute(iced::Pixels(20.0)))
.font(crate::font::semibold())
.line_height(LineHeight::Absolute(iced::Pixels(21.0)))
.font(crate::font::bold())
}
/// [`Text`] widget with the Caption Heading typography preset.
pub fn caption_heading<'a>(text: impl Into<Cow<'a, str>> + 'a) -> Text<'a, crate::Theme, Renderer> {
Text::new(text.into())
.size(10.0)
.line_height(LineHeight::Absolute(iced::Pixels(14.0)))
.size(12.0)
.line_height(LineHeight::Absolute(iced::Pixels(17.0)))
.font(crate::font::semibold())
}
@ -76,15 +76,15 @@ pub fn caption_heading<'a>(text: impl Into<Cow<'a, str>> + 'a) -> Text<'a, crate
pub fn body<'a>(text: impl Into<Cow<'a, str>> + 'a) -> Text<'a, crate::Theme, Renderer> {
Text::new(text.into())
.size(14.0)
.line_height(LineHeight::Absolute(20.0.into()))
.line_height(LineHeight::Absolute(21.0.into()))
.font(crate::font::default())
}
/// [`Text`] widget with the Caption typography preset.
pub fn caption<'a>(text: impl Into<Cow<'a, str>> + 'a) -> Text<'a, crate::Theme, Renderer> {
Text::new(text.into())
.size(10.0)
.line_height(LineHeight::Absolute(14.0.into()))
.size(12.0)
.line_height(LineHeight::Absolute(17.0.into()))
.font(crate::font::default())
}