mirror of
https://github.com/lov3b/Pong.git
synced 2024-11-09 23:10:18 +01:00
Add more locations for dejavu font under different linux distros
This commit is contained in:
parent
d4ec09a8fb
commit
1432a469ac
@ -3,11 +3,27 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
#include <filesystem>
|
||||||
|
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
#if defined(_WIN32) || defined(_WIN64)
|
#if defined(_WIN32) || defined(_WIN64)
|
||||||
const char* defaultFontPath = "C:\\Windows\\Fonts\\Arial.ttf";
|
const char* defaultFontPath = "C:\\Windows\\Fonts\\Arial.ttf";
|
||||||
#elif defined(__linux__)
|
#elif defined(__linux__)
|
||||||
const char *defaultFontPath = "/usr/share/fonts/truetype/DejaVuSans-Bold.ttf";
|
const char *defaultFontPath = getLinuxFilePath();
|
||||||
#elif defined(__APPLE__) || defined(__MACH__)
|
#elif defined(__APPLE__) || defined(__MACH__)
|
||||||
const char *defaultFontPath = "/System/Library/Fonts/Supplemental/Arial.ttf";
|
const char *defaultFontPath = "/System/Library/Fonts/Supplemental/Arial.ttf";
|
||||||
#else
|
#else
|
||||||
|
Loading…
Reference in New Issue
Block a user