TTF_RenderText_Solid(3)

πŸ’– TTF_RenderText_Solid(3) πŸ’–

okay bestie, so this is a page straight outta the SDL_ttf3 functions crew β€” say hi to TTF_RenderText_Solid(3), the render girlie who gets your UTF-8 text onto a brand new 8-bit surface at fast quality. she's not fancy, she's not smooth, she's FAST. periodt. ✨


πŸŽ€ NAME πŸŽ€

TTF_RenderText_Solid β€” render UTF-8 text at fast quality to a new 8-bit surface. that's it, that's the whole job, and she eats every time πŸ’…


πŸ“ HEADER FILE πŸ“

she lives in SDL3_ttf/SDL_ttf.h. defined there. no cap. πŸ¦‹


✨ SYNOPSIS ✨

#include "SDL3_ttf/SDL_ttf.h"

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

🌸 DESCRIPTION 🌸

okay so this function allocates a whole new 8-bit, palettized surface for you. the way it works is lowkey iconic:

  • the surface's 0 pixel becomes the colorkey, which is giving transparent background ✨
  • the surface's 1 pixel gets set to the text color

that's the entire palette situation. two pixels. tiny. efficient. she's on a budget and she's thriving. πŸ™ˆ

not me warning you though β€” this will NOT word-wrap your string. you get a surface with a single line of text, as long as the string requires. she will simply keep going. she has no off switch for width.

if you need the output wrapped to multiple lines, you gotta call

TTF_RenderText_Solid_Wrapped()

instead. that's her wrapped sister, she handles that. 🫢

also bestie, heads up: this will not wrap on newline characters. like, \n means nothing to her. she does not see it. she does not care. πŸ’€

if you're feeling ✨ extra ✨ and want other quality levels, you can render with

TTF_RenderText_Shaded,

TTF_RenderText_Blended, and

TTF_RenderText_LCD.

pick your fighter. each one is a different vibe check. πŸ”₯


🧚 FUNCTION PARAMETERS 🧚

  • font β€” the font to render with. your chosen icon. your main character font. πŸ‘‘
  • text β€” the text to render, in UTF-8 encoding. bring it as UTF-8 or don't bring it at all.
  • length β€” the length of the text, in bytes, or 0 for null terminated text. yes, bytes. not vibes. bytes. πŸ“
  • fg β€” the foreground color for the text. the lewk. the whole aesthetic. 🌈

⭐ RETURN VALUE ⭐

returns a new 8-bit, palettized surface, or NULL if there was an error. 😭 if you get NULL, something went wrong, and no, it's not you, it's the error. go check it.


πŸ”’ THREAD SAFETY πŸ”’

this function should be called on the thread that created the font. do not be out here passing her around between threads, she is not about that life. one font, one thread, one love. πŸ’œ


πŸ¦‹ AVAILABILITY πŸ¦‹

this function is available since SDL_ttf 3.0.0. so if you're on anything older, she simply does not exist yet. sorry babe. πŸ™ˆ


πŸ‘€ SEE ALSO πŸ‘€

the original lists these in the silliest way possible and honestly? we're keeping it, character for character:

β€’(3), TTF_RenderText_Blended(3), β€’(3), TTF_RenderText_LCD(3), β€’(3),
TTF_RenderText_Shaded(3), β€’(3), TTF_RenderText_Solid(3), β€’(3),
TTF_RenderText_Solid_Wrapped(3)

yeah those lone β€’(3) bits are literally in there. iykyk. πŸ’€ the actual friends to go visit are:


ok that's the whole page bestie, go render something gorgeous. πŸ’…βœ¨

and that's a wrap from your girl at SDL_ttf, shipping out with version SDL_ttf 3.2.2 β€” mwah, love u, bye πŸŽ€πŸ’–πŸ¦‹

πŸ“¦ where this page comes from