Oxygen Engine
Modern C++ 3D Engine using OpenGL
Loading...
Searching...
No Matches
oe::gui::FontAtlas Class Reference

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.
 
FontAtlasaddFile (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
 

Detailed Description

Handle and bake font atlas for using in the GUI.

To use, you first add font files to the atlas, then run a bake

Note
In this class, a "font" means the actual font but also the character size

Member Function Documentation

◆ addFile()

FontAtlas * oe::gui::FontAtlas::addFile ( const std::string &  font_name,
const std::string &  font_file,
const float &  size 
)

Add a font from a file.

Parameters
font_namecustom name identifying the font
font_filepath of the TTF font in the virtual file system (this file will not yet be opened until a call to generate())
sizeSize of the font text
Note
Empty font name "" is reserved

◆ generate()

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

◆ getIdFromName()

size_t oe::gui::FontAtlas::getIdFromName ( const std::string &  font_id) const

Get a font name from the list when you know its id.

Returns
font id
Note
It is assumed that there is an existing font with the asked name

The documentation for this class was generated from the following file: