From 2e30a57889983830bd7e0d82b2dbd5492c2acba7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Mon, 30 Oct 2023 11:05:43 +0800 Subject: [PATCH] TerminalFont: always use kitten to detect kitty term fonts --- src/detection/terminalfont/terminalfont.c | 49 +++++++++++------------ 1 file changed, 23 insertions(+), 26 deletions(-) diff --git a/src/detection/terminalfont/terminalfont.c b/src/detection/terminalfont/terminalfont.c index cf5366f5b..a50e56525 100644 --- a/src/detection/terminalfont/terminalfont.c +++ b/src/detection/terminalfont/terminalfont.c @@ -242,35 +242,32 @@ FF_MAYBE_UNUSED static bool detectKitty(const FFstrbuf* exe, FFTerminalFontResul FF_STRBUF_AUTO_DESTROY fontName = ffStrbufCreate(); FF_STRBUF_AUTO_DESTROY fontSize = ffStrbufCreate(); - FFpropquery fontQuery[] = { - {"font_family ", &fontName}, - {"font_size ", &fontSize}, - }; - - if(instance.config.general.allowSlowOperations) + FF_STRBUF_AUTO_DESTROY buf = ffStrbufCreate(); + if(!ffProcessAppendStdOut(&buf, (char* const[]){ + exe->chars, + "+kitten", + "query-terminal", + NULL, + })) { - FF_STRBUF_AUTO_DESTROY buf = ffStrbufCreate(); - if(!ffProcessAppendStdOut(&buf, (char* const[]){ - exe->chars, - "+kitten", - "query-terminal", - NULL, - })) - { - ffParsePropLines(buf.chars, "font_family: ", &fontName); - ffParsePropLines(buf.chars, "font_size: ", &fontSize); - ffFontInitValues(&result->font, fontName.chars, fontSize.chars); - return true; - } + ffParsePropLines(buf.chars, "font_family: ", &fontName); + ffParsePropLines(buf.chars, "font_size: ", &fontSize); + } + else + { + FFpropquery fontQuery[] = { + {"font_family ", &fontName}, + {"font_size ", &fontSize}, + }; + + ffParsePropFileConfigValues("kitty/kitty.conf", 2, fontQuery); + + if(fontName.length == 0) + ffStrbufSetS(&fontName, "monospace"); + if(fontSize.length == 0) + ffStrbufSetS(&fontSize, "11.0"); } - if(!ffParsePropFileConfigValues("kitty/kitty.conf", 2, fontQuery)) - return false; - - if(fontName.length == 0) - ffStrbufSetS(&fontName, "monospace"); - if(fontSize.length == 0) - ffStrbufSetS(&fontSize, "11.0"); ffFontInitValues(&result->font, fontName.chars, fontSize.chars);