Oxygen Engine
Modern C++ 3D Engine using OpenGL
|
Handle and bake font atlas for using in the GUI. More...
#include <OxygenEngine/gui/font_atlas.h>
Public Member Functions | |
void | generate () |
Generate the atlas. | |
FontAtlas * | addFile (const std::string &font_name, const std::string &font_file, const float &size) |
Add a font from a file. | |
bool | isValid () const |
Check if the font atlas is ready to use. | |
size_t | getIdFromName (const std::string &font_id) const |
Get a font name from the list when you know its id. | |
nk_font * | getHandle (const size_t &font_id) const |
Get a font handle when you know its id. | |
nk_font * | getHandle (const std::string &font_id) const |
Get a font handle from the custom font name. | |
nk_font * | getDefaultFont () |
const std::unique_ptr< oe::render::Texture > & | getTexture () |
Public Attributes | |
glm::vec2 | white_pixel_uv = glm::vec2(0.f) |
uv coordinates of a white pixel in the texture | |
Handle and bake font atlas for using in the GUI.
To use, you first add font files to the atlas, then run a bake
FontAtlas * oe::gui::FontAtlas::addFile | ( | const std::string & | font_name, |
const std::string & | font_file, | ||
const float & | size | ||
) |
Add a font from a file.
font_name | custom name identifying the font |
font_file | path of the TTF font in the virtual file system (this file will not yet be opened until a call to generate()) |
size | Size of the font text |
void oe::gui::FontAtlas::generate | ( | ) |
Generate the atlas.
Load the added fonts and bake them into a texture Also add a white pixel in the texture, which coordinates are filled in white_pixel_uv
size_t oe::gui::FontAtlas::getIdFromName | ( | const std::string & | font_id | ) | const |
Get a font name from the list when you know its id.