Skip to content

Commit b2ce36e

Browse files
author
Scrap
authored
Added setting to change font size, so can now change the default font… (#1128)
Added setting to change font size, so can now change the default font size.
1 parent a5b7497 commit b2ce36e

File tree

2 files changed

+29
-3
lines changed

2 files changed

+29
-3
lines changed

CodeEdit/Features/AppPreferences/Model/Text Editing/TextEditingPreferences.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff 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
}

CodeEdit/Features/AppPreferences/Sections/TextEditingPreferences/TextEditingPreferencesView.swift

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff 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)

0 commit comments

Comments
 (0)