mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-06-04 18:44:59 +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
|
@ -1,15 +1,30 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Input;
|
||||
using Avalonia.Interactivity;
|
||||
using Avalonia.Media;
|
||||
using Avalonia.Platform.Storage;
|
||||
|
||||
namespace SourceGit.Views
|
||||
{
|
||||
public partial class Preference : Window
|
||||
{
|
||||
public List<FontFamily> InstalledFonts
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
public List<FontFamily> InstalledMonospaceFonts
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
public string DefaultUser
|
||||
{
|
||||
get;
|
||||
|
@ -51,6 +66,37 @@ namespace SourceGit.Views
|
|||
var pref = ViewModels.Preference.Instance;
|
||||
DataContext = pref;
|
||||
|
||||
InstalledFonts = new List<FontFamily>();
|
||||
InstalledFonts.Add(new FontFamily("fonts:SourceGit#JetBrains Mono"));
|
||||
InstalledFonts.AddRange(FontManager.Current.SystemFonts);
|
||||
InstalledFonts.Remove(FontManager.Current.DefaultFontFamily);
|
||||
InstalledFonts.Add(FontManager.Current.DefaultFontFamily);
|
||||
|
||||
InstalledMonospaceFonts = new List<FontFamily>();
|
||||
InstalledMonospaceFonts.Add(new FontFamily("fonts:SourceGit#JetBrains Mono"));
|
||||
foreach (var font in FontManager.Current.SystemFonts)
|
||||
{
|
||||
var typeface = new Typeface(font);
|
||||
var testI = new FormattedText(
|
||||
"i",
|
||||
CultureInfo.CurrentCulture,
|
||||
FlowDirection.LeftToRight,
|
||||
typeface,
|
||||
12,
|
||||
Brushes.White);
|
||||
var testW = new FormattedText(
|
||||
"W",
|
||||
CultureInfo.CurrentCulture,
|
||||
FlowDirection.LeftToRight,
|
||||
typeface,
|
||||
12,
|
||||
Brushes.White);
|
||||
if (testI.Width == testW.Width)
|
||||
{
|
||||
InstalledMonospaceFonts.Add(font);
|
||||
}
|
||||
}
|
||||
|
||||
var ver = string.Empty;
|
||||
if (pref.IsGitConfigured)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue