mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-11-09 14:40:10 +01:00
TerminalFont: support Termux
This commit is contained in:
@@ -219,6 +219,7 @@ static void defaultConfig(FFinstance* instance)
|
||||
ffStrbufInitA(&instance->config.libOpenCL, 0);
|
||||
ffStrbufInitA(&instance->config.libplist, 0);
|
||||
ffStrbufInitA(&instance->config.libcJSON, 0);
|
||||
ffStrbufInitA(&instance->config.libfreetype, 0);
|
||||
|
||||
instance->config.cpuTemp = false;
|
||||
instance->config.gpuTemp = false;
|
||||
|
||||
@@ -325,3 +325,4 @@
|
||||
#--lib-opencl /usr/lib/libOpenCL.so
|
||||
#--lib-plist /usr/local/bin/libplist-2.0.dylib
|
||||
#--lib-cjson /usr/lib/libcjson.so
|
||||
#--lib-freetype /data/data/com.termux/files/usr/lib
|
||||
|
||||
@@ -1,7 +1,74 @@
|
||||
#include "fastfetch.h"
|
||||
#include "terminalfont.h"
|
||||
#include "detection/terminalshell.h"
|
||||
#include "common/io.h"
|
||||
|
||||
#include <sys/stat.h>
|
||||
|
||||
#ifdef FF_HAVE_FREETYPE
|
||||
#include "common/library.h"
|
||||
#include <ft2build.h>
|
||||
#include FT_FREETYPE_H
|
||||
#endif
|
||||
|
||||
#define FF_TERMUX_FONT_PATH FASTFETCH_TARGET_DIR_HOME "/.termux/font.ttf"
|
||||
|
||||
const char* detectTermux(const FFinstance* instance, FFTerminalFontResult* terminalFont)
|
||||
{
|
||||
#ifdef FF_HAVE_FREETYPE
|
||||
|
||||
FF_LIBRARY_LOAD(freetype, &instance->config.libfreetype, "dlopen libfreetype"FF_LIBRARY_EXTENSION " failed", "libfreetype"FF_LIBRARY_EXTENSION, 2)
|
||||
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(freetype, FT_Init_FreeType);
|
||||
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(freetype, FT_New_Face);
|
||||
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(freetype, FT_Done_Face);
|
||||
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(freetype, FT_Done_FreeType);
|
||||
|
||||
FT_Library library = NULL;
|
||||
FT_Face face = NULL;
|
||||
const char* error = NULL;
|
||||
|
||||
if(ffFT_Init_FreeType(&library))
|
||||
{
|
||||
error = "FT_Init_FreeType() failed";
|
||||
goto exit;
|
||||
}
|
||||
|
||||
if(ffFT_New_Face(library, FF_TERMUX_FONT_PATH, 0, &face ))
|
||||
{
|
||||
error = "FT_NEW_Face(" FF_TERMUX_FONT_PATH ") failed";
|
||||
goto exit;
|
||||
}
|
||||
|
||||
ffFontInitCopy(&terminalFont->font, face->family_name);
|
||||
|
||||
exit:
|
||||
if(face) ffFT_Done_Face(face);
|
||||
if(library) ffFT_Done_FreeType(library);
|
||||
dlclose(freetype);
|
||||
|
||||
return error;
|
||||
|
||||
#else
|
||||
|
||||
FF_UNUSED(terminalFont);
|
||||
ffStrbufSetS(&terminalFont->error, "fastfetch is built without freetype2 support");
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
void ffDetectTerminalFontPlatform(const FFinstance* instance, const FFTerminalShellResult* terminalShell, FFTerminalFontResult* terminalFont)
|
||||
{
|
||||
FF_UNUSED(instance, terminalShell, terminalFont);
|
||||
if(ffStrbufCompS(&terminalShell->terminalProcessName, "Termux") != 0)
|
||||
{
|
||||
ffStrbufSetS(&terminalFont->error, "Unsupported terminal");
|
||||
return;
|
||||
}
|
||||
|
||||
if(!ffFileExists(FF_TERMUX_FONT_PATH, S_IFREG))
|
||||
{
|
||||
ffFontInitCopy(&terminalFont->font, "monospace");
|
||||
return;
|
||||
}
|
||||
|
||||
ffStrbufSetS(&terminalFont->error, detectTermux(instance, terminalFont));
|
||||
}
|
||||
|
||||
@@ -1208,6 +1208,8 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con
|
||||
optionParseString(key, value, &instance->config.libPCI);
|
||||
else if(strcasecmp(key, "--lib-vulkan") == 0)
|
||||
optionParseString(key, value, &instance->config.libVulkan);
|
||||
else if(strcasecmp(key, "--lib-freetype") == 0)
|
||||
optionParseString(key, value, &instance->config.libfreetype);
|
||||
else if(strcasecmp(key, "--lib-wayland") == 0)
|
||||
optionParseString(key, value, &instance->config.libWayland);
|
||||
else if(strcasecmp(key, "--lib-xcb-randr") == 0)
|
||||
|
||||
@@ -151,6 +151,7 @@ typedef struct FFconfig
|
||||
FFstrbuf libOpenCL;
|
||||
FFstrbuf libplist;
|
||||
FFstrbuf libcJSON;
|
||||
FFstrbuf libfreetype;
|
||||
|
||||
bool cpuTemp;
|
||||
bool gpuTemp;
|
||||
|
||||
Reference in New Issue
Block a user