TTF_SetFontSizeDPI(3)
β¨ TTF_SetFontSizeDPI β¨
okay bestie so we're in the SDL_ttf3 functions era and today's main character is TTF_SetFontSizeDPI β she sets your font size dynamically, but with target resolutions in dots per inch. dpi-aware font sizing, we love to see it π
π HEADER FILE
She lives in SDL3_ttf/SDL_ttf.h β defined there, no cap.
π SYNOPSIS
#include "SDL3_ttf/SDL_ttf.h"
bool TTF_SetFontSizeDPI(TTF_Font *font, float ptsize, int hdpi, int vdpi);
look at her. three ints, one float, one bool. iconic honestly π
π DESCRIPTION
So here's the tea: this one updates any TTF_Text objects that are using this font, and it clears already-generated glyphs from the cache, if there are any. glowy fresh start energy β¨
ποΈ FUNCTION PARAMETERS
fontβ the font you wanna resize, queen πptsizeβ the new point size, freshly pickedhdpiβ the target horizontal DPIvdpiβ the target vertical DPI
π«Ά RETURN VALUE
Returns true when it ate and false when it did NOT eat π β and if it's false, go call SDL_GetError() for more info, she'll tell you what went wrong.
π§΅ THREAD SAFETY
Lowkey important: call this function on the thread that created the font. don't be out here cross-threading, it's giving chaos π
π AVAILABILITY
Been here since SDL_ttf 3.0.0 β a certified day-one legend β
π SEE ALSO
β’(3)TTF_GetFontSize(3)β’(3)TTF_GetFontSizeDPI(3)
and that's the whole page bestie, every last detail intact, no crumbs left behind ππ this was SDL_ttf 3.2.2 doing the absolute most, mwah, go resize something pretty πβ¨
π¦ 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