Get all font file names from the Fonts directories; we will use this to populate the dropdown in the Accessibility settings menu.
| 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) |
no test coverage detected