feat: configurable fonts

This commit is contained in:
Michael Aaron Murphy 2024-10-03 21:27:06 +02:00 committed by Michael Murphy
parent e645dee2f0
commit 9e064e7fa0
20 changed files with 143 additions and 124 deletions

View file

@ -549,7 +549,7 @@ where
},
);
(appearance.selected_text_color, crate::font::FONT_SEMIBOLD)
(appearance.selected_text_color, crate::font::semibold())
} else if self.hovered_option.as_ref() == Some(item) {
let item_x = bounds.x + appearance.border_width;
let item_width = bounds.width - appearance.border_width * 2.0;
@ -572,9 +572,9 @@ where
appearance.hovered_background,
);
(appearance.hovered_text_color, crate::font::FONT)
(appearance.hovered_text_color, crate::font::default())
} else {
(appearance.text_color, crate::font::FONT)
(appearance.text_color, crate::font::default())
};
let bounds = Rectangle {
@ -640,7 +640,7 @@ where
bounds: bounds.size(),
size: iced::Pixels(text_size),
line_height: text::LineHeight::Absolute(Pixels(text_line_height + 4.0)),
font: crate::font::FONT,
font: crate::font::default(),
horizontal_alignment: alignment::Horizontal::Center,
vertical_alignment: alignment::Vertical::Center,
shaping: text::Shaping::Advanced,

View file

@ -156,9 +156,7 @@ impl<'a, S: AsRef<str>, Message: 'a, Item: Clone + PartialEq + 'static>
cursor: mouse::Cursor,
viewport: &Rectangle,
) {
let font = self
.font
.unwrap_or_else(|| text::Renderer::default_font(renderer));
let font = self.font.unwrap_or_else(|| crate::font::default());
draw(
renderer,
@ -275,7 +273,7 @@ pub fn layout(
bounds: Size::new(f32::MAX, f32::MAX),
size: iced::Pixels(text_size),
line_height: text_line_height,
font: font.unwrap_or_else(|| text::Renderer::default_font(renderer)),
font: font.unwrap_or_else(|| crate::font::default()),
horizontal_alignment: alignment::Horizontal::Left,
vertical_alignment: alignment::Vertical::Top,
shaping: text::Shaping::Advanced,
@ -418,7 +416,7 @@ pub fn overlay<'a, S: AsRef<str>, Message: 'a, Item: Clone + PartialEq + 'static
bounds: Size::new(f32::MAX, f32::MAX),
size: iced::Pixels(text_size),
line_height,
font: font.unwrap_or_else(|| text::Renderer::default_font(renderer)),
font: font.unwrap_or_else(|| crate::font::default()),
horizontal_alignment: alignment::Horizontal::Left,
vertical_alignment: alignment::Vertical::Top,
shaping: text::Shaping::Advanced,