File tree Expand file tree Collapse file tree 2 files changed +29
-3
lines changed
CodeEdit/Features/AppPreferences
Sections/TextEditingPreferences Expand file tree Collapse file tree 2 files changed +29
-3
lines changed Original file line number Diff line number Diff line change @@ -97,7 +97,7 @@ extension AppPreferences {
9797 /// Indicates whether or not to use a custom font
9898 var customFont : Bool = false
9999
100- /// The font size for the custom font
100+ /// The font size for the font
101101 var size : Int = 12
102102
103103 /// The name of the custom font
@@ -117,11 +117,11 @@ extension AppPreferences {
117117 /// Returns an NSFont representation of the current configuration.
118118 ///
119119 /// Returns the custom font, if enabled and able to be instantiated.
120- /// Otherwise returns a default system font monospaced, size 12 .
120+ /// Otherwise returns a default system font monospaced.
121121 func current( ) -> NSFont {
122122 guard customFont,
123123 let customFont = NSFont ( name: name, size: Double ( size) ) else {
124- return NSFont . monospacedSystemFont ( ofSize: 12 , weight: . regular)
124+ return NSFont . monospacedSystemFont ( ofSize: Double ( size ) , weight: . regular)
125125 }
126126 return customFont
127127 }
Original file line number Diff line number Diff line change @@ -35,6 +35,15 @@ struct TextEditingPreferencesView: View {
3535 return formatter
3636 }
3737
38+ private var fontSizeFormatter : NumberFormatter {
39+ let formatter = NumberFormatter ( )
40+ formatter. allowsFloats = false
41+ formatter. minimum = 1
42+ formatter. maximum = 288
43+
44+ return formatter
45+ }
46+
3847 var body : some View {
3948 PreferencesContent {
4049 PreferencesSection ( " Default Tab Width " ) {
@@ -53,6 +62,9 @@ struct TextEditingPreferencesView: View {
5362 PreferencesSection ( " Font " ) {
5463 fontSelector
5564 }
65+ PreferencesSection ( " Font Size " ) {
66+ fontSizeSelector
67+ }
5668 PreferencesSection ( " Line Height " ) {
5769 lineHeight
5870 }
@@ -83,6 +95,20 @@ struct TextEditingPreferencesView: View {
8395 }
8496 }
8597
98+ private var fontSizeSelector : some View {
99+ HStack ( spacing: 5 ) {
100+ TextField ( " " , value: $prefs. preferences. textEditing. font. size, formatter: fontSizeFormatter)
101+ . multilineTextAlignment ( . trailing)
102+ . frame ( width: 40 )
103+ Stepper (
104+ " Font Size: " ,
105+ value: $prefs. preferences. textEditing. font. size,
106+ in: 1 ... 288 ,
107+ step: 1
108+ )
109+ }
110+ }
111+
86112 private var autocompleteBraces : some View {
87113 HStack {
88114 Toggle ( " Autocomplete braces " , isOn: $prefs. preferences. textEditing. autocompleteBraces)
You can’t perform that action at this time.
0 commit comments