How can I set the default font of an NSTextView component? I need to have an area in my app where users can make changes to a plain text file, and I'd like for the font to be a monospaced font.
+1
A:
Found it. The answer above was close, but wouldn't do it - had to access the textStorage object of the NSTextView first:
[[myNSTextView textStorage] setFont:[NSFont fontWithName:@"Menlo" size:11]];
joshbuhler
2009-12-04 23:30:17
From the NSText (superclass of NSTextView) documentation: “Sets the font of all the receiver’s text to <var>aFont</var>.” If that didn't work for you, you should look into why.
Peter Hosey
2009-12-05 06:19:10
Furthermore, you should use the user's preferred fixed-pitch font and size, not a hard-coded font and size. http://developer.apple.com/mac/library/documentation/Cocoa/Reference/ApplicationKit/Classes/NSFont_Class/Reference/Reference.html#//apple_ref/occ/clm/NSFont/userFixedPitchFontOfSize:
Peter Hosey
2009-12-05 06:19:53