@@ -24,6 +24,7 @@ public final class AppKitBackend: AppBackend {
2424 public let requiresImageUpdateOnScaleFactorChange = false
2525 public let menuImplementationStyle = MenuImplementationStyle . dynamicPopover
2626 public let canRevealFiles = true
27+ public let deviceClass = DeviceClass . desktop
2728
2829 public var scrollBarWidth : Int {
2930 // We assume that all scrollers have their controlSize set to `.regular` by default.
@@ -247,13 +248,9 @@ public final class AppKitBackend: AppBackend {
247248
248249 public func computeRootEnvironment( defaultEnvironment: EnvironmentValues ) -> EnvironmentValues {
249250 let isDark = UserDefaults . standard. string ( forKey: " AppleInterfaceStyle " ) == " Dark "
250- let font = Font . system (
251- size: Int ( NSFont . systemFont ( ofSize: 0.0 ) . pointSize. rounded ( . awayFromZero) )
252- )
253251 return
254252 defaultEnvironment
255253 . with ( \. colorScheme, isDark ? . dark : . light)
256- . with ( \. font, font)
257254 }
258255
259256 public func setRootEnvironmentChangeHandler( to action: @escaping ( ) -> Void ) {
@@ -982,50 +979,55 @@ public final class AppKitBackend: AppBackend {
982979 case . trailing:
983980 . right
984981 }
982+
983+ let resolvedFont = environment. resolvedFont
984+
985+ // This is definitely what these properties were intended for
986+ paragraphStyle. minimumLineHeight = CGFloat ( resolvedFont. lineHeight)
987+ paragraphStyle. maximumLineHeight = CGFloat ( resolvedFont. lineHeight)
988+ paragraphStyle. lineSpacing = 0
989+
985990 return [
986991 . foregroundColor: environment. suggestedForegroundColor. nsColor,
987- . font: font ( for: environment ) ,
992+ . font: font ( for: resolvedFont ) ,
988993 . paragraphStyle: paragraphStyle,
989994 ]
990995 }
991996
992- private static func font( for environment : EnvironmentValues ) -> NSFont {
993- switch environment . font {
994- case . system ( let size , let weight, let design ) :
995- switch design {
996- case . default , . none :
997- NSFont . systemFont (
998- ofSize : CGFloat ( size ) , weight : weight . map ( Self . weight ( for : ) ) ?? . regular
999- )
997+ private static func font( for font : Font . Resolved ) -> NSFont {
998+ let size = CGFloat ( font . pointSize )
999+ let weight = weight ( for : font . weight )
1000+ switch font . identifier . kind {
1001+ case . system :
1002+ switch font . design {
1003+ case . default :
1004+ return NSFont . systemFont ( ofSize : size , weight : weight )
10001005 case . monospaced:
1001- NSFont . monospacedSystemFont (
1002- ofSize: CGFloat ( size) ,
1003- weight: weight. map ( Self . weight ( for: ) ) ?? . regular
1004- )
1006+ return NSFont . monospacedSystemFont ( ofSize: size, weight: weight)
10051007 }
10061008 }
10071009 }
10081010
10091011 private static func weight( for weight: Font . Weight ) -> NSFont . Weight {
10101012 switch weight {
1011- case . black:
1012- . black
1013- case . bold:
1014- . bold
1015- case . heavy:
1016- . heavy
1013+ case . thin:
1014+ . thin
1015+ case . ultraLight:
1016+ . ultraLight
10171017 case . light:
10181018 . light
1019- case . medium:
1020- . medium
10211019 case . regular:
10221020 . regular
1021+ case . medium:
1022+ . medium
10231023 case . semibold:
10241024 . semibold
1025- case . thin:
1026- . thin
1027- case . ultraLight:
1028- . ultraLight
1025+ case . bold:
1026+ . bold
1027+ case . black:
1028+ . black
1029+ case . heavy:
1030+ . heavy
10291031 }
10301032 }
10311033
0 commit comments