Skip to main content

Text

Struct Text 

Source
pub struct Text<'a> { /* private fields */ }
Expand description

Text builder struct. Call finish to draw the text.

Created by Font::draw.

Implementations§

Source§

impl<'a> Text<'a>

Source

pub fn finish(&mut self) -> Option<Rect>

Draws the text, and returns the bounding box of all the glyphs drawn, if any were.

Source

pub fn z(&mut self, z: f32) -> &mut Self

Sets the text’s Z-coordinate.

Source

pub fn color( &mut self, (red, green, blue, alpha): (f32, f32, f32, f32), ) -> &mut Self

Sets the text’s color.

Source

pub fn alignment(&mut self, alignment: Alignment) -> &mut Self

Sets the text’s alignment. Does nothing if max width isn’t specified: the x-coordinate of this text is considered to be the left border, and the max width of the text + the x-coordinate the right.

Source

pub fn max_width(&mut self, width: f32) -> &mut Self

Sets the maximum width of this text.

Source

pub fn clip_area<R: Into<Rect>>(&mut self, clip_area: R) -> &mut Self

Sets the clipping area, ie. the area where the text will be rendered. Text that is not inside the clip area will be clipped off.

Source

pub fn visibility(&mut self, visible: bool) -> &mut Self

Sets the visibility of the text. If false, the text will not be rendered. That is, only the bounding box of the text will be calculated.

Useful for measuring the bounding box of some piece of text, without spending performance drawing it with 0 alpha, which would make it invisible as well.

Source

pub fn rotation( &mut self, rotation: f32, pivot_x: f32, pivot_y: f32, ) -> &mut Self

Specifies the rotation (in radians) and pivot of the text, relative to the text’s origin.

Auto Trait Implementations§

§

impl<'a> Freeze for Text<'a>

§

impl<'a> !RefUnwindSafe for Text<'a>

§

impl<'a> !Send for Text<'a>

§

impl<'a> !Sync for Text<'a>

§

impl<'a> Unpin for Text<'a>

§

impl<'a> UnsafeUnpin for Text<'a>

§

impl<'a> !UnwindSafe for Text<'a>

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