Skip to content

Import Theme Size / Select Default Font / Small Design Fixes #3458

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 26 commits into from
Apr 17, 2025

Conversation

onesounds
Copy link
Contributor

@onesounds onesounds commented Apr 12, 2025

What's the PR

Feature-related

  • Changed the default setting of the placeholder text to be enabled.

  • Changed the default font on first launch and reset to the OS's default font per language.

    • Fonts are displayed and stored based on their English names in the combo box and internally.

    • The previous default fonts were not suitable for WPF and caused text to appear pixelated on screen.

    • This is suspected to be the main reason why users are still posting blurry screenshots, even after all known issues affecting screen clarity have been fixed.

    • If the Noto Sans font is available, it is given priority. If not, the next default font is used. If that also fails, fall back to Segoe UI.

      • Since font names differ by language, a separate mapping table is used to match them accordingly.
  • Added Import Theme Size feature. When the button is clicked, if the theme has specified size values, they are loaded into the settings.

    • A feature that makes it easier for theme designers to convey their intended design while preserving user customizations.

Design-related

  • Redesign Combobox
  • Moved values that were fixed on the control and couldn't be changed from the theme to base.xaml.
  • Adjusted the window colors of the two blur themes to make the effect more noticeable.
  • Reduced the default query font size from 20 to 16. This also applies when resetting.
  • Added a message indicating that the backdrop effect is not applied to the preview area.

Font Issue reference

WPF uses a DirectWrite-based text rendering engine, which is different from the GDI+ rendering used in Windows Forms (System.Drawing). Because of this, font handling works differently between the two.

🔤 System.Drawing.FontFamily.GenericSansSerif vs System.Windows.Media.FontFamily

  • System.Drawing.FontFamily.GenericSansSerif is one of the generic font families used in GDI+, and it typically maps to fonts like Microsoft Sans Serif.

  • However, WPF’s System.Windows.Media.FontFamily does not support generic font families like GDI+ does. You need to specify font names directly (e.g., "Segoe UI", "Arial", etc.).

❗ Issue: Using GDI+ Fonts in WPF

  • Fonts like Microsoft Sans Serif are optimized for GDI+.

  • When used in WPF, the rendering might appear slightly blurry.

  • This is due to differences in subpixel rendering, DPI handling, and how text is rasterized in WPF compared to GDI+.

✅ Recommendation

  • Use fonts that are optimized for WPF, such as Segoe UI.

  • Alternatively, consider using SystemFonts.MessageFontFamily, which gives you the system’s default font for WPF.

Todo

  • Added a “Preset from Theme” button and its functionality. (When clicked, this button retrieves the height and size values defined in the theme and applies them to the settings.)
  • Fixed a minor issue where the ComboBox would shift by 1px when clicked and released.

Test Case

  • The code-behind for font handling and theme import functionality needs to be checked.
  • When the reset button is clicked in each size customization menu, the default font for the OS based on the current language should be automatically selected.
  • The Import Theme Size feature must apply the settings correctly when executed.

@prlabeler prlabeler bot added the bug Something isn't working label Apr 12, 2025

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

Adjust Colors

This comment has been minimized.

This comment has been minimized.

Copy link
Contributor

coderabbitai bot commented Apr 13, 2025

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Let's first get a summary of the changes in this PR to better understand the scope
git log --oneline -n 10 HEAD

# Check the specific files changed in this PR
git diff --name-status HEAD~1

# Let's examine the changes to the Settings.cs file since it seems central to the font handling changes
git diff HEAD~1 Flow.Launcher.Infrastructure/UserSettings/Settings.cs | grep -A 15 "GetSystemDefaultFont"

# Let's examine the import feature in the SettingsPaneThemeViewModel
git diff HEAD~1 Flow.Launcher/SettingPages/ViewModels/SettingsPaneThemeViewModel.cs | grep -A 15 "Import"

# Let's look at the UI changes to SettingsPaneTheme.xaml
git diff HEAD~1 Flow.Launcher/SettingPages/Views/SettingsPaneTheme.xaml

Length of output: 1065


🏁 Script executed:

