• 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 fixed pitch font (temporary) for NSTextView object
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Setting fixed pitch font (temporary) for NSTextView object


  • Subject: Re: Setting fixed pitch font (temporary) for NSTextView object
  • From: Ingvar Nedrebo <email@hidden>
  • Date: Tue, 19 Mar 2002 13:53:10 +0000

Well don't know if you think this qualifies as complex juggling, but it works:


[displayView setString:stringData];
NSFont * fixedFont = [NSFont userFixedPitchFontOfSize:0.0];
NSDictionary * attr =
[NSDictionary dictionaryWithObject:fixedFont
forKey:NSFontAttributeName];
NSTextStorage * text = [displayView textStorage];
[text setAttributes:attr range:NSMakeRange(0,[text length])];


Or just create an attributed string in the first place:


NSAttributedString * astr =
[[NSAttributedString alloc] initWithString:stringData
attributes:attr];
[text setAttributedString:astr];
[astr release];


I.

On Tuesday, March 19, 2002, at 10:28 , Gerben Wierda wrote:

I have looked at the documentation and tried a lot of calls, but so far
I have not been able to set a text view to a fixed pitch font
temporarily (the same view sometimes displays RTF as well).

For instance, I tried:

[displayView setRichText:NO];
[displayView selectAll:nil];
[[displayView textStorage] applyFontTraits:NSFixedPitchFontMask
range:[displayView selectedRange]];
[displayView setString:stringData];

I also tried a different order of these calls, but whatever I do, the
font in this text view stays Helvetica. Is there a way to set this in a
simple manner so that I can use a normal non-attributed NSString? Or do
I have to do complex juggling with NSFont and attributed strings?

Thanks,

G
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

References: 
 >Setting fixed pitch font (temporary) for NSTextView object (From: Gerben Wierda <email@hidden>)

  • Prev by Date: Re: Newbie with stupid question cont.
  • Next by Date: Learning AppleScript?
  • Previous by thread: Setting fixed pitch font (temporary) for NSTextView object
  • Next by thread: Re: Setting fixed pitch font (temporary) for NSTextView object
  • Index(es):
    • Date
    • Thread