From 0c8a0b2d2d4fd4830847f8ef9444955825e34590 Mon Sep 17 00:00:00 2001 From: Daniel Zhu Date: Thu, 2 May 2024 10:02:45 -0700 Subject: [PATCH] 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 {