#!/bin/bash
# Let's list the files to understand the directory structure
find . -type f -name "*.cs" | grep -E "Settings|Theme" | sort

# Let's look at the content of key files mentioned in the PR summary
cat Flow.Launcher.Infrastructure/UserSettings/Settings.cs | grep -A 20 "GetSystemDefaultFont"

# Look at the Theme class to understand the change to GetCurrentResourceDictionary
cat Flow.Launcher.Core/Resource/Theme.cs | grep -A 10 "GetCurrentResourceDictionary"

# Check the implementation of the Import command in SettingsPaneThemeViewModel
cat Flow.Launcher/SettingPages/ViewModels/SettingsPaneThemeViewModel.cs | grep -A 50 "Import"

# Examine the changes to the UI in SettingsPaneTheme.xaml
cat Flow.Launcher/SettingPages/Views/SettingsPaneTheme.xaml | grep -A 10 "Import Theme Size"

Length of output: 10037


🏁 Script executed:

#!/bin/bash
# Let's check the UI changes to the theme settings page
cat Flow.Launcher/SettingPages/Views/SettingsPaneTheme.xaml | grep -A 20 -B 5 "Button"

# Let's look at the language resource additions
cat Flow.Launcher/Languages/en.xaml | grep -A 1 -E "resetCustomizeToolTip|ImportThemeSize|BackdropInfo"

# Let's examine the ComboBox styling changes
cat Flow.Launcher/Resources/CustomControlTemplate.xaml | grep -A 20 "ComboBox"

# Let's check the font size changes
grep -A 2 "QueryBoxFontSize" Flow.Launcher.Infrastructure/UserSettings/Settings.cs

Length of output: 40462


@onesounds Looking at this pull request, I can see you've made several significant enhancements to improve the font handling and theme customization in Flow Launcher.

The key improvements include:

  1. Font Handling Improvements:

    • Changed the default fonts to prioritize Noto Sans fonts based on user's language
    • Added a robust system font detection method with proper fallbacks
    • Reduced the default query font size from 20 to 16 for better readability
  2. Theme Import Feature:

    • Added a new "Import Theme Size" feature to load size values from themes
    • Made GetCurrentResourceDictionary() public to enable this functionality
    • Implemented smart extraction of font sizes and layout dimensions
  3. UI Enhancements:

    • Redesigned the ComboBox with bullet indicators for selected items
    • Added visual feedback improvements for hover and selection states
    • Fixed the issue with ComboBox shifting during interaction
    • Added informational message about backdrop effect limitations
  4. Default Setting Changes:

    • Changed placeholder text to enabled by default
    • Adjusted window colors for improved visibility with blur themes

These changes should significantly improve the user experience, especially addressing the pixelated text and blurry screenshots issues you mentioned in the PR description. The font selection prioritizing Noto Sans with language-specific variants is a particularly good approach for WPF compatibility.

Very solid work on enhancing both the functionality and aesthetics of Flow Launcher!

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

@onesounds onesounds enabled auto-merge April 16, 2025 21:22

This comment has been minimized.

Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot reviewed 3 out of 15 changed files in this pull request and generated 2 comments.

Files not reviewed (12)
  • Flow.Launcher/Languages/en.xaml: Language not supported
  • Flow.Launcher/Resources/CustomControlTemplate.xaml: Language not supported
  • Flow.Launcher/Resources/Dark.xaml: Language not supported
  • Flow.Launcher/Resources/Light.xaml: Language not supported
  • Flow.Launcher/ResultListBox.xaml: Language not supported
  • Flow.Launcher/SettingPages/Views/SettingsPaneGeneral.xaml: Language not supported
  • Flow.Launcher/SettingPages/Views/SettingsPaneTheme.xaml: Language not supported
  • Flow.Launcher/SettingWindow.xaml: Language not supported
  • Flow.Launcher/Themes/Base.xaml: Language not supported
  • Flow.Launcher/Themes/Circle System.xaml: Language not supported
  • Flow.Launcher/Themes/SlimLight.xaml: Language not supported
  • Flow.Launcher/Themes/Win11Light.xaml: Language not supported

@Jack251970 Jack251970 added this to the 1.20.0 milestone Apr 17, 2025
@onesounds onesounds requested a review from Copilot April 17, 2025 20:37
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR updates the default font settings and improves theme import functionality to enhance UI clarity and ensure fonts are optimized for WPF. Key changes include:

  • Replacing hard-coded default fonts with a system-derived default using language-specific mapping.
  • Reducing the default QueryBoxFontSize from 20 to 16.
  • Adding an "Import Theme Size" command that loads size values from the active theme's resource dictionary.

Reviewed Changes

Copilot reviewed 3 out of 15 changed files in this pull request and generated 1 comment.

File Description
Flow.Launcher/SettingPages/ViewModels/SettingsPaneThemeViewModel.cs Updates default font handling and introduces the Import command.
Flow.Launcher.Infrastructure/UserSettings/Settings.cs Adjusts default font settings and QueryBoxFontSize, and adds language-based font mapping.
Flow.Launcher.Core/Resource/Theme.cs Exposes the current resource dictionary and introduces a style-copy helper.
Files not reviewed (12)
  • Flow.Launcher/Languages/en.xaml: Language not supported
  • Flow.Launcher/Resources/CustomControlTemplate.xaml: Language not supported
  • Flow.Launcher/Resources/Dark.xaml: Language not supported
  • Flow.Launcher/Resources/Light.xaml: Language not supported
  • Flow.Launcher/ResultListBox.xaml: Language not supported
  • Flow.Launcher/SettingPages/Views/SettingsPaneGeneral.xaml: Language not supported
  • Flow.Launcher/SettingPages/Views/SettingsPaneTheme.xaml: Language not supported
  • Flow.Launcher/SettingWindow.xaml: Language not supported
  • Flow.Launcher/Themes/Base.xaml: Language not supported
  • Flow.Launcher/Themes/Circle System.xaml: Language not supported
  • Flow.Launcher/Themes/SlimLight.xaml: Language not supported
  • Flow.Launcher/Themes/Win11Light.xaml: Language not supported
Comments suppressed due to low confidence (1)

Flow.Launcher/SettingPages/ViewModels/SettingsPaneThemeViewModel.cs:26

  • [nitpick] Consider marking DefaultFont as readonly if its value is not intended to be modified after initialization.
private string DefaultFont = Settings.GetSystemDefaultFont();

This comment has been minimized.

@Jack251970 Jack251970 requested a review from Copilot April 17, 2025 23:39
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR updates the theme and font initialization logic to improve UI clarity and design consistency in Flow Launcher. Key changes include:

  • Changing the default font source to use the OS's default and mapping language-specific fonts.
  • Introducing an Import Theme Size feature that updates UI element sizes from a theme.
  • Minor design fixes and adjustments to default query font size and control styling.

Reviewed Changes

Copilot reviewed 4 out of 16 changed files in this pull request and generated 1 comment.

File Description
Flow.Launcher/SettingPages/ViewModels/SettingsPaneThemeViewModel.cs Updates default font retrieval and query font size, and adds the Import command for theme size values.
Flow.Launcher.Infrastructure/Win32Helper.cs Adds language-specific Noto Sans mapping and updates GetSystemDefaultFont logic.
Flow.Launcher.Infrastructure/UserSettings/Settings.cs Changes default font settings and adjusts placeholder/show fields to match new design.
Flow.Launcher.Core/Resource/Theme.cs Alters theme resource retrieval to public, and introduces a CopyStyle method for preview style updates.
Files not reviewed (12)
  • Flow.Launcher/Languages/en.xaml: Language not supported
  • Flow.Launcher/Resources/CustomControlTemplate.xaml: Language not supported
  • Flow.Launcher/Resources/Dark.xaml: Language not supported
  • Flow.Launcher/Resources/Light.xaml: Language not supported
  • Flow.Launcher/ResultListBox.xaml: Language not supported
  • Flow.Launcher/SettingPages/Views/SettingsPaneGeneral.xaml: Language not supported
  • Flow.Launcher/SettingPages/Views/SettingsPaneTheme.xaml: Language not supported
  • Flow.Launcher/SettingWindow.xaml: Language not supported
  • Flow.Launcher/Themes/Base.xaml: Language not supported
  • Flow.Launcher/Themes/Circle System.xaml: Language not supported
  • Flow.Launcher/Themes/SlimLight.xaml: Language not supported
  • Flow.Launcher/Themes/Win11Light.xaml: Language not supported
