Load sys fonts if assets dir not found, return err if unsupported

This commit is contained in:
scawful
2024-10-04 01:33:13 -04:00
parent cc735d0094
commit a64700d601
2 changed files with 13 additions and 9 deletions

View File

@@ -2,6 +2,7 @@
#include <SDL.h>
#include <filesystem>
#include <memory>
#include "absl/status/status.h"
@@ -402,10 +403,19 @@ absl::Status Controller::CreateGuiContext() {
Renderer::GetInstance().renderer());
ImGui_ImplSDLRenderer2_Init(Renderer::GetInstance().renderer());
if (flags()->kLoadSystemFonts) {
LoadSystemFonts();
} else {
// Check if the assets/fonts directory exists in our CWD
// Otherwise, load the system fonts.
const auto assets_path = std::filesystem::path("assets");
if (std::filesystem::is_directory(assets_path)) {
RETURN_IF_ERROR(LoadFontFamilies());
} else {
#ifdef __APPLE__
LoadSystemFonts();
#else
return absl::InternalError(
"Could not find assets/fonts directory in the current working "
"directory");
#endif
}
// Set the default style