Skip to content

Commit b9b684a

Browse files
authored
fix: improve font string processing in SetFonts method (#1092)
1 parent 519bdf1 commit b9b684a

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

src/App.axaml.cs

+25
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,9 @@ public static void SetFonts(string defaultFont, string monospaceFont, bool onlyU
181181
app._fontsOverrides = null;
182182
}
183183

184+
defaultFont = ProcessFontString(defaultFont);
185+
monospaceFont = ProcessFontString(monospaceFont);
186+
184187
var resDic = new ResourceDictionary();
185188
if (!string.IsNullOrEmpty(defaultFont))
186189
resDic.Add("Fonts.Default", new FontFamily(defaultFont));
@@ -437,6 +440,28 @@ private static bool TryLaunchAsRebaseMessageEditor(string[] args, out int exitCo
437440
return true;
438441
}
439442

443+
private static string ProcessFontString(string input)
444+
{
445+
if (string.IsNullOrEmpty(input)) return string.Empty;
446+
447+
var parts = input.Split(',');
448+
var result = new StringBuilder();
449+
var isFirst = true;
450+
451+
foreach (var part in parts)
452+
{
453+
var trimmed = part.Trim();
454+
if (!string.IsNullOrEmpty(trimmed))
455+
{
456+
if (!isFirst) result.Append(',');
457+
result.Append(trimmed);
458+
isFirst = false;
459+
}
460+
}
461+
462+
return result.ToString();
463+
}
464+
440465
private bool TryLaunchAsCoreEditor(IClassicDesktopStyleApplicationLifetime desktop)
441466
{
442467
var args = desktop.Args;

0 commit comments

Comments
 (0)