Text

A text object for rendering strings with a specified font.

Constructor

Text(font: Font)

Parameters

  • font : The font to use for rendering this text.

Properties


NameDescriptionType
textThe string content of the text object.str
colorThe color of the text.Color
wrap_widthThe width at which to wrap text. Set to 0 for no wrapping.int
sizeThe size of the text in pixels.Vec2
widthThe width of the text in pixels.int
heightThe height of the text in pixels.int
shadow_colorThe color of the text shadow.Color
shadow_offsetThe offset of the text shadow.Vec2

Methods


Draw

draw(pos: Vec2 = None, anchor: Anchor = Anchor.TOP_LEFT) None

Draw text to the renderer. \n will write text on a new line. A shadow is drawn if shadow_color.a > 0 and shadow_offset is not (0, 0).

Parameters

  • pos : The position to draw the text at. Defaults to (0, 0).
  • anchor : The anchor point to draw the text from. Defaults to TOP_LEFT.

Set Font

set_font(font: Font) None

Set the font to use for drawing text.

Parameters

  • font : The font to use for drawing text.

Get Rect

get_rect() Rect

Get the bounding rectangle of the text.

Returns

Rect : The bounding rectangle of the text.