Struct sfml::graphics::Text
[−]
[src]
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]
fn new() -> Text<'s>
Create a new text
fn new_init(string: &str, font: &'s Font, character_size: u32) -> Text<'s>
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
fn set_string(&mut self, string: &str)
fn string(&self) -> String
Get the string of a text
fn character_size(&self) -> u32
Get the size of the characters
Return the size of the characters
fn set_font(&mut self, font: &'s Font)
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
fn set_style(&mut self, style: TextStyle)
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
fn set_character_size(&mut self, size: u32)
Set the size of the characters of a text
The default size is 30.
Arguments
- size - The new character size, in pixels
fn style(&self) -> TextStyle
Get the style of a text
Return the current string style (see Style enum)
fn font(&self) -> Option<&'s FontRef>
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.
fn set_fill_color(&mut self, color: &Color)
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.
fn set_outline_color(&mut self, color: &Color)
Set the outline color of the text.
By default, the text's outline color is opaque black.
fn set_outline_thickness(&mut self, thickness: f32)
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.
fn fill_color(&self) -> Color
Returns the fill color of the text.
fn outline_color(&self) -> Color
Returns the outline color of the text.
fn outline_thickness(&self) -> f32
Returns the outline thickness of the text, in pixels.
fn find_character_pos(&self, index: usize) -> Vector2f
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
fn local_bounds(&self) -> FloatRect
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
fn global_bounds(&self) -> FloatRect
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> Default for Text<'s>
[src]
impl<'s> Clone for Text<'s>
[src]
fn clone(&self) -> Text<'s>
Return a new Text or panic! if there is not enough memory
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more
impl<'s> Drawable for Text<'s>
[src]
fn draw<'se, 'tex, 'sh, 'shte>(
&'se self,
target: &mut RenderTarget,
states: RenderStates<'tex, 'sh, 'shte>
) where
'se: 'sh,
&'se self,
target: &mut RenderTarget,
states: RenderStates<'tex, 'sh, 'shte>
) where
'se: 'sh,
Draw a drawable object into a RenderTarget
impl<'s> Transformable for Text<'s>
[src]
fn set_position(&mut self, position: &Vector2f)
Sets the position of the object. Read more
fn set_position2f(&mut self, x: f32, y: f32)
Sets the position of the object. Read more
fn set_rotation(&mut self, angle: f32)
Set the orientation of the object. Read more
fn set_scale(&mut self, scale: &Vector2f)
Sets the scale factors of the object. Read more
fn set_scale2f(&mut self, scale_x: f32, scale_y: f32)
Sets the scale factors of the object. Read more
fn set_origin(&mut self, origin: &Vector2f)
Sets the local origin of the object. Read more
fn set_origin2f(&mut self, x: f32, y: f32)
Sets the local origin of the object. Read more
fn position(&self) -> Vector2f
Gets the position of the object.
fn rotation(&self) -> f32
Gets the rotation of the object. Read more
fn get_scale(&self) -> Vector2f
Gets the current scale of the object.
fn origin(&self) -> Vector2f
Gets the local origin of the object.
fn move_(&mut self, offset: &Vector2f)
Moves the object by a given offset. Read more
fn move2f(&mut self, offset_x: f32, offset_y: f32)
Moves the object by a given offset. Read more
fn rotate(&mut self, angle: f32)
Rotates the object. Read more
fn scale(&mut self, factors: &Vector2f)
Scales the object. Read more
fn scale2f(&mut self, factor_x: f32, factor_y: f32)
Scales the object. Read more
fn transform(&self) -> Transform
Gets the combined transform of the object.
fn inverse_transform(&self) -> Transform
Gets the inverse combined transform of the object.
impl<'s> Raw for Text<'s>
[src]
type Raw = *const sfText
The raw representation of this type.
fn raw(&self) -> Self::Raw
Acquires the raw representation of this type through &self
.