Struct embedded_graphics::text::Text
source · pub struct Text<'a, S> {
pub text: &'a str,
pub position: Point,
pub character_style: S,
pub text_style: TextStyle,
}
Expand description
Text drawable.
A text drawable can be used to draw text to a draw target.
See the module-level documentation for more information about text drawables and examples.
Fields§
§text: &'a str
The string.
position: Point
The position.
character_style: S
The character style.
text_style: TextStyle
The text style.
Implementations§
source§impl<'a, S> Text<'a, S>
impl<'a, S> Text<'a, S>
sourcepub const fn new(text: &'a str, position: Point, character_style: S) -> Self
pub const fn new(text: &'a str, position: Point, character_style: S) -> Self
Creates a text drawable with the default text style.
sourcepub const fn with_text_style(
text: &'a str,
position: Point,
character_style: S,
text_style: TextStyle
) -> Self
pub const fn with_text_style( text: &'a str, position: Point, character_style: S, text_style: TextStyle ) -> Self
Creates a text drawable with the given text style.
sourcepub const fn with_baseline(
text: &'a str,
position: Point,
character_style: S,
baseline: Baseline
) -> Self
pub const fn with_baseline( text: &'a str, position: Point, character_style: S, baseline: Baseline ) -> Self
Creates a text drawable with the given baseline.
sourcepub const fn with_alignment(
text: &'a str,
position: Point,
character_style: S,
alignment: Alignment
) -> Self
pub const fn with_alignment( text: &'a str, position: Point, character_style: S, alignment: Alignment ) -> Self
Creates a text drawable with the given alignment.
Trait Implementations§
source§impl<S: TextRenderer> Dimensions for Text<'_, S>
impl<S: TextRenderer> Dimensions for Text<'_, S>
source§fn bounding_box(&self) -> Rectangle
fn bounding_box(&self) -> Rectangle
Returns the bounding box.
source§impl<S: TextRenderer> Drawable for Text<'_, S>
impl<S: TextRenderer> Drawable for Text<'_, S>
source§impl<'a, S: Ord> Ord for Text<'a, S>
impl<'a, S: Ord> Ord for Text<'a, S>
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere Self: Sized,
Compares and returns the maximum of two values. Read more
source§impl<'a, S: PartialEq> PartialEq<Text<'a, S>> for Text<'a, S>
impl<'a, S: PartialEq> PartialEq<Text<'a, S>> for Text<'a, S>
source§impl<'a, S: PartialOrd> PartialOrd<Text<'a, S>> for Text<'a, S>
impl<'a, S: PartialOrd> PartialOrd<Text<'a, S>> for Text<'a, S>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moreimpl<'a, S: Copy> Copy for Text<'a, S>
impl<'a, S: Eq> Eq for Text<'a, S>
impl<'a, S> StructuralEq for Text<'a, S>
impl<'a, S> StructuralPartialEq for Text<'a, S>
Auto Trait Implementations§
impl<'a, S> RefUnwindSafe for Text<'a, S>where S: RefUnwindSafe,
impl<'a, S> Send for Text<'a, S>where S: Send,
impl<'a, S> Sync for Text<'a, S>where S: Sync,
impl<'a, S> Unpin for Text<'a, S>where S: Unpin,
impl<'a, S> UnwindSafe for Text<'a, S>where S: UnwindSafe,
Blanket Implementations§
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> 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.