TerminalFont: support contour

This commit is contained in:
李通洲
2023-09-02 08:07:28 -04:00
parent 67d04a746e
commit 34417ae692
2 changed files with 32 additions and 0 deletions
+1
View File
@@ -2,6 +2,7 @@
Features:
* Add fast path for xfce4 version detection (DE, FreeBSD)
* Add contour terminal version and font detection (Terminal / TerminalFont)
Bugfixes:
* Fix `fastfetch --config verbose` doesn't work (#547)
+31
View File
@@ -338,6 +338,35 @@ static bool detectTabby(FFTerminalFontResult* result)
return true;
}
static bool detectContour(const FFstrbuf* exe, FFTerminalFontResult* result)
{
FF_STRBUF_AUTO_DESTROY buf = ffStrbufCreate();
if(ffProcessAppendStdOut(&buf, (char* const[]){
exe->chars,
"font-locator",
NULL
}))
{
ffStrbufAppendS(&result->error, "`contour font-locator` failed");
return false;
}
//[error] Missing key .logging.enabled. Using default: false.
//[error] ...
//Matching fonts using : Fontconfig
//Font description : (family=Sarasa Term SC Nerd weight=Regular slant=Roman spacing=Monospace, strict_spacing=yes)
//Number of fonts found : 49
// path /usr/share/fonts/google-noto/NotoSansMono-Regular.ttf Regular Roman
// path ...
uint32_t index = ffStrbufFirstIndexS(&buf, "Font description : (family=");
if(index >= buf.length) return false;
index += strlen("Font description : (family=");
ffStrbufSubstrBefore(&buf, ffStrbufNextIndexS(&buf, index, " weight="));
ffFontInitCopy(&result->font, buf.chars + index);
return true;
}
void ffDetectTerminalFontPlatform(const FFTerminalShellResult* terminalShell, FFTerminalFontResult* terminalFont);
static bool detectTerminalFontCommon(const FFTerminalShellResult* terminalShell, FFTerminalFontResult* terminalFont)
@@ -350,6 +379,8 @@ static bool detectTerminalFontCommon(const FFTerminalShellResult* terminalShell,
detectWezterm(terminalFont);
else if(ffStrbufStartsWithIgnCaseS(&terminalShell->terminalProcessName, "tabby"))
detectTabby(terminalFont);
else if(ffStrbufStartsWithIgnCaseS(&terminalShell->terminalProcessName, "contour"))
detectContour(&terminalShell->terminalExe, terminalFont);
#ifndef _WIN32
else if(ffStrbufStartsWithIgnCaseS(&terminalShell->terminalExe, "/dev/pts/"))