Post

Replies

Boosts

Views

Activity

Reply to Disabling font Anti-Aliasing in a Text in SwiftUI
I really don’t appreciate answers along the lines of “Why would you want to do this? You don't need it.” That kind of response is exactly why people are increasingly turning to AI tools for help — because they aim to assist without being dismissive or patronizing. I asked the question because I do notice a difference. I’m currently using a bitmap-style font from this site: https://int10h.org/oldschool-pc-fonts/fontlist. They provide real bitmap fonts, but macOS doesn’t support them natively, so I'm forced to use outline versions instead. Creating a custom font won't help in this case — it won't behave differently regarding anti-aliasing. Here’s the context: I’m developing a music app for macOS that simulates the look of old audio equipment — specifically the monochrome dot matrix LCDs and VFDs. The font is rendered at a specific size such that each ‘fake bitmap pixel’ maps to a 3×3 block of screen pixels. I then apply a mask so that only the 4 top-left pixels of each block are visible, mimicking the glowing dots with spacing. The issue is that anti-aliasing causes a visual bleed between these ‘dots’, which breaks the illusion. It's subtle, yes — but definitely noticeable, especially when you’re going for pixel-precision. I'm a perfectionist, and this kind of detail matters for the effect I'm trying to achieve. So, if it’s simply not possible to disable anti-aliasing for font rendering in this context, that’s fine — I can accept that. But I'd much rather get a straightforward “no” than an explanation of why I shouldn't want to do it in the first place. Thanks. N.B.: I've provided two screenshots of the same text: Rendered in TextEdit: Rendered in my app:
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Aug ’25
Reply to Disabling font Anti-Aliasing in a Text in SwiftUI
I just realized that you didn't understand my first request at the first place. I already wrote in my initial question that I already used custom font that simulates the bitmap look. The problem is that they are also being anti-aliased (there's no reason they shouldn't) and it introduced artefact on those kind of font. I was so disappointed at your patronizing answer that I thought you had understood my question and were referring to the anti-aliasing artifacts when you said they wouldn't be visible on high screen resolution You assumed I wanted to make a bitmap look by using ANY font and removing the anti-alias. So your answer is even worse because you proudly marked it yourself as the recommended solution while it was what I was doing at the first place... I just needed an improvement to it since the anti-aliasing introduced artifacts on those blocky fonts. Anyway, that's not even relevant because I don't even need to explain WHY I need the anti-alias. It is not for anyone else to decide. Regardless of why I want to disable it, the technical question should stand on its own. The question was “Can we disable anti-alias on fonts ?”. The answer should have been “There's unfortunately no way or trick to remove the anti-aliasing on fonts”. Not the patronizing “Removing the anti-alias is not useful to you”. I explained the reason why I wanted to disable the anti-alias because I wanted to avoid useless answers asking me “why” I wanted it. What I got in return was even worse. I really didn't expect this kind of answer from an Apple Engineer on their official forums... Anyway, I waste my time. I don't expect any other response for you after you dropped “your recommended solution”.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Aug ’25
Reply to Properly Implementing “Open Recent” Menu for a SwiftUI non Document-Based macOS Music Player
So, here's solution I found. The following code works partially. The Open Recent menu is populated properly without quiting the app. But here's the issue: If the user opens it when the player is playing music, the Open Recent menus closes. I just found out that, apparently, it was linked to the fact that recentDiscsModel is a @StateObject. When the player is playing music, the PlayerView() is constantly updating. However, I have no idea how to solve this... (I use .fileImporter and not NSOpenPanel) Here's the code : @main struct MyApp: App @main struct MyApp: App { @NSApplicationDelegateAdaptor(AppDelegate.self) var appDelegate @StateObject private var recentDiscsModel = RecentDiscsModel.shared var body: some Scene { Window("Player", id: "main-window") { PlayerView() } .windowToolbarStyle(.unified) .windowStyle(.hiddenTitleBar) .windowResizability(.contentSize) .commands { CommandGroup(replacing: .newItem) { } CommandGroup(after: .newItem) { Button("Open...") { NotificationCenter.default.post(name: .openDocumentRequested, object: nil) } .keyboardShortcut("O", modifiers: .command) if recentDiscsModel.recentDocs.isEmpty == false { Menu("Open Recent") { ForEach(NSDocumentController.shared.recentDocumentURLs, id: \.self) { url in Button(url.lastPathComponent) { global.insertDisc(at: url) } } Divider() Button("Clear Menu") { NSDocumentController.shared.clearRecentDocuments(nil) recentDiscsModel.refresh() } } } } PlayBackMenu() } } } class RecentDiscsModel: ObservableObject class RecentDiscsModel: ObservableObject { static let shared = RecentDiscsModel() @Published private(set) var recentDocs: [URL] = [] private init() { refresh() } func refresh() { let newDocs = NSDocumentController.shared.recentDocumentURLs if newDocs != recentDocs { recentDocs = newDocs } } } class Globals: ObservableObject class Globals: ObservableObject { static let shared = MCGlobals() init() {} @Published var errorMessage = "" @Published var errorDetails = "" @Published var showingErrorAlert = false func handleFileImport(result: Result<URL, Error>) { switch result { case .success(let url): guard url.startAccessingSecurityScopedResource() else { errorMessage = "Unable to access file" errorDetails = "Permission denied" showingErrorAlert = true return } defer { url.stopAccessingSecurityScopedResource() } insertDisc(at: url) case .failure(let error): errorMessage = "Failed to import file" errorDetails = error.localizedDescription showingErrorAlert = true } } func insertDisc(at url: URL, startPlayback: Bool = false) { do { try AudioDiscPlayer.shared.insertDisc(at: url, startPlayback: startPlayback) recentFilesViewModel.addRecentFile(path: url.path) NSDocumentController.shared.noteNewRecentDocumentURL(url) } catch { let nsError = error as NSError errorMessage = nsError.localizedDescription let reason = nsError.localizedFailureReason ?? "" let recovery = nsError.localizedRecoverySuggestion ?? "" errorDetails = "\n\n\(reason)\n\n\(recovery)".trimmingCharacters(in: .whitespacesAndNewlines) showingErrorAlert = true } RecentDiscsModel.shared.refresh() } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
3w
Reply to Preventing a custom menu to close when the main window SwiftUI View is updating - (macOS App)
Well, my solution was to ditch SwiftUI and only use it for some specific views. It looks immature for completely developing a macOS app with it. The menu bar being the most abstract and frustrating part I had to deal with SwiftUI (so far...). So I made a new Xcode project based on XIB and used AppKit except for some views I already wrote in SwiftUI that things way simpler.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
3w