![]() |
LibGame v0.4.0
The LG Game Engine - Copyright (C) 2024-2026 ETMSoftware
|
Functions | |
| void | lg_fonts_list_init () |
| zboolean | lg_fonts_list_is_initialized () |
| zboolean | lg_font_add_to_list (const char *name, const char *relative_path, int size) |
| LG_Font * | lg_font_get (const char *name) |
| TTF_Font * | lg_font_get_ttf (const char *name) |
| TTF_Font * | lg_font_get_ttf_fallback (const char *name) |
| void | lg_font_free (const char *name) |
| void | lg_font_free_all () |
| void | lg_font_list_all () |
| void | lg_font_info (LG_Font *font) |
| zboolean | lg_font_load_array (LG_Font_Des fonts[], int n_fonts) |
| void | lg_font_list_array (LG_Font_Des fonts[], int n_fonts) |
=== Fonts things === TODO: using a simple list, should use a doubly-linked one to remove some stupid limitations
| void lg_fonts_list_init | ( | ) |
Initialize the global fonts list
We use a simple list at the moment
TODO: should use a doubly-linked one
| zboolean lg_fonts_list_is_initialized | ( | ) |
Check if the global fonts list has been initialized
| zboolean lg_font_add_to_list | ( | const char * | name, |
| const char * | relative_path, | ||
| int | size | ||
| ) |
Add a font to the global fonts list
Load a font once from file and register it with a user-defined name, so that it's easy later on to use it just by name
Max number of fonts is N_FONTS_MAX, defined in lg_wins.h
To check out game engine preloaded fonts, see: lg_load_engine_fonts()
=== TODO: using a simple list, should use a doubly-linked one to remove some stupid limitations ===
| name | A user-defined font name - whatever you want but you should pick sth short but descriptive and not confusing |
| relative_path | Path inside the fonts folder, not relative if symlink |
| size | Font size |
| LG_Font * lg_font_get | ( | const char * | name | ) |
| TTF_Font * lg_font_get_ttf | ( | const char * | name | ) |
Retrieve a TTF_Font from the global fonts list - search by name
| name | A user-defined font name |
| TTF_Font * lg_font_get_ttf_fallback | ( | const char * | name | ) |
Retrieve a TTF_Font from the global fonts list - search by name
Do the same as the above func then, if the requested font is not found, fall back to 'IntelOneMono-Bold.ttf' 18, which is (should) always be available
| name | A user-defined font name |
| void lg_font_free | ( | const char * | name | ) |
Find font by name and free all associated resources
You should probably not use this func because:
WARNING1: Removing a TTF font will likely remove all registered sizes
WARNING2: Doesn't enable to add extra fonts, only free all font resources (because the fonts list is not a doubly-linked one)
| name | Font user-defined name |
| void lg_font_free_all | ( | ) |
Free all fonts and associated resources from the list
To use the list again, you should first initialize it
WARNING:
| void lg_font_list_all | ( | ) |
List all loaded fonts
| zboolean lg_font_load_array | ( | LG_Font_Des | fonts[], |
| int | n_fonts | ||
| ) |
Load an array of LG_Font_Des and add them to the global fonts list
| fonts | An array of LG_Font_Des |
| n_fonts | Num of fonts |
| void lg_font_list_array | ( | LG_Font_Des | fonts[], |
| int | n_fonts | ||
| ) |
Print out nicely an array of LG_Font_Des
| fonts | An array of LG_Font_Des |
| n_fonts | Num of fonts |