TTF_RenderT...aded_Wrapped(3)

πŸ’– TTF_RenderText_Shaded_Wrapped β€” from the SDL_ttf3 FUNCTIONS era πŸ’–

okay bestie, sit down, hydrate, because we're about to render some word-wrapped UTF-8 text at high quality to a brand new 8-bit surface and honestly? iconic behavior. this one lives in the SDL_ttf 3 function family, iykyk. πŸŽ€


✨ NAME ✨

TTF_RenderText_Shaded_Wrapped β€” Render word-wrapped UTF-8 text at high quality to a new 8-bit surface. periodt. πŸ’…


πŸ¦‹ HEADER FILE πŸ¦‹

she's defined in SDL3_ttf/SDL_ttf.h β€” that's the one, that's the file, no cap.


🌸 SYNOPSIS 🌸

#include "SDL3_ttf/SDL_ttf.h"

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

look at her. six whole parameters. main character energy fr fr. πŸ‘‘


πŸ’œ DESCRIPTION πŸ’œ

so the way this works: this function will allocate a new 8-bit, palettized surface. the surface's 0 pixel is gonna be the background color you specified, and every other pixel gets varying degrees of the foreground color. it hands you back that new surface, or NULL if something went wrong. 😭

text gets wrapped to multiple lines on line endings and on word boundaries if it extends beyond wrap_width in pixels. so it's giving responsible, tidy, well-behaved text. ✨

and listen β€” if wrap_width is 0, this function will only wrap on newline characters. that's it. that's the whole rule. no pixel-width drama, just newlines. 🌈

you can also render at other quality levels, if you're feeling a different vibe:

  • TTF_RenderText_Solid_Wrapped
  • TTF_RenderText_Blended_Wrapped
  • TTF_RenderText_LCD_Wrapped

pick your fighter bestie 🫢


πŸŽ€ FUNCTION PARAMETERS πŸŽ€

  • font β€” the font to render with. your chosen one. your muse. πŸ’–
  • text β€” the text to render, in UTF-8 encoding. yes UTF-8, we're not doing 2003 encodings here. πŸ™ˆ
  • length β€” the length of the text, in bytes, or 0 for null terminated text. (bytes, not vibes β€” actually count them.)
  • fg β€” the foreground color for the text.
  • bg β€” the background color for the text.
  • wrap_width β€” the maximum width of the text surface, or 0 to wrap on newline characters. that zero again. she's special. ✨

⭐ RETURN VALUE ⭐

returns a new 8-bit, palettized surface, or NULL if there was an error. if you get NULL, that's not a slay, that's an error, check it. πŸ’€


🧡 THREAD SAFETY 🧡

this function should be called on the thread that created the font. the font's thread. her thread. don't be out here threading her from somewhere else, that's rude. πŸ™…β€β™€οΈ


🌟 AVAILABILITY 🌟

this function is available since SDL_ttf 3.0.0. so if you're on something older, sorry babe, upgrade. πŸ¦‹


πŸ‘‘ SEE ALSO πŸ‘‘

go read those too, bestie, they're all in the same little friend group. πŸ’œ


okay that's the whole page!! tysm for reading, mwah 🫢 this little legend comes to you from SDL_ttf 3.2.2, and yeah, that's the version and the source of the page β€” consider this your cute lil sign-off, go render something gorgeous, you got this πŸ’–βœ¨πŸŽ€

πŸ“¦ where this page comes from