Overview
Text functions provide capabilities for rendering text, loading custom fonts, and measuring text dimensions.Basic Text Drawing
drawText
Draws text using the default font.Text to draw
X position
Y position
Font size
Text color
drawFPS
Draws current FPS at specified position.X position
Y position
Custom Font Drawing
drawTextEx
Draws text using a custom font with spacing.Font to use
Text to draw
Position to draw at
Font size
Character spacing
Text color
drawTextPro
Draws text using font with pro parameters (rotation, origin).Font to use
Text to draw
Position
Rotation origin
Rotation in degrees
Font size
Character spacing
Text color
Font Loading
loadFont
Loads font from file into GPU memory (TTF, OTF).Path to font file
Font - Loaded font
loadFontEx
Loads font from file with extended parameters.Path to font file
Base font size
Array of codepoints to load (null for default)
Number of codepoints
Font - Loaded font
getFontDefault
Returns the default font. Returns:Font - Default font
isFontValid
Checks if a font is valid.Font to check
Boolean - True if valid
unloadFont
Unloads font from GPU memory.Font to unload
Text Measurement
measureText
Measures string width for default font.Text to measure
Font size
Number - Text width in pixels
measureTextEx
Measures string size for Font.Font to use for measurement
Text to measure
Font size
Character spacing
Vector2 - Text dimensions (width, height)
Text Configuration
setTextLineSpacing
Sets vertical line spacing when drawing text.Line spacing in pixels
Text Manipulation
These functions operate on strings at the Wren level:textLength
Returns text length (including null terminator).Text to measure
Number - Text length
textCopy
Copies text to another string.Destination string
Source string
textIsEqual
Checks if two text strings are equal.First text
Second text
Boolean - True if equal
textSubtext
Returns a substring from text.Source text
Start position
Substring length
String - Substring
textToUpper
Converts string to uppercase.Text to convert
String - Uppercase text
textToLower
Converts string to lowercase.Text to convert
String - Lowercase text
textToInteger
Converts text to integer.Text to convert
Number - Integer value
textToFloat
Converts text to float.Text to convert
Number - Float value
Complete Example
Best Practices
Use
measureText() or measureTextEx() to center text or calculate layout dimensions.