[][src]Struct tetra::graphics::text::Text

pub struct Text { /* fields omitted */ }

A piece of text that can be rendered.

Performance

The layout of the text is cached after the first time it is calculated, making subsequent rendering of the text much faster.

Cloning a Text is a fairly expensive operation, as it creates an entirely new copy of the object with its own cache.

Examples

The text example demonstrates how to load a font and then draw some text.

Implementations

impl Text[src]

pub fn new<C>(content: C, font: Font) -> Text where
    C: Into<String>, 
[src]

Creates a new Text, with the given content and font.

pub fn content(&self) -> &str[src]

Returns a reference to the content of the text.

pub fn set_content<C>(&mut self, content: C) where
    C: Into<String>, 
[src]

Sets the content of the text.

Calling this function will cause a re-layout of the text the next time it is rendered.

pub fn font(&self) -> &Font[src]

Gets the font of the text.

pub fn set_font(&mut self, font: Font)[src]

Sets the font of the text.

Calling this function will cause a re-layout of the text the next time it is rendered.

pub fn push(&mut self, ch: char)[src]

Appends the given character to the end of the text.

Calling this function will cause a re-layout of the text the next time it is rendered.

pub fn push_str(&mut self, string: &str)[src]

Appends the given string slice to the end of the text.

Calling this function will cause a re-layout of the text the next time it is rendered.

pub fn pop(&mut self) -> Option<char>[src]

Removes the last character from the text and returns it.

Returns None if the text is empty.

Calling this function will cause a re-layout of the text the next time it is rendered.

pub fn get_bounds(&self, ctx: &mut Context) -> Option<Rectangle>[src]

Get the outer bounds of the text when rendered to the screen.

If the text's layout needs calculating, this method will do so.

Note that this method will not take into account the positioning applied to the text via DrawParams.

Trait Implementations

impl Clone for Text[src]

impl Debug for Text[src]

impl Drawable for Text[src]

Auto Trait Implementations

impl !RefUnwindSafe for Text[src]

impl !Send for Text[src]

impl !Sync for Text[src]

impl Unpin for Text[src]

impl !UnwindSafe for Text[src]

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.