From 17dd32456bf1f6002556c69ea9e0518e007f96e0 Mon Sep 17 00:00:00 2001 From: leo Date: Mon, 9 Sep 2024 10:01:41 +0800 Subject: [PATCH] refactor: add `Avalonia.Fonts.Inter` as built-in default font (#447) --- src/App.axaml.cs | 16 +++++++++++++--- src/Native/Linux.cs | 9 +-------- src/Resources/Themes.axaml | 2 +- src/SourceGit.csproj | 3 ++- 4 files changed, 17 insertions(+), 13 deletions(-) diff --git a/src/App.axaml.cs b/src/App.axaml.cs index cd00517f..a434fa5e 100644 --- a/src/App.axaml.cs +++ b/src/App.axaml.cs @@ -58,6 +58,7 @@ namespace SourceGit var builder = AppBuilder.Configure(); builder.UsePlatformDetect(); builder.LogToTrace(); + builder.WithInterFont(); builder.ConfigureFonts(manager => { var monospace = new EmbeddedFontCollection( @@ -219,9 +220,18 @@ namespace SourceGit resDic.Add("Fonts.Monospace", new FontFamily(monospaceFont)); } - var primary = onlyUseMonospaceFontInEditor ? defaultFont : monospaceFont; - if (!string.IsNullOrEmpty(primary)) - resDic.Add("Fonts.Primary", new FontFamily(primary)); + if (onlyUseMonospaceFontInEditor) + { + if (string.IsNullOrEmpty(defaultFont)) + resDic.Add("Fonts.Primary", new FontFamily("fonts:Inter#Inter, $Default")); + else + resDic.Add("Fonts.Primary", new FontFamily(defaultFont)); + } + else + { + if (!string.IsNullOrEmpty(monospaceFont)) + resDic.Add("Fonts.Primary", new FontFamily(monospaceFont)); + } if (resDic.Count > 0) { diff --git a/src/Native/Linux.cs b/src/Native/Linux.cs index 59193e44..ca6e7c56 100644 --- a/src/Native/Linux.cs +++ b/src/Native/Linux.cs @@ -5,7 +5,6 @@ using System.IO; using System.Runtime.Versioning; using Avalonia; -using Avalonia.Media; namespace SourceGit.Native { @@ -36,13 +35,7 @@ namespace SourceGit.Native } public void SetupApp(AppBuilder builder) - { - // Fix issue https://github.com/sourcegit-scm/sourcegit/issues/447 - builder.With(new FontManagerOptions() - { - DefaultFamilyName = "fonts:SourceGit#JetBrains Mono", - }); - + { builder.With(new X11PlatformOptions() { EnableIme = true, diff --git a/src/Resources/Themes.axaml b/src/Resources/Themes.axaml index 2714c33e..5f8dca57 100644 --- a/src/Resources/Themes.axaml +++ b/src/Resources/Themes.axaml @@ -98,7 +98,7 @@ - $Default + fonts:Inter#Inter, $Default fonts:SourceGit#JetBrains Mono fonts:SourceGit#JetBrains Mono diff --git a/src/SourceGit.csproj b/src/SourceGit.csproj index 835185ab..9154bd2a 100644 --- a/src/SourceGit.csproj +++ b/src/SourceGit.csproj @@ -40,6 +40,7 @@ + @@ -55,6 +56,6 @@ - +