mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-23 05:05:00 +00:00
feature: supports custom fonts (#30)
This commit is contained in:
parent
0e49ad181a
commit
83aa373079
14 changed files with 181 additions and 15 deletions
|
@ -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<string, string> ToShortSHA =
|
||||
new FuncValueConverter<string, string>(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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue