mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-22 12:45:00 +00:00
feature<Preference>: add custom font settings
This commit is contained in:
parent
0643f5803c
commit
0c7f217106
29 changed files with 202 additions and 70 deletions
42
src/Models/InstalledFonts.cs
Normal file
42
src/Models/InstalledFonts.cs
Normal file
|
@ -0,0 +1,42 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Windows.Markup;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace SourceGit.Models {
|
||||
public class InstalledFont {
|
||||
public string Name { get; set; }
|
||||
public int FamilyIndex { get; set; }
|
||||
|
||||
public static List<InstalledFont> GetFonts {
|
||||
get {
|
||||
var fontList = new List<InstalledFont>();
|
||||
|
||||
var fontCollection = Fonts.SystemFontFamilies;
|
||||
var familyCount = fontCollection.Count;
|
||||
|
||||
for (int i = 0; i < familyCount; i++) {
|
||||
var fontFamily = fontCollection.ElementAt(i);
|
||||
var familyNames = fontFamily.FamilyNames;
|
||||
|
||||
if (!familyNames.TryGetValue(XmlLanguage.GetLanguage(CultureInfo.CurrentCulture.Name), out var name)) {
|
||||
if (!familyNames.TryGetValue(XmlLanguage.GetLanguage("en-us"), out name)) {
|
||||
name = familyNames.FirstOrDefault().Value;
|
||||
}
|
||||
}
|
||||
|
||||
fontList.Add(new InstalledFont() {
|
||||
Name = name,
|
||||
FamilyIndex = i
|
||||
});
|
||||
}
|
||||
|
||||
fontList.Sort((p, n) => string.Compare(p.Name, n.Name, StringComparison.Ordinal));
|
||||
|
||||
return fontList;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -27,6 +27,27 @@ namespace SourceGit.Models {
|
|||
/// </summary>
|
||||
public string Locale { get; set; } = "en_US";
|
||||
|
||||
/// <summary>
|
||||
/// 系统字体
|
||||
/// </summary>
|
||||
public string FontFamilyWindowSetting { get; set; } = "Microsoft YaHei UI";
|
||||
|
||||
[JsonIgnore]
|
||||
public string FontFamilyWindow {
|
||||
get => FontFamilyWindowSetting + ",Microsoft YaHei UI";
|
||||
set => FontFamilyWindowSetting = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 用户字体(提交列表、提交日志、差异比较等)
|
||||
/// </summary>
|
||||
public string FontFamilyContentSetting { get; set; } = "Consolas";
|
||||
|
||||
[JsonIgnore] public string FontFamilyContent {
|
||||
get => FontFamilyContentSetting + ",Microsoft YaHei UI";
|
||||
set => FontFamilyContentSetting = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 头像服务器
|
||||
/// </summary>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue