From cdbe8f54c6f7143896cb7f436440f3df1b974a19 Mon Sep 17 00:00:00 2001 From: Carter Li Date: Mon, 28 Sep 2026 09:13:16 +0800 Subject: [PATCH] TerminalFont (Linux): uses ffFontInitXft to parse foot terminal font Fixes #2624 --- CHANGELOG.md | 1 + .../terminalfont/terminalfont_linux.c | 45 +++++-------------- 2 files changed, 12 insertions(+), 34 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d3dd46c90..25430d03f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ Bugfixes: * Fixed `--config`/`-c` bash completion offering one candidate per word instead of one candidate per file for paths containing spaces. (Completion, Bash) * Fixed external monitors detected via DDC/CI being randomly reported as built-in, and libddcutil trace messages occasionally leaking into the output and breaking `--format json`. (#2615, Brightness / Linux) * Fixed the Vulkan driver name being concatenated with the driver name of a previously enumerated device on systems with more than one GPU. (#2619, Vulkan) +* Fixed the Foot terminal font size not being parsed when written in the `Font Name-size` syntax, e.g. `Berkeley Mono-12`. (#2624, TerminalFont / Linux) # 2.69.0 diff --git a/src/detection/terminalfont/terminalfont_linux.c b/src/detection/terminalfont/terminalfont_linux.c index a351e584e..23d31f2d4 100644 --- a/src/detection/terminalfont/terminalfont_linux.c +++ b/src/detection/terminalfont/terminalfont_linux.c @@ -211,27 +211,17 @@ static void detectFootTerminal(FFTerminalFontResult* terminalFont) { return; } - // Sarasa Term SC Nerd:size=8 - uint32_t colon = ffStrbufFirstIndexC(&font, ':'); - if (colon == font.length) { - ffFontInitValues(&terminalFont->font, font.chars, "8"); - return; - } - uint32_t equal = ffStrbufNextIndexS(&font, colon, "size="); - font.chars[colon] = '\0'; - if (equal == font.length) { - ffFontInitValues(&terminalFont->font, font.chars, "8"); - return; - } - uint32_t size = equal + (uint32_t) strlen("size="); - uint32_t comma = ffStrbufNextIndexC(&font, size, ','); - if (comma < font.length) { + // foot splits the font list on commas to specify fallback fonts. + // Each entry is a fontconfig pattern, e.g. "Berkeley Mono-12" or "Sarasa Term SC Nerd:size=8". + uint32_t comma = ffStrbufFirstIndexC(&font, ','); + if (comma != font.length) { + if (comma + 1 < font.length) { + ffFontInitXft(&terminalFont->fallback, &font.chars[comma + 1]); + } font.chars[comma] = '\0'; + ffStrbufRecalculateLength(&font); } - ffFontInitValues(&terminalFont->font, font.chars, &font.chars[size]); - if (comma < font.length) { - ffFontInitValues(&terminalFont->fallback, &font.chars[comma + 1], nullptr); - } + ffFontInitXft(&terminalFont->font, font.chars); } static void detectQTerminal(FFTerminalFontResult* terminalFont) { @@ -312,21 +302,8 @@ static void detectSt(FFTerminalFontResult* terminalFont, const FFTerminalResult* } } - // JetBrainsMono Nerd Font Mono:pixelsize=12:antialias=true:autohint=true - - uint32_t index = ffStrbufFirstIndexC(&font, ':'); - if (index != font.length) { - uint32_t sIndex = ffStrbufNextIndexS(&font, index + 1, "size="); - if (sIndex != font.length) { - sIndex += (uint32_t) strlen("size="); - uint32_t sIndexEnd = ffStrbufNextIndexC(&font, sIndex, ':'); - ffStrbufSetNS(&size, sIndexEnd - sIndex, font.chars + sIndex); - } - ffStrbufSubstrBefore(&font, index); - } else { - ffStrbufClear(&size); - } - ffFontInitValues(&terminalFont->font, font.chars, size.chars); + // e.g. "JetBrainsMono Nerd Font Mono:pixelsize=12:antialias=true:autohint=true" + ffFontInitXft(&terminalFont->font, font.chars); } static void detectWarp(FFTerminalFontResult* terminalFont) {