Skip to main content

RenderingContext:draw_string()

RenderingContext:draw_string(param_table)
RenderingContext:draw_string(string[, x[, y[, width[, height[, horizontal_alignment[, vertical_alignment]]]]]])

This method renders text using the font and brush set in the rendering context.

Parameters

ParameterTypeDescription
param_tabletableThis parameter is in associative array table format, meaning it's specified by keys rather than parameter positions. See the Parameters Table section.
stringstringString to be rendered.
xnumberThe size of the bounding box in which the text is drawn. It specifies the X-coordinate of the top-left corner of the bounding box.
The default value is 0.
ynumberThe size of the bounding box in which the text is drawn. It specifies the Y-coordinate of the top-left corner of the bounding box.
The default value is 0.
widthnumberThe width of the bounding box in which the text is drawn.
The default value is positive infinity.
heightnumberThe height of the bounding box in which the text is drawn.
The default value is positive infinity.
horizontal_alignmentstringSpecifies how to horizontally align the rendering result within the bounding box specified by the x, y, width, and height parameters.
It specifies either of left, center, or right.
The default is left.
vertical_alignmentstringSpecifies how to vertically align the rendering result within the bounding box specified by the x, y, width, and height parameters.
It specifies either of top, center, or bottom.
The default is top.

Parameters Table

KeyTypeDescription
stringstringString to be rendered.
xnumberThe size of the bounding box in which the text is drawn. It specifies the X-coordinate of the top-left corner of the bounding box.
The default value is 0.
ynumberThe size of the bounding box in which the text is drawn. It specifies the Y-coordinate of the top-left corner of the bounding box.
The default value is 0.
widthnumberThe width of the bounding box in which the text is drawn.
The default value is positive infinity.
heightnumberThe height of the bounding box in which the text is drawn.
The default value is positive infinity.
horizontal_alignmentstringSpecifies how to horizontally align the rendering result within the bounding box specified by the x, y, width, and height parameters.
It specifies either of left, center, or right.
The default is left.
vertical_alignmentstringSpecifies how to vertically align the rendering result within the bounding box specified by the x, y, width, and height parameters.
It specifies either of top, center, or bottom.
The default is top.
Note

If the font set in the rendering context is a BitmapFont object, text wrapping and alignment changes within the bounding box are not possible. The following parameters are ignored for BitmapFont objects.

  • width
  • height
  • horizontal_alignment
  • vertical_alignment

Return Values

This method doesn't return any value.

See Also