@@ -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 ) {
@@ -981,50 +978,55 @@ public final class AppKitBackend: AppBackend {
981978 case . trailing:
982979 . right
983980 }
981+
982+ let resolvedFont = environment. resolvedFont
983+
984+ // This is definitely what these properties were intended for
985+ paragraphStyle. minimumLineHeight = CGFloat ( resolvedFont. lineHeight)
986+ paragraphStyle. maximumLineHeight = CGFloat ( resolvedFont. lineHeight)
987+ paragraphStyle. lineSpacing = 0
988+
984989 return [
985990 . foregroundColor: environment. suggestedForegroundColor. nsColor,
986- . font: font ( for: environment ) ,
991+ . font: font ( for: resolvedFont ) ,
987992 . paragraphStyle: paragraphStyle,
988993 ]
989994 }
990995
991- private static func font( for environment : EnvironmentValues ) -> NSFont {
992- switch environment . font {
993- case . system ( let size , let weight, let design ) :
994- switch design {
995- case . default , . none :
996- NSFont . systemFont (
997- ofSize : CGFloat ( size ) , weight : weight . map ( Self . weight ( for : ) ) ?? . regular
998- )
996+ private static func font( for font : Font . Resolved ) -> NSFont {
997+ let size = CGFloat ( font . pointSize )
998+ let weight = weight ( for : font . weight )
999+ switch font . identifier . kind {
1000+ case . system :
1001+ switch font . design {
1002+ case . default :
1003+ return NSFont . systemFont ( ofSize : size , weight : weight )
9991004 case . monospaced:
1000- NSFont . monospacedSystemFont (
1001- ofSize: CGFloat ( size) ,
1002- weight: weight. map ( Self . weight ( for: ) ) ?? . regular
1003- )
1005+ return NSFont . monospacedSystemFont ( ofSize: size, weight: weight)
10041006 }
10051007 }
10061008 }
10071009
10081010 private static func weight( for weight: Font . Weight ) -> NSFont . Weight {
10091011 switch weight {
1010- case . black:
1011- . black
1012- case . bold:
1013- . bold
1014- case . heavy:
1015- . heavy
1012+ case . thin:
1013+ . thin
1014+ case . ultraLight:
1015+ . ultraLight
10161016 case . light:
10171017 . light
1018- case . medium:
1019- . medium
10201018 case . regular:
10211019 . regular
1020+ case . medium:
1021+ . medium
10221022 case . semibold:
10231023 . semibold
1024- case . thin:
1025- . thin
1026- case . ultraLight:
1027- . ultraLight
1024+ case . bold:
1025+ . bold
1026+ case . black:
1027+ . black
1028+ case . heavy:
1029+ . heavy
10281030 }
10291031 }
10301032
0 commit comments