feat: configurable fonts
This commit is contained in:
parent
e645dee2f0
commit
9e064e7fa0
20 changed files with 143 additions and 124 deletions
|
|
@ -145,10 +145,9 @@ impl<'a, Message: Clone + 'static> From<Button<'a, Message>> for Element<'a, Mes
|
|||
crate::widget::text(builder.label)
|
||||
.size(builder.font_size)
|
||||
.line_height(LineHeight::Absolute(builder.line_height.into()))
|
||||
.font({
|
||||
let mut font = crate::font::DEFAULT;
|
||||
font.weight = builder.font_weight;
|
||||
font
|
||||
.font(crate::font::Font {
|
||||
weight: builder.font_weight,
|
||||
..crate::font::default()
|
||||
})
|
||||
.into(),
|
||||
);
|
||||
|
|
@ -182,10 +181,9 @@ impl<'a, Message: Clone + 'static> From<Button<'a, Message>> for Element<'a, Mes
|
|||
} else {
|
||||
tooltip(button, builder.tooltip, tooltip::Position::Top)
|
||||
.size(builder.font_size)
|
||||
.font({
|
||||
let mut font = crate::font::DEFAULT;
|
||||
font.weight = builder.font_weight;
|
||||
font
|
||||
.font(crate::font::Font {
|
||||
weight: builder.font_weight,
|
||||
..crate::font::default()
|
||||
})
|
||||
.into()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -63,14 +63,14 @@ impl<'a, Message: Clone + 'static> From<Button<'a, Message>> for Element<'a, Mes
|
|||
fn from(mut builder: Button<'a, Message>) -> Element<'a, Message> {
|
||||
let button: super::Button<'a, Message> = row::with_capacity(2)
|
||||
.push({
|
||||
let mut font = crate::font::DEFAULT;
|
||||
font.weight = builder.font_weight;
|
||||
|
||||
// TODO: Avoid allocation
|
||||
crate::widget::text(builder.label.to_string())
|
||||
.size(builder.font_size)
|
||||
.line_height(LineHeight::Absolute(builder.line_height.into()))
|
||||
.font(font)
|
||||
.font(crate::font::Font {
|
||||
weight: builder.font_weight,
|
||||
..crate::font::default()
|
||||
})
|
||||
})
|
||||
.push_maybe(if builder.variant.trailing_icon {
|
||||
Some(icon().icon().size(builder.icon_size))
|
||||
|
|
@ -93,10 +93,9 @@ impl<'a, Message: Clone + 'static> From<Button<'a, Message>> for Element<'a, Mes
|
|||
} else {
|
||||
tooltip(button, builder.tooltip, tooltip::Position::Top)
|
||||
.size(builder.font_size)
|
||||
.font({
|
||||
let mut font = crate::font::DEFAULT;
|
||||
font.weight = builder.font_weight;
|
||||
font
|
||||
.font(crate::font::Font {
|
||||
weight: builder.font_weight,
|
||||
..crate::font::default()
|
||||
})
|
||||
.into()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -101,8 +101,10 @@ impl<'a, Message: Clone + 'static> From<Button<'a, Message>> for Element<'a, Mes
|
|||
});
|
||||
|
||||
let label: Option<Element<'_, _>> = (!builder.label.is_empty()).then(|| {
|
||||
let mut font = crate::font::DEFAULT;
|
||||
font.weight = builder.font_weight;
|
||||
let font = crate::font::Font {
|
||||
weight: builder.font_weight,
|
||||
..crate::font::default()
|
||||
};
|
||||
|
||||
// TODO: Avoid allocation
|
||||
crate::widget::text(builder.label.to_string())
|
||||
|
|
@ -135,10 +137,9 @@ impl<'a, Message: Clone + 'static> From<Button<'a, Message>> for Element<'a, Mes
|
|||
} else {
|
||||
tooltip(button, builder.tooltip, tooltip::Position::Top)
|
||||
.size(builder.font_size)
|
||||
.font({
|
||||
let mut font = crate::font::DEFAULT;
|
||||
font.weight = builder.font_weight;
|
||||
font
|
||||
.font(crate::font::Font {
|
||||
weight: builder.font_weight,
|
||||
..crate::font::default()
|
||||
})
|
||||
.into()
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue