Skip to content

Allow setting of the font and font size used in the text viewer - #1930

Merged
emako merged 3 commits into
QL-Win:masterfrom
pmrochen:textviewer-font
May 6, 2026
Merged

emako merged 3 commits into
QL-Win:masterfrom
pmrochen:textviewer-font

Conversation

@pmrochen

@pmrochen pmrochen commented May 5, 2026 •

Copy link
Copy Markdown
Contributor

PR Checklist

  • Functionality has been tested, no obvious bugs
  • Code style follows project conventions
  • Documentation/comments updated (if applicable)

Brief Description of Changes

Add support for the font and font size settings in the configuration file (QuickLook.Plugin.TextViewer.config).

Related Issue (if any)

Additional Notes

Summary by Sourcery

Add configurable font family and font size support to the text viewer plugin via settings and documentation updates.

New Features:

  • Allow configuring the text viewer font family through the plugin configuration file.
  • Allow configuring the text viewer font size through the plugin configuration file.

Documentation:

  • Document new FontFamily and FontSize options in OPTIONS.md.

@sourcery-ai

sourcery-ai Bot commented May 5, 2026 •

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Adds configurable font family and font size support for the text viewer plugin, wiring new XML settings into TextViewerPanel initialization and documenting them in OPTIONS.md.

Sequence diagram for TextViewerPanel initialization with configurable font settings

sequenceDiagram
    actor User
    participant ConfigFile as QuickLook.Plugin.TextViewer.config
    participant TextViewerPanel
    participant SettingHelper
    participant TranslationHelper
    participant Assembly

    User->>ConfigFile: Edit FontFamily and FontSize values
    User->>TextViewerPanel: Open text preview

    activate TextViewerPanel
    TextViewerPanel->>SettingHelper: Get(FontSize, 14.0, QuickLook.Plugin.TextViewer)
    SettingHelper-->>TextViewerPanel: FontSize value (from config or default)
    TextViewerPanel->>Assembly: GetExecutingAssembly()
    Assembly-->>TextViewerPanel: AssemblyName
    TextViewerPanel->>TranslationHelper: Get(Editor_FontFamily, AssemblyName)
    TranslationHelper-->>TextViewerPanel: default font family
    TextViewerPanel->>SettingHelper: Get(FontFamily, defaultFontFamily, QuickLook.Plugin.TextViewer)
    SettingHelper-->>TextViewerPanel: FontFamily value (from config or default)
    TextViewerPanel-->>User: Display text with configured font family and size
    deactivate TextViewerPanel
Loading

Class diagram for updated TextViewerPanel font configuration

classDiagram
    class TextViewerPanel {
        +double FontSize
        +FontFamily FontFamily
        +bool ShowLineNumbers
        +bool WordWrap
        +bool IsReadOnly
        +TextViewerPanel()
    }

    class SettingHelper {
        +double Get(string key, double defaultValue, string domain)
        +string Get(string key, string defaultValue, string domain)
    }

    class TranslationHelper {
        +string Get(string key, string domain)
    }

    class Assembly {
        +AssemblyName GetExecutingAssembly()
    }

    class AssemblyName {
        +string GetName()
    }

    TextViewerPanel ..> SettingHelper : uses
    TextViewerPanel ..> TranslationHelper : uses
    TextViewerPanel ..> Assembly : uses
    TranslationHelper ..> AssemblyName : uses
Loading

File-Level Changes

Change Details Files
Make text viewer font size configurable via plugin settings.
  • Replace hard-coded FontSize initialization with a SettingHelper.Get lookup using key "FontSize" and default 14.0 for the QuickLook.Plugin.TextViewer domain.
  • Ensure TextViewerPanel respects user-defined font size from QuickLook.Plugin.TextViewer.config while preserving existing behavior when the setting is absent.
QuickLook.Plugin/QuickLook.Plugin.TextViewer/TextViewerPanel.cs
Make text viewer font family configurable via plugin settings.
  • Replace FontFamily initialization that uses TranslationHelper "Editor_FontFamily" only with a SettingHelper.Get lookup for key "FontFamily" falling back to the translated default value.
  • Continue to use the plugin assembly name as the translation domain while allowing override via QuickLook.Plugin.TextViewer.config.
QuickLook.Plugin/QuickLook.Plugin.TextViewer/TextViewerPanel.cs
Document new font configuration options for the text viewer plugin.
  • Add OPTIONS.md entries describing and settings, including defaults, types, descriptions, and examples.
  • Clarify that these keys live in the plugin configuration (QuickLook.Plugin.TextViewer.config).
OPTIONS.md

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hey - I've left some high level feedback:

  • Consider centralizing the default font size (14.0) and default font family key into a shared constant so the code and configuration documentation cannot drift out of sync.
  • It may be worth validating the configured FontSize (e.g., enforcing a reasonable min/max) before applying it to avoid unusable text viewer states from extreme values.
  • When reading FontFamily from settings, consider handling invalid or unavailable font families by gracefully falling back to the translation-based default rather than throwing at runtime.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Consider centralizing the default font size (14.0) and default font family key into a shared constant so the code and configuration documentation cannot drift out of sync.
- It may be worth validating the configured FontSize (e.g., enforcing a reasonable min/max) before applying it to avoid unusable text viewer states from extreme values.
- When reading FontFamily from settings, consider handling invalid or unavailable font families by gracefully falling back to the translation-based default rather than throwing at runtime.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@emako
emako merged commit c84a85f into QL-Win:master May 6, 2026
1 check passed
ahocagil pushed a commit to ahocagil/UA-FastLook that referenced this pull request Sep 9, 2026
…in#1930)

* Allow setting of the font and font size used in the text viewer

* Refactor font settings initialization

* Clamp TextViewer font size from Settings

---------

Co-authored-by: ema <mccoy39082@163.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants