TTF_RenderText_LCD(3)

πŸ’– TTF_RenderText_LCD(3) πŸ’–

okay bestie, welcome to the SDL_ttf3 functions club β€” this one lives in the SDL_ttf3 section of the manual, and it is literally the glow-up your text has been waiting for. ✨


✨ NAME ✨

TTF_RenderText_LCD β€” render UTF-8 text at LCD subpixel quality to a new ARGB surface. it's giving crisp. it's giving subpixel. it's giving ✨new surface✨.


πŸ“ HEADER FILE πŸ“

Defined in SDL3_ttf/SDL_ttf.h β€” that's the one, don't @ me. πŸŽ€


πŸ¦‹ SYNOPSIS πŸ¦‹

#include "SDL3_ttf/SDL_ttf.h"

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

copy it exactly, no cap. πŸ’…


🌸 DESCRIPTION 🌸

so the way this works: this function will allocate a new 32-bit, ARGB surface, and render alpha-blended text using FreeType's LCD subpixel rendering. it returns the new surface, or NULL if there was an error. that's it, that's the whole vibe. πŸ’œ

⚠️ heads up: it returns NULL on error, so check your pointer before you go using it, bestie. 😭

this will not word-wrap the string. you'll get a surface with a single line of text, as long as the string requires. if you need to wrap the output to multiple lines, use

TTF_RenderText_LCD_Wrapped () instead. 🫢

this will not wrap on newline characters. nope. not happening. πŸ™ˆ

and if you wanna render at other quality levels, you have options, icon:

  • TTF_RenderText_Solid
  • TTF_RenderText_Shaded
  • TTF_RenderText_Blended

pick your fighter. πŸ‘‘


πŸŽ€ FUNCTION PARAMETERS πŸŽ€

  • font β€” the font to render with. your main character. 🧚
  • text β€” text to render, in UTF-8 encoding. yes, UTF-8, we're not living in the dark ages. 🌈
  • length β€” the length of the text, in bytes, or 0 for null terminated text. zero means "just read til the null, trust". ⭐
  • fg β€” the foreground color for the text. the lewk. πŸ’…
  • bg β€” the background color for the text. the canvas behind the lewk. πŸ“

🫢 RETURN VALUE 🫢

Returns a new 32-bit, ARGB surface, or NULL if there was an error. that's the whole deal, fr fr. πŸ”₯


🧡 THREAD SAFETY 🧡

This function should be called on the thread that created the font. like, the same thread. don't be sending it off to some other thread, it'll get messy. πŸ’€


πŸ“… AVAILABILITY πŸ“…

This function is available since SDL_ttf 3.0.0. vintage-ish but make it slay. ✨


πŸ‘€ SEE ALSO πŸ‘€

go read those too, iykyk. πŸ“šπŸ’–


okay that's the whole page, bestie β€” go render something gorgeous. this lil manual moment came to you from SDL_ttf, version SDL_ttf 3.2.2, and it's filed under TTF_RenderText_LCD(3). mwah, bye! πŸ’‹πŸŽ€βœ¨

πŸ“¦ where this page comes from