fix: endless loop when character missing both in current active font and the default font and the fallback font is same with the default.

This commit is contained in:
leo 2024-03-21 20:55:08 +08:00
parent 8f3f011d81
commit 98a46f8211
6 changed files with 15 additions and 18 deletions

View file

@ -175,8 +175,15 @@ namespace SourceGit
{ {
AvaloniaXamlLoader.Load(this); AvaloniaXamlLoader.Load(this);
SetLocale(ViewModels.Preference.Instance.Locale); var pref = ViewModels.Preference.Instance;
SetTheme(ViewModels.Preference.Instance.Theme);
SetLocale(pref.Locale);
SetTheme(pref.Theme);
if (string.IsNullOrEmpty(pref.DefaultFont))
{
pref.DefaultFont = FontManager.Current.DefaultFontFamily.ToString();
}
} }
public override void OnFrameworkInitializationCompleted() public override void OnFrameworkInitializationCompleted()

View file

@ -4,6 +4,7 @@ using System.Runtime.Versioning;
using Avalonia; using Avalonia;
using Avalonia.Dialogs; using Avalonia.Dialogs;
using Avalonia.Media;
namespace SourceGit.Native namespace SourceGit.Native
{ {
@ -12,9 +13,11 @@ namespace SourceGit.Native
{ {
public void SetupApp(AppBuilder builder) public void SetupApp(AppBuilder builder)
{ {
#if USE_FONT_INTER builder.With(new FontManagerOptions()
builder.WithInterFont(); {
#endif DefaultFamilyName = "fonts:SourceGit#JetBrains Mono",
});
// Free-desktop file picker has an extra black background panel. // Free-desktop file picker has an extra black background panel.
builder.UseManagedSystemDialogs(); builder.UseManagedSystemDialogs();
} }

View file

@ -16,9 +16,6 @@ namespace SourceGit.Native
builder.With(new FontManagerOptions() builder.With(new FontManagerOptions()
{ {
DefaultFamilyName = "PingFang SC", DefaultFamilyName = "PingFang SC",
FontFallbacks = [
new FontFallback { FontFamily = new FontFamily("PingFang SC") }
]
}); });
} }

View file

@ -21,9 +21,6 @@ namespace SourceGit.Native
builder.With(new FontManagerOptions() builder.With(new FontManagerOptions()
{ {
DefaultFamilyName = "Microsoft YaHei UI", DefaultFamilyName = "Microsoft YaHei UI",
FontFallbacks = [
new FontFallback { FontFamily = new FontFamily("Microsoft YaHei UI") }
]
}); });
} }

View file

@ -20,10 +20,6 @@
<RepositoryType>Public</RepositoryType> <RepositoryType>Public</RepositoryType>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="$([MSBuild]::IsOSPlatform('Linux'))">
<DefineConstants>$(DefineConstants);USE_FONT_INTER</DefineConstants>
</PropertyGroup>
<ItemGroup> <ItemGroup>
<AvaloniaResource Include="App.ico" /> <AvaloniaResource Include="App.ico" />
<AvaloniaResource Include="Resources/Fonts/*" /> <AvaloniaResource Include="Resources/Fonts/*" />
@ -47,7 +43,6 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="Avalonia" Version="11.0.10" /> <PackageReference Include="Avalonia" Version="11.0.10" />
<PackageReference Include="Avalonia.Fonts.Inter" Version="11.0.10" Condition="$([MSBuild]::IsOSPlatform('Linux'))" />
<PackageReference Include="Avalonia.Desktop" Version="11.0.10" /> <PackageReference Include="Avalonia.Desktop" Version="11.0.10" />
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.0.10" /> <PackageReference Include="Avalonia.Themes.Fluent" Version="11.0.10" />
<PackageReference Include="Avalonia.Controls.DataGrid" Version="11.0.10" /> <PackageReference Include="Avalonia.Controls.DataGrid" Version="11.0.10" />

View file

@ -72,8 +72,6 @@ namespace SourceGit.Views
InstalledFonts = new AvaloniaList<FontFamily>(); InstalledFonts = new AvaloniaList<FontFamily>();
InstalledFonts.Add(new FontFamily("fonts:SourceGit#JetBrains Mono")); InstalledFonts.Add(new FontFamily("fonts:SourceGit#JetBrains Mono"));
InstalledFonts.AddRange(FontManager.Current.SystemFonts); InstalledFonts.AddRange(FontManager.Current.SystemFonts);
InstalledFonts.Remove(FontManager.Current.DefaultFontFamily);
InstalledFonts.Add(FontManager.Current.DefaultFontFamily);
InstalledMonospaceFonts = new AvaloniaList<FontFamily>(); InstalledMonospaceFonts = new AvaloniaList<FontFamily>();
InstalledMonospaceFonts.Add(new FontFamily("fonts:SourceGit#JetBrains Mono")); InstalledMonospaceFonts.Add(new FontFamily("fonts:SourceGit#JetBrains Mono"));