MCPcopy Create free account
hub / github.com/TheForceEngine/TheForceEngine / tryLoadFont

Function tryLoadFont

TheForceEngine/TFE_A11y/accessibility.cpp:204–225  ·  view source on GitHub ↗

Try to load the font at the given path. If the font doesn't exist or can't be read, we automatically fall back to the default font.

Source from the content-addressed store, hash-verified

202 // Try to load the font at the given path. If the font doesn't exist or can't be read,
203 // we automatically fall back to the default font.
204 void tryLoadFont(const string path, bool clearAtlas)
205 {
206 if (!path.empty() && FileUtil::exists(path.c_str()))
207 {
208 try
209 {
210 loadFont(path, clearAtlas);
211 }
212 catch (...)
213 {
214 TFE_System::logWrite(LOG_ERROR, "a11y", string("Couldn't read font file at " + path
215 + "; falling back to default font").c_str());
216 loadDefaultFont(clearAtlas);
217 }
218 }
219 else
220 {
221 TFE_System::logWrite(LOG_ERROR, "a11y", string("Couldn't find font file at " + path
222 + "; falling back to default font").c_str());
223 loadDefaultFont(clearAtlas);
224 }
225 }
226
227 // Load the font at the given path. The font will be added to the ImGui font atlas if it hasn't
228 // been loaded before.

Callers 2

findFontFilesFunction · 0.85
loadPendingFontFunction · 0.85

Calls 6

loadFontFunction · 0.85
logWriteFunction · 0.85
loadDefaultFontFunction · 0.85
c_strMethod · 0.80
existsFunction · 0.50
emptyMethod · 0.45

Tested by

no test coverage detected