#include <font.h>
This class should be instantiated once for each font or font size to be used. Each font and size is cached for quick rendering at runtime. Fonts can be any color, size, or style. The .ttf file must be available for rendering to occur.
Definition at line 31 of file font.h.
Public Member Functions | |
| Font () | |
| Constructor. | |
| ~Font () | |
| Deconstructor. | |
| int | init () |
| Initializes the font based on given parameters. | |
| int | init (char *file, int size, int r, int g, int b, int style) |
| Specify font file and size at init. | |
| int | render (SDL_Surface *surface, char *text, int x, int y) |
| Renders the text on screen. | |
Public Attributes | |
| char * | file |
| int | size |
| int | r |
| int | g |
| int | b |
| int | style |
|
|
Constructor. Initializes the font and creates a buffer for glyph storage. |
|
|
Deconstructor. Ensures that the font memory is freed and that SDL is shut down. |
|
||||||||||||||||||||||||||||
|
Specify font file and size at init.
|
|
|
Initializes the font based on given parameters. This method starts up SDL_TTF, fills the glyph caches with characters from the loaded font file, and prepares to render them on screen.
|
|
||||||||||||||||||||
|
Renders the text on screen. This method renders the given text string into a specified SDL surface. The color can be specified as well as the x and y coordinates within the surface.
Definition at line 83 of file font.cpp. References Metrics::advance, Metrics::maxY, and Metrics::minX. |
1.4.2