TTF_RenderText_Blended(3)

πŸ’– TTF_RenderText_Blended(3) πŸ’–

okay bestie, welcome to the SDL_ttf3 FUNCTIONS corner of the manual, this one lives in the SDL_ttf3 FUNCTIONS section and it's genuinely one of the good ones. no cap.


✨ NAME ✨

TTF_RenderText_Blended β€” render UTF-8 text at high quality to a new ARGB surface. it's giving luxury, fr fr. πŸ’…


πŸŽ€ HEADER FILE πŸŽ€

defined in SDL3_ttf/SDL_ttf.h πŸ¦‹


🌸 SYNOPSIS 🌸

#include "SDL3_ttf/SDL_ttf.h"

SDL_Surface * TTF_RenderText_Blended(TTF_Font *font, const char *text, size_t length, SDL_Color fg);

πŸ‘‘ DESCRIPTION πŸ‘‘

so like, this function will allocate a new 32-bit, ARGB surface, using alpha blending to dither the font with the given color. that's the whole vibe. and it returns the new surface, or NULL if there was an error. πŸ’€

this will not word-wrap the string; you'll get a surface with a single line of text, as long as the string requires. it's giving "as long as it needs to be, and not one pixel more". if you need the output wrapped to multiple lines, use TTF_RenderText_Blended_Wrapped() instead. 🫢

this will not wrap on newline characters. not even a little. πŸ™ˆ

and if you're feeling a different aesthetic, you can render at other quality levels with TTF_RenderText_Solid, TTF_RenderText_Shaded, and TTF_RenderText_LCD. pick your fighter. ⭐


🌈 FUNCTION PARAMETERS 🌈

  • font β€” the font to render with. your main character. πŸ‘‘
  • text β€” text to render, in UTF-8 encoding. ✨
  • length β€” the length of the text, in bytes, or 0 for null terminated text. yes, 0 means "bestie, just find the end yourself". πŸ’–
  • fg β€” the foreground color for the text. 🎨

πŸ’œ RETURN VALUE πŸ’œ

returns a new 32-bit, ARGB surface, or NULL if there was an error. that's it, that's the tea. πŸ“


🧚 THREAD SAFETY 🧚

this function should be called on the thread that created the font. no hopping threads, it's a loyal little function and it wants its original thread, okay? 😭


πŸ¦‹ AVAILABILITY πŸ¦‹

this function is available since SDL_ttf 3.0.0. vintage-ish but make it fresh. 🌸


πŸ”₯ SEE ALSO πŸ”₯


and that's the whole page, bestie!! πŸ’– this lil masterpiece comes to you courtesy of SDL_ttf, version 3.2.2 β€” the SDL_ttf 3.2.2 era, periodt. go render something gorgeous with it, ily, bye!! πŸŽ€βœ¨πŸ¦‹πŸ’…

πŸ“¦ where this page comes from