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)
5
5
add_library (${NAME} STATIC
6
6
Core/Log .cpp Core/Log .hpp Core/Debug/Instrumentor.hpp
7
7
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)
9
10
10
11
# Define set of OS specific files to include
11
12
if (CMAKE_SYSTEM_NAME STREQUAL "Windows" )
Original file line number Diff line number Diff line change @@ -66,8 +66,13 @@ ExitStatus App::Application::run() {
66
66
const float font_size{18 .0F * font_scaling_factor};
67
67
const std::string font_path{Resources::font_path (" Manrope.ttf" ).generic_string ()};
68
68
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
+
71
76
DPIHandler::set_global_font_scaling (&io);
72
77
73
78
// 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 {
9
9
public:
10
10
[[nodiscard]] static std::filesystem::path resource_path (const std::filesystem::path& file_path);
11
11
[[nodiscard]] static std::filesystem::path font_path (const std::string_view& font_file);
12
+ [[nodiscard]] static bool exists (const std::filesystem::path& pathname);
12
13
};
13
14
14
15
} // namespace App
You can’t perform that action at this time.
0 commit comments