font
This commit is contained in:
parent
21aeaab088
commit
cf7a9a1f1a
@ -20,6 +20,8 @@ add_executable(hang_man src/main.cpp
|
||||
src/utils.hpp
|
||||
src/GuessCorrector.cpp
|
||||
src/GuessCorrector.hpp
|
||||
src/default_font.cpp
|
||||
src/default_font.hpp
|
||||
)
|
||||
|
||||
target_link_libraries(hang_man PRIVATE
|
||||
|
31
src/default_font.cpp
Normal file
31
src/default_font.cpp
Normal file
@ -0,0 +1,31 @@
|
||||
#include "default_font.hpp"
|
||||
|
||||
#ifdef __linux__
|
||||
#include <filesystem>
|
||||
|
||||
constexpr const char *getLinuxFilePath() {
|
||||
const char *fonts[] = {"/usr/share/fonts/truetype/DejaVuSans-Bold.ttf", // openSUSE
|
||||
"/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf", // Debian
|
||||
"/usr/share/fonts/TTF/DejaVuSans-Bold.ttf", // Arch
|
||||
"/usr/share/fonts/dejavu-sans-fonts/DejaVuSans-Bold.ttf", // Fedora
|
||||
};
|
||||
for (const char *font: fonts)
|
||||
if (std::filesystem::exists(font))
|
||||
return font;
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
const char *getDefaultFontPath() {
|
||||
#if defined(_WIN32) || defined(_WIN64)
|
||||
return R"(C:\Windows\Fonts\Arial.ttf)";
|
||||
#elifdef __linux__
|
||||
return getLinuxFilePath();
|
||||
#elif defined(__APPLE__) || defined(__MACH__)
|
||||
return "/System/Library/Fonts/Supplemental/Arial.ttf";
|
||||
#else
|
||||
return nullptr;
|
||||
#endif
|
||||
}
|
3
src/default_font.hpp
Normal file
3
src/default_font.hpp
Normal file
@ -0,0 +1,3 @@
|
||||
#pragma once
|
||||
|
||||
const char *getDefaultFontPath();
|
Loading…
Reference in New Issue
Block a user