fix: failed get default font on some Linux distro (#447)

This commit is contained in:
leo 2024-09-08 18:29:05 +08:00
parent 2a59cdbe92
commit 6688319714
No known key found for this signature in database
3 changed files with 10 additions and 3 deletions

View file

@ -75,7 +75,7 @@ namespace SourceGit
AvaloniaXamlLoader.Load(this); AvaloniaXamlLoader.Load(this);
var pref = ViewModels.Preference.Instance; var pref = ViewModels.Preference.Instance;
pref.PropertyChanged += (_1, _2) => pref.Save(); pref.PropertyChanged += (_, _) => pref.Save();
SetLocale(pref.Locale); SetLocale(pref.Locale);
SetTheme(pref.Theme, pref.ThemeOverrides); SetTheme(pref.Theme, pref.ThemeOverrides);

View file

@ -5,6 +5,7 @@ using System.IO;
using System.Runtime.Versioning; using System.Runtime.Versioning;
using Avalonia; using Avalonia;
using Avalonia.Media;
namespace SourceGit.Native namespace SourceGit.Native
{ {
@ -36,6 +37,12 @@ namespace SourceGit.Native
public void SetupApp(AppBuilder builder) 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() builder.With(new X11PlatformOptions()
{ {
EnableIme = true, EnableIme = true,

View file

@ -99,6 +99,6 @@
<SolidColorBrush x:Key="Brush.Link" Color="{DynamicResource Color.Link}"/> <SolidColorBrush x:Key="Brush.Link" Color="{DynamicResource Color.Link}"/>
<FontFamily x:Key="Fonts.Default">$Default</FontFamily> <FontFamily x:Key="Fonts.Default">$Default</FontFamily>
<FontFamily x:Key="Fonts.Monospace">fonts:SourceGit#JetBrains Mono,$Default</FontFamily> <FontFamily x:Key="Fonts.Monospace">fonts:SourceGit#JetBrains Mono</FontFamily>
<FontFamily x:Key="Fonts.Primary">fonts:SourceGit#JetBrains Mono,$Default</FontFamily> <FontFamily x:Key="Fonts.Primary">fonts:SourceGit#JetBrains Mono</FontFamily>
</ResourceDictionary> </ResourceDictionary>