Files
fastfetch/src/detection/font/font_linux.c
T

58 lines
1.6 KiB
C
Raw Normal View History

2022-09-25 18:21:08 +08:00
#include "common/font.h"
2023-04-04 11:43:17 +08:00
#include "common/parsing.h"
#include "detection/displayserver/displayserver.h"
2023-02-14 17:46:21 +08:00
#include "detection/gtk_qt/gtk_qt.h"
2022-09-25 18:21:08 +08:00
#include "font.h"
2023-04-04 11:43:17 +08:00
static void generateString(FFFontResult* font)
{
if(font->fonts[0].length > 0)
{
ffStrbufAppend(&font->display, &font->fonts[0]);
ffStrbufAppendS(&font->display, " [QT]");
2023-05-28 12:34:18 +02:00
for(uint8_t i = 1; i < sizeof(font->fonts) / sizeof(font->fonts[0]); i++)
{
if(font->fonts[i].length > 0)
{
ffStrbufAppendS(&font->display, ", ");
break;
}
}
2023-04-04 11:43:17 +08:00
}
2023-05-28 12:34:18 +02:00
ffParseGTK(&font->display, &font->fonts[1], &font->fonts[2], &font->fonts[3]);
2023-04-04 11:43:17 +08:00
}
const char* ffDetectFontImpl(FFFontResult* result)
2022-09-25 18:21:08 +08:00
{
const FFDisplayServerResult* wmde = ffConnectDisplayServer();
if(ffStrbufIgnCaseCompS(&wmde->wmProtocolName, FF_WM_PROTOCOL_TTY) == 0)
2023-06-12 22:36:43 +08:00
return "Font isn't supported in TTY";
2022-09-29 14:15:11 +02:00
FFfont qt;
ffFontInitQt(&qt, ffDetectQt()->font.chars);
2022-09-29 14:15:11 +02:00
ffStrbufAppend(&result->fonts[0], &qt.pretty);
ffFontDestroy(&qt);
FFfont gtk2;
ffFontInitPango(&gtk2, ffDetectGTK2()->font.chars);
2022-09-29 14:15:11 +02:00
ffStrbufAppend(&result->fonts[1], &gtk2.pretty);
ffFontDestroy(&gtk2);
FFfont gtk3;
ffFontInitPango(&gtk3, ffDetectGTK3()->font.chars);
2022-09-29 14:15:11 +02:00
ffStrbufAppend(&result->fonts[2], &gtk3.pretty);
ffFontDestroy(&gtk3);
FFfont gtk4;
ffFontInitPango(&gtk4, ffDetectGTK4()->font.chars);
2022-09-29 14:15:11 +02:00
ffStrbufAppend(&result->fonts[3], &gtk4.pretty);
ffFontDestroy(&gtk4);
2023-04-04 11:43:17 +08:00
generateString(result);
2023-06-12 22:36:43 +08:00
return NULL;
2022-09-25 18:21:08 +08:00
}