pub struct MultiMonoTextStyleBuilder<'a, C> { /* private fields */ }Expand description
Text style builder for monospaced fonts.
Use this builder to create MultiMonoTextStyles for Text.
§Examples
§Render yellow text on a blue background
This uses the FONT_6X9 font, but other fonts can also be used.
use multi_mono_font::{ascii::FONT_6X9, MultiMonoTextStyle, MultiMonoTextStyleBuilder};
use embedded_graphics::{
pixelcolor::Rgb565,
prelude::*,
text::Text,
};
let style = MultiMonoTextStyleBuilder::new()
.font(&FONT_6X9)
.text_color(Rgb565::YELLOW)
.background_color(Rgb565::BLUE)
.build();
let text = Text::new("Hello Rust!", Point::new(0, 0), style);§Transparent background
If a property is omitted, it will remain at its default value in the resulting
MultiMonoTextStyle returned by .build(). This example draws white text with no background at
all.
use multi_mono_font::{ascii::FONT_6X9, MultiMonoTextStyle, MultiMonoTextStyleBuilder};
use embedded_graphics::{
pixelcolor::Rgb565,
prelude::*,
text::Text,
};
let style = MultiMonoTextStyleBuilder::new()
.font(&FONT_6X9)
.text_color(Rgb565::WHITE)
.build();
let text = Text::new("Hello Rust!", Point::new(0, 0), style);§Modifying an existing style
The builder can also be used to modify an existing style.
use multi_mono_font::{ascii::FONT_6X9, MultiMonoTextStyle, MultiMonoTextStyleBuilder};
use embedded_graphics::{
pixelcolor::Rgb565,
prelude::*,
text::Text,
};
let style = MultiMonoTextStyle::new(&FONT_6X9, Rgb565::YELLOW);
let style_larger = MultiMonoTextStyleBuilder::from(&style)
.font(&FONT_10X20)
.build();Implementations§
Source§impl<'a, C> MultiMonoTextStyleBuilder<'a, C>where
C: PixelColor,
impl<'a, C> MultiMonoTextStyleBuilder<'a, C>where
C: PixelColor,
Sourcepub const fn font<'b>(
self,
font_list: &'b [&'b MultiMonoFont<'b>],
line_height: MultiMonoLineHeight,
) -> MultiMonoTextStyleBuilder<'b, C>
pub const fn font<'b>( self, font_list: &'b [&'b MultiMonoFont<'b>], line_height: MultiMonoLineHeight, ) -> MultiMonoTextStyleBuilder<'b, C>
Sets the font.
Sourcepub const fn reset_background_color(self) -> Self
pub const fn reset_background_color(self) -> Self
Resets the background color to transparent.
Sourcepub const fn text_color(self, text_color: C) -> Self
pub const fn text_color(self, text_color: C) -> Self
Sets the text color.
Sourcepub const fn line_height(self, line_height: MultiMonoLineHeight) -> Self
pub const fn line_height(self, line_height: MultiMonoLineHeight) -> Self
Sets the line height.
Sourcepub const fn background_color(self, background_color: C) -> Self
pub const fn background_color(self, background_color: C) -> Self
Sets the background color.
Sourcepub const fn build(self) -> MultiMonoTextStyle<'a, C>
pub const fn build(self) -> MultiMonoTextStyle<'a, C>
Builds the text style.
This method can only be called after a font was set by using the font method. All other
settings are optional and they will be set to their default value if they are missing.
Trait Implementations§
Source§impl<'a, C: Clone> Clone for MultiMonoTextStyleBuilder<'a, C>
impl<'a, C: Clone> Clone for MultiMonoTextStyleBuilder<'a, C>
Source§fn clone(&self) -> MultiMonoTextStyleBuilder<'a, C>
fn clone(&self) -> MultiMonoTextStyleBuilder<'a, C>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<'a, C: Debug> Debug for MultiMonoTextStyleBuilder<'a, C>
impl<'a, C: Debug> Debug for MultiMonoTextStyleBuilder<'a, C>
Source§impl<'a, C> From<&MultiMonoTextStyle<'a, C>> for MultiMonoTextStyleBuilder<'a, C>where
C: PixelColor,
impl<'a, C> From<&MultiMonoTextStyle<'a, C>> for MultiMonoTextStyleBuilder<'a, C>where
C: PixelColor,
Source§fn from(style: &MultiMonoTextStyle<'a, C>) -> Self
fn from(style: &MultiMonoTextStyle<'a, C>) -> Self
Converts to this type from the input type.
impl<'a, C: Copy> Copy for MultiMonoTextStyleBuilder<'a, C>
Auto Trait Implementations§
impl<'a, C> Freeze for MultiMonoTextStyleBuilder<'a, C>where
C: Freeze,
impl<'a, C> RefUnwindSafe for MultiMonoTextStyleBuilder<'a, C>where
C: RefUnwindSafe,
impl<'a, C> Send for MultiMonoTextStyleBuilder<'a, C>where
C: Send,
impl<'a, C> Sync for MultiMonoTextStyleBuilder<'a, C>where
C: Sync,
impl<'a, C> Unpin for MultiMonoTextStyleBuilder<'a, C>where
C: Unpin,
impl<'a, C> UnwindSafe for MultiMonoTextStyleBuilder<'a, C>where
C: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CheckedAs for T
impl<T> CheckedAs for T
Source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
Casts the value.
Source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
Source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
Casts the value.
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> OverflowingAs for T
impl<T> OverflowingAs for T
Source§fn overflowing_as<Dst>(self) -> (Dst, bool)where
T: OverflowingCast<Dst>,
fn overflowing_as<Dst>(self) -> (Dst, bool)where
T: OverflowingCast<Dst>,
Casts the value.
Source§impl<Src, Dst> OverflowingCastFrom<Src> for Dstwhere
Src: OverflowingCast<Dst>,
impl<Src, Dst> OverflowingCastFrom<Src> for Dstwhere
Src: OverflowingCast<Dst>,
Source§fn overflowing_cast_from(src: Src) -> (Dst, bool)
fn overflowing_cast_from(src: Src) -> (Dst, bool)
Casts the value.
Source§impl<T> SaturatingAs for T
impl<T> SaturatingAs for T
Source§fn saturating_as<Dst>(self) -> Dstwhere
T: SaturatingCast<Dst>,
fn saturating_as<Dst>(self) -> Dstwhere
T: SaturatingCast<Dst>,
Casts the value.
Source§impl<Src, Dst> SaturatingCastFrom<Src> for Dstwhere
Src: SaturatingCast<Dst>,
impl<Src, Dst> SaturatingCastFrom<Src> for Dstwhere
Src: SaturatingCast<Dst>,
Source§fn saturating_cast_from(src: Src) -> Dst
fn saturating_cast_from(src: Src) -> Dst
Casts the value.
Source§impl<T> UnwrappedAs for T
impl<T> UnwrappedAs for T
Source§fn unwrapped_as<Dst>(self) -> Dstwhere
T: UnwrappedCast<Dst>,
fn unwrapped_as<Dst>(self) -> Dstwhere
T: UnwrappedCast<Dst>,
Casts the value.
Source§impl<Src, Dst> UnwrappedCastFrom<Src> for Dstwhere
Src: UnwrappedCast<Dst>,
impl<Src, Dst> UnwrappedCastFrom<Src> for Dstwhere
Src: UnwrappedCast<Dst>,
Source§fn unwrapped_cast_from(src: Src) -> Dst
fn unwrapped_cast_from(src: Src) -> Dst
Casts the value.
Source§impl<T> WrappingAs for T
impl<T> WrappingAs for T
Source§fn wrapping_as<Dst>(self) -> Dstwhere
T: WrappingCast<Dst>,
fn wrapping_as<Dst>(self) -> Dstwhere
T: WrappingCast<Dst>,
Casts the value.
Source§impl<Src, Dst> WrappingCastFrom<Src> for Dstwhere
Src: WrappingCast<Dst>,
impl<Src, Dst> WrappingCastFrom<Src> for Dstwhere
Src: WrappingCast<Dst>,
Source§fn wrapping_cast_from(src: Src) -> Dst
fn wrapping_cast_from(src: Src) -> Dst
Casts the value.