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.
| 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. |