From 0c8a0b2d2d4fd4830847f8ef9444955825e34590 Mon Sep 17 00:00:00 2001 From: Daniel Zhu Date: Thu, 2 May 2024 10:02:45 -0700 Subject: [PATCH 1/3] Basic font weight management --- .../Controller/TextViewController+Highlighter.swift | 3 ++- Sources/CodeEditSourceEditor/Theme/EditorTheme.swift | 9 +++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/Sources/CodeEditSourceEditor/Controller/TextViewController+Highlighter.swift b/Sources/CodeEditSourceEditor/Controller/TextViewController+Highlighter.swift index 0ad8597e9..f7490944d 100644 --- a/Sources/CodeEditSourceEditor/Controller/TextViewController+Highlighter.swift +++ b/Sources/CodeEditSourceEditor/Controller/TextViewController+Highlighter.swift @@ -48,7 +48,8 @@ extension TextViewController: ThemeAttributesProviding { [ .font: font, .foregroundColor: theme.colorFor(capture), - .kern: textView.kern + .kern: textView.kern, + .strokeWidth: theme.widthFor(capture), ] } } diff --git a/Sources/CodeEditSourceEditor/Theme/EditorTheme.swift b/Sources/CodeEditSourceEditor/Theme/EditorTheme.swift index 9118fb2b0..1dc7f6ebf 100644 --- a/Sources/CodeEditSourceEditor/Theme/EditorTheme.swift +++ b/Sources/CodeEditSourceEditor/Theme/EditorTheme.swift @@ -82,6 +82,15 @@ public struct EditorTheme { default: return text } } + + func widthFor(_ capture: CaptureName?) -> Float { + switch capture { + case .include, .constructor, .keyword, .boolean, .variableBuiltin, + .keywordReturn, .keywordFunction, .repeat, .conditional, .tag, .type: + return -4.0 + default: return 0.0 + } + } } extension EditorTheme: Equatable { From 06d25b16b6f38bad68078812674b5735ecfb5eb9 Mon Sep 17 00:00:00 2001 From: Daniel Zhu Date: Thu, 2 May 2024 10:08:55 -0700 Subject: [PATCH 2/3] Change weight and add docs --- Sources/CodeEditSourceEditor/Theme/EditorTheme.swift | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Sources/CodeEditSourceEditor/Theme/EditorTheme.swift b/Sources/CodeEditSourceEditor/Theme/EditorTheme.swift index 1dc7f6ebf..dd709921f 100644 --- a/Sources/CodeEditSourceEditor/Theme/EditorTheme.swift +++ b/Sources/CodeEditSourceEditor/Theme/EditorTheme.swift @@ -83,11 +83,14 @@ public struct EditorTheme { } } + /// Gets the `strokeWidth` for the specified capture name. + /// - Parameter capture: The capture name + /// - Returns: a float representing `strokeWidth` func widthFor(_ capture: CaptureName?) -> Float { switch capture { case .include, .constructor, .keyword, .boolean, .variableBuiltin, .keywordReturn, .keywordFunction, .repeat, .conditional, .tag, .type: - return -4.0 + return -3.0 default: return 0.0 } } From 09827a146eedf07aa997105d4007493b93cabb41 Mon Sep 17 00:00:00 2001 From: Daniel Zhu Date: Fri, 3 May 2024 08:32:18 -0700 Subject: [PATCH 3/3] Change weight to -5.0 --- Sources/CodeEditSourceEditor/Theme/EditorTheme.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sources/CodeEditSourceEditor/Theme/EditorTheme.swift b/Sources/CodeEditSourceEditor/Theme/EditorTheme.swift index dd709921f..e26854457 100644 --- a/Sources/CodeEditSourceEditor/Theme/EditorTheme.swift +++ b/Sources/CodeEditSourceEditor/Theme/EditorTheme.swift @@ -89,8 +89,8 @@ public struct EditorTheme { func widthFor(_ capture: CaptureName?) -> Float { switch capture { case .include, .constructor, .keyword, .boolean, .variableBuiltin, - .keywordReturn, .keywordFunction, .repeat, .conditional, .tag, .type: - return -3.0 + .keywordReturn, .keywordFunction, .repeat, .conditional, .tag: + return -5.0 default: return 0.0 } }