feature: supports custom fonts (#30)

This commit is contained in:
leo 2024-03-21 18:02:06 +08:00
parent 0e49ad181a
commit 83aa373079
14 changed files with 181 additions and 15 deletions

View file

@ -2256,6 +2256,15 @@ namespace SourceGit.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to Default FontFamily.
/// </summary>
public static string Text_Preference_General_DefaultFont {
get {
return ResourceManager.GetString("Text.Preference.General.DefaultFont", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Language.
/// </summary>
@ -2274,6 +2283,15 @@ namespace SourceGit.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to Monospace FontFamily.
/// </summary>
public static string Text_Preference_General_MonospaceFont {
get {
return ResourceManager.GetString("Text.Preference.General.MonospaceFont", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Restore windows.
/// </summary>

View file

@ -1290,4 +1290,10 @@
<data name="Text.Diff.SyntaxHighlight" xml:space="preserve">
<value>Syntax Highlighting</value>
</data>
<data name="Text.Preference.General.DefaultFont" xml:space="preserve">
<value>Default FontFamily</value>
</data>
<data name="Text.Preference.General.MonospaceFont" xml:space="preserve">
<value>Monospace FontFamily</value>
</data>
</root>

View file

@ -1290,4 +1290,10 @@
<data name="Text.Diff.SyntaxHighlight" xml:space="preserve">
<value>Syntax Highlighting</value>
</data>
<data name="Text.Preference.General.DefaultFont" xml:space="preserve">
<value>Default FontFamily</value>
</data>
<data name="Text.Preference.General.MonospaceFont" xml:space="preserve">
<value>Monospace FontFamily</value>
</data>
</root>

View file

@ -1290,4 +1290,10 @@
<data name="Text.Diff.SyntaxHighlight" xml:space="preserve">
<value>语法高亮</value>
</data>
<data name="Text.Preference.General.DefaultFont" xml:space="preserve">
<value>缺省字体</value>
</data>
<data name="Text.Preference.General.MonospaceFont" xml:space="preserve">
<value>等宽字体</value>
</data>
</root>

View file

@ -1,5 +1,7 @@
<Styles xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:vm="using:SourceGit.ViewModels"
xmlns:c="using:SourceGit.Converters"
xmlns:ae="using:AvaloniaEdit"
xmlns:aes="using:AvaloniaEdit.Search">
<Design.PreviewWith>
@ -13,6 +15,10 @@
</Style.Resources>
</Style>
<Style Selector="ContentPresenter">
<Setter Property="FontFamily" Value="{Binding Source={x:Static vm:Preference.Instance}, Path=DefaultFont, Converter={x:Static c:StringConverters.ToFontFamily}}"/>
</Style>
<Style Selector="Path">
<Setter Property="Fill" Value="{DynamicResource Brush.FG1}"/>
<Setter Property="Stretch" Value="Uniform"/>
@ -64,7 +70,7 @@
<Setter Property="FontStyle" Value="Italic"/>
</Style>
<Style Selector="TextBlock.monospace">
<Setter Property="FontFamily" Value="fonts:SourceGit#JetBrains Mono"/>
<Setter Property="FontFamily" Value="{Binding Source={x:Static vm:Preference.Instance}, Path=MonospaceFont, Converter={x:Static c:StringConverters.ToFontFamily}}"/>
</Style>
<Style Selector="TextBlock.group_header_label">
<Setter Property="Foreground" Value="{DynamicResource Brush.FG2}"/>