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

Function findFontFiles

TheForceEngine/TFE_A11y/accessibility.cpp:163–186  ·  view source on GitHub ↗

Get all font file names from the Fonts directories; we will use this to populate the dropdown in the Accessibility settings menu.

Source from the content-addressed store, hash-verified

161 // Get all font file names from the Fonts directories; we will use this to populate the
162 // dropdown in the Accessibility settings menu.
163 void findFontFiles()
164 {
165 // First we check the User Documents directory for custom font files added by the user.
166 char docsFontsDir[TFE_MAX_PATH];
167 const char* docsDir = TFE_Paths::getPath(PATH_USER_DOCUMENTS);
168 sprintf(docsFontsDir, "%sFonts/", docsDir);
169 if (!FileUtil::directoryExits(docsFontsDir))
170 {
171 FileUtil::makeDirectory(docsFontsDir);
172 }
173 s_fontFileList.addFiles(docsFontsDir, "ttf", nullptr);
174
175 // Then we check the Program directory for font files that shipped with TFE.
176 char programFontsDir[TFE_MAX_PATH];
177 sprintf(programFontsDir, "Fonts/");
178 TFE_Paths::mapSystemPath(programFontsDir);
179 s_fontFileList.addFiles(programFontsDir, "ttf", nullptr);
180
181 // Try to load the previously selected font.
182 string lastFontPath = TFE_Settings::getA11ySettings()->lastFontPath;
183
184 if (!lastFontPath.empty() && ImGui::GetIO().Fonts->Locked) { setPendingFont(lastFontPath); }
185 else { tryLoadFont(lastFontPath, false); }
186 }
187
188 // Specify a font to load after ImGui finishes rendering.
189 void setPendingFont(const string path)

Callers 1

findFilesFunction · 0.85

Calls 9

getA11ySettingsFunction · 0.85
setPendingFontFunction · 0.85
tryLoadFontFunction · 0.85
addFilesMethod · 0.80
getPathFunction · 0.50
directoryExitsFunction · 0.50
makeDirectoryFunction · 0.50
mapSystemPathFunction · 0.50
emptyMethod · 0.45

Tested by

no test coverage detected