FreeRTOS Tetris
Data Structures | Macros | Typedefs | Functions | Variables
TUM_Font.c File Reference

Manages fonts used in TUM Draw. More...

#include <stdlib.h>
#include <pthread.h>
#include "TUM_Font.h"
#include "TUM_Utils.h"
Include dependency graph for TUM_Font.c:

Data Structures

struct  tum_font_ref
 
struct  tum_font
 

Macros

#define PRINT_TTF_ERROR(msg, ...)
 

Typedefs

typedef struct tum_font tum_font_t
 

Functions

static char * getFontPath (char *font_name)
 
static struct tum_fonttumFontCreateFont (char *font_name, ssize_t size)
 
int tumFontInit (char *path)
 Initializes the font backend, the executing binary path is required, this is usually already passed to TUM_Draw init and subsequently to tumFontInit. More...
 
void tumFontDeleteFont (struct tum_font *font)
 
void tumFontExit (void)
 Exits the font backend. More...
 
void tumFontPutFontHandle (font_handle_t font)
 Finds the tum_font object associated with the loaded SDL2 TFF font, decreasing the reference count to the object with each call, once an object's reference count has reached zero and the font backed has flagged the tum_font object as no longer being needed it is then free'd. More...
 
void tumFontPutFont (TTF_Font *font)
 Finds the tum_font object associated with the loaded SDL2 TFF font, decreasing the reference count to the object with each call, once an object's reference count has reached zero and the font backed has flagged the tum_font object as no longer being needed it is then free'd. More...
 
TTF_Font * tumFontGetCurFont (void)
 Retrieved a reference to the current SDL2 TTF font, increasing the reference count of the respective tum_font object. Objects can not be free'd until all references have been put, this for each call to tumFontGetCurFont() a call to tumFontPutFont() must be made, passing in the SDL2 TTF font reference returned from this function. More...
 
ssize_t tumFontGetCurFontSize (void)
 Returns the size of the currently active font. More...
 
char * tumFontGetCurFontName (void)
 Retrieved the string name of the currently active font. More...
 
font_handle_t tumFontGetCurFontHandle (void)
 Retrieved a handle to the current font, unlike tumFontGetCurFont() the handle contains the TUM_Font's metadata structure for the font instance where as tumFontGetCurFont() returns a SDL2 TTF Font reference. More...
 
static struct tum_fonttumFontAppendFont (char *font_name, ssize_t size)
 
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 resources/fonts More...
 
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 the font's name within the FONT_DIRECTORY directory. The font is only able to be made active if it was firstly loaded using tumFontLoadFont(). More...
 
int tumFontSelectFontFromHandle (font_handle_t font_handle)
 Sets the active font based off of a font handle. More...
 
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 the current font's configuration (font + size) is being referenced by pending draw jobs. All subsequent text draw jobs will use the currently active font and the specified size until the size and/or font are changed again. More...
 

Variables

pthread_mutex_t list_lock = PTHREAD_MUTEX_INITIALIZER
 
static struct tum_font font_list = { 0 }
 
static const char * fonts_dir
 
static struct tum_fontcur_default_font = NULL
 

Detailed Description

Manages fonts used in TUM Draw.

Author
Alex Hoffman
Date
30 April 2020
----------------------------------------------------------------------
Copyright (C) Alexander Hoffman, 2020
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
----------------------------------------------------------------------

Macro Definition Documentation

◆ PRINT_TTF_ERROR

#define PRINT_TTF_ERROR (   msg,
  ... 
)
Value:
PRINT_ERROR("[TTF Error] %s\n" #msg, (char *)TTF_GetError(), \
##__VA_ARGS__)