You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

47 lines
1.2 KiB

2 months ago
using Avalonia;
using Avalonia.Media;
using Avalonia.ReactiveUI;
using System;
using System.Runtime.InteropServices;
namespace MyAvaloniaApp;
class Program
{
[STAThread]
public static void Main(string[] args)
{
// 简化的启动方式,HostBuilder 配置已集成到 App 中
BuildAvaloniaApp().StartWithClassicDesktopLifetime(args);
}
/// <summary>
/// 构建 Avalonia 应用程序
/// </summary>
/// <returns>AppBuilder</returns>
public static AppBuilder BuildAvaloniaApp()
{
var builder = AppBuilder.Configure<App>()
.UsePlatformDetect()
.LogToTrace()
.UseReactiveUI();
// Linux字体配置
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
// 在Linux上使用系统字体而不是Inter字体
builder = builder.With(new FontManagerOptions
{
DefaultFamilyName = "DejaVu Sans, Liberation Sans, Arial, sans-serif"
});
}
else
{
// Windows和macOS使用Inter字体
builder = builder.WithInterFont();
}
return builder;
}
}