Update AppBuilderExtension.cs

This commit is contained in:
JieXu 2025-11-17 20:35:44 +08:00 committed by GitHub
parent faac943049
commit d433d4a174
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -2,6 +2,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.IO; using System.IO;
using Avalonia;
using Avalonia.Media; using Avalonia.Media;
namespace v2rayN.Desktop.Common; namespace v2rayN.Desktop.Common;
@ -24,7 +25,7 @@ public static class AppBuilderExtension
var fallbacks = new List<FontFallback>(); var fallbacks = new List<FontFallback>();
string? zhFamily = RunFcMatchFamily("sans:lang=zh-cn"); var zhFamily = RunFcFamily("sans:lang=zh-cn");
if (!string.IsNullOrWhiteSpace(zhFamily)) if (!string.IsNullOrWhiteSpace(zhFamily))
{ {
fallbacks.Add(new FontFallback fallbacks.Add(new FontFallback
@ -33,7 +34,7 @@ public static class AppBuilderExtension
}); });
} }
string? emojiFamily = RunFcMatchFamily("emoji"); var emojiFamily = RunFcFamily("emoji");
if (!string.IsNullOrWhiteSpace(emojiFamily)) if (!string.IsNullOrWhiteSpace(emojiFamily))
{ {
fallbacks.Add(new FontFallback fallbacks.Add(new FontFallback
@ -54,20 +55,16 @@ public static class AppBuilderExtension
}); });
} }
private static string? RunFcMatchFamily(string pattern) private static string? RunFcFamily(string pattern)
{ {
try try
{ {
var psi = new ProcessStartInfo var psi = new ProcessStartInfo
{ {
FileName = "/bin/bash", FileName = "/bin/bash",
ArgumentList = ArgumentList = { "-c", $"fc-match -f \"%{{family}}\\n\" \"{pattern}\" | head -n 1" },
{
"-c",
$"fc-match -f \"%{{family[0]}}\\n\" \"{pattern}\" | head -n 1"
},
RedirectStandardOutput = true, RedirectStandardOutput = true,
RedirectStandardError = false, RedirectStandardError = true,
UseShellExecute = false UseShellExecute = false
}; };