From 1432a469acfa2f3706b0e6c92a1bc7848f7792db Mon Sep 17 00:00:00 2001 From: lov3b Date: Sun, 28 Jan 2024 21:54:43 +0100 Subject: [PATCH] Add more locations for dejavu font under different linux distros --- src/defaultfont.h | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/defaultfont.h b/src/defaultfont.h index e8b2e94..886d1b8 100644 --- a/src/defaultfont.h +++ b/src/defaultfont.h @@ -3,11 +3,27 @@ // #pragma once +#include + + +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) const char* defaultFontPath = "C:\\Windows\\Fonts\\Arial.ttf"; #elif defined(__linux__) -const char *defaultFontPath = "/usr/share/fonts/truetype/DejaVuSans-Bold.ttf"; +const char *defaultFontPath = getLinuxFilePath(); #elif defined(__APPLE__) || defined(__MACH__) const char *defaultFontPath = "/System/Library/Fonts/Supplemental/Arial.ttf"; #else