@@ -303,6 +303,34 @@ static void detectSt(FFTerminalFontResult* terminalFont, uint32_t pid)
303303 ffFontInitValues (& terminalFont -> font , font .chars , size .chars );
304304}
305305
306+ static void detectWarp (FFTerminalFontResult * terminalFont )
307+ {
308+ FF_STRBUF_AUTO_DESTROY baseDir = ffStrbufCreateA (64 );
309+
310+ FF_LIST_FOR_EACH (FFstrbuf , dirPrefix , instance .state .platform .configDirs )
311+ {
312+ //We need to copy the dir each time, because it used by multiple threads, so we can't directly write to it.
313+ ffStrbufSet (& baseDir , dirPrefix );
314+ ffStrbufAppendS (& baseDir , "warp-terminal/user_preferences.json" );
315+
316+ yyjson_doc * doc = yyjson_read_file (baseDir .chars , YYJSON_READ_INSITU | YYJSON_READ_ALLOW_TRAILING_COMMAS | YYJSON_READ_ALLOW_COMMENTS , NULL , NULL );
317+ if (!doc ) continue ;
318+
319+ yyjson_val * prefs = yyjson_obj_get (yyjson_doc_get_root (doc ), "prefs" );
320+ if (yyjson_is_obj (prefs ))
321+ {
322+ const char * fontName = yyjson_get_str (yyjson_obj_get (prefs , "FontName" ));
323+ if (!fontName ) fontName = "Hack" ;
324+ const char * fontSize = yyjson_get_str (yyjson_obj_get (prefs , "FontSize" ));
325+ if (!fontSize ) fontSize = "13" ;
326+
327+ ffFontInitValues (& terminalFont -> font , fontName , fontSize );
328+ }
329+ yyjson_doc_free (doc );
330+ return ;
331+ }
332+ }
333+
306334void ffDetectTerminalFontPlatform (const FFTerminalResult * terminal , FFTerminalFontResult * terminalFont )
307335{
308336 if (ffStrbufIgnCaseEqualS (& terminal -> processName , "konsole" ))
@@ -331,4 +359,6 @@ void ffDetectTerminalFontPlatform(const FFTerminalResult* terminal, FFTerminalFo
331359 detectXterm (terminalFont );
332360 else if (ffStrbufIgnCaseEqualS (& terminal -> processName , "st" ))
333361 detectSt (terminalFont , terminal -> pid );
362+ else if (ffStrbufIgnCaseEqualS (& terminal -> processName , "warp" ))
363+ detectWarp (terminalFont );
334364}
0 commit comments