Browse Source

Built-in font for Desktop

https://github.com/2dust/v2rayN/issues/5970
pull/6014/head
2dust 2 weeks ago
parent
commit
689a81a985
  1. BIN
      v2rayN/v2rayN.Desktop/Assets/Fonts/NotoSansSC-Regular.ttf
  2. 19
      v2rayN/v2rayN.Desktop/Common/AppBuilderExtension.cs
  3. 4
      v2rayN/v2rayN.Desktop/Program.cs

BIN
v2rayN/v2rayN.Desktop/Assets/Fonts/NotoSansSC-Regular.ttf

Binary file not shown.

19
v2rayN/v2rayN.Desktop/Common/AppBuilderExtension.cs

@ -0,0 +1,19 @@
using Avalonia;
using Avalonia.Media;
using System.Reflection;
namespace v2rayN.Desktop.Common
{
public static class AppBuilderExtension
{
public static AppBuilder WithFontByDefault(this AppBuilder appBuilder)
{
var uri = $"avares://{Assembly.GetExecutingAssembly().GetName().Name}/Assets/Fonts#Noto Sans SC";
return appBuilder.With(new FontManagerOptions()
{
DefaultFamilyName = uri,
FontFallbacks = new[] { new FontFallback { FontFamily = new FontFamily(uri) } }
});
}
}
}

4
v2rayN/v2rayN.Desktop/Program.cs

@ -1,5 +1,6 @@
using Avalonia; using Avalonia;
using Avalonia.ReactiveUI; using Avalonia.ReactiveUI;
using v2rayN.Desktop.Common;
namespace v2rayN.Desktop; namespace v2rayN.Desktop;
@ -48,7 +49,8 @@ internal class Program
public static AppBuilder BuildAvaloniaApp() public static AppBuilder BuildAvaloniaApp()
=> AppBuilder.Configure<App>() => AppBuilder.Configure<App>()
.UsePlatformDetect() .UsePlatformDetect()
.WithInterFont() //.WithInterFont()
.WithFontByDefault()
.LogToTrace() .LogToTrace()
.UseReactiveUI(); .UseReactiveUI();
} }
Loading…
Cancel
Save