mirror of
https://github.com/2dust/v2rayN.git
synced 2025-11-29 03:02:53 +00:00
Update AppBuilderExtension.cs
This commit is contained in:
parent
d433d4a174
commit
995097801d
1 changed files with 10 additions and 11 deletions
|
|
@ -1,9 +1,9 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using Avalonia;
|
using Avalonia;
|
||||||
using Avalonia.Media;
|
using Avalonia.Media;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace v2rayN.Desktop.Common;
|
namespace v2rayN.Desktop.Common;
|
||||||
|
|
||||||
|
|
@ -23,9 +23,11 @@ public static class AppBuilderExtension
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
var fallbacks = new List<FontFallback>();
|
List<FontFallback> fallbacks = new();
|
||||||
|
|
||||||
|
string? zhFamily = RunFcMatchFamily("sans:lang=zh-cn");
|
||||||
|
string? emojiFamily = RunFcMatchFamily("emoji");
|
||||||
|
|
||||||
var zhFamily = RunFcFamily("sans:lang=zh-cn");
|
|
||||||
if (!string.IsNullOrWhiteSpace(zhFamily))
|
if (!string.IsNullOrWhiteSpace(zhFamily))
|
||||||
{
|
{
|
||||||
fallbacks.Add(new FontFallback
|
fallbacks.Add(new FontFallback
|
||||||
|
|
@ -34,7 +36,6 @@ public static class AppBuilderExtension
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
var emojiFamily = RunFcFamily("emoji");
|
|
||||||
if (!string.IsNullOrWhiteSpace(emojiFamily))
|
if (!string.IsNullOrWhiteSpace(emojiFamily))
|
||||||
{
|
{
|
||||||
fallbacks.Add(new FontFallback
|
fallbacks.Add(new FontFallback
|
||||||
|
|
@ -43,10 +44,10 @@ public static class AppBuilderExtension
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
var notoUri = Path.Combine(Global.AvaAssets, "Fonts#Noto Sans SC");
|
var localFont = Path.Combine(Global.AvaAssets, "Fonts#Noto Sans SC");
|
||||||
fallbacks.Add(new FontFallback
|
fallbacks.Add(new FontFallback
|
||||||
{
|
{
|
||||||
FontFamily = new FontFamily(notoUri)
|
FontFamily = new FontFamily(localFont)
|
||||||
});
|
});
|
||||||
|
|
||||||
return appBuilder.With(new FontManagerOptions
|
return appBuilder.With(new FontManagerOptions
|
||||||
|
|
@ -55,7 +56,7 @@ public static class AppBuilderExtension
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private static string? RunFcFamily(string pattern)
|
private static string? RunFcMatchFamily(string pattern)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
@ -64,15 +65,13 @@ public static class AppBuilderExtension
|
||||||
FileName = "/bin/bash",
|
FileName = "/bin/bash",
|
||||||
ArgumentList = { "-c", $"fc-match -f \"%{{family}}\\n\" \"{pattern}\" | head -n 1" },
|
ArgumentList = { "-c", $"fc-match -f \"%{{family}}\\n\" \"{pattern}\" | head -n 1" },
|
||||||
RedirectStandardOutput = true,
|
RedirectStandardOutput = true,
|
||||||
RedirectStandardError = true,
|
|
||||||
UseShellExecute = false
|
UseShellExecute = false
|
||||||
};
|
};
|
||||||
|
|
||||||
using var p = Process.Start(psi);
|
using var p = Process.Start(psi);
|
||||||
if (p == null)
|
if (p == null) return null;
|
||||||
return null;
|
|
||||||
|
|
||||||
var output = p.StandardOutput.ReadToEnd().Trim();
|
string output = p.StandardOutput.ReadToEnd().Trim();
|
||||||
return string.IsNullOrWhiteSpace(output) ? null : output;
|
return string.IsNullOrWhiteSpace(output) ? null : output;
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue