Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting default fonts in NSTextView

Tags:

cocoa

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.

like image 426
Josh Buhler Avatar asked Dec 04 '09 18:12

Josh Buhler


2 Answers

Found it. This answer 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]];
like image 89
Josh Buhler Avatar answered Oct 22 '22 07:10

Josh Buhler


NSFont* font = <whatever>;
[textView setFont: font];
like image 17
Dewayne Christensen Avatar answered Oct 22 '22 07:10

Dewayne Christensen