Solarus quests
1.6
Quest maker's reference
|
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.
Creates a text surface with the specified properties.
properties
(optional table): A table that describes all properties of the text surface to create. Its key-value pairs are all optional, they can be:horizontal_alignment
(string, default "left"
): "left"
, "center"
or "right"
. When you draw the text surface at some coordinates on a destination surface, it is anchored at this position.vertical_alignment
(string, default "middle"
): "top"
, "middle"
or "bottom"
. When you draw the text surface at some coordinates on a destination surface, it is anchored at this position.font
(string, default the first one in alphabetical order): Name of the font file to use, relative to the fonts
directory and without extension. It must be a declared in the resource list of the quest database. The following extensions are auto-detected in this order:
.png
,
.ttf
,
.otf
,
.ttc
and
.fon
.rendering_mode
(string, default "solid"
): "solid"
(faster) or "antialiasing"
(smooth effect on letters).color
(table, default white): Color of the text to draw (array of 3 RGB values between 0 and 255). No effect on bitmap fonts.font_size
(number, default 11
): Font size to use. No effect on bitmap fonts.text
(string, default ""
): The text to show (must be valid UTF-8).text_key
(string, default nil
): Key of the localized text to show. The string must exist in the file text/strings.dat of the current language.Predicts the size of a text surface while avoid its costly creation. This can be useful for example to split text into lines or to insert an image in your dialog box.
font_id
(string) : Name of the font file to use, relative to the fonts
directory and without extension. It must be declared in the resource list of the quest database. The following extensions are auto-detected in this order:
.png
,
.ttf
,
.otf
,
.ttc
and
.fon
.font_size
(number) : Font size to use. No effect on bitmap fonts.text
(string) : Text to predict the surface size for. Must be valid UTF-8.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.
The following methods are specific to text surfaces.
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.
"left"
, "center"
or "right"
.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.
horizontal_alignment
(string): "left"
, "center"
or "right"
.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.
"top"
, "middle"
or "bottom"
.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.
vertical_alignment
(string): "top"
, "middle"
or "bottom"
.Returns the font used to draw this text surface.
Sets the font used to draw this text surface.
font_id
(string): Name of the font file to use, relative to the fonts
directory and without extension. It must be a declared in the resource list of the quest database. The following extensions are auto-detected in this order:
.png
,
.ttf
,
.ttc
and
.fon
.Returns the rendering mode of the text.
"solid"
(faster) or "antialiasing"
(smooth effect on letters).Sets the rendering mode of the text.
rendering_mode
(string): "solid"
(faster) or "antialiasing"
(smooth effect on letters).Returns the color used to draw the text.
This only has an effect for outline fonts.
0
to 255
).Sets the color used to draw the text.
This only has an effect for outline fonts.
color
(table): The text color as an array of 3 RGB values (0
to 255
).Returns the font size used to draw the text.
This only has an effect for outline fonts.
Sets the size used to draw the text.
This only has an effect for outline fonts.
font_size
(number): The font size.Returns the string displayed in this object.
Sets the string displayed in this object.
The string must be encoded in UTF-8.
text
(string, optional): The text to set. No value or an empty string mean no text.Sets the text as a localized string in the current language.
key
(string): Key of the text to set.text_surface:set_text(sol.language.get_string(key))
.Returns the size of this text surface.