mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-21 20:24:59 +00:00
refactor: change the way loading custom fonts
This commit is contained in:
parent
636096c713
commit
f834af10a2
31 changed files with 136 additions and 183 deletions
|
@ -4,6 +4,7 @@ using Avalonia.Controls.ApplicationLifetimes;
|
|||
using Avalonia.Data.Core.Plugins;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using Avalonia.Media;
|
||||
using Avalonia.Media.Fonts;
|
||||
using Avalonia.Styling;
|
||||
using System;
|
||||
using System.IO;
|
||||
|
@ -41,15 +42,23 @@ namespace SourceGit {
|
|||
public static AppBuilder BuildAvaloniaApp() {
|
||||
var builder = AppBuilder.Configure<App>();
|
||||
builder.UsePlatformDetect();
|
||||
builder.ConfigureFonts(manager => {
|
||||
var monospace = new EmbeddedFontCollection(
|
||||
new Uri("fonts:SourceGit", UriKind.Absolute),
|
||||
new Uri("avares://SourceGit/Resources/Fonts", UriKind.Absolute));
|
||||
manager.AddFontCollection(monospace);
|
||||
});
|
||||
|
||||
if (OperatingSystem.IsWindows()) {
|
||||
builder.With(new FontManagerOptions() {
|
||||
DefaultFamilyName = "Microsoft YaHei UI",
|
||||
FontFallbacks = [
|
||||
new FontFallback { FontFamily = new FontFamily("Microsoft YaHei UI") }
|
||||
]
|
||||
});
|
||||
} else if (OperatingSystem.IsMacOS()) {
|
||||
builder.With(new FontManagerOptions() {
|
||||
DefaultFamilyName = "PingFang SC",
|
||||
FontFallbacks = [
|
||||
new FontFallback { FontFamily = new FontFamily("PingFang SC") }
|
||||
]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue