font
This commit is contained in:
		
							
								
								
									
										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();
 | 
			
		||||
		Reference in New Issue
	
	Block a user