perf: cache font from appearance

This commit is contained in:
lwouis committed 2026-02-11 21:35:23 +01:00
1 parent 52530b2d5c
commit 305870b3ee
1 file changed
+11 -9
+11 -9
View File
@@ -10,7 +10,8 @@ class Appearance {
static var maxWidthOnScreen = CGFloat(1000)
static var rowsCount = CGFloat(1000)
static var iconSize = CGFloat(1000)
static var fontHeight = CGFloat(1000)
static var fontHeight = CGFloat(3)
static var font = NSFont.systemFont(ofSize: fontHeight)
static var windowMinWidthInRow = CGFloat(1000)
static var windowMaxWidthInRow = CGFloat(1000)
@@ -33,14 +34,6 @@ class Appearance {
static var highlightFocusedBorderColor: NSColor { get { NSColor.systemAccentColor } }
static var highlightHoveredBorderColor: NSColor { get { NSColor.systemAccentColor.withAlphaComponent(0.7) } }
// derived
static var font: NSFont {
if #available(macOS 26.0, *) {
return NSFont.systemFont(ofSize: fontHeight, weight: currentStyle == .appIcons ? .semibold : .medium)
}
return NSFont.systemFont(ofSize: fontHeight)
}
private static var currentStyle: AppearanceStylePreference { Preferences.appearanceStyle }
private static var currentSize: AppearanceSizePreference { Preferences.appearanceSize }
static var currentTheme: AppearanceThemePreference {
@@ -66,6 +59,7 @@ class Appearance {
} else {
thumbnailsSize(isHorizontalScreen)
}
updateFont()
}
private static func updateTheme() {
@@ -172,6 +166,14 @@ class Appearance {
}
}
private static func updateFont() {
if #available(macOS 26.0, *) {
font = NSFont.systemFont(ofSize: fontHeight, weight: currentStyle == .appIcons ? .semibold : .medium)
} else {
font = NSFont.systemFont(ofSize: fontHeight)
}
}
private static func lightTheme() {
fontColor = .black.withAlphaComponent(0.8)
imagesShadowColor = .gray.withAlphaComponent(0.8)