Repository: fastfetch-cli/fastfetch
File: src/modules/terminalfont.c (C)

Code before:

    if(fontName == NULL)
        ffPrintError(instance, FF_TERMFONT_MODULE_NAME, 0, &instance->config.terminalFont, "Couldn't find \"xsettings::/Gtk/MonospaceFontName\" in XFConf");
    else
    {
        FFfont font;
        ffFontInitPango(&font, fontName);
        printTerminalFont(instance, fontName, &font);
        ffFontDestroy(&font);
    }
}

static void printAlacritty(FFinstance* instance) {
    FFstrbuf fontName;
    ffStrbufInit(&fontName);
    // alacritty parses config files in this order
    ffParsePropFileConfig(instance, "alacritty/alacritty.yml", "family:", &fontName);
    if(fontName.length == 0)
        ffParsePropFileConfig(instance, "alacritty.yml", "family:", &fontName);
    if(fontName.length == 0)
        ffParsePropFileConfig(instance, ".alacritty.yml", "family:", &fontName);
    if(fontName.length == 0)
        ffStrbufAppendS(&fontName, "alacritty"); //by default alacritty uses it's own font called alacritty

    FFfont font;
    ffFontInitPango(&font, fontName.chars);
    printTerminalFont(instance, fontName.chars, &font);
    ffFontDestroy(&font);

    ffStrbufDestroy(&fontName);
}

static void printTTY(FFinstance* instance)
{
    FFstrbuf fontName;
    ffStrbufInit(&fontName);

    ffParsePropFile(FASTFETCH_TARGET_DIR_ROOT"/etc/vconsole.conf", "Font =", &fontName);

    if(fontName.length == 0)
    {
        ffStrbufAppendS(&fontName, "VGA default kernel font ");
        ffProcessAppendStdOut(&fontName, (char* const[]){
            "showconsolefont",
            "--info",
            NULL
        });
    }

    ffStrbufTrimRight(&fontName, ' ');


Review comment (suggestion):
Does alacritty really uses [pango](https://pango.gnome.org/) for font IO? This is usually a GTK thing. Pango fonts for example look like this: `Semi-Bold NotoMono Underline 10`. According to the one and only [arch wiki](https://wiki.archlinux.org/title/Alacritty) alacritty just saves the name under family, so a `ffFontInitCopy` should be much faster and enough.
The key `size: ` should only be used for font size, so we can parse for it too. You can use `ffParsePropFileConfigValues` to parse for multiple values at once.

Code after:
    const char* fontName = ffSettingsGetXFConf(instance, "xsettings", "/Gtk/MonospaceFontName", FF_VARIANT_TYPE_STRING).strValue;

    if(fontName == NULL)
        ffPrintError(instance, FF_TERMFONT_MODULE_NAME, 0, &instance->config.terminalFont, "Couldn't find \"xsettings::/Gtk/MonospaceFontName\" in XFConf");
    else
    {
        FFfont font;
        ffFontInitPango(&font, fontName);
        printTerminalFont(instance, fontName, &font);
        ffFontDestroy(&font);
    }
}

static void printAlacritty(FFinstance* instance) {
    FFstrbuf fontName;
    FFstrbuf fontSize;
    ffStrbufInit(&fontName);
    ffStrbufInit(&fontSize);

    FFpropquery fontQuery[] = {
        {"family:", &fontName},
        {"size:", &fontSize},
    };

    // alacritty parses config files in this order
    ffParsePropFileConfigValues(instance, "alacritty/alacritty.yml", 2, fontQuery);
    if(fontName.length == 0 || fontSize.length == 0)
        ffParsePropFileConfigValues(instance, "alacritty.yml", 2, fontQuery);
    if(fontName.length == 0 || fontSize.length == 0)
        ffParsePropFileConfigValues(instance, ".alacritty.yml", 2, fontQuery);

    //by default alacritty uses it's own font called alacritty
    if(fontName.length == 0)
        ffStrbufAppendS(&fontName, "alacritty");

    // the default font size is 11
    if(fontSize.length == 0)
        ffStrbufAppendS(&fontSize, "11");

    FFfont font;
    ffFontInitCopy(&font, fontName.chars);
    ffStrbufAppend(&font.size, &fontSize);
    printTerminalFont(instance, fontName.chars, &font);
    ffFontDestroy(&font);

    ffStrbufDestroy(&fontName);
    ffStrbufDestroy(&fontSize);
}

static void printTTY(FFinstance* instance)
{