mirror of
https://github.com/2dust/v2rayN.git
synced 2026-09-22 22:38:10 +03:00
* Update AppBuilderExtension.cs * Update MainWindow.axaml.cs * Update MacAppUtils.cs * Update App.axaml.cs * Add regions for MacOS activation and app events --------- Co-authored-by: 2dust <31833384+2dust@users.noreply.github.com>
50 lines
1.4 KiB
C#
50 lines
1.4 KiB
C#
namespace v2rayN.Desktop.Common;
|
|
|
|
public static class AppBuilderExtension
|
|
{
|
|
private static readonly string DefaultFontFamilyName =
|
|
Path.Combine(Global.AvaAssets, "Fonts#Noto Sans SC");
|
|
|
|
public static AppBuilder WithFontByDefault(this AppBuilder appBuilder)
|
|
{
|
|
var fallbacks = new List<FontFallback>();
|
|
|
|
var notoSansSc = new FontFamily(DefaultFontFamilyName);
|
|
|
|
fallbacks.Add(new FontFallback
|
|
{
|
|
FontFamily = notoSansSc
|
|
});
|
|
|
|
if (OperatingSystem.IsWindows())
|
|
{
|
|
AddFontFallback(fallbacks, "Segoe UI Emoji");
|
|
AddFontFallback(fallbacks, "Segoe UI Symbol");
|
|
}
|
|
else if (OperatingSystem.IsMacOS())
|
|
{
|
|
AddFontFallback(fallbacks, "Apple Color Emoji");
|
|
AddFontFallback(fallbacks, "Apple Symbols");
|
|
}
|
|
else if (OperatingSystem.IsLinux())
|
|
{
|
|
AddFontFallback(fallbacks, "Noto Color Emoji");
|
|
AddFontFallback(fallbacks, "Noto Sans Symbols");
|
|
}
|
|
|
|
return appBuilder.With(new FontManagerOptions
|
|
{
|
|
DefaultFamilyName = DefaultFontFamilyName,
|
|
FontFallbacks = fallbacks.ToArray()
|
|
});
|
|
}
|
|
|
|
private static void AddFontFallback(List<FontFallback> fallbacks, string fontFamilyName)
|
|
{
|
|
fallbacks.Add(new FontFallback
|
|
{
|
|
FontFamily = new FontFamily(fontFamilyName)
|
|
});
|
|
}
|
|
}
|