Force Lucida Grande Font in a Yosemite Cocoa app

627 Views Asked by At

I have a requirement for some labels in my app to use Lucida Grande. When I specify this font in Xcode it renders correctly in the xib, but when you launch the app in Yosemite it switches back to Helvetica Neue.

How can I get this to work correctly?

lucida in xib lucida in app

1

There are 1 best solutions below

0
Demian Turner On BEST ANSWER

As per Ken's advice, setting the font manually in the awakeFromNib() method gives the correct result.

You can either set the font property of the NSTextField

[self.myLabel setFont:[NSFont fontWithName:@"Lucida Grande" size:50.f]];

or use an NSAttributedString

NSDictionary *attributes = @{ NSFontAttributeName : [NSFont fontWithName:@"Lucida Grande" size:50] };
NSAttributedString *text = [[NSAttributedString alloc] initWithString:@"Hello" attributes:attributes];
[self.myLabel setAttributedStringValue:text];

Interestingly, in many cases I have seen fonts with spaces in the font name input with dashes, i.e. @"Lucida-Grande", this actually breaks the output, dashes must be omitted.