![]() |
Rendering Engine 0.2.9
Modular Graphics Rendering Engine | v0.2.9
|
Manages glyph data, font atlases, and font-level metrics. More...
#include <font_resources.hpp>
Public Member Functions | |
| FontResources (RenderResourceContext rrc, TextRenderer *textRenderer, std::string filepath, unsigned int const fontSize) | |
| Constructs font resources from a font file. More... | |
| FontResources (RenderResourceContext rrc, TextRenderer *textRenderer, std::string fontName, std::vector< uint8_t > const &fileBytes, unsigned int const fontSize) | |
| Constructs font resources from in-memory font data. More... | |
| ~FontResources () | |
| Releases all font-related resources. More... | |
| void | LoadGlyphsFromCodePointRange (std::uint32_t begin, std::uint32_t end) |
| Preloads glyphs for a continuous Unicode range. More... | |
| void | EnsureGlyphs (const std::vector< std::uint32_t > &codePoints) |
| Ensures glyphs for the given Unicode code points exist. More... | |
| void | EnsureGlyphs (const std::vector< GlyphIndex > &glyphIndexes) |
| Ensures glyphs for the given glyph indices exist. More... | |
| void | StoreFontAtlasesInFiles (bool in) |
| Enables or disables storing generated font atlases on disk. More... | |
| const FontMetrics & | GetFontMetrics () const |
| Returns global font metrics. More... | |
| GlyphMetrics | GetGlyphMetrics (GlyphIndex glyphIndex) const |
| Returns metrics for a specific glyph. More... | |
| std::string | GetFontAtlasTextureName (GlyphIndex glyphIndex) const |
| Returns the texture name of the atlas containing the glyph. More... | |
| std::string | GetFontAtlasMaterialName (GlyphIndex glyphIndex) const |
| Returns the material name associated with the glyph. More... | |
| GlyphIndex | GetIndexFromCodePoint (std::uint32_t codePoint) const |
| Resolves a Unicode code point to a glyph index. More... | |
| FT_Face | GetFontFace () |
| Returns the internal font face handle. More... | |
Protected Member Functions | |
| std::pair< GlyphMetrics, ImageData > | CreateGlyphBitmapBy (GlyphIndex glyphIndex) |
| Creates a bitmap and metrics for a glyph by index. More... | |
| std::pair< GlyphMetrics, ImageData > | CreateGlyphBitmapBy (std::uint32_t codePoint) |
| Creates a bitmap and metrics for a glyph by code point. More... | |
| void | CreateFontAtlasFromList (const std::vector< GlyphIndex > &glyphIndexes) |
| Creates a font atlas for a list of glyphs. More... | |
| void | CreateFontAtlasFromRange (std::uint32_t begin, std::uint32_t end) |
| Creates a font atlas for a continuous code point range. More... | |
| bool | HasGlyph (uint32_t codePoint) const |
| Checks whether a glyph exists for a code point. More... | |
Protected Attributes | |
| RenderResourceContext | mRenderResourceContext |
| TextRenderer * | mTextRenderer |
| std::string | mFontName |
| const unsigned int | mFontSize |
| FT_Error | mErrorResult = FT_Err_Ok |
| FT_Face | mFace = 0 |
| FontMetrics | mFontMetrics |
| std::unordered_map< std::uint32_t, std::pair< GlyphMetrics, std::string > > | mGlyphsByIndex |
| std::unordered_map< std::string, std::string > | mFontAtlases |
| std::vector< uint8_t > | mFontFileBytes |
| bool | bStoreFontAtlasesInFiles = false |
Static Protected Attributes | |
| static std::uint32_t | sMaxGlyphsPerFontAtlas = 1024 |
| Maximum number of glyphs per font atlas. More... | |
| static unsigned int | sFontAtlasPaddingPx = 4 |
| Padding in pixels around glyphs inside atlases. More... | |
Manages glyph data, font atlases, and font-level metrics.
Responsible for loading glyphs on demand, generating texture atlases, and providing glyph and font metrics required for text layout and rendering.
Instances are bound to a specific font and font size.
Definition at line 79 of file font_resources.hpp.
| rendering_engine::FontResources::FontResources | ( | RenderResourceContext | rrc, |
| TextRenderer * | textRenderer, | ||
| std::string | filepath, | ||
| unsigned int const | fontSize | ||
| ) |
Constructs font resources from a font file.
| rrc | Rendering resource context. |
| textRenderer | Owning text renderer. |
| filepath | Path to the font file. |
| fontSize | Font size in pixels. |
Definition at line 19 of file font_resources.cpp.
| rendering_engine::FontResources::FontResources | ( | RenderResourceContext | rrc, |
| TextRenderer * | textRenderer, | ||
| std::string | fontName, | ||
| std::vector< uint8_t > const & | fileBytes, | ||
| unsigned int const | fontSize | ||
| ) |
Constructs font resources from in-memory font data.
| rrc | Rendering resource context. |
| textRenderer | Owning text renderer. |
| fontName | Logical font name. |
| fileBytes | Font file data. |
| fontSize | Font size in pixels. |
Definition at line 46 of file font_resources.cpp.
| rendering_engine::FontResources::~FontResources | ( | ) |
Releases all font-related resources.
Definition at line 73 of file font_resources.cpp.
|
protected |
Creates a font atlas for a list of glyphs.
| glyphIndexes | List of glyph indices. |
Definition at line 330 of file font_resources.cpp.
|
protected |
Creates a font atlas for a continuous code point range.
| begin | First Unicode code point. |
| end | Last Unicode code point. |
Definition at line 201 of file font_resources.cpp.
|
protected |
Creates a bitmap and metrics for a glyph by index.
| glyphIndex | Glyph identifier. |
Definition at line 135 of file font_resources.cpp.
|
protected |
Creates a bitmap and metrics for a glyph by code point.
| codePoint | Unicode code point. |
Definition at line 193 of file font_resources.cpp.
| void rendering_engine::FontResources::EnsureGlyphs | ( | const std::vector< GlyphIndex > & | glyphIndexes | ) |
Ensures glyphs for the given glyph indices exist.
| glyphIndexes | List of glyph indices. |
Definition at line 108 of file font_resources.cpp.
| void rendering_engine::FontResources::EnsureGlyphs | ( | const std::vector< std::uint32_t > & | codePoints | ) |
Ensures glyphs for the given Unicode code points exist.
| codePoints | List of Unicode code points. |
Definition at line 94 of file font_resources.cpp.
| std::string rendering_engine::FontResources::GetFontAtlasMaterialName | ( | GlyphIndex | glyphIndex | ) | const |
Returns the material name associated with the glyph.
| glyphIndex | Glyph identifier. |
Definition at line 308 of file font_resources.cpp.
| std::string rendering_engine::FontResources::GetFontAtlasTextureName | ( | GlyphIndex | glyphIndex | ) | const |
Returns the texture name of the atlas containing the glyph.
| glyphIndex | Glyph identifier. |
Definition at line 293 of file font_resources.cpp.
| FT_Face rendering_engine::FontResources::GetFontFace | ( | ) |
Returns the internal font face handle.
Definition at line 325 of file font_resources.cpp.
| const FontMetrics & rendering_engine::FontResources::GetFontMetrics | ( | ) | const |
Returns global font metrics.
Definition at line 278 of file font_resources.cpp.
| GlyphMetrics rendering_engine::FontResources::GetGlyphMetrics | ( | GlyphIndex | glyphIndex | ) | const |
Returns metrics for a specific glyph.
| glyphIndex | Glyph identifier. |
Definition at line 283 of file font_resources.cpp.
| GlyphIndex rendering_engine::FontResources::GetIndexFromCodePoint | ( | std::uint32_t | codePoint | ) | const |
Resolves a Unicode code point to a glyph index.
| codePoint | Unicode code point. |
Definition at line 318 of file font_resources.cpp.
|
protected |
Checks whether a glyph exists for a code point.
| codePoint | Unicode code point. |
Definition at line 273 of file font_resources.cpp.
| void rendering_engine::FontResources::LoadGlyphsFromCodePointRange | ( | std::uint32_t | begin, |
| std::uint32_t | end | ||
| ) |
Preloads glyphs for a continuous Unicode range.
| begin | First Unicode code point. |
| end | Last Unicode code point. |
Definition at line 82 of file font_resources.cpp.
| void rendering_engine::FontResources::StoreFontAtlasesInFiles | ( | bool | in | ) |
Enables or disables storing generated font atlases on disk.
| in | True to store atlases in files. |
Definition at line 130 of file font_resources.cpp.
|
protected |
Definition at line 232 of file font_resources.hpp.
|
protected |
Definition at line 216 of file font_resources.hpp.
|
protected |
Definition at line 217 of file font_resources.hpp.
|
protected |
Definition at line 228 of file font_resources.hpp.
|
protected |
Definition at line 230 of file font_resources.hpp.
|
protected |
Definition at line 219 of file font_resources.hpp.
|
protected |
Definition at line 213 of file font_resources.hpp.
|
protected |
Definition at line 214 of file font_resources.hpp.
|
protected |
Definition at line 225 of file font_resources.hpp.
|
protected |
Definition at line 211 of file font_resources.hpp.
|
protected |
Definition at line 212 of file font_resources.hpp.
|
staticprotected |
Padding in pixels around glyphs inside atlases.
Definition at line 237 of file font_resources.hpp.
|
staticprotected |
Maximum number of glyphs per font atlas.
Definition at line 235 of file font_resources.hpp.