From 9c9aa5866c73335cd04346647667a3b7c999b4f1 Mon Sep 17 00:00:00 2001 From: Pavel Sountsov Date: Wed, 13 Nov 2024 20:00:06 -0800 Subject: [PATCH] Fix monospace fonts on MacOS in al_open_native_text_log. The font needs to be set on each line, since we're using NSAttributeStrings. Fixes #1592 --- addons/native_dialog/osx_dialog.m | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/addons/native_dialog/osx_dialog.m b/addons/native_dialog/osx_dialog.m index 394d19a77..746f4eb30 100644 --- a/addons/native_dialog/osx_dialog.m +++ b/addons/native_dialog/osx_dialog.m @@ -284,7 +284,10 @@ - (void)emitCloseEventWithKeypress: (BOOL)keypress - (void)appendText: (NSString*)text { - NSDictionary *attributes = [NSDictionary dictionaryWithObject:[NSColor controlTextColor] forKey:NSForegroundColorAttributeName]; + id keys[] = {NSForegroundColorAttributeName, NSFontAttributeName}; + id objects[] = {[NSColor controlTextColor], [NSFont userFixedPitchFontOfSize: 0]}; + int count = textlog->flags & ALLEGRO_TEXTLOG_MONOSPACE ? 2 : 1; + NSDictionary *attributes = [NSDictionary dictionaryWithObjects:objects forKeys:keys count:count]; NSAttributedString *attributedString = [[[NSAttributedString alloc] initWithString:text attributes:attributes] autorelease]; NSTextStorage* store = [self textStorage]; [store beginEditing]; @@ -335,10 +338,6 @@ bool _al_open_native_text_log(ALLEGRO_NATIVE_DIALOG *textlog) [view setAutoresizingMask: NSViewHeightSizable | NSViewWidthSizable]; [[view textContainer] setContainerSize: NSMakeSize(rect.size.width, 1000000)]; [[view textContainer] setWidthTracksTextView: NO]; - [view setTextColor: [NSColor grayColor]]; - if (textlog->flags & ALLEGRO_TEXTLOG_MONOSPACE) { - [view setFont: [NSFont userFixedPitchFontOfSize: 0]]; - } [view setEditable: NO]; [scrollView setDocumentView: view];