TrueType fonts present a higher quality font rendering with the use of font outlines. Each font character is called a glyph. TTF files contain not only outlines but also the glyph's information. Glyph rendering from outlines is much slower than drawing bitmap font characters on screen. This is mainly because these glyphs are being drawn on-the-run and font rendering may be enhanced with antialiasing, which is costly. Because of this, applications using TrueType fonts often cache font glyphs into textures.
The SDL_ttf
library manages the loading of the TrueType font files. Everything you need to use these files is included in the LuaSDL library.
This recipe will deal with loading font glyph in surface object, which you can store into the texture or as a smaller part of the bigger texture—texture atlas.