1.09.02 - Text surfaces

A text surface is a single line of text that you can display. A text surface can be seen as a special surface able to contain text.

Functions of sol.text_surface

sol.text_surface.create([properties])

Creates a text surface with the specified properties.

Methods inherited from drawable

Text surfaces are particular drawable objects. Therefore, they inherit all methods from the type drawable.

See Methods of all drawable types to know these methods.

Methods of the type text surface

The following methods are specific to text surfaces.

text_surface:get_horizontal_alignment()

Returns the horizontal alignment of the text.

When you draw the text surface at some coordinates on a destination surface, it is anchored at this position.

text_surface:set_horizontal_alignment(horizontal_alignment)

Sets the horizontal alignment of the text.

When you draw the text surface at some coordinates on a destination surface, it is anchored at this position.

text_surface:get_vertical_alignment()

Returns the vertical alignment of the text.

When you draw the text surface at some coordinates on a destination surface, it is anchored at this position.

text_surface:set_vertical_alignment(vertical_alignment)

Sets the vertical alignment of the text.

When you draw the text surface at some coordinates on a destination surface, it is anchored at this position.

text_surface:get_font()

Returns the font used to draw this text surface.

text_surface:set_font(font_id)

Sets the font used to draw this text surface.

text_surface:get_rendering_mode()

Returns the rendering mode of the text.

text_surface:set_rendering_mode(rendering_mode)

Sets the rendering mode of the text.

text_surface:get_color()

Returns the color used to draw the text.

This only has an effect for outline fonts.

text_surface:set_color(color)

Sets the color used to draw the text.

This only has an effect for outline fonts.

text_surface:get_font_size()

Returns the font size used to draw the text.

This only has an effect for outline fonts.

text_surface:set_font_size(font_size)

Sets the size used to draw the text.

This only has an effect for outline fonts.

text_surface:get_text()

Returns the string displayed in this object.

text_surface:set_text([text])

Sets the string displayed in this object.

The string must be encoded in UTF-8.

text_surface:set_text_key(key)

Sets the text as a localized string in the current language.

Remarks
This function is equivalent to text_surface:set_text(sol.language.get_string(key)).

text_surface:get_size()

Returns the size of this text surface.

Remarks
Note that you cannot set the size of a text surface. The size is determined by the text and the font.