how do I set a font in a text view but leave the size alone?

Hi All,

originalSong’s setFont_(current application’s NSFont’s fontWithName_size_(“Courier”, 12)) changes font and size.

How do I retain the existing size and only change the font?
originalSong’s setFont_(current application’s NSFont’s fontWithName_(“Courier”) does not work.

Thanks

You have to specify a size. You need to get the font of the original, and get its size (using pointSize()).

Thanks Shane,

Do you know where in the documentation I can learn how to get the font of the original, and get its size (using pointSize())?

I tried all I could but to no avail?

What is the original?

originalSong is the text view.
I want to force a monospace font into it but maintain the size my user chooses.
originalSong’s setFont_(current application’s NSFont’s fontWithName_size_(“Courier”, 12)) changes font and size is good for both but I only want to change the font.

Try this:

set oldSize to originalSong's |font|()'s pointSize()
originalSong's setFont_(current application's NSFont's fontWithName_size_("Courier", oldSize))

Like the doctor ordered!
Thanks Shane
PS:
Where the hell is that info in the docs?
Is there a manual for AppleScriptObjC coding?
It would be much simpler if I could just read it instead of having to bother others.
Do you know?

No. My book is the nearest thing; beyond that, it’s a matter of getting familiar with Cocoa and translating from Objective-C.

Thanks for the lead to your book and your help to resolve this.
I feel I’ll finish writing my last app in ASOC and then move on to OC.
Tricky it may be but at least you have documentation.

Hi Shane,

I bought your book version 4 and it is helping a lot.

Thanks a million!