From f834af10a284b632307bb7292ef01a1a5575a527 Mon Sep 17 00:00:00 2001 From: leo Date: Tue, 5 Mar 2024 15:53:38 +0800 Subject: [PATCH] refactor: change the way loading custom fonts --- src/App.axaml | 1 - src/App.axaml.cs | 9 +++++++++ src/Resources/Fonts.axaml | 6 ------ src/Resources/Styles.axaml | 10 ++------- src/Views/Archive.axaml | 2 +- src/Views/Avatar.cs | 11 +--------- src/Views/Blame.axaml | 2 +- src/Views/ChangeStatusIcon.cs | 12 ++--------- src/Views/CherryPick.axaml | 2 +- src/Views/CommitBaseInfo.axaml | 23 +++++++-------------- src/Views/CommitChanges.axaml | 14 ++++++------- src/Views/CommitDetail.axaml | 4 ++-- src/Views/CreateBranch.axaml | 2 +- src/Views/CreateTag.axaml | 2 +- src/Views/DiffView.axaml | 36 ++++++++++++++++----------------- src/Views/FileHistories.axaml | 14 +++++-------- src/Views/Histories.axaml | 17 ++++++++-------- src/Views/Hotkeys.axaml | 18 ++++++++--------- src/Views/Launcher.axaml | 4 ++-- src/Views/Rebase.axaml | 2 +- src/Views/Repository.axaml | 9 ++++----- src/Views/Revert.axaml | 2 +- src/Views/RevisionCompare.axaml | 36 ++++++++++++++++----------------- src/Views/RevisionFiles.axaml | 6 +++--- src/Views/StashesPage.axaml | 10 ++++----- src/Views/Statistics.axaml | 1 - src/Views/Statistics.axaml.cs | 10 +-------- src/Views/TextDiffView.axaml | 6 +++--- src/Views/TextDiffView.axaml.cs | 16 +++++++-------- src/Views/Welcome.axaml | 4 ++-- src/Views/WorkingCopy.axaml | 28 ++++++++++++------------- 31 files changed, 136 insertions(+), 183 deletions(-) delete mode 100644 src/Resources/Fonts.axaml diff --git a/src/App.axaml b/src/App.axaml index b9124294..83cbf2cb 100644 --- a/src/App.axaml +++ b/src/App.axaml @@ -6,7 +6,6 @@ - diff --git a/src/App.axaml.cs b/src/App.axaml.cs index 96276fb9..98425fc3 100644 --- a/src/App.axaml.cs +++ b/src/App.axaml.cs @@ -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(); 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") } ] diff --git a/src/Resources/Fonts.axaml b/src/Resources/Fonts.axaml deleted file mode 100644 index 29681db5..00000000 --- a/src/Resources/Fonts.axaml +++ /dev/null @@ -1,6 +0,0 @@ - - avares://SourceGit/Resources/Fonts/JetBrainsMono-Regular.ttf#JetBrains Mono - avares://SourceGit/Resources/Fonts/JetBrainsMono-Bold.ttf#JetBrains Mono - avares://SourceGit/Resources/Fonts/JetBrainsMono-Italic.ttf#JetBrains Mono - diff --git a/src/Resources/Styles.axaml b/src/Resources/Styles.axaml index c5ed0ebf..2ce2628b 100644 --- a/src/Resources/Styles.axaml +++ b/src/Resources/Styles.axaml @@ -68,13 +68,7 @@ - -