Skip to content

Commit 813b80c

Browse files
committed
TerminalFont: support Ghostty
Fix #1466
1 parent ddce9b2 commit 813b80c

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

src/detection/terminalfont/terminalfont.c

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,31 @@ static void detectAlacritty(FFTerminalFontResult* terminalFont)
4848
ffFontInitValues(&terminalFont->font, fontName.chars, fontSize.chars);
4949
}
5050

51+
static void detectGhostty(FFTerminalFontResult* terminalFont)
52+
{
53+
FF_STRBUF_AUTO_DESTROY fontName = ffStrbufCreate();
54+
FF_STRBUF_AUTO_DESTROY fontSize = ffStrbufCreate();
55+
56+
FFpropquery fontQueryToml[] = {
57+
{"font-family =", &fontName},
58+
{"font-size =", &fontSize},
59+
};
60+
61+
if (!ffParsePropFileConfigValues("ghostty/config", 2, fontQueryToml))
62+
{
63+
ffStrbufAppendS(&terminalFont->error, "Couldn't find file `ghostty/config`");
64+
return;
65+
}
66+
67+
if(fontName.length == 0)
68+
ffStrbufAppendS(&fontName, "monospace");
69+
70+
if(fontSize.length == 0)
71+
ffStrbufAppendS(&fontSize, "13");
72+
73+
ffFontInitValues(&terminalFont->font, fontName.chars, fontSize.chars);
74+
}
75+
5176
FF_MAYBE_UNUSED static void detectTTY(FFTerminalFontResult* terminalFont)
5277
{
5378
FF_STRBUF_AUTO_DESTROY fontName = ffStrbufCreate();
@@ -230,6 +255,8 @@ static bool detectTerminalFontCommon(const FFTerminalResult* terminal, FFTermina
230255
detectTabby(terminalFont);
231256
else if(ffStrbufStartsWithIgnCaseS(&terminal->processName, "contour"))
232257
detectContour(&terminal->exe, terminalFont);
258+
else if(ffStrbufStartsWithIgnCaseS(&terminal->processName, "ghostty"))
259+
detectGhostty(terminalFont);
233260

234261
#ifndef _WIN32
235262
else if(ffStrbufStartsWithIgnCaseS(&terminal->exe, "/dev/pts/"))

0 commit comments

Comments
 (0)