From c3453161bd21659e7d1df76b6104c22f5d7aeb1c Mon Sep 17 00:00:00 2001 From: Johnathan Date: Mon, 19 Jun 2023 14:09:13 -0500 Subject: [PATCH] Fixing Font bugs (#1337) Fixes font bugs --- CodeEdit/Features/CodeFile/CodeFileView.swift | 7 ++++++- .../Features/Settings/Views/MonospacedFontPicker.swift | 4 ++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/CodeEdit/Features/CodeFile/CodeFileView.swift b/CodeEdit/Features/CodeFile/CodeFileView.swift index 060d62e95..c25bd9d75 100644 --- a/CodeEdit/Features/CodeFile/CodeFileView.swift +++ b/CodeEdit/Features/CodeFile/CodeFileView.swift @@ -36,6 +36,8 @@ struct CodeFileView: View { private let isEditable: Bool + private let systemFont: NSFont = .monospacedSystemFont(ofSize: 11, weight: .medium) + init(codeFile: CodeFileDocument, isEditable: Bool = true) { self.codeFile = codeFile self.isEditable = isEditable @@ -142,7 +144,10 @@ struct CodeFileView: View { self.selectedTheme = theme } .onChange(of: settingsFont) { _ in - font = Settings.shared.preferences.textEditing.font.current() + font = NSFont( + name: settingsFont.name, + size: CGFloat(settingsFont.size) + ) ?? systemFont } .onChange(of: bracketHighlight) { _ in bracketPairHighlight = getBracketPairHighlight() diff --git a/CodeEdit/Features/Settings/Views/MonospacedFontPicker.swift b/CodeEdit/Features/Settings/Views/MonospacedFontPicker.swift index c36a4aa4f..dd7a78f6d 100644 --- a/CodeEdit/Features/Settings/Views/MonospacedFontPicker.swift +++ b/CodeEdit/Features/Settings/Views/MonospacedFontPicker.swift @@ -83,9 +83,9 @@ struct MonospacedFontPicker: View { } } } - .onChange(of: selectedFontName) { selection in + .onChange(of: selectedFontName) { _ in if selectedFontName != "SF Mono" { - pushIntoRecentFonts(selection) + pushIntoRecentFonts(selectedFontName) } } .onAppear(perform: getFonts)