File tree Expand file tree Collapse file tree 4 files changed +28
-3
lines changed Expand file tree Collapse file tree 4 files changed +28
-3
lines changed Original file line number Diff line number Diff line change @@ -5,7 +5,8 @@ include(${PROJECT_SOURCE_DIR}/cmake/StaticAnalyzers.cmake)
55add_library (${NAME} STATIC
66 Core/Log .cpp Core/Log .hpp Core/Debug/Instrumentor.hpp
77 Core/Application.cpp Core/Application.hpp Core/Window.cpp Core/Window.hpp
8- Core/Resources.hpp Core/DPIHandler.hpp)
8+ Core/Resources.hpp Core/Resources.cpp
9+ Core/DPIHandler.hpp)
910
1011# Define set of OS specific files to include
1112if (CMAKE_SYSTEM_NAME STREQUAL "Windows" )
Original file line number Diff line number Diff line change @@ -66,8 +66,13 @@ ExitStatus App::Application::run() {
6666 const float font_size{18 .0F * font_scaling_factor};
6767 const std::string font_path{Resources::font_path (" Manrope.ttf" ).generic_string ()};
6868
69- io.Fonts ->AddFontFromFileTTF (font_path.c_str (), font_size);
70- io.FontDefault = io.Fonts ->AddFontFromFileTTF (font_path.c_str (), font_size);
69+ if (Resources::exists (font_path)) {
70+ io.Fonts ->AddFontFromFileTTF (font_path.c_str (), font_size);
71+ io.FontDefault = io.Fonts ->AddFontFromFileTTF (font_path.c_str (), font_size);
72+ } else {
73+ APP_WARN (" Could not find font file under: {}" , font_path.c_str ());
74+ }
75+
7176 DPIHandler::set_global_font_scaling (&io);
7277
7378 // Setup Platform/Renderer backends
Original file line number Diff line number Diff line change 1+ #include " Core/Resources.hpp"
2+
3+ #include < sys/stat.h>
4+
5+ #include < filesystem>
6+
7+ #include " Core/Debug/Instrumentor.hpp"
8+
9+ namespace App {
10+
11+ bool Resources::exists (const std::filesystem::path& pathname) {
12+ APP_PROFILE_FUNCTION ();
13+
14+ struct stat buffer;
15+ return (stat (pathname.generic_string ().c_str (), &buffer) == 0 );
16+ }
17+
18+ } // namespace App
Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ class Resources {
99 public:
1010 [[nodiscard]] static std::filesystem::path resource_path (const std::filesystem::path& file_path);
1111 [[nodiscard]] static std::filesystem::path font_path (const std::string_view& font_file);
12+ [[nodiscard]] static bool exists (const std::filesystem::path& pathname);
1213};
1314
1415} // namespace App
You can’t perform that action at this time.
0 commit comments