11using System . Collections . Generic ;
22using System . Collections . ObjectModel ;
3+ using System . Diagnostics ;
34using System . Drawing ;
5+ using System . Globalization ;
46using System . Text . Json . Serialization ;
57using System . Windows ;
68using CommunityToolkit . Mvvm . DependencyInjection ;
1012using Flow . Launcher . Plugin ;
1113using Flow . Launcher . Plugin . SharedModels ;
1214using Flow . Launcher . ViewModel ;
15+ using SystemFonts = System . Windows . SystemFonts ;
1316
1417namespace 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 ]
0 commit comments