1
1
using System . Collections . Generic ;
2
2
using System . Collections . ObjectModel ;
3
+ using System . Diagnostics ;
3
4
using System . Drawing ;
5
+ using System . Globalization ;
4
6
using System . Text . Json . Serialization ;
5
7
using System . Windows ;
6
8
using CommunityToolkit . Mvvm . DependencyInjection ;
10
12
using Flow . Launcher . Plugin ;
11
13
using Flow . Launcher . Plugin . SharedModels ;
12
14
using Flow . Launcher . ViewModel ;
15
+ using SystemFonts = System . Windows . SystemFonts ;
13
16
14
17
namespace Flow . Launcher . Infrastructure . UserSettings
15
18
{
@@ -34,6 +37,24 @@ public void Save()
34
37
}
35
38
36
39
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
+
37
58
private string _theme = Constant . DefaultTheme ;
38
59
public string Hotkey { get ; set ; } = $ "{ KeyConstant . Alt } + { KeyConstant . Space } ";
39
60
public string OpenResultModifiers { get ; set ; } = KeyConstant . Alt ;
@@ -85,15 +106,15 @@ public string Theme
85
106
public double QueryBoxFontSize { get ; set ; } = 18 ;
86
107
public double ResultItemFontSize { get ; set ; } = 16 ;
87
108
public double ResultSubItemFontSize { get ; set ; } = 13 ;
88
- public string QueryBoxFont { get ; set ; } = FontFamily . GenericSansSerif . Name ;
109
+ public string QueryBoxFont { get ; set ; } = GetSystemDefaultFont ( ) ;
89
110
public string QueryBoxFontStyle { get ; set ; }
90
111
public string QueryBoxFontWeight { get ; set ; }
91
112
public string QueryBoxFontStretch { get ; set ; }
92
- public string ResultFont { get ; set ; } = FontFamily . GenericSansSerif . Name ;
113
+ public string ResultFont { get ; set ; } = GetSystemDefaultFont ( ) ;
93
114
public string ResultFontStyle { get ; set ; }
94
115
public string ResultFontWeight { get ; set ; }
95
116
public string ResultFontStretch { get ; set ; }
96
- public string ResultSubFont { get ; set ; } = FontFamily . GenericSansSerif . Name ;
117
+ public string ResultSubFont { get ; set ; } = GetSystemDefaultFont ( ) ;
97
118
public string ResultSubFontStyle { get ; set ; }
98
119
public string ResultSubFontWeight { get ; set ; }
99
120
public string ResultSubFontStretch { get ; set ; }
@@ -140,7 +161,6 @@ public string PlaceholderText
140
161
}
141
162
}
142
163
}
143
-
144
164
public int CustomExplorerIndex { get ; set ; } = 0 ;
145
165
146
166
[ JsonIgnore ]
0 commit comments