|
utility 2026.1.9
A comprehensive C++ utilities library tailored for the development of modern desktop and extended reality (XR) applications.
|
The FontSized class represents a specific size of a font face, managing the glyphs and texture atlas for that size. More...
#include <headers/utility/graphic/text/font_sized.hpp>
Public Member Functions | |
| FontSized (uint32_t fontSize, void *face) | |
| Constructs a FontSized object for a specific font size and corresponding FreeType face. | |
| ~FontSized ()=default | |
| Destructs the FontSized object, releasing any allocated resources. | |
| std::shared_ptr< Texture > | getAtlas (bool shouldRegenerate=false) |
| Retrieves the texture atlas containing the rendered glyphs for this font size. | |
| bool | hasGlyph (uint32_t codePoint) const |
| Checks whether a glyph has already been generated for this font size. | |
| Glyph | generateGlyph (uint32_t codePoint) |
| Generates a glyph for a specific Unicode code point and adds it to the texture atlas. | |
| std::vector< Glyph > | generateGlyphs (const codePointString &codePoints) |
| Generates glyphs for a string of Unicode code points and adds them to the texture atlas. | |
| Glyph | measureGlyph (uint32_t codePoint) const |
| Compute glyph metrics for a code point without rasterizing or mutating the texture atlas. | |
Public Attributes | |
| float | _ascender |
| The ascender value for the font size, representing the height of the tallest glyph above the baseline. | |
| float | _descender |
| The descender value for the font size, representing the depth of the lowest glyph below the baseline. | |
| float | _lineHeight |
| The line height value for the font size, representing the vertical distance between lines of text. | |
Protected Member Functions | |
| void | generateAtlas () |
| Generates the texture atlas based on the currently generated glyphs for this font size. | |
| void | resizeAtlas (int newHeight) |
| Grow the atlas to the given new height, preserving existing glyphs. | |
Protected Attributes | |
| std::shared_ptr< Texture > | _generatedAtlas |
| The font size in points for this FontSized object. | |
| uint32_t | _fontSize |
| The font size in points for this FontSized object. | |
| void * | _correspondingFace |
| The corresponding FreeType face associated with this FontSized object. | |
| std::map< uint32_t, Glyph > | _generatedGlyphs |
| A map storing the generated glyphs for this font size. | |
| int | _atlasWidth |
| The width of the texture atlas. | |
| int | _atlasHeight |
| The height of the texture atlas. | |
| int | _penX |
| The x-coordinate of the pen for glyph placement. | |
| int | _penY |
| The y-coordinate of the pen for glyph placement. | |
| int | _rowHeight |
| The height of each row in the texture atlas. | |
The FontSized class represents a specific size of a font face, managing the glyphs and texture atlas for that size.
The FontSized class is responsible for generating glyphs for a specific font size and managing the texture atlas that contains the rendered glyphs. It uses the FreeType library to load and render the glyphs, and it provides functionality to retrieve the generated texture atlas and glyph information for rendering text.
Definition at line 31 of file font_sized.hpp.
| utility::graphic::FontSized::FontSized | ( | uint32_t | fontSize, |
| void * | face | ||
| ) |
Constructs a FontSized object for a specific font size and corresponding FreeType face.
This constructor initializes the FontSized object with the specified font size and the corresponding FreeType face. It sets up the necessary data structures for managing glyphs and the texture atlas for rendering text at the specified size.
| fontSize | The font size in points for this FontSized object. |
| face | The corresponding FreeType face associated with this FontSized object (opaque handle). |
Definition at line 28 of file font_sized.cpp.
|
protected |
Generates the texture atlas based on the currently generated glyphs for this font size.
This method creates a texture atlas by arranging the generated glyphs in a grid and rendering them into a single Texture object. It updates the texture coordinates for each glyph based on their position in the atlas, allowing for efficient rendering of text using the associated shader.
Definition at line 212 of file font_sized.cpp.

| Glyph utility::graphic::FontSized::generateGlyph | ( | uint32_t | codePoint | ) |
Generates a glyph for a specific Unicode code point and adds it to the texture atlas.
This method generates a glyph for the specified Unicode code point using the FreeType library. It renders the glyph and adds it to the texture atlas managed by this FontSized object. The generated glyph information is stored in a map for later retrieval when rendering text.
| codePoint | The Unicode code point for which to generate the glyph. |
Definition at line 58 of file font_sized.cpp.


| std::vector< Glyph > utility::graphic::FontSized::generateGlyphs | ( | const codePointString & | codePoints | ) |
Generates glyphs for a string of Unicode code points and adds them to the texture atlas.
This method takes a string of Unicode code points and generates the corresponding glyphs for each code point using the FreeType library. It renders each glyph and adds them to the texture atlas managed by this FontSized object. The generated glyph information is stored in a map for later retrieval when rendering text.
| codePoints | A string of Unicode code points representing the characters for which to generate glyphs. |
Definition at line 149 of file font_sized.cpp.

| std::shared_ptr< Texture > utility::graphic::FontSized::getAtlas | ( | bool | shouldRegenerate = false | ) |
Retrieves the texture atlas containing the rendered glyphs for this font size.
This method returns a shared pointer to the Texture object that contains the rendered glyphs for this font size. The texture atlas is generated based on the glyphs that have been created for this font size, and it can be used for rendering text with the associated shader.
| shouldRegenerate | A boolean flag indicating whether to regenerate the texture atlas. If true, the atlas will be regenerated based on the current glyphs; if false, the existing atlas will be returned. |
Definition at line 191 of file font_sized.cpp.

| bool utility::graphic::FontSized::hasGlyph | ( | uint32_t | codePoint | ) | const |
Checks whether a glyph has already been generated for this font size.
| codePoint | The Unicode code point to look up. |
Definition at line 207 of file font_sized.cpp.
| Glyph utility::graphic::FontSized::measureGlyph | ( | uint32_t | codePoint | ) | const |
Compute glyph metrics for a code point without rasterizing or mutating the texture atlas.
| codePoint | The Unicode code point to measure. |
Definition at line 161 of file font_sized.cpp.

|
protected |
Grow the atlas to the given new height, preserving existing glyphs.
| newHeight | The new atlas height in pixels. |
Definition at line 227 of file font_sized.cpp.

| float utility::graphic::FontSized::_ascender |
The ascender value for the font size, representing the height of the tallest glyph above the baseline.
Definition at line 135 of file font_sized.hpp.
|
protected |
The height of the texture atlas.
Definition at line 201 of file font_sized.hpp.
|
protected |
The width of the texture atlas.
Definition at line 196 of file font_sized.hpp.
|
protected |
The corresponding FreeType face associated with this FontSized object.
Stored as an opaque handle to keep FreeType types out of the public API.
Definition at line 186 of file font_sized.hpp.
| float utility::graphic::FontSized::_descender |
The descender value for the font size, representing the depth of the lowest glyph below the baseline.
Definition at line 141 of file font_sized.hpp.
|
protected |
The font size in points for this FontSized object.
Definition at line 177 of file font_sized.hpp.
|
protected |
The font size in points for this FontSized object.
Definition at line 172 of file font_sized.hpp.
|
protected |
A map storing the generated glyphs for this font size.
Definition at line 191 of file font_sized.hpp.
| float utility::graphic::FontSized::_lineHeight |
The line height value for the font size, representing the vertical distance between lines of text.
Definition at line 147 of file font_sized.hpp.
|
protected |
The x-coordinate of the pen for glyph placement.
Definition at line 206 of file font_sized.hpp.
|
protected |
The y-coordinate of the pen for glyph placement.
Definition at line 211 of file font_sized.hpp.
|
protected |
The height of each row in the texture atlas.
Definition at line 216 of file font_sized.hpp.