Update AppBuilderExtension.cs

This commit is contained in:
JieXu 2025-11-18 22:06:28 +08:00 committed by GitHub
parent 2697cddfa6
commit f57cc41058
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

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