@@ -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.
@@ -323,13 +324,9 @@ public final class AppKitBackend: AppBackend {
323324
324325 public func computeRootEnvironment( defaultEnvironment: EnvironmentValues ) -> EnvironmentValues {
325326 let isDark = UserDefaults . standard. string ( forKey: " AppleInterfaceStyle " ) == " Dark "
326- let font = Font . system (
327- size: Int ( NSFont . systemFont ( ofSize: 0.0 ) . pointSize. rounded ( . awayFromZero) )
328- )
329327 return
330328 defaultEnvironment
331329 . with ( \. colorScheme, isDark ? . dark : . light)
332- . with ( \. font, font)
333330 }
334331
335332 public func setRootEnvironmentChangeHandler( to action: @escaping ( ) -> Void ) {
@@ -1112,50 +1109,55 @@ public final class AppKitBackend: AppBackend {
11121109 case . trailing:
11131110 . right
11141111 }
1112+
1113+ let resolvedFont = environment. resolvedFont
1114+
1115+ // This is definitely what these properties were intended for
1116+ paragraphStyle. minimumLineHeight = CGFloat ( resolvedFont. lineHeight)
1117+ paragraphStyle. maximumLineHeight = CGFloat ( resolvedFont. lineHeight)
1118+ paragraphStyle. lineSpacing = 0
1119+
11151120 return [
11161121 . foregroundColor: environment. suggestedForegroundColor. nsColor,
1117- . font: font ( for: environment ) ,
1122+ . font: font ( for: resolvedFont ) ,
11181123 . paragraphStyle: paragraphStyle,
11191124 ]
11201125 }
11211126
1122- private static func font( for environment : EnvironmentValues ) -> NSFont {
1123- switch environment . font {
1124- case . system ( let size , let weight, let design ) :
1125- switch design {
1126- case . default , . none :
1127- NSFont . systemFont (
1128- ofSize : CGFloat ( size ) , weight : weight . map ( Self . weight ( for : ) ) ?? . regular
1129- )
1127+ private static func font( for font : Font . Resolved ) -> NSFont {
1128+ let size = CGFloat ( font . pointSize )
1129+ let weight = weight ( for : font . weight )
1130+ switch font . identifier . kind {
1131+ case . system :
1132+ switch font . design {
1133+ case . default :
1134+ return NSFont . systemFont ( ofSize : size , weight : weight )
11301135 case . monospaced:
1131- NSFont . monospacedSystemFont (
1132- ofSize: CGFloat ( size) ,
1133- weight: weight. map ( Self . weight ( for: ) ) ?? . regular
1134- )
1136+ return NSFont . monospacedSystemFont ( ofSize: size, weight: weight)
11351137 }
11361138 }
11371139 }
11381140
11391141 private static func weight( for weight: Font . Weight ) -> NSFont . Weight {
11401142 switch weight {
1141- case . black:
1142- . black
1143- case . bold:
1144- . bold
1145- case . heavy:
1146- . heavy
1143+ case . thin:
1144+ . thin
1145+ case . ultraLight:
1146+ . ultraLight
11471147 case . light:
11481148 . light
1149- case . medium:
1150- . medium
11511149 case . regular:
11521150 . regular
1151+ case . medium:
1152+ . medium
11531153 case . semibold:
11541154 . semibold
1155- case . thin:
1156- . thin
1157- case . ultraLight:
1158- . ultraLight
1155+ case . bold:
1156+ . bold
1157+ case . black:
1158+ . black
1159+ case . heavy:
1160+ . heavy
11591161 }
11601162 }
11611163
0 commit comments