• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Setting the default font of an NSTextView...
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Setting the default font of an NSTextView...


  • Subject: Re: Setting the default font of an NSTextView...
  • From: Mike Wright <email@hidden>
  • Date: Fri, 7 Apr 2006 14:22:47 -0500


Nick Zitzmann <email@hidden> wrote:

I already searched the archives, and not one person had a solution to
the problem of setting a text view's default font that works. I have
tried the following:

1. Setting the font using the font panel in IB
2. Using -[NSTextView setFont:]
3. Using -[NSTextView setTypingAttributes:]
4. Using -[NSTextStorage setFont:]
5. Using -[NSTextStorage setAttributedString:] with an
NSAttributedString equal to @"" and the font as the only attribute

No matter what I do, when the first character is typed into the
NSTextView, the font always reverts back to Helvetica 12.

So is there any way at all to change the default font of an
NSTextView, and if so, then what is it? Nothing I've tried so far
actually works...

"Shawn Erickson" <email@hidden> replied:

On 4/7/06, Nick Zitzmann <email@hidden> wrote:
I already searched the archives, and not one person had a solution to
the problem of setting a text view's default font that works. I have
tried the following:

3. Using -[NSTextView setTypingAttributes:]

I am fairly sure that typing attributes is what you want but I believe you have to reapply them if the selection, etc. changes. Try having a delegate of that text view respond to textViewDidChangeTypingAttributes: or possibly textViewDidChangeSelection: and in one of those reapply the desired default type attributes. (not tried this myself in any prior project)

Just thought I'd add my two cents (and, believe me, it's worth it).

I have a nib file with two text fields, both embedded in scroll views, one further embedded in a split view.

In IB, the one in the split view shows Lucida Grande 11 for both the NSScollView (NSTextView) and the NSTextView.

The other shows Lucida Grande 12 for the NSScollView (NSTextView) and Helvetica 12 for the NSTextView.

Although they pretend to respond when I bring up the Font Panel and change them, they revert as soon as I click somewhere else. I haven't found any way to change either of them, and I have no idea why they don't default to the same font settings.

Both seem to respond just fine to -[NSTextView setFont:]. That's all I use for the one not in the split view. For a variety of reasons, I also do the following with the one in the split view:

[textView setTypingAttributes:nil];
NSRange range = NSMakeRange(0, [[textView string] length]);
[textView replaceCharactersInRange:range withString:@""];
[textView setFont:[[self settings] textFont]];

Cheers,
Mike Wright
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Prev by Date: Unable to link universal binary
  • Next by Date: precision problem or my error?
  • Previous by thread: Re: Setting the default font of an NSTextView...
  • Next by thread: Universal Binaries with 10.2.8 vs 10.4 conditional compiling
  • Index(es):
    • Date
    • Thread