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 picked
  • hdpi β€” the target horizontal DPI
  • vdpi β€” 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


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