Download Documentation API Reference Samples Asset Store Donate




Text


Text Size



Set .scale or .world_scale:
text_entity = Text('hello', world_scale=2)

Changing default text size (globally):
Text.size = .05 # make all the text double as big (default: .025).

Changing the text size of the non-uniformly scaled Button:
button = Button(scale=(.2,.1), text='Start') button.text_entity.world_scale = 2 # make the text_entity twice as big.



Font and Resolution



For one Text Entity:

text = Text(font='VeraMono.ttf', resolution=100*Text.size) text.text = descr

For all Text Entities:

Text.default_font = 'VeraMono.ttf' Text.default_resolution = 100 * Text.size

Keep in mind you don't *have* to change the resolution, but for pixel fonts for example, you
might want a higher resolution in order for it to not appear blurry.


Text Alignment



Change text alignment by setting .origin:
Text('Hello\nWorld!', origin=(-.5,.5)) # the default. text starts in the upper left like normal. Text('Hello\nWorld!', origin=(0,0)) ``` is centered both horizontally and vertically.



Text Colors



Set .color to color the whole text.
t = Text('This is some text', color=color.blue)

Use tags to color parts of the text.
t = Text('This is some <pink>colored text. <default>Reset color back to default.', color=color.blue)


Changing Text of Prefabs



Things like Slider, InputField, etc., usually has .text_entity which you can access if you need it.