diff --git a/src/SourceGit/Converters/StringConverters.cs b/src/SourceGit/Converters/StringConverters.cs index 3b227316..ea1ddd42 100644 --- a/src/SourceGit/Converters/StringConverters.cs +++ b/src/SourceGit/Converters/StringConverters.cs @@ -2,6 +2,7 @@ using System.Globalization; using Avalonia.Data.Converters; +using Avalonia.Media; using Avalonia.Styling; namespace SourceGit.Converters @@ -69,5 +70,29 @@ namespace SourceGit.Converters public static FuncValueConverter ToShortSHA = new FuncValueConverter(v => v.Length > 10 ? v.Substring(0, 10) : v); + + public class ToFontFamilyConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + var name = value as string; + if (string.IsNullOrEmpty(name)) + { + return FontManager.Current.DefaultFontFamily; + } + else + { + return new FontFamily(name); + } + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + var fontFamily = value as FontFamily; + return fontFamily == null ? string.Empty : fontFamily.ToString(); + } + } + + public static ToFontFamilyConverter ToFontFamily = new ToFontFamilyConverter(); } -} \ No newline at end of file +} diff --git a/src/SourceGit/Resources/Locales.Designer.cs b/src/SourceGit/Resources/Locales.Designer.cs index da001ddf..ca6b1087 100644 --- a/src/SourceGit/Resources/Locales.Designer.cs +++ b/src/SourceGit/Resources/Locales.Designer.cs @@ -2256,6 +2256,15 @@ namespace SourceGit.Resources { } } + /// + /// Looks up a localized string similar to Default FontFamily. + /// + public static string Text_Preference_General_DefaultFont { + get { + return ResourceManager.GetString("Text.Preference.General.DefaultFont", resourceCulture); + } + } + /// /// Looks up a localized string similar to Language. /// @@ -2274,6 +2283,15 @@ namespace SourceGit.Resources { } } + /// + /// Looks up a localized string similar to Monospace FontFamily. + /// + public static string Text_Preference_General_MonospaceFont { + get { + return ResourceManager.GetString("Text.Preference.General.MonospaceFont", resourceCulture); + } + } + /// /// Looks up a localized string similar to Restore windows. /// diff --git a/src/SourceGit/Resources/Locales.en.resx b/src/SourceGit/Resources/Locales.en.resx index d1ddab22..3cf630ae 100644 --- a/src/SourceGit/Resources/Locales.en.resx +++ b/src/SourceGit/Resources/Locales.en.resx @@ -1290,4 +1290,10 @@ Syntax Highlighting + + Default FontFamily + + + Monospace FontFamily + \ No newline at end of file diff --git a/src/SourceGit/Resources/Locales.resx b/src/SourceGit/Resources/Locales.resx index 3eaa6b39..bedb8136 100644 --- a/src/SourceGit/Resources/Locales.resx +++ b/src/SourceGit/Resources/Locales.resx @@ -1290,4 +1290,10 @@ Syntax Highlighting + + Default FontFamily + + + Monospace FontFamily + \ No newline at end of file diff --git a/src/SourceGit/Resources/Locales.zh.resx b/src/SourceGit/Resources/Locales.zh.resx index 75cdd061..50ae5094 100644 --- a/src/SourceGit/Resources/Locales.zh.resx +++ b/src/SourceGit/Resources/Locales.zh.resx @@ -1290,4 +1290,10 @@ 语法高亮 + + 缺省字体 + + + 等宽字体 + \ No newline at end of file diff --git a/src/SourceGit/Resources/Styles.axaml b/src/SourceGit/Resources/Styles.axaml index 9e6b3099..333fc136 100644 --- a/src/SourceGit/Resources/Styles.axaml +++ b/src/SourceGit/Resources/Styles.axaml @@ -1,5 +1,7 @@ @@ -13,6 +15,10 @@ + +