Struct embedded_graphics::mono_font::MonoTextStyleBuilder [−][src]
pub struct MonoTextStyleBuilder<'a, C> { /* fields omitted */ }
Expand description
Text style builder for monospaced fonts.
Use this builder to create MonoTextStyle
s for Text
.
Examples
Render yellow text on a blue background
This uses the FONT_6X9
font, but other fonts can also be used.
use embedded_graphics::{ mono_font::{ascii::FONT_6X9, MonoTextStyle, MonoTextStyleBuilder}, pixelcolor::Rgb565, prelude::*, text::Text, }; let style = MonoTextStyleBuilder::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
MonoTextStyle
returned by .build()
. This example draws white text with no background at
all.
use embedded_graphics::{ mono_font::{ascii::FONT_6X9, MonoTextStyle, MonoTextStyleBuilder}, pixelcolor::Rgb565, prelude::*, text::Text, }; let style = MonoTextStyleBuilder::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 embedded_graphics::{ mono_font::{ascii::{FONT_6X9, FONT_10X20}, MonoTextStyle, MonoTextStyleBuilder}, pixelcolor::Rgb565, prelude::*, text::Text, }; let style = MonoTextStyle::new(&FONT_6X9, Rgb565::YELLOW); let style_larger = MonoTextStyleBuilder::from(&style) .font(&FONT_10X20) .build();
Implementations
Sets the font.
Enables strikethrough using the text color.
Resets the text color to transparent.
Resets the background color to transparent.
Removes the underline decoration.
Removes the strikethrough decoration.
Sets the text color.
Sets the background color.
Enables underline with a custom color.
Enables strikethrough with a custom color.
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
Performs the conversion.
Auto Trait Implementations
impl<'a, C> !RefUnwindSafe for MonoTextStyleBuilder<'a, C>
impl<'a, C> !Send for MonoTextStyleBuilder<'a, C>
impl<'a, C> !Sync for MonoTextStyleBuilder<'a, C>
impl<'a, C> Unpin for MonoTextStyleBuilder<'a, C> where
C: Unpin,
impl<'a, C> !UnwindSafe for MonoTextStyleBuilder<'a, C>
Blanket Implementations
Mutably borrows from an owned value. Read more
Casts the value.
Performs the conversion.
Performs the conversion.
Casts the value.
type Output = T
type Output = T
Should always be Self
Casts the value.
The inverse inclusion map: attempts to construct self
from the equivalent element of its
superset. Read more
pub fn is_in_subset(&self) -> bool
pub fn is_in_subset(&self) -> bool
Checks if self
is actually part of its subset T
(and can be converted to it).
pub fn to_subset_unchecked(&self) -> SS
pub fn to_subset_unchecked(&self) -> SS
Use with care! Same as self.to_subset
but without any property checks. Always succeeds.
pub fn from_subset(element: &SS) -> SP
pub fn from_subset(element: &SS) -> SP
The inclusion map: converts self
to the equivalent element of its superset.
Casts the value.
pub fn vzip(self) -> V
Casts the value.