diff --git a/Flow.Launcher.Infrastructure/UserSettings/Settings.cs b/Flow.Launcher.Infrastructure/UserSettings/Settings.cs index 0bd1a809b..d91574bdc 100644 --- a/Flow.Launcher.Infrastructure/UserSettings/Settings.cs +++ b/Flow.Launcher.Infrastructure/UserSettings/Settings.cs @@ -65,19 +65,21 @@ namespace Flow.Launcher.Infrastructure.UserSettings { "pt", "Noto Sans" } }; - public static string GetSystemDefaultFont() + public static string GetSystemDefaultFont(bool? useNoto = null) { try { - var culture = CultureInfo.CurrentCulture; - var language = culture.Name; // e.g., "zh-TW" - var langPrefix = language.Split('-')[0]; // e.g., "zh" - - // First, try to find by full name, and if not found, fallback to prefix - if (TryGetNotoFont(language, out var notoFont) || TryGetNotoFont(langPrefix, out notoFont)) + if (useNoto != false) { - if (Fonts.SystemFontFamilies.Any(f => f.Source.Equals(notoFont))) - return notoFont; + var culture = CultureInfo.CurrentCulture; + var language = culture.Name; // e.g., "zh-TW" + var langPrefix = language.Split('-')[0]; // e.g., "zh" + + if (TryGetNotoFont(language, out var notoFont) || TryGetNotoFont(langPrefix, out notoFont)) + { + if (Fonts.SystemFontFamilies.Any(f => f.Source.Equals(notoFont))) + return notoFont; + } } var font = SystemFonts.MessageFontFamily; @@ -162,6 +164,7 @@ namespace Flow.Launcher.Infrastructure.UserSettings public string ResultSubFontStyle { get; set; } public string ResultSubFontWeight { get; set; } public string ResultSubFontStretch { get; set; } + public string SettingWindowFont { get; set; } = GetSystemDefaultFont(false); public bool UseGlyphIcons { get; set; } = true; public bool UseAnimation { get; set; } = true; public bool UseSound { get; set; } = true; diff --git a/Flow.Launcher/SettingPages/ViewModels/SettingsPaneAboutViewModel.cs b/Flow.Launcher/SettingPages/ViewModels/SettingsPaneAboutViewModel.cs index 6cfb98306..abc7a2d16 100644 --- a/Flow.Launcher/SettingPages/ViewModels/SettingsPaneAboutViewModel.cs +++ b/Flow.Launcher/SettingPages/ViewModels/SettingsPaneAboutViewModel.cs @@ -1,9 +1,11 @@ using System; using System.Collections.Generic; +using System.ComponentModel; using System.IO; using System.Linq; using System.Threading.Tasks; using System.Windows; +using System.Windows.Media; using CommunityToolkit.Mvvm.Input; using Flow.Launcher.Core; using Flow.Launcher.Infrastructure; @@ -268,4 +270,51 @@ public partial class SettingsPaneAboutViewModel : BaseModel return "0 B"; } + + public event PropertyChangedEventHandler PropertyChanged; + protected virtual void OnPropertyChanged(string propertyName) + { + PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); + } + + private string _settingWindowFont; + + public string SettingWindowFont + { + get => _settings.SettingWindowFont; + set + { + if (_settings.SettingWindowFont != value) + { + _settings.SettingWindowFont = value; + OnPropertyChanged(nameof(SettingWindowFont)); + } + } + } + + [RelayCommand] + private void ResetSettingWindowFont() + { + string defaultFont = GetSystemDefaultFont(); + _settings.SettingWindowFont = defaultFont; + } + + public static string GetSystemDefaultFont() + { + try + { + var font = SystemFonts.MessageFontFamily; + if (font.FamilyNames.TryGetValue(System.Windows.Markup.XmlLanguage.GetLanguage("en-US"), out var englishName)) + { + return englishName; + } + + return font.Source ?? "Segoe UI"; + } + catch + { + return "Segoe UI"; + } + } + } diff --git a/Flow.Launcher/SettingPages/Views/SettingsPaneAbout.xaml b/Flow.Launcher/SettingPages/Views/SettingsPaneAbout.xaml index f7deee7cf..b3991743d 100644 --- a/Flow.Launcher/SettingPages/Views/SettingsPaneAbout.xaml +++ b/Flow.Launcher/SettingPages/Views/SettingsPaneAbout.xaml @@ -12,6 +12,11 @@ d:DesignHeight="450" d:DesignWidth="800" mc:Ignorable="d"> + + + + + - - - + + + + + + + +