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>

source

pub const fn new(text: &'a str, position: Point, character_style: S) -> Self

Creates a text drawable with the default text style.

source

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.

source

pub const fn with_baseline( text: &'a str, position: Point, character_style: S, baseline: Baseline ) -> Self

Creates a text drawable with the given baseline.

source

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<'a, S: Clone> Clone for Text<'a, S>

source§

fn clone(&self) -> Text<'a, S>

Returns a copy 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, S: Debug> Debug for Text<'a, S>

source§

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

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

impl<S: TextRenderer> Dimensions for Text<'_, S>

source§

fn bounding_box(&self) -> Rectangle

Returns the bounding box.
source§

impl<S: TextRenderer> Drawable for Text<'_, S>

§

type Color = <S as TextRenderer>::Color

The pixel color type.
§

type Output = Point

The return type of the draw method. Read more
source§

fn draw<D>(&self, target: &mut D) -> Result<Point, D::Error>where D: DrawTarget<Color = Self::Color>,

Draw the graphics object using the supplied DrawTarget.
source§

impl<'a, S: Hash> Hash for Text<'a, S>

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl<'a, S: Ord> Ord for Text<'a, S>

source§

fn cmp(&self, other: &Text<'a, S>) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Selfwhere Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Selfwhere Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Selfwhere Self: Sized + PartialOrd<Self>,

Restrict a value to a certain interval. Read more
source§

impl<'a, S: PartialEq> PartialEq<Text<'a, S>> for Text<'a, S>

source§

fn eq(&self, other: &Text<'a, S>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<'a, S: PartialOrd> PartialOrd<Text<'a, S>> for Text<'a, S>

source§

fn partial_cmp(&self, other: &Text<'a, S>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

fn lt(&self, other: &Rhs) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

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 more
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl<S: Clone> Transform for Text<'_, S>

source§

fn translate(&self, by: Point) -> Self

Move the origin of an object by a given number of (x, y) pixels, returning a new object
source§

fn translate_mut(&mut self, by: Point) -> &mut Self

Move the origin of an object by a given number of (x, y) pixels, mutating the object in place
source§

impl<'a, S: Copy> Copy for Text<'a, S>

source§

impl<'a, S: Eq> Eq for Text<'a, S>

source§

impl<'a, S> StructuralEq for Text<'a, S>

source§

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> Any for Twhere 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) -> Dstwhere T: Cast<Dst>,

Casts the value.
source§

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

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<Src, Dst> CastFrom<Src> for Dstwhere 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 Dstwhere Src: CheckedCast<Dst>,

source§

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

Casts the value.
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

const: unstable · 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 Dstwhere 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) -> Dstwhere T: SaturatingCast<Dst>,

Casts the value.
source§

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

source§

fn saturating_cast_from(src: Src) -> Dst

Casts the value.
source§

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

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
const: unstable · 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) -> Dstwhere T: UnwrappedCast<Dst>,

Casts the value.
source§

impl<Src, Dst> UnwrappedCastFrom<Src> for Dstwhere 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) -> Dstwhere T: WrappingCast<Dst>,

Casts the value.
source§

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

source§

fn wrapping_cast_from(src: Src) -> Dst

Casts the value.