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
font | The font. |
text | The text, in UTF-8. |
length | The length of the text in bytes, or 0 for a string that ends with a null character. |
fg | The color of the text. |
wrap_width | The width in pixels, or 0 to break lines only at a newline character. |
Return value
A new surface, or NULL on failure.
Example
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
- Make a texture from the surface, then free the surface.
In SDL2
Use TTF_RenderUTF8_Blended_Wrapped, which has no length argument.