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

Function loadFont

TheForceEngine/TFE_A11y/accessibility.cpp:229–253  ·  view source on GitHub ↗

Load the font at the given path. The font will be added to the ImGui font atlas if it hasn't been loaded before.

Source from the content-addressed store, hash-verified

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.
229 void loadFont(const string path, bool clearAtlas)
230 {
231 ImGuiIO& io = ImGui::GetIO();
232
233 if (s_fontMap.count(path) > 0) // Font has already been loaded.
234 {
235 s_currentCaptionFont = s_fontMap.at(path);
236 }
237 else // Font hasn't been loaded before.
238 {
239 s_currentCaptionFont = io.Fonts->AddFontFromFileTTF(path.c_str(), 32, nullptr, GetGlyphRanges());
240 s_fontMap[path] = s_currentCaptionFont;
241 // If we're loading a new font after the game first initializes, we'll need to clear the
242 // ImGui font atlas so that it is automatically regenerated at the start of the next frame.
243 if (clearAtlas) { TFE_Ui::invalidateFontAtlas(); }
244 }
245 assert(s_currentCaptionFont != nullptr);
246
247 char name[TFE_MAX_PATH];
248 FileUtil::getFileNameFromPath(path.c_str(), name);
249 s_currentFontFile.name = string(name);
250 s_currentFontFile.path = path;
251
252 TFE_Settings::getA11ySettings()->lastFontPath = path;
253 }
254
255 void loadPendingFont()
256 {

Callers 2

loadDefaultFontFunction · 0.85
tryLoadFontFunction · 0.85

Calls 8

GetGlyphRangesFunction · 0.85
invalidateFontAtlasFunction · 0.85
getA11ySettingsFunction · 0.85
countMethod · 0.80
atMethod · 0.80
AddFontFromFileTTFMethod · 0.80
c_strMethod · 0.80
getFileNameFromPathFunction · 0.50

Tested by

no test coverage detected