Skip to content

Commit 17dd324

Browse files
committed
refactor: add Avalonia.Fonts.Inter as built-in default font (sourcegit-scm#447)
1 parent 6688319 commit 17dd324

File tree

4 files changed

+17
-13
lines changed

4 files changed

+17
-13
lines changed

src/App.axaml.cs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ public static AppBuilder BuildAvaloniaApp()
5858
var builder = AppBuilder.Configure<App>();
5959
builder.UsePlatformDetect();
6060
builder.LogToTrace();
61+
builder.WithInterFont();
6162
builder.ConfigureFonts(manager =>
6263
{
6364
var monospace = new EmbeddedFontCollection(
@@ -219,9 +220,18 @@ public static void SetFonts(string defaultFont, string monospaceFont, bool onlyU
219220
resDic.Add("Fonts.Monospace", new FontFamily(monospaceFont));
220221
}
221222

222-
var primary = onlyUseMonospaceFontInEditor ? defaultFont : monospaceFont;
223-
if (!string.IsNullOrEmpty(primary))
224-
resDic.Add("Fonts.Primary", new FontFamily(primary));
223+
if (onlyUseMonospaceFontInEditor)
224+
{
225+
if (string.IsNullOrEmpty(defaultFont))
226+
resDic.Add("Fonts.Primary", new FontFamily("fonts:Inter#Inter, $Default"));
227+
else
228+
resDic.Add("Fonts.Primary", new FontFamily(defaultFont));
229+
}
230+
else
231+
{
232+
if (!string.IsNullOrEmpty(monospaceFont))
233+
resDic.Add("Fonts.Primary", new FontFamily(monospaceFont));
234+
}
225235

226236
if (resDic.Count > 0)
227237
{

src/Native/Linux.cs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
using System.Runtime.Versioning;
66

77
using Avalonia;
8-
using Avalonia.Media;
98

109
namespace SourceGit.Native
1110
{
@@ -36,13 +35,7 @@ public Linux()
3635
}
3736

3837
public void SetupApp(AppBuilder builder)
39-
{
40-
// Fix issue https://github.com/sourcegit-scm/sourcegit/issues/447
41-
builder.With(new FontManagerOptions()
42-
{
43-
DefaultFamilyName = "fonts:SourceGit#JetBrains Mono",
44-
});
45-
38+
{
4639
builder.With(new X11PlatformOptions()
4740
{
4841
EnableIme = true,

src/Resources/Themes.axaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@
9898
<SolidColorBrush x:Key="Brush.Diff.DeletedHighlight" Color="{DynamicResource Color.Diff.DeletedHighlight}"/>
9999
<SolidColorBrush x:Key="Brush.Link" Color="{DynamicResource Color.Link}"/>
100100

101-
<FontFamily x:Key="Fonts.Default">$Default</FontFamily>
101+
<FontFamily x:Key="Fonts.Default">fonts:Inter#Inter, $Default</FontFamily>
102102
<FontFamily x:Key="Fonts.Monospace">fonts:SourceGit#JetBrains Mono</FontFamily>
103103
<FontFamily x:Key="Fonts.Primary">fonts:SourceGit#JetBrains Mono</FontFamily>
104104
</ResourceDictionary>

src/SourceGit.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
<ItemGroup>
4141
<PackageReference Include="Avalonia" Version="11.1.3" />
4242
<PackageReference Include="Avalonia.Desktop" Version="11.1.3" />
43+
<PackageReference Include="Avalonia.Fonts.Inter" Version="11.1.3" />
4344
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.1.3" />
4445
<PackageReference Include="Avalonia.Diagnostics" Version="11.1.3" Condition="'$(Configuration)' == 'Debug'" />
4546
<PackageReference Include="Avalonia.AvaloniaEdit" Version="11.1.0" />
@@ -55,6 +56,6 @@
5556
</ItemGroup>
5657

5758
<ItemGroup Condition="$([MSBuild]::IsOSPlatform('OSX'))">
58-
<LinkerArg Include="-mmacosx-version-min=11.0" Condition="'$(Configuration)' == 'Release'"/>
59+
<LinkerArg Include="-mmacosx-version-min=11.0" Condition="'$(Configuration)' == 'Release'" />
5960
</ItemGroup>
6061
</Project>

0 commit comments

Comments
 (0)