From 2697cddfa622692e0b665161d75afa25fd2b0ab4 Mon Sep 17 00:00:00 2001 From: JieXu Date: Tue, 18 Nov 2025 20:58:52 +0800 Subject: [PATCH] Update AppBuilderExtension.cs --- .../Common/AppBuilderExtension.cs | 37 ++++++++++++------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/v2rayN/v2rayN.Desktop/Common/AppBuilderExtension.cs b/v2rayN/v2rayN.Desktop/Common/AppBuilderExtension.cs index 1b0bd8fa..ba59adbb 100644 --- a/v2rayN/v2rayN.Desktop/Common/AppBuilderExtension.cs +++ b/v2rayN/v2rayN.Desktop/Common/AppBuilderExtension.cs @@ -1,20 +1,29 @@ -public static AppBuilder WithFontByDefault(this AppBuilder appBuilder) +using System.IO; +using Avalonia; +using Avalonia.Media; + +namespace v2rayN.Desktop.Common; + +public static class AppBuilderExtension { - var fallbacks = new List(); - - var notoSansSc = new FontFamily(Path.Combine(Global.AvaAssets, "Fonts#Noto Sans SC")); - fallbacks.Add(new FontFallback { FontFamily = notoSansSc }); - - if (OperatingSystem.IsLinux()) + public static AppBuilder WithFontByDefault(this AppBuilder appBuilder) { - fallbacks.Add(new FontFallback + var notoSansSc = new FontFamily(Path.Combine(Global.AvaAssets, "Fonts#Noto Sans SC")); + + var fallbacks = new[] { - FontFamily = new FontFamily("Noto Color Emoji") + new FontFallback { FontFamily = notoSansSc }, + + OperatingSystem.IsLinux() + ? new FontFallback { FontFamily = new FontFamily("Noto Color Emoji") } + : null + }; + + var validFallbacks = fallbacks.Where(f => f is not null).ToArray()!; + + return appBuilder.With(new FontManagerOptions + { + FontFallbacks = validFallbacks }); } - - return appBuilder.With(new FontManagerOptions - { - FontFallbacks = fallbacks.ToArray() - }); }