|
MayaFlux 0.4.0
Digital-First Multimedia Processing Framework
|
Rasterizes and packs glyphs from a FontFace into a TextureContainer. More...
#include <GlyphAtlas.hpp>
Collaboration diagram for MayaFlux::Portal::Text::GlyphAtlas:Public Member Functions | |
| uint32_t | atlas_size () const |
| Atlas texture dimension (width == height == atlas_size). | |
| void | clear_dirty () |
| Clear the dirty flag after re-uploading the atlas to GPU. | |
| const GlyphMetrics * | get_or_rasterize (FT_UInt glyph_index) |
| Return metrics for a glyph, rasterizing it into the atlas if needed. | |
| const GlyphMetrics * | get_or_rasterize (FT_ULong codepoint) |
| Convenience: look up by Unicode codepoint. | |
| GlyphAtlas (const GlyphAtlas &)=delete | |
| GlyphAtlas (FontFace &face, uint32_t pixel_size, uint32_t atlas_size=512) | |
| Construct an atlas for a specific face and pixel size. | |
| GlyphAtlas (GlyphAtlas &&)=delete | |
| bool | is_dirty () const |
| Returns true if at least one glyph was rasterized since the last call to clear_dirty(). | |
| uint32_t | line_height () const |
| Line advance in pixels for this atlas's pixel_size. | |
| GlyphAtlas & | operator= (const GlyphAtlas &)=delete |
| GlyphAtlas & | operator= (GlyphAtlas &&)=delete |
| uint32_t | pixel_size () const |
| Pixel size passed at construction. | |
| Kakshya::TextureContainer & | texture () |
| const Kakshya::TextureContainer & | texture () const |
| The atlas texture as a TextureContainer (R8, atlas_size x atlas_size). | |
| ~GlyphAtlas ()=default | |
Private Member Functions | |
| bool | rasterize (FT_UInt glyph_index) |
Private Attributes | |
| uint32_t | m_atlas_size |
| std::unordered_map< FT_UInt, GlyphMetrics > | m_cache |
| uint32_t | m_cursor_x { 0 } |
| uint32_t | m_cursor_y { 0 } |
| bool | m_dirty { false } |
| FontFace & | m_face |
| uint32_t | m_pixel_size |
| uint32_t | m_shelf_height { 0 } |
| std::unique_ptr< Kakshya::TextureContainer > | m_texture |
Rasterizes and packs glyphs from a FontFace into a TextureContainer.
One atlas corresponds to one (FontFace, pixel_size) pair. The atlas texture is R8 (single-channel coverage); colour is applied in the shader.
Glyphs are rasterized on first request via get_or_rasterize() and packed into the atlas using a simple shelf packing algorithm. The atlas texture is rebuilt whenever a new glyph causes a shelf overflow.
The atlas is keyed on FT_UInt glyph index, not Unicode codepoint. Callers obtain glyph indices via FT_Get_Char_Index on the FontFace. This keeps the path open for HarfBuzz, which outputs glyph indices directly.
Thread safety: not thread-safe. Rasterization must occur on the thread that owns the FontFace.
Definition at line 57 of file GlyphAtlas.hpp.