[][src]Struct sfml::graphics::Text

pub struct Text<'s> { /* fields omitted */ }

Graphical text

Text is a drawable type that allows to easily display some text with custom style and color on a render target.

Methods

impl<'s> Text<'s>[src]

pub fn new<S: SfStrConv>(
    string: S,
    font: &'s Font,
    character_size: u32
) -> Text<'s>
[src]

Create a new text with initialized value

Default value for characterSize on SFML is 30.

Arguments

  • string - The string of the text
  • font - The font to display the Text
  • characterSize - The size of the Text

pub fn set_string<S: SfStrConv>(&mut self, string: S)[src]

Set the string of a text

A text's string is empty by default.

Arguments

  • string - New string

pub fn string(&self) -> &SfStr[src]

Get the string of a text

pub fn character_size(&self) -> u32[src]

Get the size of the characters

Return the size of the characters

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

Set the font of the text

The font argument refers to a texture that must exist as long as the text uses it. Indeed, the text doesn't store its own copy of the font, but rather keeps a pointer to the one that you passed to this function. If the font is destroyed and the text tries to use it, the behaviour is undefined.

font - New font

pub fn set_style(&mut self, style: TextStyle)[src]

Set the style of a text

You can pass a combination of one or more styles, for example Bold | Italic. The default style is Regular.

Arguments

  • style - New style

pub fn set_character_size(&mut self, size: u32)[src]

Set the size of the characters of a text

The default size is 30.

Arguments

  • size - The new character size, in pixels

pub fn style(&self) -> TextStyle[src]

Get the style of a text

Return the current string style (see Style enum)

pub fn font(&self) -> Option<&'s Font>[src]

Get the font of a text If the text has no font attached, a None is returned. The returned pointer is const, which means that you can't modify the font when you retrieve it with this function.

pub fn set_fill_color(&mut self, color: Color)[src]

Set the fill color of the text.

By default, the text's fill color is opaque white. Setting the fill color to a transparent color with an outline will cause the outline to be displayed in the fill area of the text.

pub fn set_outline_color(&mut self, color: Color)[src]

Set the outline color of the text.

By default, the text's outline color is opaque black.

pub fn set_outline_thickness(&mut self, thickness: f32)[src]

Set the thickness of the text's outline.

By default, the outline thickness is 0.

Be aware that using a negative value for the outline thickness will cause distorted rendering.

pub fn fill_color(&self) -> Color[src]

Returns the fill color of the text.

pub fn outline_color(&self) -> Color[src]

Returns the outline color of the text.

pub fn outline_thickness(&self) -> f32[src]

Returns the outline thickness of the text, in pixels.

pub fn find_character_pos(&self, index: usize) -> Vector2f[src]

Return the position of the index-th character in a text

This function computes the visual position of a character from its index in the string. The returned position is in global coordinates (translation, rotation, scale and origin are applied). If index is out of range, the position of the end of the string is returned.

Arguments

  • index - The index of the character

Return the position of the character

pub fn local_bounds(&self) -> FloatRect[src]

Get the local bounding rectangle of a text

The returned rectangle is in local coordinates, which means that it ignores the transformations (translation, rotation, scale, ...) that are applied to the entity. In other words, this function returns the bounds of the entity in the entity's coordinate system.

Return the local bounding rectangle of the entity

pub fn global_bounds(&self) -> FloatRect[src]

Get the global bounding rectangle of a text

The returned rectangle is in global coordinates, which means that it takes in account the transformations (translation, rotation, scale, ...) that are applied to the entity. In other words, this function returns the bounds of the text in the global 2D world's coordinate system.

Return the global bounding rectangle of the entity

Trait Implementations

impl<'s> Drawable for Text<'s>[src]

impl<'s> Transformable for Text<'s>[src]

impl<'s> Drop for Text<'s>[src]

impl<'s> Clone for Text<'s>[src]

fn clone(&self) -> Text<'s>[src]

Return a new Text or panic! if there is not enough memory

impl<'s> Default for Text<'s>[src]

impl<'s> Debug for Text<'s>[src]

Auto Trait Implementations

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

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

impl<'s> Unpin for Text<'s>

impl<'s> UnwindSafe for Text<'s>

impl<'s> RefUnwindSafe for Text<'s>

Blanket Implementations

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

impl<T> From<T> for 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.

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

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

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