Skip to content

Commit

Permalink
Fix monospace fonts on MacOS in al_open_native_text_log.
Browse files Browse the repository at this point in the history
The font needs to be set on each line, since we're using
NSAttributeStrings.

Fixes liballeg#1592
  • Loading branch information
SiegeLordEx authored and SiegeLord committed Nov 14, 2024
1 parent bee5c7b commit 9c9aa58
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions addons/native_dialog/osx_dialog.m
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down Expand Up @@ -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];

Expand Down

0 comments on commit 9c9aa58

Please sign in to comment.