mirror of
https://github.com/QL-Win/QuickLook.git
synced 2026-05-08 03:06:29 +08:00
Allow setting of the font and font size used in the text viewer (#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>
This commit is contained in:
+14
@@ -237,6 +237,20 @@ These keys are also stored in `QuickLook.config`.
|
||||
- Example:
|
||||
- `<AllowDarkTheme>True</AllowDarkTheme>`
|
||||
|
||||
### `<FontFamily>`
|
||||
- Default: default font of the current language
|
||||
- Type: `String`
|
||||
- Description: Allow setting of the font used in the text viewer.
|
||||
- Example:
|
||||
- `<FontFamily>Cascadia Mono SemiLight</FontFamily>`
|
||||
|
||||
### `<FontSize>`
|
||||
- Default: 14.0
|
||||
- Type: `Double`
|
||||
- Description: Allow setting of font size used in the text viewer.
|
||||
- Example:
|
||||
- `<FontSize>13</FontSize>`
|
||||
|
||||
## Notes
|
||||
|
||||
- All option names are case-sensitive and stored as XML element names under `<Settings>`.
|
||||
|
||||
@@ -72,7 +72,6 @@ public partial class TextViewerPanel : TextEditor, IDisposable
|
||||
|
||||
public TextViewerPanel()
|
||||
{
|
||||
FontSize = 14;
|
||||
ShowLineNumbers = true;
|
||||
WordWrap = true;
|
||||
IsReadOnly = true;
|
||||
@@ -117,8 +116,13 @@ public partial class TextViewerPanel : TextEditor, IDisposable
|
||||
|
||||
PreviewMouseWheel += Viewer_MouseWheel;
|
||||
|
||||
FontFamily = new FontFamily(TranslationHelper.Get("Editor_FontFamily",
|
||||
domain: Assembly.GetExecutingAssembly().GetName().Name));
|
||||
// Read configured font size and validate it to avoid negative or unreasonable values
|
||||
FontSize = Math.Max(1d, Math.Min(72d, SettingHelper.Get("FontSize", 14d, "QuickLook.Plugin.TextViewer")));
|
||||
FontFamily = new FontFamily(
|
||||
SettingHelper.Get("FontFamily",
|
||||
failsafe: TranslationHelper.Get("Editor_FontFamily",
|
||||
domain: Assembly.GetExecutingAssembly().GetName().Name),
|
||||
"QuickLook.Plugin.TextViewer"));
|
||||
|
||||
// Add a custom element generator (e.g., to truncate extremely long lines).
|
||||
TextArea.TextView.ElementGenerators.Add(new TruncateLongLines());
|
||||
|
||||
Reference in New Issue
Block a user