Draft Font type and implement Text::font
This commit is contained in:
parent
f0b1e65ba4
commit
6857829dc3
10 changed files with 96 additions and 31 deletions
8
core/src/font.rs
Normal file
8
core/src/font.rs
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
#[derive(Debug, Clone, Copy)]
|
||||
pub enum Font {
|
||||
Default,
|
||||
External {
|
||||
name: &'static str,
|
||||
bytes: &'static [u8],
|
||||
},
|
||||
}
|
||||
|
|
@ -3,6 +3,7 @@ pub mod widget;
|
|||
mod align;
|
||||
mod background;
|
||||
mod color;
|
||||
mod font;
|
||||
mod length;
|
||||
mod point;
|
||||
mod rectangle;
|
||||
|
|
@ -11,6 +12,7 @@ mod vector;
|
|||
pub use align::Align;
|
||||
pub use background::Background;
|
||||
pub use color::Color;
|
||||
pub use font::Font;
|
||||
pub use length::Length;
|
||||
pub use point::Point;
|
||||
pub use rectangle::Rectangle;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
//! Write some text for your users to read.
|
||||
use crate::{Color, Length};
|
||||
use crate::{Color, Font, Length};
|
||||
|
||||
/// A paragraph of text.
|
||||
///
|
||||
|
|
@ -16,6 +16,7 @@ pub struct Text {
|
|||
pub content: String,
|
||||
pub size: Option<u16>,
|
||||
pub color: Option<Color>,
|
||||
pub font: Font,
|
||||
pub width: Length,
|
||||
pub height: Length,
|
||||
pub horizontal_alignment: HorizontalAlignment,
|
||||
|
|
@ -31,6 +32,7 @@ impl Text {
|
|||
content: String::from(label),
|
||||
size: None,
|
||||
color: None,
|
||||
font: Font::Default,
|
||||
width: Length::Fill,
|
||||
height: Length::Shrink,
|
||||
horizontal_alignment: HorizontalAlignment::Left,
|
||||
|
|
@ -54,6 +56,11 @@ impl Text {
|
|||
self
|
||||
}
|
||||
|
||||
pub fn font(mut self, font: Font) -> Self {
|
||||
self.font = font;
|
||||
self
|
||||
}
|
||||
|
||||
/// Sets the width of the [`Text`] boundaries.
|
||||
///
|
||||
/// [`Text`]: struct.Text.html
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue