Rendering Engine 0.2.17
Modular Graphics Rendering Engine | v0.2.17
Loading...
Searching...
No Matches
rendering_engine::FontResources Class Reference

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.
 
 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.
 
 ~FontResources ()
 Releases all font-related resources.
 
void LoadGlyphsFromCodePointRange (std::uint32_t begin, std::uint32_t end)
 Preloads glyphs for a continuous Unicode range.
 
void EnsureGlyphs (const std::vector< std::uint32_t > &codePoints)
 Ensures glyphs for the given Unicode code points exist.
 
void EnsureGlyphs (const std::vector< GlyphIndex > &glyphIndexes)
 Ensures glyphs for the given glyph indices exist.
 
void StoreFontAtlasesInFiles (bool in)
 Enables or disables storing generated font atlases on disk.
 
const FontMetrics & GetFontMetrics () const
 Returns global font metrics.
 
GlyphMetrics GetGlyphMetrics (GlyphIndex glyphIndex) const
 Returns metrics for a specific glyph.
 
std::string GetFontAtlasTextureName (GlyphIndex glyphIndex) const
 Returns the texture name of the atlas containing the glyph.
 
std::string GetFontAtlasMaterialName (GlyphIndex glyphIndex) const
 Returns the material name associated with the glyph.
 
GlyphIndex GetIndexFromCodePoint (std::uint32_t codePoint) const
 Resolves a Unicode code point to a glyph index.
 
FT_Face GetFontFace ()
 Returns the internal font face handle.
 

Protected Member Functions

std::pair< GlyphMetrics, ImageData > CreateGlyphBitmapBy (GlyphIndex glyphIndex)
 Creates a bitmap and metrics for a glyph by index.
 
std::pair< GlyphMetrics, ImageData > CreateGlyphBitmapBy (std::uint32_t codePoint)
 Creates a bitmap and metrics for a glyph by code point.
 
void CreateFontAtlasFromList (const std::vector< GlyphIndex > &glyphIndexes)
 Creates a font atlas for a list of glyphs.
 
void CreateFontAtlasFromRange (std::uint32_t begin, std::uint32_t end)
 Creates a font atlas for a continuous code point range.
 
bool HasGlyph (uint32_t codePoint) const
 Checks whether a glyph exists for a code point.
 

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.
 
static unsigned int sFontAtlasPaddingPx = 4
 Padding in pixels around glyphs inside atlases.
 

Detailed Description

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 80 of file font_resources.hpp.

Constructor & Destructor Documentation

◆ FontResources() [1/2]

rendering_engine::FontResources::FontResources ( RenderResourceContext  rrc,
TextRenderer *  textRenderer,
std::string  filepath,
unsigned int const  fontSize 
)

Constructs font resources from a font file.

Parameters
rrcRendering resource context.
textRendererOwning text renderer.
filepathPath to the font file.
fontSizeFont size in pixels.

Definition at line 22 of file font_resources.cpp.

23 :
25 mTextRenderer(textRenderer),
26 mFontName(std::filesystem::path(filepath).stem().string()),
27 mFontSize(fontSize),
28 mErrorResult(FT_Err_Ok),
29 mFace(0)
30{
31 if (mFontSize >
32 static_cast<unsigned int>(
33 std::numeric_limits<FT_F26Dot6>::max() >> 6))
34 {
35 throw std::out_of_range("Font size exceeds FreeType supported range.");
36 }
37
38 const FT_F26Dot6 fontSize26Dot6 =
39 static_cast<FT_F26Dot6>(mFontSize) << 6;
40
41 mErrorResult = FT_New_Face(mTextRenderer->GetFontLibrary(), filepath.c_str(), 0, &mFace);
42 if (mErrorResult)
43 {
44 throw std::runtime_error{ "Failed to create new face!" };
45 }
46
47 mErrorResult = FT_Set_Char_Size(mFace, fontSize26Dot6, fontSize26Dot6, 90, 90);
48 if (mErrorResult)
49 {
50 throw std::runtime_error{ "Failed to set char size!" };
51 }
52
53 mFontMetrics.lineHeight = FreeType26Dot6ToPixelInt(mFace->size->metrics.height);
54 mFontMetrics.ascender = FreeType26Dot6ToPixelInt(mFace->size->metrics.ascender);
55 mFontMetrics.descender = FreeType26Dot6ToPixelInt(mFace->size->metrics.descender);
56}
RenderResourceContext mRenderResourceContext
FT_Library & GetFontLibrary()
Returns the internal FreeType library instance.

