Skip to main content

MultiMonoTextStyleBuilder

Struct MultiMonoTextStyleBuilder 

Source
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,

Source

pub const fn new(text_color: C) -> Self

Creates a new text style builder.

Source

pub const fn font<'b>( self, font_list: &'b [&'b MultiMonoFont<'b>], line_height: MultiMonoLineHeight, ) -> MultiMonoTextStyleBuilder<'b, C>

Sets the font.

Source

pub const fn reset_background_color(self) -> Self

Resets the background color to transparent.

Source

pub const fn text_color(self, text_color: C) -> Self

Sets the text color.

Source

pub const fn line_height(self, line_height: MultiMonoLineHeight) -> Self

Sets the line height.

Source

pub const fn background_color(self, background_color: C) -> Self

Sets the background color.

Source

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>

Source§

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)

Performs copy-assignment from source. Read more
Source§

impl<'a, C: Debug> Debug for MultiMonoTextStyleBuilder<'a, C>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'a, C> From<&MultiMonoTextStyle<'a, C>> for MultiMonoTextStyleBuilder<'a, C>
where C: PixelColor,

Source§

fn from(style: &MultiMonoTextStyle<'a, C>) -> Self

Converts to this type from the input type.
Source§

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Az for T

Source§

fn az<Dst>(self) -> Dst
where T: Cast<Dst>,

Casts the value.
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<Src, Dst> CastFrom<Src> for Dst
where Src: Cast<Dst>,

Source§

fn cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T> CheckedAs for T

Source§

fn checked_as<Dst>(self) -> Option<Dst>
where T: CheckedCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> CheckedCastFrom<Src> for Dst
where Src: CheckedCast<Dst>,

Source§

fn checked_cast_from(src: Src) -> Option<Dst>

Casts the value.
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> OverflowingAs for T

Source§

fn overflowing_as<Dst>(self) -> (Dst, bool)
where T: OverflowingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> OverflowingCastFrom<Src> for Dst
where Src: OverflowingCast<Dst>,

Source§

fn overflowing_cast_from(src: Src) -> (Dst, bool)

Casts the value.
Source§

impl<T> SaturatingAs for T

Source§

fn saturating_as<Dst>(self) -> Dst
where T: SaturatingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> SaturatingCastFrom<Src> for Dst
where Src: SaturatingCast<Dst>,

Source§

fn saturating_cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> UnwrappedAs for T

Source§

fn unwrapped_as<Dst>(self) -> Dst
where T: UnwrappedCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> UnwrappedCastFrom<Src> for Dst
where Src: UnwrappedCast<Dst>,

Source§

fn unwrapped_cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T> WrappingAs for T

Source§

fn wrapping_as<Dst>(self) -> Dst
where T: WrappingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> WrappingCastFrom<Src> for Dst
where Src: WrappingCast<Dst>,

Source§

fn wrapping_cast_from(src: Src) -> Dst

Casts the value.