Skip to content

Commit 13aa475

Browse files
committed
- Change default font logic
1 parent 1b8336b commit 13aa475

File tree

2 files changed

+27
-5
lines changed

2 files changed

+27
-5
lines changed

Flow.Launcher.Infrastructure/UserSettings/Settings.cs

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
using System.Collections.Generic;
22
using System.Collections.ObjectModel;
3+
using System.Diagnostics;
34
using System.Drawing;
5+
using System.Globalization;
46
using System.Text.Json.Serialization;
57
using System.Windows;
68
using CommunityToolkit.Mvvm.DependencyInjection;
@@ -10,6 +12,7 @@
1012
using Flow.Launcher.Plugin;
1113
using Flow.Launcher.Plugin.SharedModels;
1214
using Flow.Launcher.ViewModel;
15+
using SystemFonts = System.Windows.SystemFonts;
1316

1417
namespace Flow.Launcher.Infrastructure.UserSettings
1518
{
@@ -34,6 +37,24 @@ public void Save()
3437
}
3538

3639
private string language = Constant.SystemLanguageCode;
40+
public static string GetSystemDefaultFont()
41+
{
42+
try
43+
{
44+
var font = SystemFonts.MessageFontFamily;
45+
46+
if (font.FamilyNames.TryGetValue(System.Windows.Markup.XmlLanguage.GetLanguage("en-US"), out var englishName))
47+
{
48+
return englishName;
49+
}
50+
return font.Source ?? "Segoe UI";
51+
}
52+
catch
53+
{
54+
return "Segoe UI";
55+
}
56+
}
57+
3758
private string _theme = Constant.DefaultTheme;
3859
public string Hotkey { get; set; } = $"{KeyConstant.Alt} + {KeyConstant.Space}";
3960
public string OpenResultModifiers { get; set; } = KeyConstant.Alt;
@@ -85,15 +106,15 @@ public string Theme
85106
public double QueryBoxFontSize { get; set; } = 18;
86107
public double ResultItemFontSize { get; set; } = 16;
87108
public double ResultSubItemFontSize { get; set; } = 13;
88-
public string QueryBoxFont { get; set; } = FontFamily.GenericSansSerif.Name;
109+
public string QueryBoxFont { get; set; } = GetSystemDefaultFont();
89110
public string QueryBoxFontStyle { get; set; }
90111
public string QueryBoxFontWeight { get; set; }
91112
public string QueryBoxFontStretch { get; set; }
92-
public string ResultFont { get; set; } = FontFamily.GenericSansSerif.Name;
113+
public string ResultFont { get; set; } = GetSystemDefaultFont();
93114
public string ResultFontStyle { get; set; }
94115
public string ResultFontWeight { get; set; }
95116
public string ResultFontStretch { get; set; }
96-
public string ResultSubFont { get; set; } = FontFamily.GenericSansSerif.Name;
117+
public string ResultSubFont { get; set; } = GetSystemDefaultFont();
97118
public string ResultSubFontStyle { get; set; }
98119
public string ResultSubFontWeight { get; set; }
99120
public string ResultSubFontStretch { get; set; }
@@ -140,7 +161,6 @@ public string PlaceholderText
140161
}
141162
}
142163
}
143-
144164
public int CustomExplorerIndex { get; set; } = 0;
145165

146166
[JsonIgnore]

Flow.Launcher/SettingPages/ViewModels/SettingsPaneThemeViewModel.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using System.Collections.Generic;
3+
using System.Diagnostics;
34
using System.Windows;
45
using System.Globalization;
56
using System.IO;
@@ -21,7 +22,7 @@ namespace Flow.Launcher.SettingPages.ViewModels;
2122

2223
public partial class SettingsPaneThemeViewModel : BaseModel
2324
{
24-
private const string DefaultFont = "Segoe UI";
25+
private string DefaultFont = Settings.GetSystemDefaultFont();
2526
public string BackdropSubText => !Win32Helper.IsBackdropSupported() ? App.API.GetTranslation("BackdropTypeDisabledToolTip") : "";
2627
public Settings Settings { get; }
2728
private readonly Theme _theme = Ioc.Default.GetRequiredService<Theme>();
@@ -507,4 +508,5 @@ public void Reset()
507508
WindowHeightSize = 42;
508509
ItemHeightSize = 58;
509510
}
511+
510512
}

0 commit comments

Comments
 (0)