diff --git a/Chord Provider/General/ChordProviderSettings.swift b/Chord Provider/General/ChordProviderSettings.swift index ffce139..11baaab 100644 --- a/Chord Provider/General/ChordProviderSettings.swift +++ b/Chord Provider/General/ChordProviderSettings.swift @@ -14,6 +14,7 @@ struct ChordProviderSettings: Equatable, Codable { var showChords: Bool = true var showInlineDiagrams: Bool = false var paging: Song.DisplayOptions.Paging = .asList + var editorFontSize: Int = 14 } extension ChordProviderSettings { diff --git a/Chord Provider/Views/EditorView/EditorView+directiveMenus.swift b/Chord Provider/Views/EditorView/EditorView+directiveMenus.swift index 4bad2f0..a6a2a2c 100644 --- a/Chord Provider/Views/EditorView/EditorView+directiveMenus.swift +++ b/Chord Provider/Views/EditorView/EditorView+directiveMenus.swift @@ -45,6 +45,14 @@ extension EditorView { Label("More...", systemImage: "pencil") } ) + Picker("Font Size:", selection: $appState.settings.editorFontSize) { + ForEach(12...24, id: \.self) { value in + Text("\(value)px") + .tag(value) + } + } + .labelsHidden() + .frame(maxWidth: 75) } .menuStyle(.button) } diff --git a/Chord Provider/Views/EditorView/EditorView+rules.swift b/Chord Provider/Views/EditorView/EditorView+rules.swift index b04c975..9851f3e 100644 --- a/Chord Provider/Views/EditorView/EditorView+rules.swift +++ b/Chord Provider/Views/EditorView/EditorView+rules.swift @@ -28,7 +28,6 @@ extension EditorView { static let rules: [HighlightRule] = [ /// The rule for all lines HighlightRule(pattern: NSRegularExpression.all, formattingRules: [ - TextFormattingRule(key: .font, value: font(weight: .light)), TextFormattingRule(key: .paragraphStyle, value: nsParagraphStyle) ]), /// The rule for a chord @@ -37,8 +36,7 @@ extension EditorView { ]), /// The rule for a directive HighlightRule(pattern: EditorView.directiveRegex, formattingRules: [ - TextFormattingRule(key: .foregroundColor, value: SWIFTColor.systemTeal), - TextFormattingRule(key: .font, value: font(weight: .medium)) + TextFormattingRule(key: .foregroundColor, value: SWIFTColor.systemTeal) ]), /// The rule for the value of a directive HighlightRule(pattern: EditorView.directiveValueRegex, formattingRules: [ @@ -53,15 +51,8 @@ extension EditorView { /// The style of a paragraph in the editor static let nsParagraphStyle: NSParagraphStyle = { let style = NSMutableParagraphStyle() - style.lineHeightMultiple = 1.2 + style.lineHeightMultiple = 1.5 style.headIndent = 10 return style }() - - /// The font for a line in the editor - /// - Parameter weight: The weight of a font - /// - Returns: A font declaration - static func font(weight: SWIFTFont.Weight) -> SWIFTFont { - return SWIFTFont.monospacedSystemFont(ofSize: 14, weight: weight) - } } diff --git a/Chord Provider/Views/EditorView/EditorView.swift b/Chord Provider/Views/EditorView/EditorView.swift index 35727b1..5561934 100644 --- a/Chord Provider/Views/EditorView/EditorView.swift +++ b/Chord Provider/Views/EditorView/EditorView.swift @@ -34,6 +34,8 @@ import HighlightedTextEditor struct EditorView: View { /// The ChordPro document @Binding var document: ChordProDocument + /// The app state + @EnvironmentObject var appState: AppState /// The scene state @EnvironmentObject var sceneState: SceneState /// Show a directive sheet @@ -90,6 +92,10 @@ struct EditorView: View { #endif sceneState.textView = editor.textView } + editor.textView.font = SWIFTFont.monospacedSystemFont( + ofSize: Double(appState.settings.editorFontSize), + weight: .regular + ) } } }