Open 3D Engine AtomLyIntegration Gem API Reference  24.09
O3DE is an open-source, fully-featured, high-fidelity, modular 3D engine for building games and simulations, available to every industry.
AZ::GlyphCache Class Reference

#include <GlyphCache.h>

Public Member Functions

int Create (int iCacheSize, int glyphBitmapWidth, int glyphBitmapHeight, FontSmoothMethod smoothMethod, FontSmoothAmount smoothAmount, float sizeRatio)
 
int Release ()
 
int LoadFontFromFile (const AZStd::string &fileName)
 
int LoadFontFromMemory (unsigned char *fileBuffer, int dataSize)
 
int ReleaseFont ()
 
int SetEncoding (FT_Encoding encoding)
 
FT_Encoding GetEncoding ()
 
int GetGlyphBitmapSize (int *width, int *height)
 
void SetGlyphBitmapSize (int width, int height, float sizeRatio)
 
int PreCacheGlyph (uint32_t character, const AtomFont::GlyphSize &glyphSize=AtomFont::defaultGlyphSize, const FFont::FontHintParams &glyphFlags=FFont::FontHintParams())
 
int UnCacheGlyph (uint32_t character, const AtomFont::GlyphSize &glyphSize=AtomFont::defaultGlyphSize)
 
int GlyphCached (uint32_t character, const AtomFont::GlyphSize &glyphSize=AtomFont::defaultGlyphSize)
 
CacheSlotGetLRUSlot ()
 
CacheSlotGetMRUSlot ()
 
int GetGlyph (GlyphBitmap **glyph, int *horizontalAdvance, int *width, int *height, int32_t &m_characterOffsetX, int32_t &m_characterOffsetY, uint32_t character, const AtomFont::GlyphSize &glyphSize=AtomFont::defaultGlyphSize, const FFont::FontHintParams &glyphFlags=FFont::FontHintParams())
 
bool GetMonospaced () const
 
Vec2 GetKerning (uint32_t leftGlyph, uint32_t rightGlyph)
 
float GetAscenderToHeightRatio ()
 

Detailed Description

The glyph cache maps UTF32 codepoints to their corresponding FreeType data.

This cache is used to associate font glyph info (read from FreeType) with UTF32 codepoints. Ultimately the glyph info will be read into a font texture (FontTexture) to avoid future FreeType lookups.

If a FontTexture is missing a glyph that is currently stored in the glyph cache, the cached data can be returned instead of having to be rendered from FreeType again.

See also
FontTexture

Member Function Documentation

◆ GetGlyph()

int AZ::GlyphCache::GetGlyph ( GlyphBitmap **  glyph,
int *  horizontalAdvance,
int *  width,
int *  height,
int32_t &  m_characterOffsetX,
int32_t &  m_characterOffsetY,
uint32_t  character,
const AtomFont::GlyphSize glyphSize = AtomFont::defaultGlyphSize,
const FFont::FontHintParams glyphFlags = FFont::FontHintParams() 
)

Obtains glyph information for the given UTF32 codepoint. This information is obtained from a CacheSlot that corresponds to the given codepoint. If the codepoint doesn't exist within the cache table (m_cacheTable), then the information is obtain from FreeType directly via FontRenderer.

Ultimately the glyph bitmap is copied into a font texture (FontTexture). Once the glyph is copied into the font texture then the font texture is referenced directly rather than relying on the glyph cache or FreeType.

See also
FontRenderer::GetGlyph, FontTexture::UpdateSlot

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