|
lmgl 1.0.0
A lightweight OpenGL graphics engine library written in C++
|
Font class for loading and rendering text. More...
#include <font.hpp>
Public Member Functions | |
| Font (const std::string &filepath, unsigned int font_size=48) | |
| Load a font from file. | |
| ~Font ()=default | |
| Destructor. | |
| const Glyph & | get_glyph (char c) const |
| Get glyph metadata for a character. | |
| std::shared_ptr< renderer::Texture > | get_atlas () const |
| Get the texture atlas containing all glyphs. | |
| unsigned int | get_font_size () const |
| Get the font size in pixels. | |
| float | get_line_height () const |
| Get the line height for this font. | |
| float | measure_text (const std::string &text) const |
| Calculate the width of a text string in pixels. | |
Font class for loading and rendering text.
The Font class uses FreeType to load TrueType fonts, generates a texture atlas containing all ASCII glyphs, and provides metrics for text rendering.
| lmgl::ui::Font::Font | ( | const std::string & | filepath, |
| unsigned int | font_size = 48 ) |
Load a font from file.
| filepath | Path to the TTF/OTF font file. |
| font_size | Size of the font in pixels. |
|
inline |
Get the texture atlas containing all glyphs.
|
inline |
Get the font size in pixels.
| const Glyph & lmgl::ui::Font::get_glyph | ( | char | c | ) | const |
Get glyph metadata for a character.
| c | Character to get glyph for. |
|
inline |
Get the line height for this font.
| float lmgl::ui::Font::measure_text | ( | const std::string & | text | ) | const |
Calculate the width of a text string in pixels.
| text | Text string to measure. |