File tree 2 files changed +12
-12
lines changed
Example/CodeEditSourceEditorExample/CodeEditSourceEditorExample/Views
Sources/CodeEditSourceEditor/Theme
2 files changed +12
-12
lines changed Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ struct ContentView: View {
16
16
17
17
@State private var language : CodeLanguage = . default
18
18
@State private var theme : EditorTheme = . standard
19
- @State private var font : NSFont = NSFont . monospacedSystemFont ( ofSize: 12 , weight: . regular )
19
+ @State private var font : NSFont = NSFont . monospacedSystemFont ( ofSize: 12 , weight: . medium )
20
20
@AppStorage ( " wrapLines " ) private var wrapLines : Bool = true
21
21
@State private var cursorPositions : [ CursorPosition ] = [ ]
22
22
@AppStorage ( " systemCursor " ) private var useSystemCursor : Bool = false
Original file line number Diff line number Diff line change @@ -23,15 +23,6 @@ public struct EditorTheme: Equatable {
23
23
self . bold = bold
24
24
self . italic = italic
25
25
}
26
-
27
- var fontDescriptorTraits : NSFontDescriptor . SymbolicTraits {
28
- switch ( bold, italic) {
29
- case ( true , true ) : return [ . bold, . italic]
30
- case ( true , false ) : return [ . bold]
31
- case ( false , true ) : return [ . italic]
32
- case ( false , false ) : return [ ]
33
- }
34
- }
35
26
}
36
27
37
28
public var text : Attribute
@@ -125,7 +116,16 @@ public struct EditorTheme: Equatable {
125
116
return font
126
117
}
127
118
128
- let descriptor = font. fontDescriptor. withSymbolicTraits ( attributes. fontDescriptorTraits)
129
- return NSFont ( descriptor: descriptor, size: font. pointSize) ?? font
119
+ var font = font
120
+
121
+ if attributes. bold {
122
+ font = NSFontManager . shared. convert ( font, toHaveTrait: . boldFontMask)
123
+ }
124
+
125
+ if attributes. italic {
126
+ font = NSFontManager . shared. convert ( font, toHaveTrait: . italicFontMask)
127
+ }
128
+
129
+ return font
130
130
}
131
131
}
You can’t perform that action at this time.
0 commit comments