Text

Graphical text that can be drawn to a render target.

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

It inherits all the functions from Transformable: position, rotation, scale, origin. It also adds text-specific properties such as the font to use, the character size, the font style (bold, italic, underlined), the global color and the text to display of course. It also provides convenience functions to calculate the graphical size of the text, or to get the global position of a given character.

Text works in combination with the Font class, which loads and provides the glyphs (visual characters) of a given font.

The separation of Font and Text allows more flexibility and better performances: indeed a Font is a heavy resource, and any operation on it is slow (often too slow for real-time applications). On the other side, a Text is a lightweight object which can combine the glyphs data and metrics of a Font to display any text on a render target.

It is important to note that the Text instance doesn't copy the font that it uses, it only keeps a reference to it. Thus, a Font must not be destructed while it is used by a Text (i.e. never write a function that uses a local Font instance for creating a text).

Constructors

this
this()
Undocumented in source.
this
this(immutable(T)[] text, const(Font) font, uint characterSize)
Undocumented in source.

Destructor

~this
~this()
Undocumented in source.

Members

Enums

Style
enum Style

Enumeration of the string drawing styles.

Functions

draw
void draw(RenderTarget renderTarget, RenderStates renderStates)

Draw the object to a render target.

findCharacterPos
Vector2f findCharacterPos(size_t index)

Return the position of the index-th character.

getCharacterSize
uint getCharacterSize()

Get the character size.

getColor
Color getColor()

Get the global color of the text.

getFont
const(Font) getFont()

Get thet text's font.

getGlobalBounds
FloatRect getGlobalBounds()

Get the global bounding rectangle of the entity.

getLocalBounds
FloatRect getLocalBounds()

Get the local bounding rectangle of the entity.

getString
immutable(T)[] getString()

Get the text's string.

getStyle
Style getStyle()

Get the text's style.

setCharacterSize
void setCharacterSize(uint size)

Set the character size.

setColor
void setColor(Color color)

Set the global color of the text.

setFont
void setFont(const(Font) font)

Set the text's font.

setString
void setString(immutable(T)[] text)

Set the text's string.

setStyle
void setStyle(Style style)

Set the text's style.

Mixins

__anonymous
mixin NormalTransformable
Undocumented in source.

Mixed In Members

From mixin NormalTransformable

origin
Vector2f origin [@property setter]

The local origin of the object.

origin
Vector2f origin [@property getter]
Undocumented in source. Be warned that the author may not have intended to support it.
position
Vector2f position [@property setter]

The position of the object. The default is (0, 0).

position
Vector2f position [@property getter]
Undocumented in source. Be warned that the author may not have intended to support it.
rotation
float rotation [@property setter]

The orientation of the object, in degrees. The default is 0 degrees.

rotation
float rotation [@property getter]
Undocumented in source. Be warned that the author may not have intended to support it.
scale
Vector2f scale [@property setter]

The scale factors of the object. The default is (1, 1).

scale
Vector2f scale [@property getter]
Undocumented in source. Be warned that the author may not have intended to support it.
getInverseTransform
const(Transform) getInverseTransform()

Get the inverse of the combined transform of the object.

getTransform
const(Transform) getTransform()

Get the combined transform of the object.

move
void move(Vector2f offset)

Move the object by a given offset.

Inherited Members

From Drawable

draw
void draw(RenderTarget renderTarget, RenderStates renderStates)

Draw the object to a render target.

From Transformable

origin
Vector2f origin [@property setter]

The local origin of the object.

origin
Vector2f origin [@property getter]
Undocumented in source.
position
Vector2f position [@property setter]

The position of the object. The default is (0, 0).

position
Vector2f position [@property getter]
Undocumented in source.
rotation
float rotation [@property setter]

The orientation of the object, in degrees. The default is 0 degrees.

rotation
float rotation [@property getter]
Undocumented in source.
scale
Vector2f scale [@property setter]

The scale factors of the object. The default is (1, 1).

scale
Vector2f scale [@property getter]
Undocumented in source.
getTransform
const(Transform) getTransform()

Get the inverse of the combined transform of the object.

getInverseTransform
const(Transform) getInverseTransform()

Get the combined transform of the object.

move
void move(Vector2f offset)

Move the object by a given offset.

See Also

Meta

Authors

Laurent Gomila, Jeremy DeHaan