Draws text string at specified position using loaded font.
Takes text (string to display, any UTF-8 text), x (X position in pixels, integer), y (Y position in pixels, integer), centre (alignment: 0=left-aligned, 1=centered on x position), font (font handle from b2dLoadFont, positive integer).
Returns nothing.
2D Overlay
Parameters & Returns
Parameters
textString
xInt
yInt
centreInt
fontInt
Returns
Void
Quick Summary
Draws text string at specified position using loaded font.
Takes text (string to display, any UTF-8 text), x (X position in pixels, integer), y (Y position in pixels, integer), centre (alignment: 0=left-aligned, 1=centered on x position), font (font handle from b2dLoadFont, positive integer).
Returns nothing.
Technical Exegesis...
Draws text string at specified position using loaded font. Takes text (string to display, any UTF-8 text), x (X position in pixels, integer), y (Y position in pixels, integer), centre (alignment: 0=left-aligned, 1=centered on x position), font (font handle from b2dLoadFont, positive integer). Returns nothing. Queues text draw command to deferred rendering buffer, executed during b3dRenderWorld. Uses current color state from b2dSetColor and alpha from b2dSetAlpha.
Draws text string at specified position using loaded font. Takes text (string to display, any UTF-8 text), x (X position in pixels, integer), y (Y position in pixels, integer), centre (alignment: 0=left-aligned, 1=centered on x position), font (font handle from b2dLoadFont, positive integer). Returns nothing. Queues text draw command to deferred rendering buffer, executed during b3dRenderWorld. Uses current color state from b2dSetColor and alpha from b2dSetAlpha.
Text rendering: uses bitmap font rendering (pre-rendered font texture atlas), supports Unicode/UTF-8 characters (international text), antialiased text (smooth edges), hardware accelerated (GPU texture sampling).
Alignment modes: left-aligned (centre=0, text starts at x position, extends right), centered (centre=1, text centered on x position, extends left and right equally), y position is always text baseline (top of text).
Use cases: (1) UI text (labels, buttons, menu items, descriptions), (2) Debug output (FPS counter, coordinates, status), (3) Game text (scores, health, ammunition, timers), (4) Dialogue (character speech, subtitles, instructions).
Performance: text rendering cost ~0.02ms per string (depends on length), each character is textured quad (2 triangles), batching improves multi-string performance, font texture cached in GPU memory.
Common patterns: left-aligned label = b2dDrawText("Score: "+ToString(score), 10, 10, 0, myFont); centered title = b2dDrawText("GAME OVER", screenWidth/2, 100, 1, titleFont); colored text = b2dSetColor(255,255,0): b2dDrawText("Warning!", x, y, 0, font); transparent text = b2dSetAlpha(0.7): b2dDrawText(message, x, y, 0, font).
Font requirements: font must be loaded with b2dLoadFont before use, invalid font handle ignored (no draw), font determines size and appearance (load different fonts for different sizes).
Related: b2dLoadFont loads font for rendering, b2dFreeFont releases font resources, b2dGetStringWidth measures text width, b2dGetStringHeight measures text height, b2dDrawTextInt draws integer value, b2dDrawTextDouble draws floating-point value.