TTF_SetFontScript(3)

πŸ’– TTF_SetFontScript(3) πŸ’–

okay bestie, welcome to the SDL_ttf3 FUNCTIONS corner of the manual, and today's main character is TTF_SetFontScript ✨


🌸 NAME 🌸

TTF_SetFontScript β€” set the script that a font uses for text shaping. that's it, that's the whole job πŸ’…


πŸ“ HEADER FILE πŸ“

it lives in SDL3_ttf/SDL_ttf.h, no cap 🫢


✨ SYNOPSIS ✨

#include "SDL3_ttf/SDL_ttf.h"

bool TTF_SetFontScript(TTF_Font *font, Uint32 script);

look at that signature, so clean, so iconic πŸ‘‘


πŸ¦‹ DESCRIPTION πŸ¦‹

so here's the tea: this returns false if SDL_ttf isn't built with HarfBuzz support. like, no HarfBuzz, no script-setting, sorry babe 😭

also lowkey important β€” this updates any TTF_Text objects using this font. so it's not just a vibe change for the font itself, it ripples out to the text objects too 🌊


πŸŽ€ FUNCTION PARAMETERS πŸŽ€

  • font β€” the font you're modifying. your little typography baby 🍼
  • script β€” an ISO 15924 code. the link in the original is a lil cursed-looking, so here it is exactly as-is:
https://unicode.www:lenstrwww:splitstr:nwww:splitstr:r[char46]org/iso15924/iso15924-codes.www:lenstrwww:splitstr:nwww:splitstr:r[char46]html

iykyk, it's the ISO 15924 codes page πŸ’œ


⭐ RETURN VALUE ⭐

returns true on success or false on failure 🫠 and if it fails, go call SDL_GetError() for more information. she will tell you what went wrong, fr fr


🧡 THREAD SAFETY 🧡

this function should be called on the thread that created the font. don't be out here calling it from some random thread, that's not the vibe πŸ™ˆ


🌈 AVAILABILITY 🌈

this function is available since SDL_ttf 3.0.0 ⭐


πŸ‘€ SEE ALSO πŸ‘€


and that's the whole page, bestie πŸ’– this was brought to you by SDL_ttf 3.2.2, straight from the SDL_ttf era of the docs. go forth and shape some text, you absolute legend πŸ¦‹πŸ’…πŸŽ€

πŸ“¦ where this page comes from