Load the font at the given path. The font will be added to the ImGui font atlas if it hasn't been loaded before.
| 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 | { |
no test coverage detected