File tree Expand file tree Collapse file tree 2 files changed +12
-12
lines changed
Example/CodeEditSourceEditorExample/CodeEditSourceEditorExample/Views
Sources/CodeEditSourceEditor/Theme Expand file tree Collapse file tree 2 files changed +12
-12
lines changed Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ struct ContentView: View {
1616
1717 @State private var language : CodeLanguage = . default
1818 @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 )
2020 @AppStorage ( " wrapLines " ) private var wrapLines : Bool = true
2121 @State private var cursorPositions : [ CursorPosition ] = [ ]
2222 @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 {
2323 self . bold = bold
2424 self . italic = italic
2525 }
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- }
3526 }
3627
3728 public var text : Attribute
@@ -125,7 +116,16 @@ public struct EditorTheme: Equatable {
125116 return font
126117 }
127118
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
130130 }
131131}
You can’t perform that action at this time.
0 commit comments