This commit is contained in:
JieXu 2025-11-18 23:46:40 +08:00 committed by GitHub
parent f57cc41058
commit ece4b6af05
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,4 +1,3 @@
using System.Collections.Generic;
using System.IO; using System.IO;
using Avalonia; using Avalonia;
using Avalonia.Media; using Avalonia.Media;
@ -9,22 +8,22 @@ public static class AppBuilderExtension
{ {
public static AppBuilder WithFontByDefault(this AppBuilder appBuilder) public static AppBuilder WithFontByDefault(this AppBuilder appBuilder)
{ {
var fallbacks = new List<FontFallback>();
var notoSansSc = new FontFamily(Path.Combine(Global.AvaAssets, "Fonts#Noto Sans SC")); var notoSansSc = new FontFamily(Path.Combine(Global.AvaAssets, "Fonts#Noto Sans SC"));
fallbacks.Add(new FontFallback { FontFamily = notoSansSc });
if (OperatingSystem.IsLinux()) var fallbacks = new[]
{ {
fallbacks.Add(new FontFallback new FontFallback { FontFamily = notoSansSc },
{
FontFamily = new FontFamily("Noto Color Emoji") 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 return appBuilder.With(new FontManagerOptions
{ {
FontFallbacks = fallbacks.ToArray() FontFallbacks = validFallbacks
}); });
} }
} }