How to set font in NSTextView?

Easier, as it seems, I just CANNOT FULLY find ANY way to do this ( setFont:does not work):

  • You have NSTextView
  • Set your font to NSFont.

Hint: (Pretty obvious, but independent ...) If the user adds any text, the new text should “inherit” the same style ...

+5
source share
2 answers

I do not know what you are doing wrong, I can change the font NSTextView in my own project. Are you sure you are setting the font AFTER the text view has been loaded? Check if the text view is loaded using NSLog.

+7
source

You should set the font in textStorage, not in TextView

[[textView textStorage] setFont:[NSFont fontWithName:@"Menlo" size:12]];
+5
source

All Articles