How to set monospaced font for a NSTextView

Hi,


I'm trying to set a textview to use a monospaced font, the default monospace font and while it's working, I'm getting this warning.


The code I'm using is the one from Apple's docs:


textView.font = NSFont.monospacedSystemFont(ofSize: 12, weight: .regular)


but when I run my app the warning below shows up:


2020-04-04 09:18:10.725876-0500 Xcutioner[58296:2835209] CoreText note: Client requested name ".SFNSMono-Bold", it will get Times-Roman rather than the intended font. All system UI font access should be through proper APIs such as CTFontCreateUIFontForLanguage() or +[NSFont systemFontOfSize:].


Any idea on how to get rid of this warning? Is the preferred way to set a monospaced font not the one in Apple's documentation?


Thanks

Set it through setTypingAttributes: and possibly setDefaultParagraphStyle: if you want to fiddle with those as well (line spacing, etc.).

Hi,


Thanks for your help. I'll have to try that one later. For some reason the error disappeared, and it's not giving me a warning anymore. The code is the same as before. I'm pretty sure it got updated with Xcode the other day.


In any case, thanks again.

Things get curiouser--I had this error pop up. I put a button on a window--the button had the default font from what ever IB decided to give it--a system font if I recall. Well, that same error popped up. I went in and changed the font for the button and the error went away. I am wondering if this is a bug.

How to set monospaced font for a NSTextView
 
 
Q