SDL School

API reference / Text with SDL_ttf

TTF_RenderText_Blended_Wrapped

Function, SDL_ttf

Draws text into a new surface, with smooth edges. Long text breaks onto new lines at the width that you choose.

Declaration

#include <SDL3_ttf/SDL_ttf.h>

SDL_Surface * TTF_RenderText_Blended_Wrapped(TTF_Font *font, const char *text, size_t length, SDL_Color fg, int wrap_width);

Parameters

fontThe font.
textThe text, in UTF-8.
lengthThe length of the text in bytes, or 0 for a string that ends with a null character.
fgThe color of the text.
wrap_widthThe width in pixels, or 0 to break lines only at a newline character.

Return value

A new surface, or NULL on failure.

Example

Draw text
SDL_Surface *surface = TTF_RenderText_Blended_Wrapped(font, text, 0, color, wrap_width);

See this code run in Draw text. Download the full program (.zip)

Notes

In SDL2

Use TTF_RenderUTF8_Blended_Wrapped, which has no length argument.

See also