Overhaul Font type to allow font family selection

This commit is contained in:
Héctor Ramón Jiménez 2023-02-04 07:33:33 +01:00
parent a7580e0696
commit b29de28d1f
No known key found for this signature in database
GPG key ID: 140CC052C94F138E
25 changed files with 147 additions and 256 deletions

View file

@ -31,6 +31,9 @@ pub trait Text {
/// [`ICON_FONT`]: Self::ICON_FONT
const ARROW_DOWN_ICON: char;
/// Returns the default [`Font`].
fn default_font(&self) -> Font;
/// Returns the default size of text.
fn default_size(&self) -> f32;

View file

@ -63,7 +63,7 @@ impl<'a> Layer<'a> {
),
color: Color::new(0.9, 0.9, 0.9, 1.0),
size: 20.0,
font: Font::Default,
font: Font::Monospace,
horizontal_alignment: alignment::Horizontal::Left,
vertical_alignment: alignment::Vertical::Top,
};

View file

@ -130,6 +130,10 @@ where
const CHECKMARK_ICON: char = B::CHECKMARK_ICON;
const ARROW_DOWN_ICON: char = B::ARROW_DOWN_ICON;
fn default_font(&self) -> Self::Font {
self.backend().default_font()
}
fn default_size(&self) -> f32 {
self.backend().default_size()
}

View file

@ -34,7 +34,7 @@ impl Default for Text {
position: Point::ORIGIN,
color: Color::BLACK,
size: 16.0,
font: Font::Default,
font: Font::SansSerif,
horizontal_alignment: alignment::Horizontal::Left,
vertical_alignment: alignment::Vertical::Top,
}