mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-10-29 16:26:39 +01:00
TerminalFont (Linux): detect system mono font
This commit is contained in:
@@ -322,34 +322,6 @@ FF_MAYBE_UNUSED static bool detectKitty(const FFstrbuf* exe, FFTerminalFontResul
|
||||
return true;
|
||||
}
|
||||
|
||||
static void detectTerminator(FFTerminalFontResult* result)
|
||||
{
|
||||
FF_STRBUF_AUTO_DESTROY useSystemFont = ffStrbufCreate();
|
||||
FF_STRBUF_AUTO_DESTROY fontName = ffStrbufCreate();
|
||||
|
||||
FFpropquery fontQuery[] = {
|
||||
{"use_system_font =", &useSystemFont},
|
||||
{"font =", &fontName},
|
||||
};
|
||||
|
||||
if(!ffParsePropFileConfigValues("terminator/config", 2, fontQuery))
|
||||
{
|
||||
ffStrbufAppendS(&result->error, "Couldn't read Terminator config file");
|
||||
return;
|
||||
}
|
||||
|
||||
if(ffStrbufIgnCaseEqualS(&useSystemFont, "True"))
|
||||
{
|
||||
ffFontInitCopy(&result->font, "System");
|
||||
return;
|
||||
}
|
||||
|
||||
if(fontName.length == 0)
|
||||
ffFontInitValues(&result->font, "mono", "8");
|
||||
else
|
||||
ffFontInitPango(&result->font, fontName.chars);
|
||||
}
|
||||
|
||||
static bool detectWezterm(const FFstrbuf* exe, FFTerminalFontResult* result)
|
||||
{
|
||||
FF_STRBUF_AUTO_DESTROY cli = ffStrbufCreateCopy(exe);
|
||||
@@ -442,8 +414,6 @@ static bool detectTerminalFontCommon(const FFTerminalResult* terminal, FFTermina
|
||||
{
|
||||
if(ffStrbufStartsWithIgnCaseS(&terminal->processName, "alacritty"))
|
||||
detectAlacritty(terminalFont);
|
||||
else if(ffStrbufStartsWithIgnCaseS(&terminal->processName, "terminator"))
|
||||
detectTerminator(terminalFont);
|
||||
else if(ffStrbufStartsWithIgnCaseS(&terminal->processName, "wezterm-gui"))
|
||||
detectWezterm(&terminal->exe, terminalFont);
|
||||
else if(ffStrbufStartsWithIgnCaseS(&terminal->processName, "tabby"))
|
||||
|
||||
@@ -379,6 +379,30 @@ static void detectWarp(FFTerminalFontResult* terminalFont)
|
||||
}
|
||||
}
|
||||
|
||||
static void detectTerminator(FFTerminalFontResult* result)
|
||||
{
|
||||
FF_STRBUF_AUTO_DESTROY useSystemFont = ffStrbufCreate();
|
||||
FF_STRBUF_AUTO_DESTROY fontName = ffStrbufCreate();
|
||||
|
||||
if(!ffParsePropFileConfigValues("terminator/config", 2, (FFpropquery[]) {
|
||||
{"use_system_font =", &useSystemFont},
|
||||
{"font =", &fontName},
|
||||
}) || ffStrbufIgnCaseEqualS(&useSystemFont, "True"))
|
||||
{
|
||||
FF_AUTO_FREE const char* fontName = getSystemMonospaceFont();
|
||||
if(ffStrSet(fontName))
|
||||
ffFontInitPango(&result->font, fontName);
|
||||
else
|
||||
ffStrbufAppendS(&result->error, "Couldn't get system monospace font name from GSettings / DConf");
|
||||
return;
|
||||
}
|
||||
|
||||
if(fontName.length == 0)
|
||||
ffFontInitValues(&result->font, "Mono", "10");
|
||||
else
|
||||
ffFontInitPango(&result->font, fontName.chars);
|
||||
}
|
||||
|
||||
static void detectWestonTerminal(FFTerminalFontResult* terminalFont)
|
||||
{
|
||||
FF_STRBUF_AUTO_DESTROY font = ffStrbufCreate();
|
||||
@@ -426,4 +450,6 @@ void ffDetectTerminalFontPlatform(const FFTerminalResult* terminal, FFTerminalFo
|
||||
detectWarp(terminalFont);
|
||||
else if(ffStrbufIgnCaseEqualS(&terminal->processName, "weston-terminal"))
|
||||
detectWestonTerminal(terminalFont);
|
||||
else if(ffStrbufStartsWithIgnCaseS(&terminal->processName, "terminator"))
|
||||
detectTerminator(terminalFont);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user