FreeRTOS Tetris
TUM_Font.h
Go to the documentation of this file.
1 
25 #ifndef __TUM_FONT_H__
26 #define __TUM_FONT_H__
27 
28 #include <SDL2/SDL_ttf.h>
29 
30 #include "EmulatorConfig.h"
31 
49 #ifndef DEFAULT_FONT_SIZE
50 #define DEFAULT_FONT_SIZE 15
51 #endif //DEFAULT_FONT_SIZE
52 
56 #ifndef DEFAULT_FONT
57 #define DEFAULT_FONT "IBMPlexSans-Medium.ttf"
58 #endif //DEFAULT_FONT
59 
63 #ifndef FONTS_DIRECTORY
64 #ifdef RESOURCES_DIRECTORY
65 #define FONTS_DIRECTORY "/" RESOURCES_DIRECTORY "/fonts/"
66 #else
67 #define FONTS_DIRECTORY "/../resources/fonts/"
68 #endif //RESOURCES_DIRECTORY
69 #endif // FONTS_DIRECTORY
70 
71 #define FONTS_DIR "/" FONTS_DIRECTORY "/"
72 
76 #define MAX_FONT_NAME_LENGTH 256
77 
83 typedef void *font_handle_t;
84 
95 int tumFontLoadFont(char *font_name, ssize_t size);
96 
105 int tumFontInit(char *path);
106 
111 void tumFontExit(void);
112 
123 TTF_Font *tumFontGetCurFont(void);
124 
133 void tumFontPutFont(TTF_Font *font);
134 
144 
153 
159 ssize_t tumFontGetCurFontSize(void);
160 
167 char *tumFontGetCurFontName(void);
168 
178 int tumFontSelectFontFromName(char *font_name);
179 
187 
198 int tumFontSetSize(ssize_t font_size);
199 
201 #endif // __TUM_FONT_H__
tumFontInit
int tumFontInit(char *path)
Initializes the font backend, the executing binary path is required, this is usually already passed t...
Definition: TUM_Font.c:111
tumFontGetCurFontName
char * tumFontGetCurFontName(void)
Retrieved the string name of the currently active font.
Definition: TUM_Font.c:229
tumFontGetCurFontHandle
font_handle_t tumFontGetCurFontHandle(void)
Retrieved a handle to the current font, unlike tumFontGetCurFont() the handle contains the TUM_Font's...
Definition: TUM_Font.c:237
tumFontPutFontHandle
void tumFontPutFontHandle(font_handle_t font)
Finds the tum_font object associated with the loaded SDL2 TFF font, decreasing the reference count to...
Definition: TUM_Font.c:148
tumFontExit
void tumFontExit(void)
Exits the font backend.
Definition: TUM_Font.c:132
tumFontGetCurFontSize
ssize_t tumFontGetCurFontSize(void)
Returns the size of the currently active font.
Definition: TUM_Font.c:221
tumFontSetSize
int tumFontSetSize(ssize_t font_size)
Sets the size of the current font to be used. The font is set by making a copy of the current font if...
Definition: TUM_Font.c:312
tumFontGetCurFont
TTF_Font * tumFontGetCurFont(void)
Retrieved a reference to the current SDL2 TTF font, increasing the reference count of the respective ...
Definition: TUM_Font.c:207
tumFontPutFont
void tumFontPutFont(TTF_Font *font)
Finds the tum_font object associated with the loaded SDL2 TFF font, decreasing the reference count to...
Definition: TUM_Font.c:178
font_handle_t
void * font_handle_t
Handle used to reference a specific font/size configuration when restoring a font using tumFontSelect...
Definition: TUM_Font.h:83
tumFontSelectFontFromHandle
int tumFontSelectFontFromHandle(font_handle_t font_handle)
Sets the active font based off of a font handle.
Definition: TUM_Font.c:295
tumFontSelectFontFromName
int tumFontSelectFontFromName(char *font_name)
Sets the active font from a string of the font's filename. The filename is not the absolute file but ...
Definition: TUM_Font.c:277
tumFontLoadFont
int tumFontLoadFont(char *font_name, ssize_t size)
Loads a font with the given font name from the FONTS_DIRECTORY directory, by default this is in resou...
Definition: TUM_Font.c:261
EmulatorConfig.h
File containing some configuration for the FreeRTOS Emulator.