◆ FontResources() [2/2]

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.

Parameters
rrcRendering resource context.
textRendererOwning text renderer.
fontNameLogical font name.
fileBytesFont file data.
fontSizeFont size in pixels.

Definition at line 58 of file font_resources.cpp.

59 :
61 mTextRenderer(textRenderer),
62 mFontName(fontName),
63 mFontSize(fontSize),
64 mErrorResult(FT_Err_Ok),
65 mFace(0),
66 mFontFileBytes(fileBytes)
67{
68 if (mFontSize >
69 static_cast<unsigned int>(
70 std::numeric_limits<FT_F26Dot6>::max() >> 6))
71 {
72 throw std::out_of_range("Font size exceeds FreeType supported range.");
73 }
74
75 const FT_F26Dot6 fontSize26Dot6 =
76 static_cast<FT_F26Dot6>(mFontSize) << 6;
77
78 mErrorResult = FT_New_Memory_Face(mTextRenderer->GetFontLibrary(), mFontFileBytes.data(), static_cast<FT_Long>(mFontFileBytes.size()), 0, &mFace);
79 if (mErrorResult)
80 {
81 throw std::runtime_error{ "Failed to create new face!" };
82 }
83
84 mErrorResult = FT_Set_Char_Size(mFace, fontSize26Dot6, fontSize26Dot6, 90, 90);
85 if (mErrorResult)
86 {
87 throw std::runtime_error{ "Failed to set char size!" };
88 }
89
90 mFontMetrics.lineHeight = FreeType26Dot6ToPixelInt(mFace->size->metrics.height);
91 mFontMetrics.ascender = FreeType26Dot6ToPixelInt(mFace->size->metrics.ascender);
92 mFontMetrics.descender = FreeType26Dot6ToPixelInt(mFace->size->metrics.descender);
93}
std::vector< uint8_t > mFontFileBytes

◆ ~FontResources()

rendering_engine::FontResources::~FontResources ( )

Releases all font-related resources.

Definition at line 95 of file font_resources.cpp.

96{
97 if (mFace)
98 {
99 FT_Done_Face(mFace);
100 mFace = nullptr;
101 }
102}

Member Function Documentation

◆ CreateFontAtlasFromList()

void rendering_engine::FontResources::CreateFontAtlasFromList ( const std::vector< GlyphIndex > &  glyphIndexes)
protected

Creates a font atlas for a list of glyphs.

Parameters
glyphIndexesList of glyph indices.

Definition at line 358 of file font_resources.cpp.

359{
360 // 1. Create font atlas from list
361 std::unordered_map<std::uint32_t, std::pair<GlyphMetrics, ImageData>> glyphs;
362 for (auto glyphIndex : glyphIndexes)
363 {
364 auto found = mGlyphsByIndex.find(glyphIndex.index);
365 if (found != mGlyphsByIndex.end())
366 continue;
367 // Creating bitmaps of glyphs should be considered to dome multithreaded
368 glyphs[glyphIndex.index] = CreateGlyphBitmapBy(glyphIndex);
369 }
370 if (glyphs.empty())
371 return;
372
373 auto fontAtlas = TextureAtlasMaker::CreateTextureAtlas(glyphs);
374
375 // 2. Upload texture via TextureCache
376
377 auto textureCache = mRenderResourceContext.textureCache;
378 const std::string textureName = mFontName + "_" + std::to_string(mFontSize) + "_FontAtlas_" + std::to_string(mFontAtlases.size());
380 {
381 const std::string fileName = textureName + ".png";
382 auto fullPath = Utility::GetContentFolderPath() / fileName;
383 fontAtlas.WritePngFile(fullPath.string().c_str());
384 }
385 textureCache->LoadTexture(textureName, fontAtlas);
386
387 // 3. Create a material via MaterialCache and add texture to it
388 auto materialCache = mRenderResourceContext.materialCache;
389 const std::string materialName = textureName + "_Mat";
390 MaterialSettings materialSettings;
391 materialSettings.parentMaterialName = std::string{ "Font2D" };
392 materialSettings.materialName = materialName;
393 materialSettings.materialDomain = MaterialDomain::Sprite2D;
394 materialSettings.shadingModel = ShadingModel::Unlit;
395 materialSettings.blendMode = BlendMode::Translucent;
396 materialSettings.parameterLayout = &Font2DLayout;
397
398 materialCache->AddMaterial(materialSettings);
399 Material* material = materialCache->GetMaterial(materialName);
400 material->SetVec4("FontColor", glm::vec4(1.0f, 1.0f, 1.0f, 1.0f));
401 material->SetVec4("OutlineColor", glm::vec4(0, 0, 0, 1));
402 material->SetFloat("OutlineThicknessPx", 0.0f); // OFF by default
403 const float invW = 1.0f / static_cast<float>(fontAtlas.GetWidth());
404 const float invH = 1.0f / static_cast<float>(fontAtlas.GetHeight());
405 material->SetFloat("InvAtlasSizeWidth", invW);
406 material->SetFloat("InvAtlasSizeHeight", invH);
407
408 material->AddTexture(textureName);
409
410 // material->SetFloat >> Add custom material parameters for UV manipulation
411 material->InitializeRenderResources();
412
413 // 4 Upload to container mFontAtlases
414 for (auto& it : glyphs)
415 {
416 mGlyphsByIndex[it.first] = std::pair<GlyphMetrics, std::string>(it.second.first, materialName);
417 }
418
419 mFontAtlases[materialName] = textureName;
420}
std::pair< GlyphMetrics, ImageData > CreateGlyphBitmapBy(GlyphIndex glyphIndex)
Creates a bitmap and metrics for a glyph by index.
std::unordered_map< std::uint32_t, std::pair< GlyphMetrics, std::string > > mGlyphsByIndex
std::unordered_map< std::string, std::string > mFontAtlases
void AddMaterial(MaterialSettings matSettings)
Adds a new Material instance using the provided settings.
bool CreateTextureAtlas(std::map< char, std::pair< unsigned int, unsigned int > > &texAtlasData, ImageData &texAtlasImage)
Creates a texture atlas from the stored image collection.
static std::filesystem::path GetContentFolderPath()
Returns absolute path to Content.
Definition utility.cpp:248
static const std::vector< MaterialParameterLayoutEntry > Font2DLayout

◆ CreateFontAtlasFromRange()

void rendering_engine::FontResources::CreateFontAtlasFromRange ( std::uint32_t  begin,
std::uint32_t  end 
)
protected

Creates a font atlas for a continuous code point range.

Parameters
beginFirst Unicode code point.
endLast Unicode code point.

Definition at line 229 of file font_resources.cpp.

230{
231 if (begin > end)
232 {
233 // range is not valid
234 return;
235 }
236
237 // 1. Create font atlas in range of [begin; end]
238 std::unordered_map<std::uint32_t, std::pair<GlyphMetrics, ImageData>> glyphs;
239 for (auto codePoint = begin; codePoint <= end; ++codePoint)
240 {
241 if (!HasGlyph(codePoint))
242 {
243 continue;
244 }
245 // Creating bitmaps of glyphs should be considered to dome multythreaded
246 glyphs[codePoint] = CreateGlyphBitmapBy(codePoint);
247 }
248 if (glyphs.empty())
249 return;
250
251 auto fontAtlas = TextureAtlasMaker::CreateTextureAtlas(glyphs);
252
253 // 2. Upload texture via TextureCache
254
255 auto textureCache = mRenderResourceContext.textureCache;
256 const std::string textureName = mFontName + "_" + std::to_string(mFontSize) + "_FontAtlas_" + std::to_string(mFontAtlases.size());
258 {
259 const std::string fileName = textureName + ".png";
260 auto fullPath = Utility::GetContentFolderPath() / fileName;
261 fontAtlas.WritePngFile(fullPath.string().c_str());
262 }
263 textureCache->LoadTexture(textureName, fontAtlas);
264
265 // 3. Create a material via MaterialCache and add texture to it
266 auto materialCache = mRenderResourceContext.materialCache;
267 const std::string materialName = textureName + "_Mat";
268 MaterialSettings materialSettings;
269 materialSettings.parentMaterialName = std::string{ "Font2D" };
270 materialSettings.materialName = materialName;
271 materialSettings.materialDomain = MaterialDomain::Sprite2D;
272 materialSettings.shadingModel = ShadingModel::Unlit;
273 materialSettings.blendMode = BlendMode::Translucent;
274 materialSettings.parameterLayout = &Font2DLayout;
275
276 materialCache->AddMaterial(materialSettings);
277 Material* material = materialCache->GetMaterial(materialName);
278 material->SetVec4("FontColor", glm::vec4(1.0f, 1.0f, 1.0f, 1.0f));
279 material->SetVec4("OutlineColor", glm::vec4(0, 0, 0, 1));
280 material->SetFloat("OutlineThicknessPx", 0.0); // OFF by default
281 const float invW = 1.0f / static_cast<float>(fontAtlas.GetWidth());
282 const float invH = 1.0f / static_cast<float>(fontAtlas.GetHeight());
283 material->SetFloat("InvAtlasSizeWidth", invW);
284 material->SetFloat("InvAtlasSizeHeight", invH);
285
286 material->AddTexture(textureName);
287
288 // material->SetFloat >> Add custom material parameters for UV manipulation
289 material->InitializeRenderResources();
290
291 // 4 Upload to container mFontAtlases
292 for (auto& it : glyphs)
293 {
294 const std::uint32_t glyphIndex = static_cast<std::uint32_t>(FT_Get_Char_Index(mFace, static_cast<FT_ULong>(it.first)));
295 mGlyphsByIndex[glyphIndex] = std::pair<GlyphMetrics, std::string>(it.second.first, materialName);
296 }
297
298 mFontAtlases[materialName] = textureName;
299}
bool HasGlyph(uint32_t codePoint) const
Checks whether a glyph exists for a code point.

◆ CreateGlyphBitmapBy() [1/2]

std::pair< GlyphMetrics, ImageData > rendering_engine::FontResources::CreateGlyphBitmapBy ( GlyphIndex  glyphIndex)
protected

Creates a bitmap and metrics for a glyph by index.

Parameters
glyphIndexGlyph identifier.
Returns
Pair of glyph metrics and image data.

Definition at line 156 of file font_resources.cpp.

157{
158 mErrorResult = FT_Load_Glyph(mFace, glyphIndex.index, FT_LOAD_DEFAULT);
159 if (mErrorResult)
160 {
161 throw std::runtime_error{ "Failed to load glyph!" };
162 }
163
164 mErrorResult = FT_Render_Glyph(mFace->glyph, FT_RENDER_MODE_NORMAL);
165 if (mErrorResult)
166 {
167 throw std::runtime_error{ "Failed to render glyph!" };
168 }
169
170 const unsigned padding = sFontAtlasPaddingPx;
171
172 const auto srcW = mFace->glyph->bitmap.width;
173 const auto srcH = mFace->glyph->bitmap.rows;
174
175 const auto dstW = srcW + padding * 2;
176 const auto dstH = srcH + padding * 2;
177
178 const auto bufferSize = dstW * dstH * 4;
179 std::vector<uint8_t> buffer(bufferSize, 0);
180 for (unsigned int y = 0; y < srcH; ++y)
181 {
182 for (unsigned int x = 0; x < srcW; ++x)
183 {
184 const size_t srcIndex =
185 static_cast<size_t>(y) * static_cast<size_t>(srcW) +
186 static_cast<size_t>(x);
187
188 const uint8_t coverage =
189 mFace->glyph->bitmap.buffer[srcIndex];
190
191 const size_t dstX =
192 static_cast<size_t>(x) + static_cast<size_t>(padding);
193
194 const size_t dstY =
195 static_cast<size_t>(y) + static_cast<size_t>(padding);
196
197 const size_t idx =
198 (dstY * static_cast<size_t>(dstW) + dstX) * 4U;
199
200 buffer[idx + 0] = coverage;
201 buffer[idx + 1] = coverage;
202 buffer[idx + 2] = coverage;
203 buffer[idx + 3] = coverage;
204 }
205 }
206 GlyphMetrics glyphMetrics;
207 glyphMetrics.width = srcW;
208 glyphMetrics.height = srcH;
209
210
211 glyphMetrics.bearingX = mFace->glyph->bitmap_left;
212 glyphMetrics.bearingY = mFace->glyph->bitmap_top;
213
214 glyphMetrics.advanceX = FreeType26Dot6ToPixelInt(mFace->glyph->advance.x);
215
216 glyphMetrics.padding = padding;
217
218 return std::pair(glyphMetrics, ImageData(dstW, dstH, buffer));
219}
static unsigned int sFontAtlasPaddingPx
Padding in pixels around glyphs inside atlases.

◆ CreateGlyphBitmapBy() [2/2]

std::pair< GlyphMetrics, ImageData > rendering_engine::FontResources::CreateGlyphBitmapBy ( std::uint32_t  codePoint)
protected

Creates a bitmap and metrics for a glyph by code point.

Parameters
codePointUnicode code point.
Returns
Pair of glyph metrics and image data.

Definition at line 221 of file font_resources.cpp.

222{
223 GlyphIndex glyphIndex;
224 glyphIndex.index = static_cast<std::uint32_t>(FT_Get_Char_Index(mFace, static_cast<FT_ULong>(codePoint)));
225
226 return CreateGlyphBitmapBy(glyphIndex);
227}

◆ EnsureGlyphs() [1/2]

void rendering_engine::FontResources::EnsureGlyphs ( const std::vector< GlyphIndex > &  glyphIndexes)

Ensures glyphs for the given glyph indices exist.

Parameters
glyphIndexesList of glyph indices.

Definition at line 129 of file font_resources.cpp.

130{
131 if (glyphIndexes.empty())
132 return;
133
134 std::vector<GlyphIndex> lackingGlyphs;
135 for (const auto& glyphIndex : glyphIndexes)
136 {
137 auto found = mGlyphsByIndex.find(glyphIndex.index);
138 if (found == mGlyphsByIndex.end())
139 {
140 GlyphIndex gi;
141 gi.index = glyphIndex.index;
142 lackingGlyphs.push_back(gi);
143 }
144 }
145 if (!lackingGlyphs.empty())
146 {
147 CreateFontAtlasFromList(lackingGlyphs);
148 }
149}
void CreateFontAtlasFromList(const std::vector< GlyphIndex > &glyphIndexes)
Creates a font atlas for a list of glyphs.

◆ EnsureGlyphs() [2/2]

void rendering_engine::FontResources::EnsureGlyphs ( const std::vector< std::uint32_t > &  codePoints)

Ensures glyphs for the given Unicode code points exist.

Parameters
codePointsList of Unicode code points.

Definition at line 115 of file font_resources.cpp.

116{
117 if (codePoints.empty())
118 return;
119
120 std::vector<GlyphIndex> glyphs;
121 for (auto codePoint : codePoints)
122 {
123 glyphs.push_back(GetIndexFromCodePoint(codePoint));
124 }
125
126 EnsureGlyphs(glyphs);
127}
void EnsureGlyphs(const std::vector< std::uint32_t > &codePoints)
Ensures glyphs for the given Unicode code points exist.
GlyphIndex GetIndexFromCodePoint(std::uint32_t codePoint) const
Resolves a Unicode code point to a glyph index.

◆ GetFontAtlasMaterialName()

std::string rendering_engine::FontResources::GetFontAtlasMaterialName ( GlyphIndex  glyphIndex) const

Returns the material name associated with the glyph.

Parameters
glyphIndexGlyph identifier.
Returns
Material name or empty string if unavailable.

Definition at line 336 of file font_resources.cpp.

337{
338 auto search = mGlyphsByIndex.find(glyphIndex.index);
339 if (search == mGlyphsByIndex.end())
340 {
341 return std::string();
342 }
343 return search->second.second;
344}

◆ GetFontAtlasTextureName()

std::string rendering_engine::FontResources::GetFontAtlasTextureName ( GlyphIndex  glyphIndex) const

Returns the texture name of the atlas containing the glyph.

Parameters
glyphIndexGlyph identifier.
Returns
Texture name or empty string if unavailable.

Definition at line 321 of file font_resources.cpp.

322{
323 auto matName = GetFontAtlasMaterialName(glyphIndex);
324 if (matName.empty())
325 {
326 return std::string();
327 }
328 auto search = mFontAtlases.find(matName);
329 if(search == mFontAtlases.end())
330 {
331 return std::string();
332 }
333 return search->second;
334}
std::string GetFontAtlasMaterialName(GlyphIndex glyphIndex) const
Returns the material name associated with the glyph.

◆ GetFontFace()

FT_Face rendering_engine::FontResources::GetFontFace ( )

Returns the internal font face handle.

Note
Intended for internal use only.

Definition at line 353 of file font_resources.cpp.

354{
355 return mFace;
356}

◆ GetFontMetrics()

const FontMetrics & rendering_engine::FontResources::GetFontMetrics ( ) const

Returns global font metrics.

Returns
Font metrics.

Definition at line 306 of file font_resources.cpp.

307{
308 return mFontMetrics;
309}

◆ GetGlyphMetrics()

GlyphMetrics rendering_engine::FontResources::GetGlyphMetrics ( GlyphIndex  glyphIndex) const

Returns metrics for a specific glyph.

Parameters
glyphIndexGlyph identifier.
Returns
Glyph metrics or default-initialized metrics if unavailable.

Definition at line 311 of file font_resources.cpp.

312{
313 auto search = mGlyphsByIndex.find(glyphIndex.index);
314 if (search == mGlyphsByIndex.end())
315 {
316 return GlyphMetrics();
317 }
318 return search->second.first;
319}

