Skip to main content

Text

Struct 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>

Source

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

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, ) -> Text<'a, S>

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, ) -> Text<'a, S>

Creates a text drawable with the given baseline.

Source

pub const fn with_alignment( text: &'a str, position: Point, character_style: S, alignment: Alignment, ) -> Text<'a, S>

Creates a text drawable with the given alignment.

Trait Implementations§

Source§

impl<'a, S> Clone for Text<'a, S>
where S: Clone,

Source§

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

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

Source§

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

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

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

Source§

fn bounding_box(&self) -> Rectangle

Returns the bounding box.
Source§

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

Source§

type Color = <S as TextRenderer>::Color

The pixel color type.
Source§

type Output = Point

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

fn draw<D>(&self, target: &mut D) -> Result<Point, <D as DrawTarget>::Error>
where D: DrawTarget<Color = <Text<'_, S> as Drawable>::Color>,

Draw the graphics object using the supplied DrawTarget.
Source§

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

Source§

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

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

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) -> Self
where Self: Sized,

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

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

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

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

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

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

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

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

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

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

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

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

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

Source§

fn translate(&self, by: Point) -> Text<'_, S>

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 Text<'_, S>

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

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

Source§

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

Source§

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

Auto Trait Implementations§

§

impl<'a, S> Freeze for Text<'a, S>
where S: Freeze,

§

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

§

impl<'a, S> UnwindSafe for Text<'a, S>
where S: 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.