Skip to content

Commit

Permalink
Use non-monospaced text on macOS Ventura due to bugs in macOS/SwiftUI
Browse files Browse the repository at this point in the history
_closes #1122
  • Loading branch information
nikitabobko committed Feb 23, 2025
1 parent 24143af commit 106f994
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions Sources/AppBundle/MenuBar.swift
Original file line number Diff line number Diff line change
Expand Up @@ -65,16 +65,20 @@ struct MonospacedText: View {
init(_ text: String) { self.text = text }

var body: some View {
let renderer = ImageRenderer(
content: Text(text)
.font(.system(.largeTitle, design: .monospaced))
.foregroundStyle(colorScheme == .light ? Color.black : Color.white)
)
if let cgImage = renderer.cgImage {
// Using scale: 1 results in a blurry image for unknown reasons
Image(cgImage, scale: 2, label: Text(text))
if #available(macOS 14, *) { // https://github.com/nikitabobko/AeroSpace/issues/1122
let renderer = ImageRenderer(
content: Text(text)
.font(.system(.largeTitle, design: .monospaced))
.foregroundStyle(colorScheme == .light ? Color.black : Color.white)
)
if let cgImage = renderer.cgImage {
// Using scale: 1 results in a blurry image for unknown reasons
Image(cgImage, scale: 2, label: Text(text))
} else {
// In case image can't be rendered fallback to plain text
Text(text)
}
} else {
// In case image can't be rendered fallback to plain text
Text(text)
}
}
Expand Down

0 comments on commit 106f994

Please sign in to comment.