MayaFlux 0.4.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
MayaFlux::Portal::Text::GlyphAtlas Class Reference

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 GlyphMetricsget_or_rasterize (FT_UInt glyph_index)
 Return metrics for a glyph, rasterizing it into the atlas if needed.
 
const GlyphMetricsget_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.
 
GlyphAtlasoperator= (const GlyphAtlas &)=delete
 
GlyphAtlasoperator= (GlyphAtlas &&)=delete
 
uint32_t pixel_size () const
 Pixel size passed at construction.
 
Kakshya::TextureContainertexture ()
 
const Kakshya::TextureContainertexture () 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, GlyphMetricsm_cache
 
uint32_t m_cursor_x { 0 }
 
uint32_t m_cursor_y { 0 }
 
bool m_dirty { false }
 
FontFacem_face
 
uint32_t m_pixel_size
 
uint32_t m_shelf_height { 0 }
 
std::unique_ptr< Kakshya::TextureContainerm_texture
 

Detailed Description

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.


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