◆ GetIndexFromCodePoint()

GlyphIndex rendering_engine::FontResources::GetIndexFromCodePoint ( std::uint32_t  codePoint) const

Resolves a Unicode code point to a glyph index.

Parameters
codePointUnicode code point.
Returns
Glyph index.

Definition at line 346 of file font_resources.cpp.

347{
348 GlyphIndex result;
349 result.index = FT_Get_Char_Index(mFace, codePoint);
350 return result;
351}

◆ HasGlyph()

bool rendering_engine::FontResources::HasGlyph ( uint32_t  codePoint) const
protected

Checks whether a glyph exists for a code point.

Parameters
codePointUnicode code point.
Returns
True if the glyph exists.

Definition at line 301 of file font_resources.cpp.

302{
303 return FT_Get_Char_Index(mFace, codePoint) != 0;
304}

◆ LoadGlyphsFromCodePointRange()

void rendering_engine::FontResources::LoadGlyphsFromCodePointRange ( std::uint32_t  begin,
std::uint32_t  end 
)

Preloads glyphs for a continuous Unicode range.

Parameters
beginFirst Unicode code point.
endLast Unicode code point.

Definition at line 104 of file font_resources.cpp.

105{
106 std::uint32_t start = begin;
107 while (start < end)
108 {
109 std::uint32_t currentEnd = std::min(start + sMaxGlyphsPerFontAtlas - 1, end);
110 CreateFontAtlasFromRange(start, currentEnd);
111 start += sMaxGlyphsPerFontAtlas;
112 }
113}
static std::uint32_t sMaxGlyphsPerFontAtlas
Maximum number of glyphs per font atlas.
void CreateFontAtlasFromRange(std::uint32_t begin, std::uint32_t end)
Creates a font atlas for a continuous code point range.

◆ StoreFontAtlasesInFiles()

void rendering_engine::FontResources::StoreFontAtlasesInFiles ( bool  in)

Enables or disables storing generated font atlases on disk.

Parameters
inTrue to store atlases in files.

Definition at line 151 of file font_resources.cpp.

152{
154}

Member Data Documentation

◆ bStoreFontAtlasesInFiles

bool rendering_engine::FontResources::bStoreFontAtlasesInFiles = false
protected

Definition at line 235 of file font_resources.hpp.

◆ mErrorResult

FT_Error rendering_engine::FontResources::mErrorResult = FT_Err_Ok
protected

Definition at line 219 of file font_resources.hpp.

◆ mFace

FT_Face rendering_engine::FontResources::mFace = 0
protected

Definition at line 220 of file font_resources.hpp.

◆ mFontAtlases

std::unordered_map<std::string, std::string> rendering_engine::FontResources::mFontAtlases
protected

Definition at line 231 of file font_resources.hpp.

◆ mFontFileBytes

std::vector<uint8_t> rendering_engine::FontResources::mFontFileBytes
protected

Definition at line 233 of file font_resources.hpp.

◆ mFontMetrics

FontMetrics rendering_engine::FontResources::mFontMetrics
protected

Definition at line 222 of file font_resources.hpp.

◆ mFontName

std::string rendering_engine::FontResources::mFontName
protected

Definition at line 216 of file font_resources.hpp.

◆ mFontSize

const unsigned int rendering_engine::FontResources::mFontSize
protected

Definition at line 217 of file font_resources.hpp.

◆ mGlyphsByIndex

std::unordered_map<std::uint32_t, std::pair<GlyphMetrics, std::string> > rendering_engine::FontResources::mGlyphsByIndex
protected

Definition at line 228 of file font_resources.hpp.

◆ mRenderResourceContext

RenderResourceContext rendering_engine::FontResources::mRenderResourceContext
protected

Definition at line 214 of file font_resources.hpp.

◆ mTextRenderer

TextRenderer* rendering_engine::FontResources::mTextRenderer
protected

Definition at line 215 of file font_resources.hpp.

◆ sFontAtlasPaddingPx

unsigned int rendering_engine::FontResources::sFontAtlasPaddingPx = 4
staticprotected

Padding in pixels around glyphs inside atlases.

Definition at line 240 of file font_resources.hpp.

◆ sMaxGlyphsPerFontAtlas

std::uint32_t rendering_engine::FontResources::sMaxGlyphsPerFontAtlas = 1024
staticprotected

Maximum number of glyphs per font atlas.

Definition at line 238 of file font_resources.hpp.


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