diff options
| author | sumuel <samuel@yakubos.org> | 2026-08-17 20:44:55 +0000 |
|---|---|---|
| committer | sumuel <samuel@yakubos.org> | 2026-08-17 20:44:55 +0000 |
| commit | 76424950e373d3b04ac3dd13019151bfba3e8423 (patch) | |
| tree | 4c3cfdbda039e592b9186be3e28f8d7cfd439e8a /src/detection/terminalfont/terminalfont_android.c | |
Add the files
Diffstat (limited to 'src/detection/terminalfont/terminalfont_android.c')
| -rw-r--r-- | src/detection/terminalfont/terminalfont_android.c | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/src/detection/terminalfont/terminalfont_android.c b/src/detection/terminalfont/terminalfont_android.c new file mode 100644 index 0000000..a721078 --- /dev/null +++ b/src/detection/terminalfont/terminalfont_android.c @@ -0,0 +1,71 @@ +#include "fastfetch.h" +#include "terminalfont.h" +#include "detection/terminalshell/terminalshell.h" +#include "common/io.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(FFTerminalFontResult* terminalFont) { + if (!ffPathExists(FF_TERMUX_FONT_PATH, FF_PATHTYPE_FILE)) { + ffFontInitCopy(&terminalFont->font, "monospace"); + return NULL; + } + +#ifdef FF_HAVE_FREETYPE + + FF_LIBRARY_LOAD_MESSAGE(freetype, "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); + } + + return error; + +#else + + FF_UNUSED(terminalFont); + return "Fastfetch was built without freetype2 support"; + +#endif +} + +bool ffDetectTerminalFontPlatform(const FFTerminalResult* terminal, FFTerminalFontResult* terminalFont) { + if (ffStrbufEqualS(&terminal->processName, "com.termux")) { + ffStrbufSetS(&terminalFont->error, detectTermux(terminalFont)); + } else { + bool ffDetectTerminalFontPlatformLinux(const FFTerminalResult* terminal, FFTerminalFontResult* terminalFont); + return ffDetectTerminalFontPlatformLinux(terminal, terminalFont); + } + + return true; +} |