Kraken Logo

Kraken Engine

DocumentationGuidesShowcaseCommunity
Ctrl
K
Navigating the Docs
Building Docs
Overview
Anchor
AnimationController
Audio
Batcher
Body
Camera
Capsule
CastHit
CharacterBody
Circle
Collision
Color
DistanceJoint
Effect
Event
FilterJoint
Flip (Texture)
Font
ImageLayer
InputAction
Joint
Layer
Line
Map
MapObject
Mask
MotorJoint
MouseJoint
ObjectGroup
Orchestrator
PixelArray
PolarCoordinate
Polygon
PrismaticJoint
Rect
RevoluteJoint
RigidBody
Sample
Sampler
Shader
SheetStrip
StaticBody
Stream
Style
Terrain (TileSet)
Text
TextProperties
Texture
Tile (TileLayer)
Tile (TileSet)
TileLayer
TileResult (TileLayer)
TileSet
Timer
Transform
Tween
Vec2
Vertex
WeldJoint
WheelJoint
World

Built bydurkisneer1.Kraken Engine is open source and available onGitHub.

  1. Docs
  2. Classes
  3. Text

Text

A text object for rendering text to the active renderer.

Constructor

  • Text(font: Font, text: str = '') → TextText(font: Font, text: str = '') → Text

A text object for rendering text to the active renderer.

Properties


NameDescriptionType
colorGet or set the color of the rendered text.Color
heightGet the height in pixels of the current text.int
shadow_colorGet or set the shadow color for the text.Color
shadow_offsetGet or set the shadow offset for the text.Vec2
sizeGet the size (width, height) of the current text as a Vec2.Vec2
textGet or set the text string to be rendered.str
widthGet the width in pixels of the current text.int
wrap_widthGet or set the wrap width in pixels for text wrapping.int

Methods


Draw

draw(pos: Vec2 = Vec2(0.0, 0.0), anchor: Vec2 = Vec2(0.0, 0.0)) → Nonedraw(pos: Vec2 = Vec2(0.0, 0.0), anchor: Vec2 = Vec2(0.0, 0.0)) → None

Draw the text to the renderer at the specified position with alignment. A shadow is drawn if shadow_color.a > 0 and shadow_offset is not (0, 0).

Args

  • pos : The position in pixels. Defaults to (0, 0).
  • anchor : The anchor point for alignment (0.0-1.0). Defaults to top left (0, 0).

Raises

  • RuntimeError : If the renderer is not initialized or text drawing fails.
  • RuntimeError : If the text font is not set or has gone out of scope.

Get Rect

get_rect() → Rectget_rect() → Rect

Get the bounding rectangle of the current text.

Returns

Rect : A rectangle with x=0, y=0, and width/height of the text.

Set Font

set_font(font: Font) → Noneset_font(font: Font) → None

Set the font to use for rendering this text.

Args

  • font : The font to use.
PreviousTerrain (TileSet)
NextTextProperties

On this page

ConstructorPropertiesMethodsDrawGet RectSet Font