feat: configurable fonts
This commit is contained in:
parent
e645dee2f0
commit
9e064e7fa0
20 changed files with 143 additions and 124 deletions
|
|
@ -459,7 +459,7 @@ impl<'a, S: AsRef<str>, Message> Widget<Message, crate::Theme, crate::Renderer>
|
|||
},
|
||||
);
|
||||
|
||||
(appearance.selected_text_color, crate::font::FONT_SEMIBOLD)
|
||||
(appearance.selected_text_color, crate::font::semibold())
|
||||
} else if *self.hovered_option == Some(i) {
|
||||
let item_x = bounds.x + appearance.border_width;
|
||||
let item_width = appearance.border_width.mul_add(-2.0, bounds.width);
|
||||
|
|
@ -480,9 +480,9 @@ impl<'a, S: AsRef<str>, Message> Widget<Message, crate::Theme, crate::Renderer>
|
|||
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 {
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ impl<'a, S: AsRef<str>, Message> Dropdown<'a, S, Message> {
|
|||
size: iced::Pixels(self.text_size.unwrap_or(14.0)),
|
||||
|
||||
line_height: self.text_line_height,
|
||||
font: self.font.unwrap_or(crate::font::FONT),
|
||||
font: self.font.unwrap_or_else(crate::font::default),
|
||||
horizontal_alignment: alignment::Horizontal::Left,
|
||||
vertical_alignment: alignment::Vertical::Top,
|
||||
shaping: text::Shaping::Advanced,
|
||||
|
|
@ -113,7 +113,7 @@ impl<'a, S: AsRef<str>, Message: 'a> Widget<Message, crate::Theme, crate::Render
|
|||
size: iced::Pixels(self.text_size.unwrap_or(14.0)),
|
||||
|
||||
line_height: self.text_line_height,
|
||||
font: self.font.unwrap_or(crate::font::FONT),
|
||||
font: self.font.unwrap_or_else(crate::font::default),
|
||||
horizontal_alignment: alignment::Horizontal::Left,
|
||||
vertical_alignment: alignment::Vertical::Top,
|
||||
shaping: text::Shaping::Advanced,
|
||||
|
|
@ -194,9 +194,7 @@ impl<'a, S: AsRef<str>, Message: 'a> Widget<Message, crate::Theme, crate::Render
|
|||
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,
|
||||
theme,
|
||||
|
|
@ -308,7 +306,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,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue