TTF_CloseFont(3)
π TTF_CloseFont(3) π
okay bestie, gather round, because this one is short but it MATTERS. we're in the SDL_ttf3 FUNCTIONS section of the manual, and today's main character is TTF_CloseFont. she's the goodbye girl. the one who cleans up after the party. no cap.
β¨ NAME β¨
TTF_CloseFont β dispose of a previously-created font.
like, yeet it. responsibly. π
πΈ HEADER FILE πΈ
defined in SDL3_ttf/SDL_ttf.h
π¦ SYNOPSIS π¦
#include "SDL3_ttf/SDL_ttf.h"
void TTF_CloseFont(TTF_Font *font);
look at her. one function, one argument, zero drama. iconic.
π DESCRIPTION π
call this when you're done with a font, bestie. this function will free any resources associated with it. that's it, that's the job. she takes the font and she frees everything it was holding onto. very demure, very mindful.
and here's the part that makes her sooooo forgiving: it is safe to call this function on NULL, for example on the result of a failed call to TTF_OpenFont(). so if your font-opening went sideways and you got NULL back, you can still hand it to TTF_CloseFont and she will simply not care. no crash, no tears. π«Ά
β οΈ but listen. the font is not valid after being passed to this function. gone. done. do not touch. do not look at it. do not pass go.
and it's not just the font object itself β string pointers from functions that return information on this font, such as TTF_GetFontFamilyName() and TTF_GetFontStyleName(), are no longer valid after this call, as well. so if you were holding onto one of those strings thinking you could use it later? nope. she's dust. π
π FUNCTION PARAMETERS π
fontβ the font to dispose of. hand her over and let her go. ποΈ
π THREAD SAFETY π
this function should not be called while any other thread is using the font.
read that again. fr fr. if another thread is out here using that font, you do NOT get to close it yet. that's not a vibe check you want to fail. π
β AVAILABILITY β
this function is available since SDL_ttf 3.0.0.
π SEE ALSO π
β’(3),TTF_OpenFont(3),β’(3),TTF_OpenFontIO(3)
(yes bestie, the bullet-thingies are literally in the source. we keep it real here. β¨)
that's the whole page, gorgeous. short, sweet, and absolutely essential β because every font you open needs a bestie who'll close her properly. π
SDL_ttf, version 3.2.2 β that's the source and version this page came from, mwah, talk later, don't forget to free your fonts ππΈπ¦
π¦ 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