diff options
author | 2019-11-13 07:22:21 +0100 | |
---|---|---|
committer | 2019-11-13 07:22:21 +0100 | |
commit | 6857829dc3171fd68065498b6cd29f0ef02a8d43 (patch) | |
tree | db844c70cc8fbd2f48b175e97bde50866641a1b4 /core | |
parent | f0b1e65ba4f8df173f8201585a1d81245e93ab94 (diff) | |
download | iced-6857829dc3171fd68065498b6cd29f0ef02a8d43.tar.gz iced-6857829dc3171fd68065498b6cd29f0ef02a8d43.tar.bz2 iced-6857829dc3171fd68065498b6cd29f0ef02a8d43.zip |
Draft `Font` type and implement `Text::font`
Diffstat (limited to 'core')
-rw-r--r-- | core/src/font.rs | 8 | ||||
-rw-r--r-- | core/src/lib.rs | 2 | ||||
-rw-r--r-- | core/src/widget/text.rs | 9 |
3 files changed, 18 insertions, 1 deletions
diff --git a/core/src/font.rs b/core/src/font.rs new file mode 100644 index 00000000..75ba6a72 --- /dev/null +++ b/core/src/font.rs @@ -0,0 +1,8 @@ +#[derive(Debug, Clone, Copy)] +pub enum Font { + Default, + External { + name: &'static str, + bytes: &'static [u8], + }, +} diff --git a/core/src/lib.rs b/core/src/lib.rs index ab43ab94..b61f2eae 100644 --- a/core/src/lib.rs +++ b/core/src/lib.rs @@ -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; diff --git a/core/src/widget/text.rs b/core/src/widget/text.rs index 427d9471..0996e7ff 100644 --- a/core/src/widget/text.rs +++ b/core/src/widget/text.rs @@ -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 |