Skip to content

Commit e59e7ed

Browse files
committed
Add stepper to font settings
1 parent 10b78e7 commit e59e7ed

File tree

4 files changed

+235
-0
lines changed

4 files changed

+235
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
### Improvements
77

8+
- Revert the steppers to the font setting controls in the Appearance settings pane.
89
- Remove the Script menu from the context menu.
910

1011

CotEditor/Resources/Localizables/Settings/Panes/AppearanceSettings.xcstrings

Lines changed: 177 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,95 @@
11
{
22
"sourceLanguage" : "en",
33
"strings" : {
4+
"%@ points" : {
5+
"comment" : "accessibility label for font size",
6+
"localizations" : {
7+
"cs" : {
8+
"stringUnit" : {
9+
"state" : "translated",
10+
"value" : "%@ bodů"
11+
}
12+
},
13+
"de" : {
14+
"stringUnit" : {
15+
"state" : "translated",
16+
"value" : "%@ Punkt"
17+
}
18+
},
19+
"en-GB" : {
20+
"stringUnit" : {
21+
"state" : "translated",
22+
"value" : "%@ points"
23+
}
24+
},
25+
"es" : {
26+
"stringUnit" : {
27+
"state" : "translated",
28+
"value" : "%@ punto"
29+
}
30+
},
31+
"fr" : {
32+
"stringUnit" : {
33+
"state" : "translated",
34+
"value" : "%@ points"
35+
}
36+
},
37+
"it" : {
38+
"stringUnit" : {
39+
"state" : "translated",
40+
"value" : "%@ punto"
41+
}
42+
},
43+
"ja" : {
44+
"stringUnit" : {
45+
"state" : "translated",
46+
"value" : "%@ポイント"
47+
}
48+
},
49+
"ko" : {
50+
"stringUnit" : {
51+
"state" : "translated",
52+
"value" : "%@포인트"
53+
}
54+
},
55+
"nl" : {
56+
"stringUnit" : {
57+
"state" : "translated",
58+
"value" : "%@-punts"
59+
}
60+
},
61+
"pl" : {
62+
"stringUnit" : {
63+
"state" : "translated",
64+
"value" : "%@ pkt"
65+
}
66+
},
67+
"pt" : {
68+
"stringUnit" : {
69+
"state" : "translated",
70+
"value" : "%@ ponto"
71+
}
72+
},
73+
"tr" : {
74+
"stringUnit" : {
75+
"state" : "translated",
76+
"value" : "%@ punto"
77+
}
78+
},
79+
"zh-Hans" : {
80+
"stringUnit" : {
81+
"state" : "translated",
82+
"value" : "%@点"
83+
}
84+
},
85+
"zh-Hant" : {
86+
"stringUnit" : {
87+
"state" : "translated",
88+
"value" : "%@點"
89+
}
90+
}
91+
}
92+
},
493
"%@ times" : {
594
"comment" : "accessibility label for line height",
695
"localizations" : {
@@ -728,6 +817,94 @@
728817
}
729818
}
730819
},
820+
"Font size" : {
821+
"localizations" : {
822+
"cs" : {
823+
"stringUnit" : {
824+
"state" : "translated",
825+
"value" : "Velikost písma"
826+
}
827+
},
828+
"de" : {
829+
"stringUnit" : {
830+
"state" : "translated",
831+
"value" : "Schriftgröße"
832+
}
833+
},
834+
"en-GB" : {
835+
"stringUnit" : {
836+
"state" : "translated",
837+
"value" : "Font size"
838+
}
839+
},
840+
"es" : {
841+
"stringUnit" : {
842+
"state" : "translated",
843+
"value" : "Tamaño de letra"
844+
}
845+
},
846+
"fr" : {
847+
"stringUnit" : {
848+
"state" : "translated",
849+
"value" : "Taille de la police"
850+
}
851+
},
852+
"it" : {
853+
"stringUnit" : {
854+
"state" : "translated",
855+
"value" : "Dimensioni font"
856+
}
857+
},
858+
"ja" : {
859+
"stringUnit" : {
860+
"state" : "translated",
861+
"value" : "フォントサイズ"
862+
}
863+
},
864+
"ko" : {
865+
"stringUnit" : {
866+
"state" : "translated",
867+
"value" : "서체 크기"
868+
}
869+
},
870+
"nl" : {
871+
"stringUnit" : {
872+
"state" : "translated",
873+
"value" : "Tekstgrootte"
874+
}
875+
},
876+
"pl" : {
877+
"stringUnit" : {
878+
"state" : "translated",
879+
"value" : "Wielkość czcionki"
880+
}
881+
},
882+
"pt" : {
883+
"stringUnit" : {
884+
"state" : "translated",
885+
"value" : "Tamanho da fonte"
886+
}
887+
},
888+
"tr" : {
889+
"stringUnit" : {
890+
"state" : "translated",
891+
"value" : "Font puntosu"
892+
}
893+
},
894+
"zh-Hans" : {
895+
"stringUnit" : {
896+
"state" : "translated",
897+
"value" : "字体大小"
898+
}
899+
},
900+
"zh-Hant" : {
901+
"stringUnit" : {
902+
"state" : "translated",
903+
"value" : "字體大小"
904+
}
905+
}
906+
}
907+
},
731908
"Ligatures" : {
732909
"localizations" : {
733910
"cs" : {

CotEditor/Sources/Settings Window/Panes/AppearanceSettingsView.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,10 @@ private struct FontSettingView: View {
189189
.help(self.displayFontName)
190190
.frame(maxWidth: 260)
191191
.alignmentGuide(.firstTextBaseline) { $0.height }
192+
FontSizeStepper(String(localized: "Font size", table: "AppearanceSettings"), font: self.font)
193+
.accessibilityValue(String(localized: "\(self.font.wrappedValue.pointSize, format: .number) points",
194+
table: "AppearanceSettings", comment: "accessibility label for font size"))
195+
.padding(.leading, -4)
192196
FontPicker(String(localized: "Select…", table: "AppearanceSettings", comment: "label for font picker button"), selection: self.font)
193197
}
194198
HStack {
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
//
2+
// FontSizeStepper.swift
3+
//
4+
// CotEditor
5+
// https://coteditor.com
6+
//
7+
// Created by 1024jp on 2025-03-03.
8+
//
9+
// ---------------------------------------------------------------------------
10+
//
11+
// © 2025 1024jp
12+
//
13+
// Licensed under the Apache License, Version 2.0 (the "License");
14+
// you may not use this file except in compliance with the License.
15+
// You may obtain a copy of the License at
16+
//
17+
// https://www.apache.org/licenses/LICENSE-2.0
18+
//
19+
// Unless required by applicable law or agreed to in writing, software
20+
// distributed under the License is distributed on an "AS IS" BASIS,
21+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22+
// See the License for the specific language governing permissions and
23+
// limitations under the License.
24+
//
25+
26+
import SwiftUI
27+
28+
struct FontSizeStepper: View {
29+
30+
private var label: String
31+
@Binding private var font: NSFont
32+
33+
34+
private var fontSize: Binding<Double> {
35+
36+
Binding(get: { self.font.pointSize },
37+
set: { self.font = self.font.withSize($0) })
38+
}
39+
40+
41+
init(_ label: String, font: Binding<NSFont>) {
42+
43+
self.label = label
44+
self._font = font
45+
}
46+
47+
48+
var body: some View {
49+
50+
Stepper(self.label, value: self.fontSize, in: 1...100, step: 1)
51+
.labelsHidden()
52+
}
53+
}

0 commit comments

Comments
 (0)