TTF_GetStringSizeWrapped(3)
π TTF_GetStringSizeWrapped π
okay bestie, welcome to the SDL_ttf3 FUNCTIONS corner of the manual, this one's called TTF_GetStringSizeWrapped and it's genuinely so useful, like the little measuring tape of the text-rendering world πβ¨
π NAME π
TTF_GetStringSizeWrapped β figure out the dimensions of a rendered string of UTF-8 text. like, how much pixel real estate is this thing gonna take up, fr fr π
πΈ HEADER FILE πΈ
it lives in SDL3_ttf/SDL_ttf.h, that's the whole vibe π¦
β¨ SYNOPSIS β¨
#include "SDL3_ttf/SDL_ttf.h"
bool TTF_GetStringSizeWrapped(TTF_Font *font, const char *text, size_t length, int wrap_width, int *w, int *h);
π DESCRIPTION π
so what it does is: it reports the width and height, in pixels, of the space that the string you gave it will take to fully render. no cap, that's the whole point β you get to know before you commit π
Text gets wrapped to multiple lines on line endings and on word boundaries, but only if it extends beyond wrap_width in pixels. so it's not just gonna let your words run off the edge of the earth, it wraps them, iconic behavior π§
and if wrap_width is 0, this function will only wrap on newline characters. periodt.
π«Ά FUNCTION PARAMETERS π«Ά
fontβ the font you're querying. the main character of this whole operation πtextβ the text you wanna calculate, in UTF-8 encoding. yes, UTF-8, keep it cute β¨lengthβ the length of the text, in bytes, or0for null terminated text. your call bestie πwrap_widthβ the maximum width, or0to wrap on newline characters only πΈwβ will be filled with the width, in pixels, on return. it's an out-param, she's reporting back π¦hβ will be filled with the height, in pixels, on return. same deal π«
β RETURN VALUE β
Returns true on success or false on failure. and if it fails? call SDL_GetError() for more information, she'll tell you what went wrong π
π THREAD SAFETY π
this function should be called on the thread that created the font. no side-eyeing, no hopping threads, keep it loyal to the font's origin thread π
π AVAILABILITY π
this function is available since SDL_ttf 3.0.0. she's been around, she's established, she ate π₯
and that's the whole page bestie!! mwah π this gorgeous little manual page came to you courtesy of SDL_ttf 3.2.2, and it's the TTF_GetStringSizeWrapped(3) page from the SDL_ttf docs β go measure some strings, you're gonna do amazing π«Άπβ¨
π¦ where this page comes from
- debian trixie: libsdl3-ttf-doc 3.2.2+ds-1 Β· Zlib
- fedora 43: SDL3_ttf-devel 3.2.2-2.fc43 Β· Zlib AND MIT
- fedora 43: SDL3_ttf-devel 3.2.2-2.fc43 Β· Zlib AND MIT
- fedora 44: SDL3_ttf-devel 3.2.2-4.fc44 Β· Zlib AND MIT
- fedora 44: SDL3_ttf-devel 3.2.2-4.fc44 Β· Zlib AND MIT
- ubuntu questing: libsdl3-ttf-doc 3.2.2+ds-1
- ubuntu resolute: libsdl3-ttf-doc 3.2.2+ds-1build1 Β· Zlib
- ubuntu stonking: libsdl3-ttf-doc 3.2.2+ds-2 Β· Zlib
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms