Skip to main content

Text

text!

Draws ASCII text.

turbo::canvas
text!(
&str,
x = i32,
y = i32,
color = u32,
font = &str
)
ParamTypeDefaultDescription
-&str-Text to be displayed
xi320Starting x position of the text
yi320Starting y position of the text
coloru320xffffffffHex color to display text in
font&str"medium"Size to display text in: "small", "medium", or "large"
note

For font sizes Turbo has "small", "medium", and "large" available by default.

Basic Usage

text!("Hello, world!");

Hello, World Screenshot

Advanced Usage

Customized text with specified position, color, and font size:

text!(
"Greetings, earthlings >:3",
x = 30,
y = 40,
color = 0x00ff00ff,
font = "small"
);

Greetings, Earthlings Screenshot

Custom Fonts

You can add custom fonts by creating a folder called fonts and adding a font file in there. Then call the font by using it's name (minus the file extension).

text!("Magic Missile!!", font = "OldWizard");

Magic Missile Screenshot

tip

Head over to Use Custom Fonts to learn more about custom fonts!