summaryrefslogtreecommitdiffstats
path: root/src/detection/font/font_linux.c
blob: 5e82b682cc422726003f4cb78e23e1c21fc6efaf (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include "common/font.h"
#include "common/parsing.h"
#include "detection/displayserver/displayserver.h"
#include "detection/gtk_qt/gtk_qt.h"
#include "font.h"

static void generateString(FFFontResult* font) {
    if (font->fonts[0].length > 0) {
        ffStrbufAppend(&font->display, &font->fonts[0]);
        ffStrbufAppendS(&font->display, " [Qt]");

        for (uint8_t i = 1; i < ARRAY_SIZE(font->fonts); i++) {
            if (font->fonts[i].length > 0) {
                ffStrbufAppendS(&font->display, ", ");
                break;
            }
        }
    }

    ffParseGTK(&font->display, &font->fonts[1], &font->fonts[2], &font->fonts[3]);
}

const char* ffDetectFontImpl(FFFontResult* result) {
    const FFDisplayServerResult* wmde = ffConnectDisplayServer();

    if (ffStrbufIgnCaseEqualS(&wmde->wmProtocolName, FF_WM_PROTOCOL_TTY)) {
        return "Font isn't supported in TTY";
    }

    FFfont qt;
    ffFontInitQt(&qt, ffDetectQt()->font.chars);
    ffStrbufAppend(&result->fonts[0], &qt.pretty);
    ffFontDestroy(&qt);

    FFfont gtk2;
    ffFontInitPango(&gtk2, ffDetectGTK2()->font.chars);
    ffStrbufAppend(&result->fonts[1], &gtk2.pretty);
    ffFontDestroy(&gtk2);

    FFfont gtk3;
    ffFontInitPango(&gtk3, ffDetectGTK3()->font.chars);
    ffStrbufAppend(&result->fonts[2], &gtk3.pretty);
    ffFontDestroy(&gtk3);

    FFfont gtk4;
    ffFontInitPango(&gtk4, ffDetectGTK4()->font.chars);
    ffStrbufAppend(&result->fonts[3], &gtk4.pretty);
    ffFontDestroy(&gtk4);

    generateString(result);

    return NULL;
}