A lightweight python game engine powered by SDL3
Luma supports TrueType font rendering through the engine’s font system.
Open a font with engine.Font.open(path, size):
font = engine.Font.open("examples/font.TTF", 16)
The returned font object is used to create drawable text surfaces.
Create a text object with font.write(text, x=0, y=0):
text = font.write("hello world", 20, 40)
The text object exposes x, y, text, and font properties and can be
redrawn every frame with text.draw():
@engine.draw
def draw():
graphics.setDrawColor(255, 255, 255)
text.draw()
The current draw color is applied when text is rendered, and the text object
can be updated by changing text.text, text.x, text.y, or text.font.
For example:
text.text = "PRESS SPACE!"
text.x += 10
text.y = 100
A full working example is available in examples/font.py.
python examples/font.py
That script demonstrates loading a font, creating text objects, drawing them, and updating their content and position at runtime.