Comments suppressed due to low confidence (1)

Flow.Launcher.Infrastructure/UserSettings/Settings.cs:310

  • [nitpick] Consider explicitly initializing _hideNotifyIcon (e.g. = false) for clarity and consistency with other field declarations.
private bool _hideNotifyIcon;

Copy link

@check-spelling-bot Report

🔴 Please review

See the 📂 files view, the 📜action log, or 📝 job summary for details.

❌ Errors Count
❌ forbidden-pattern 22
⚠️ non-alpha-in-dictionary 19

See ❌ Event descriptions for more information.

If the flagged items are 🤯 false positives

If items relate to a ...

  • binary file (or some other file you wouldn't want to check at all).

    Please add a file path to the excludes.txt file matching the containing file.

    File paths are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your files.

    ^ refers to the file's path from the root of the repository, so ^README\.md$ would exclude README.md (on whichever branch you're using).

  • well-formed pattern.

    If you can write a pattern that would match it,
    try adding it to the patterns.txt file.

    Patterns are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your lines.

    Note that patterns can't match multiline strings.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
Flow.Launcher.Infrastructure/Win32Helper.cs (1)

603-669: Consider adding a comment explaining the font selection strategy.

While the implementation is solid, adding a high-level comment at the beginning of the region would help other developers understand the rationale behind the font selection strategy, particularly why Noto Sans fonts are prioritized for different languages.

 #region System Font
+// This region implements a system-aware font detection strategy that prioritizes:
+// 1. Language-specific Noto Sans fonts that work well with WPF's DirectWrite rendering
+// 2. The system's default message font if appropriate Noto Sans isn't available
+// 3. Segoe UI as a final fallback
+// This approach addresses issues with pixelated text and blurry fonts reported by users.

 private static readonly Dictionary<string, string> _languageToNotoSans = new()
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b2a3782 and 5cea434.

📒 Files selected for processing (3)
  • Flow.Launcher.Infrastructure/UserSettings/Settings.cs (6 hunks)
  • Flow.Launcher.Infrastructure/Win32Helper.cs (3 hunks)
  • Flow.Launcher/SettingPages/ViewModels/SettingsPaneThemeViewModel.cs (4 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • Flow.Launcher/SettingPages/ViewModels/SettingsPaneThemeViewModel.cs
  • Flow.Launcher.Infrastructure/UserSettings/Settings.cs
🔇 Additional comments (4)
Flow.Launcher.Infrastructure/Win32Helper.cs (4)

2-20: Appropriate using statements added for new functionality.

The added using statements are necessary for the new System Font functionality, including Collections.Generic for Dictionary, Linq for font queries, Markup for XmlLanguage, and the SystemFonts alias to avoid ambiguity.


605-629: Well-structured language-to-font mapping dictionary.

The dictionary comprehensively maps language codes to appropriate Noto Sans font variants for a wide range of languages, addressing the PR's goal of improving font handling across different writing systems. The static readonly approach is appropriate for this immutable mapping.


631-662: Robust system font detection implementation with appropriate fallbacks.

The implementation follows a sensible priority order:

  1. Try language-specific Noto Sans font if available
  2. Fall back to system default message font if Noto Sans isn't available
  3. Use "Segoe UI" as a last resort

The try-catch block ensures the method always returns a valid font name, preventing crashes in the UI.


664-667: Concise helper method improving code readability.

The TryGetNotoFont method encapsulates the dictionary lookup logic, making the main method cleaner and more maintainable.

@onesounds onesounds merged commit 0591970 into Flow-Launcher:dev Apr 17, 2025
4 checks passed
@jjw24 jjw24 removed the bug Something isn't working label May 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request kind/ui related to UI, icons, themes, etc
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants