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 MonoTextStyles 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
impl<C> MonoTextStyleBuilder<'_, C>[src]
impl<C> MonoTextStyleBuilder<'_, C>[src]impl<'a, C> MonoTextStyleBuilder<'a, C>[src]
impl<'a, C> MonoTextStyleBuilder<'a, C>[src]pub fn font<'b>(self, font: &'b MonoFont<'b>) -> MonoTextStyleBuilder<'b, C>[src]
pub fn font<'b>(self, font: &'b MonoFont<'b>) -> MonoTextStyleBuilder<'b, C>[src]Sets the font.
pub fn strikethrough(self) -> Self[src]
pub fn strikethrough(self) -> Self[src]Enables strikethrough using the text color.
pub fn reset_text_color(self) -> Self[src]
pub fn reset_text_color(self) -> Self[src]Resets the text color to transparent.
pub fn reset_background_color(self) -> Self[src]
pub fn reset_background_color(self) -> Self[src]Resets the background color to transparent.
pub fn reset_underline(self) -> Self[src]
pub fn reset_underline(self) -> Self[src]Removes the underline decoration.
pub fn reset_strikethrough(self) -> Self[src]
pub fn reset_strikethrough(self) -> Self[src]Removes the strikethrough decoration.
impl<C: PixelColor> MonoTextStyleBuilder<'_, C>[src]
impl<C: PixelColor> MonoTextStyleBuilder<'_, C>[src]pub fn text_color(self, text_color: C) -> Self[src]
pub fn text_color(self, text_color: C) -> Self[src]Sets the text color.
pub fn background_color(self, background_color: C) -> Self[src]
pub fn background_color(self, background_color: C) -> Self[src]Sets the background color.
pub fn underline_with_color(self, underline_color: C) -> Self[src]
pub fn underline_with_color(self, underline_color: C) -> Self[src]Enables underline with a custom color.
pub fn strikethrough_with_color(self, strikethrough_color: C) -> Self[src]
pub fn strikethrough_with_color(self, strikethrough_color: C) -> Self[src]Enables strikethrough with a custom color.
impl<'a, C: PixelColor> MonoTextStyleBuilder<'a, C>[src]
impl<'a, C: PixelColor> MonoTextStyleBuilder<'a, C>[src]pub fn build(self) -> MonoTextStyle<'a, C>[src]
pub fn build(self) -> MonoTextStyle<'a, C>[src]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
impl<'a, C: Clone> Clone for MonoTextStyleBuilder<'a, C>[src]
impl<'a, C: Clone> Clone for MonoTextStyleBuilder<'a, C>[src]fn clone(&self) -> MonoTextStyleBuilder<'a, C>[src]
fn clone(&self) -> MonoTextStyleBuilder<'a, C>[src]Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)1.0.0[src]
fn clone_from(&mut self, source: &Self)1.0.0[src]Performs copy-assignment from source. Read more
impl<'a, C: Debug> Debug for MonoTextStyleBuilder<'a, C>[src]
impl<'a, C: Debug> Debug for MonoTextStyleBuilder<'a, C>[src]impl<'a, C: PixelColor> From<&'_ MonoTextStyle<'a, C>> for MonoTextStyleBuilder<'a, C>[src]
impl<'a, C: PixelColor> From<&'_ MonoTextStyle<'a, C>> for MonoTextStyleBuilder<'a, C>[src]fn from(style: &MonoTextStyle<'a, C>) -> Self[src]
fn from(style: &MonoTextStyle<'a, C>) -> Self[src]Performs the conversion.
impl<'a, C: Copy> Copy for MonoTextStyleBuilder<'a, C>[src]
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,
C: Unpin,
impl<'a, C> !UnwindSafe for MonoTextStyleBuilder<'a, C>
Blanket Implementations
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]pub fn borrow_mut(&mut self) -> &mut T[src]
pub fn borrow_mut(&mut self) -> &mut T[src]Mutably borrows from an owned value. Read more
impl<Src, Dst> LosslessTryInto<Dst> for Src where
Dst: LosslessTryFrom<Src>, [src]
impl<Src, Dst> LosslessTryInto<Dst> for Src where
Dst: LosslessTryFrom<Src>, [src]pub fn lossless_try_into(self) -> Option<Dst>[src]
pub fn lossless_try_into(self) -> Option<Dst>[src]Performs the conversion.
impl<Src, Dst> LossyInto<Dst> for Src where
Dst: LossyFrom<Src>, [src]
impl<Src, Dst> LossyInto<Dst> for Src where
Dst: LossyFrom<Src>, [src]pub fn lossy_into(self) -> Dst[src]
pub fn lossy_into(self) -> Dst[src]Performs the conversion.
impl<T> Same<T> for T
impl<T> Same<T> for Ttype Output = T
type Output = TShould always be Self
impl<SS, SP> SupersetOf<SS> for SP where
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SP where
SS: SubsetOf<SP>, pub fn to_subset(&self) -> Option<SS>
pub fn to_subset(&self) -> Option<SS>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) -> boolChecks 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) -> SSUse 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) -> SPThe inclusion map: converts self to the equivalent element of its superset.
impl<T> ToOwned for T where
T: Clone, [src]
impl<T> ToOwned for T where
T: Clone, [src]type Owned = T
type Owned = TThe resulting type after obtaining ownership.
pub fn to_owned(&self) -> T[src]
pub fn to_owned(&self) -> T[src]Creates owned data from borrowed data, usually by cloning. Read more
pub fn clone_into(&self, target: &mut T)[src]
pub fn clone_into(&self, target: &mut T)[src]🔬 This is a nightly-only experimental API. (toowned_clone_into)
recently added
Uses borrowed data to replace owned data, usually by cloning. Read more
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,